Interface StateService


public interface StateService
Provides services for obtaining content state information, and for changing the state.
Since:
1.0
  • Method Summary

    Modifier and Type
    Method
    Description
    getCurrentApprovals(com.atlassian.confluence.core.ContentEntityObject content)
    Returns the approvals that exist on the current state for the given content.
    getCurrentState(com.atlassian.confluence.core.ContentEntityObject content)
    Returns the current content's state Retrieves the
    getPublishedState(com.atlassian.confluence.core.ContentEntityObject content)
    Retrieves the most recent published state of the content if it has active workflows.
    List<? extends State>
    getStates(com.atlassian.confluence.core.ContentEntityObject content)
    Deprecated.
    since 7.0, use methods in DocumentActivityService instead with an adequate query - filtering by type "state" and subtype "transition" - to obtain the list of states recorded for the page.
    getWorkflowStateNames(com.atlassian.confluence.core.ContentEntityObject content)
    Returns the names of all possible states in the workflow associated with the given content.
    setState(com.atlassian.confluence.core.ContentEntityObject content, String stateName, String comment)
    Changes the state of the content.
    setState(com.atlassian.confluence.core.ContentEntityObject content, String stateName, String comment, boolean validate)
    Changes the state of pages.
    com.atlassian.confluence.util.longrunning.LongRunningTaskId
    setState(String stateName, boolean override, String spaceKey)
    Changes the states of pages in given space.
    com.atlassian.confluence.util.longrunning.LongRunningTaskId
    setState(String stateName, String comment, boolean runInBackground, boolean validate, Long... pageIds)
    Changes the states of pages.
    com.atlassian.confluence.util.longrunning.LongRunningTaskId
    setState(String stateName, String comment, boolean runInBackground, Long... pageIds)
    Changes the states of pages.
    com.atlassian.confluence.util.longrunning.LongRunningTaskId
    setState(String workflowName, String stateName, boolean override, String spaceKey)
    Changes the states of pages that have a given workflow in a space.
    updateExpiryDate(com.atlassian.confluence.core.ContentEntityObject content, Date newExpiryDate)
    Change the expiry date for the current state on the page.
    updateExpiryDate(com.atlassian.confluence.core.ContentEntityObject content, Date newExpiryDate, boolean validateChangeDueDate)
    Change the expiry date for the current state on the page.
  • Method Details

    • getCurrentState

      State getCurrentState(com.atlassian.confluence.core.ContentEntityObject content)
      Returns the current content's state Retrieves the
      Parameters:
      content - the content object
      Returns:
      the current state, or null of there is no state or workflow associated to the content provided
      Since:
      1.0
    • getCurrentApprovals

      List<StateApproval> getCurrentApprovals(com.atlassian.confluence.core.ContentEntityObject content)
      Returns the approvals that exist on the current state for the given content.
      Parameters:
      content - the page or blog post
      Returns:
      the list of approvals that exist on the current state for the given content.
      Since:
      1.7
    • getPublishedState

      State getPublishedState(com.atlassian.confluence.core.ContentEntityObject content)
      Retrieves the most recent published state of the content if it has active workflows. Note that it may not be the most current state
      Parameters:
      content - the content object
      Returns:
      the latest published state, or null if the content has not been in a published state or no active workflow applies to the content
      Since:
      1.0
    • getStates

      @Deprecated List<? extends State> getStates(com.atlassian.confluence.core.ContentEntityObject content)
      Deprecated.
      since 7.0, use methods in DocumentActivityService instead with an adequate query - filtering by type "state" and subtype "transition" - to obtain the list of states recorded for the page.
      Retrieves all the states on which the content has been. The last state is the most recent (current)
      Parameters:
      content - the content object
      Returns:
      the List of states.
      Since:
      1.0
    • getWorkflowStateNames

      List<String> getWorkflowStateNames(com.atlassian.confluence.core.ContentEntityObject content)
      Returns the names of all possible states in the workflow associated with the given content.
      Parameters:
      content - the content object the Id of the content to get the workflow states from
      Returns:
      List of names of all states in the workflow.
      Since:
      1.0
    • setState

      State setState(com.atlassian.confluence.core.ContentEntityObject content, String stateName, String comment) throws WorkflowException
      Changes the state of the content. The new state must be defined in the active workflow. State validation is always done in this method. To choose not to validate the state transition use setState(ContentEntityObject, String, String, boolean) with the validate param set to “false” instead.
      Parameters:
      content - the content object, which must have already a workflow associated to it
      stateName - the new state name
      comment - a comment to be recorded for the change
      Returns:
      new state
      Throws:
      WorkflowException - if there is any problem changing the state.
      Since:
      1.15
    • setState

      com.atlassian.confluence.util.longrunning.LongRunningTaskId setState(String stateName, String comment, boolean runInBackground, Long... pageIds) throws WorkflowException
      Changes the states of pages. The new state must be defined in the active workflow. State validation is always done in this method. To choose not to validate the state transition use setState(String, String, boolean, boolean, Long...) with the validate param set to “false” instead.
      Parameters:
      stateName - the new state name
      comment - a comment to be recorded for the change
      runInBackground - true if want to run in the background
      pageIds - list of page ids to change states on
      Returns:
      null or LongRunningTaskId if run in background
      Throws:
      WorkflowException
      Since:
      1.13
    • setState

      com.atlassian.confluence.util.longrunning.LongRunningTaskId setState(String stateName, String comment, boolean runInBackground, boolean validate, Long... pageIds) throws WorkflowException
      Changes the states of pages. The new state must be defined in the active workflow.
      Parameters:
      stateName - the new state name
      comment - a comment to be recorded for the change
      runInBackground - true if want to run in the background
      validate - if the state is valid or not. If is true, the state transition is validated. The required parameters in the state to be set are validated too. When validation fails, if user is a workflow admin, the state is changed but with ”admin override” change reason.
      pageIds - list of page ids to change states on
      Returns:
      null or LongRunningTaskId if run in background
      Throws:
      WorkflowException
      Since:
      6.5.0
    • setState

      com.atlassian.confluence.util.longrunning.LongRunningTaskId setState(String stateName, boolean override, String spaceKey) throws WorkflowException
      Changes the states of pages in given space. The new state must be defined in the active workflow.
      Parameters:
      stateName - the new state name
      override - true if want to override existing page states
      spaceKey - the space to change page states in
      Returns:
      LongRunningTaskId
      Throws:
      WorkflowException - if there is any problem changing the state
      Since:
      1.13
    • setState

      com.atlassian.confluence.util.longrunning.LongRunningTaskId setState(String workflowName, String stateName, boolean override, String spaceKey) throws WorkflowException
      Changes the states of pages that have a given workflow in a space. The new state must be defined in the indicated workflow
      Parameters:
      workflowName - the name of the workflow which states want to be changed
      stateName - the new state name
      override - true if want to override existing page states
      spaceKey - the space to change page states in
      Returns:
      LongRunningTaskId
      Throws:
      WorkflowException - if there is any problem changing the state
      Since:
      1.16
    • setState

      State setState(com.atlassian.confluence.core.ContentEntityObject content, String stateName, String comment, boolean validate) throws WorkflowException
      Changes the state of pages. The new state must be defined in the active workflow.
      Parameters:
      content - the content object, which must have already a workflow associated to it.
      stateName - the new state name.
      comment - a comment to be recorded for the change.
      validate - if the state is valid or not. If true, the state transition is validated if the user is not a workflow admin. The required parameters in the state to be set are validated too.
      Returns:
      a new state
      Throws:
      WorkflowException - if there is any problem changing the state
      Since:
      6.5.0
    • updateExpiryDate

      State updateExpiryDate(com.atlassian.confluence.core.ContentEntityObject content, Date newExpiryDate)
      Change the expiry date for the current state on the page. The current state must allow due date changes for the change to take effect.
      Parameters:
      content - the content object
      newExpiryDate -
      Returns:
      Since:
      1.8
    • updateExpiryDate

      State updateExpiryDate(com.atlassian.confluence.core.ContentEntityObject content, Date newExpiryDate, boolean validateChangeDueDate)
      Change the expiry date for the current state on the page.
      Parameters:
      content -
      newExpiryDate -
      validateChangeDueDate - if false will not check the changeduedate param on the state before changing the date.
      Returns:
      Since:
      1.11