Package com.day.cq.workflow
Interface WorkflowSession
public interface WorkflowSession
The
WorkflowSession class provides all functionality (depending
on the users rights) for managing WorkflowModels, Workflow
instances and their execution.
It provides methods to:
- deploy/create a workflow models
- start, stop, suspend, resume and complete a workflow instance
- retrieve and complete
WorkItems assigned to a user/group
-
Method Summary
Modifier and TypeMethodDescriptionvoidCompletes thefor the assignedWorkIteminstance and assign to the nextWorkflowaccording to the givenWorkflowNode.RoutecreateNewModel(String title) Creates a new blank.WorkflowModelcreateNewModel(String title, String id) Creates a new blankunder the given path.WorkflowModelvoiddelegateWorkItem(WorkItem item, Authorizable participant) Delegates theWorkItemto the specifiedAuthorizable.voiddeleteModel(String id) Deletes the given.WorkflowModelvoiddeployModel(WorkflowModel model) Deploys a new or modified.WorkflowModelbooleanevaluate(WorkflowData data, String rule) Evaluate the passed rule by choosing the right rule engine.WorkItem[]getActiveWorkItems(long start, long limit) getActiveWorkItems(long start, long limit, WorkItemFilter filter) Workflow[]Returns allWorkflows which thehas access to.WorkflowSessionWorkItem[]getAllWorkItems(long start, long limit) getBackRoutes(WorkItem item) Allto all possible already passed destinations will be returned.RoutegetBackRoutes(WorkItem item, boolean expand) Allto all possible already passed destinations will be returned.RoutegetDelegatees(WorkItem item) Returns alldelegateesasAuthorizablewho are allowed to take over theWorkItemgetHistory(Workflow instance) The complete ordered list ofHistoryItems is returned for the givenWorkflowinstance.Returns newest version of thewith the given ID.WorkflowModelReturns thewith the given ID and version.WorkflowModelReturns newest versions of all deployeds.WorkflowModelgetModels(long start, long limit) Returns newest versions of all deployeds.WorkflowModelgetModels(long start, long limit, WorkflowModelFilter filter) Returns newest versions of all deployeds.WorkflowModelgetModels(WorkflowModelFilter filter) Returns newest versions of all deployeds.WorkflowModelAllto all possible destinations will be returned.RouteAllto all possible destinations will be returned.RouteReturns the JCRassigned to theSessionWorkflowSessioninstance.getUser()Returns the user that owns theWorkflowSession.getWorkflow(String id) Retrieve theinstance with the given ID.WorkflowWorkflow[]getWorkflows(String[] states) Returns allinstances that are in one of the given states and to which theWorkflowhas access to.WorkflowSessiongetWorkflows(String[] states, long start, long limit) Returns alls instances that are in one of the given states and to which theWorkflowhas access to.WorkflowSessionReturns thethat was used to create theWorkflowServiceWorkflowSessioninstance.getWorkItem(String id) booleanChecks for the workflow superuservoidlogout()The logout method has to be called in order to clean up all jcr session references.newWorkflowData(String payloadType, Object payload) Creates a newinstance based on the given data.WorkflowDatavoidrestartWorkflow(Workflow workflow) This method restarts a workflow instance that is in a "stale" state.voidresumeWorkflow(Workflow instance) Resumes the givenWorkflowinstance.startWorkflow(WorkflowModel model, WorkflowData data) startWorkflow(WorkflowModel model, WorkflowData data, Dictionary<String, String> metaData) Deprecated.It is recommended to use startWorkflow(WorkflowModel, WorkflowData, Map) instead.startWorkflow(WorkflowModel model, WorkflowData data, Map<String, Object> metaData) voidsuspendWorkflow(Workflow instance) Suspends the givenWorkflowinstance.voidterminateWorkflow(Workflow instance) Terminates the givenWorkflowinstance.voidupdateWorkflowData(Workflow instance, WorkflowData data) Updates the workflow data of a running workflow instance to the givenWorkflowData.
-
Method Details
-
getWorkflowService
WorkflowService getWorkflowService()Returns thethat was used to create theWorkflowServiceWorkflowSessioninstance.- Returns:
- The
that was used to create theWorkflowServiceWorkflowSessioninstance.
-
getSession
Session getSession()Returns the JCRassigned to theSessionWorkflowSessioninstance.- Returns:
- The JCR
assigned to theSessionWorkflowSessioninstance.
-
getUser
Authorizable getUser()Returns the user that owns theWorkflowSession.- Returns:
- The user that owns the
WorkflowSession.
-
evaluate
Evaluate the passed rule by choosing the right rule engine.- Parameters:
data- workflow data to apply the rulerule- rule to execute- Returns:
trueif rule evaluation is true or the rule isnull
-
deployModel
Deploys a new or modified.WorkflowModel- Parameters:
model- Theto be deployed.WorkflowModel- Throws:
WorkflowException- Thrown in case an error prevents deployment of the.WorkflowModel
-
createNewModel
Creates a new blank.WorkflowModel- Parameters:
title- The title of the newly created.WorkflowModel- Returns:
- The newly created
.WorkflowModel - Throws:
WorkflowException- Thrown in case an error prevents creation of the.WorkflowModel
-
createNewModel
Creates a new blankunder the given path.WorkflowModel- Parameters:
title- The title of the newly created.WorkflowModelid- The ID of the new.WorkflowModel- Returns:
- The newly created
.WorkflowModel - Throws:
WorkflowException- Thrown in case an error prevents creation of the.WorkflowModel
-
deleteModel
Deletes the given.WorkflowModel- Parameters:
id- The ID of theto be deleted.WorkflowModel- Throws:
WorkflowException- Thrown in case an error prevents deployment of the.WorkflowModel
-
getModels
Returns newest versions of all deployeds.WorkflowModel- Returns:
- All deployed
at their newest versions.WorkflowModel - Throws:
WorkflowException- Thrown in case an error occurs while fetching thes.WorkflowModel
-
getModels
Returns newest versions of all deployeds.WorkflowModel- Parameters:
filter- Theused for getting workflow modelsWorkflowModelFilter- Returns:
- All deployed
at their newest versions.WorkflowModel - Throws:
WorkflowException- Thrown in case an error occurs while fetching the.WorkflowModel
-
getModels
Returns newest versions of all deployeds.WorkflowModel- Parameters:
start- Start index of the result set.limit- Limit of the result set.- Returns:
- All deployed
at their newest versions.WorkflowModel - Throws:
WorkflowException- Thrown in case an error occurs while fetching thes.WorkflowModel
-
getModels
ResultSet<WorkflowModel> getModels(long start, long limit, WorkflowModelFilter filter) throws WorkflowException Returns newest versions of all deployeds.WorkflowModel- Parameters:
start- Start index of the result set.limit- Limit of the result set.filter- Theused for getting workflow modelsWorkflowModelFilter- Returns:
- All deployed
at their newest versions.WorkflowModel - Throws:
WorkflowException- Thrown in case an error occurs while fetching thes.WorkflowModel
-
getModel
Returns newest version of thewith the given ID.WorkflowModel- Parameters:
id- The ID of theWorkflowModel.- Returns:
- The newest version of the
with the given ID or null, if noWorkflowModelwith the given ID exists.WorkflowModel - Throws:
WorkflowException- Thrown in case an error occurs while fetching the.WorkflowModel
-
getModel
Returns thewith the given ID and version.WorkflowModel- Parameters:
id- The ID of theWorkflowModel.version- The version of theWorkflowModel.- Returns:
- The
with the given ID and version or null, if noWorkflowModelmatches the given ID and/or version.WorkflowModel - Throws:
WorkflowException- Thrown in case an error occurs while fetching the.WorkflowModelVersionException- Thrown in case the version does not exist or can not be accessed.
-
startWorkflow
- Parameters:
model-to be used for the newWorkflowModelWorkflowinstance.data-to be attached to the new workflow instance.WorkflowData- Returns:
- The
of the newly startedWorkflowWorkflowinstance. - Throws:
WorkflowException- Thrown in case the workflow process cannot be started.
-
startWorkflow
Workflow startWorkflow(WorkflowModel model, WorkflowData data, Dictionary<String, String> metaData) throws WorkflowExceptionDeprecated.It is recommended to use startWorkflow(WorkflowModel, WorkflowData, Map) instead.- Parameters:
model-to be used for the newWorkflowModelWorkflowinstance.data-to be attached to the new workflow instance.WorkflowDatametaData- Meta data assigned to the new.Workflow- Returns:
- The
of the newly startedWorkflowWorkflowinstance. - Throws:
WorkflowException- Thrown in case the workflow process cannot be started.
-
startWorkflow
Workflow startWorkflow(WorkflowModel model, WorkflowData data, Map<String, Object> metaData) throws WorkflowException- Parameters:
model-to be used for the newWorkflowModelWorkflowinstance.data-to be attached to the new workflow instance.WorkflowDatametaData- Meta data assigned to the new.Workflow- Returns:
- The
of the newly startedWorkflowWorkflowinstance. - Throws:
WorkflowException- Thrown in case the workflow process cannot be started.
-
terminateWorkflow
Terminates the givenWorkflowinstance.- Parameters:
instance- Theinstance that shall be terminated.Workflow- Throws:
WorkflowException- Thrown in case the workflow instance cannot be terminated.
-
resumeWorkflow
Resumes the givenWorkflowinstance.- Parameters:
instance- Theinstance that shall be resumed.Workflow- Throws:
WorkflowException- Thrown in case the workflow instance cannot be resumed.
-
suspendWorkflow
Suspends the givenWorkflowinstance.- Parameters:
instance- Theof the workflow instance that shall be suspended.Workflow- Throws:
WorkflowException- Thrown in case the workflow instance cannot be suspended.
-
getActiveWorkItems
Alls assigned to an activeWorkItemWorkflowinstance and the respective user of theWorkflowSessionwill be returned.- Returns:
- All
s assigned to an active workflow and the respective usersWorkItemWorkflowSession. - Throws:
WorkflowException- Thrown in case an exception occurs while fetching the actives.WorkItem
-
getActiveWorkItems
Alls assigned to an activeWorkItemWorkflowinstance and the respective user of theWorkflowSessionwill be returned.- Parameters:
start- Start index of the result set.limit- Limit of the result set.- Returns:
- All
s assigned to an active workflow and the respective usersWorkItemWorkflowSession. - Throws:
WorkflowException- Thrown in case an exception occurs while fetching the actives.WorkItem
-
getActiveWorkItems
ResultSet<WorkItem> getActiveWorkItems(long start, long limit, WorkItemFilter filter) throws WorkflowException Alls assigned to an activeWorkItemWorkflowinstance and the respective user of theWorkflowSessionwill be returned.- Parameters:
start- Start index of the result set.limit- Limit of the result set.filter- filter for work items- Returns:
- All
s assigned to an active workflow and the respective usersWorkItemWorkflowSession. - Throws:
WorkflowException- Thrown in case an exception occurs while fetching the actives.WorkItem
-
getAllWorkItems
Alls assigned to aWorkItemWorkflowinstance and assigned to the respective user of theWorkflowSessionwill be returned.- Returns:
- All
s assigned to aWorkItemWorkflowinstance and the respective usersWorkflowSession. - Throws:
WorkflowException- Thrown in case an exception occurs while fetching alls.WorkItem
-
getAllWorkItems
Alls assigned to aWorkItemWorkflowinstance and assigned to the respective user of theWorkflowSessionwill be returned.- Parameters:
start- Start index of the result set.limit- Limit of the result set.- Returns:
- All
s assigned to aWorkItemWorkflowinstance and the respective usersWorkflowSession. - Throws:
WorkflowException- Thrown in case an exception occurs while fetching alls.WorkItem
-
getWorkItem
Returns thewith the given ID assigned to aWorkItemWorkflowinstance, but only if the respective usersWorkflowSession}has access to it.- Parameters:
id- The ID of the.WorkItem- Returns:
- The
with the given ID.WorkItem - Throws:
WorkflowException- Thrown in case an exception is occurs while fetching the.WorkItem
-
getWorkflows
Returns allinstances that are in one of the given states and to which theWorkflowhas access to.WorkflowSession- Parameters:
states- The list of states used to select theinstances.Workflow- Returns:
- All
s that are in one of the given states and to which theWorkflowhas access to.WorkflowSession - Throws:
WorkflowException- Thrown in case an error occurred while retrieving thes.Workflow
-
getWorkflows
Returns alls instances that are in one of the given states and to which theWorkflowhas access to.WorkflowSession- Parameters:
states- The list of states used to select theinstances.Workflowstart- Start index of the result set.limit- Limit of the result set.- Returns:
- All
s that are in one of the given states and to which theWorkflowhas access to.WorkflowSession - Throws:
WorkflowException- Thrown in case an error occurred while retrieving thes.Workflow
-
getAllWorkflows
Returns allWorkflows which thehas access to.WorkflowSession- Returns:
- All
s theWorkflowhas access to.WorkflowSession - Throws:
WorkflowException- Thrown in case an error occurred while retrieving thes.Workflow
-
getWorkflow
Retrieve theinstance with the given ID.Workflow- Parameters:
id- The ID of theinstance that should be returned.Workflow- Returns:
- The
instance with the given ID or null, if noWorkflowinstance ID matches the given ID.Workflow - Throws:
WorkflowException- Thrown in case an unexpected error occurs while retrieving the.Workflow
-
complete
Completes thefor the assignedWorkIteminstance and assign to the nextWorkflowaccording to the givenWorkflowNode.Route- Parameters:
item- Theto be completed.WorkItemroute- Theto the destination to be advanced.Route- Throws:
WorkflowException- Thrown in case an error is occurs while completing the.WorkItem
-
getRoutes
Allto all possible destinations will be returned. Rules will be already executed, thus all routes that are active can be selected.Route- Parameters:
item- Theto retrieve routes from.WorkItem- Returns:
- All
s to advance.Route - Throws:
WorkflowException- Thrown in case an error is occurs while evaluating thes.Route
-
getRoutes
Allto all possible destinations will be returned. Rules will be already executed, thus all routes that are active can be selected.Route- Parameters:
item- Theto retrieve routes from.WorkItemexpand- Expands the group members if the destination points to a group. Means that not only the group is retourned as route but as well all group members.- Returns:
- All
s to advance.Route - Throws:
WorkflowException- Thrown in case an error is occurs while evaluating thes.Route
-
getBackRoutes
Allto all possible already passed destinations will be returned. Rules will be already executed, thus all routes that are active can be selected.Route- Parameters:
item- Theto retrieve back routes from.WorkItem- Returns:
- All
s to advance (back).Route - Throws:
WorkflowException- Thrown in case an error is occurs while evaluating thes.Route
-
getBackRoutes
Allto all possible already passed destinations will be returned. Rules will be already executed, thus all routes that are active can be selected.Route- Parameters:
item- Theto retrieve back routes from.WorkItemexpand- Expands the group members if the destination points to a group. Means that not only the group is retourned as route but as well all group members.- Returns:
- All
s to advance (back).Route - Throws:
WorkflowException- Thrown in case an error is occurs while evaluating thes.Route
-
newWorkflowData
Creates a newinstance based on the given data.WorkflowData- Parameters:
payloadType- The type of payload for the newinstance.WorkflowDatapayload- The payload object used for creating the newinstance.WorkflowDatainstance.WorkflowData- Returns:
- The new
instance.WorkflowData
-
getDelegatees
Returns alldelegateesasAuthorizablewho are allowed to take over theWorkItem- Parameters:
item- The workitem- Returns:
- The list of
Authorizables who are allowed to act as delegatees. - Throws:
WorkflowException- in case the delegatees could not be retrieved for some reason
-
delegateWorkItem
void delegateWorkItem(WorkItem item, Authorizable participant) throws WorkflowException, AccessControlException Delegates theWorkItemto the specifiedAuthorizable.- Parameters:
item- the corresponding workitemparticipant- the participant to delegate- Throws:
AccessControlException- if the given participant is not allowed to take over the workitem.WorkflowException- in case the delegation fails in regards of persisting the "new" state.
-
getHistory
The complete ordered list ofHistoryItems is returned for the givenWorkflowinstance.- Parameters:
instance-Workflowinstance- Returns:
ListofHistoryItems- Throws:
WorkflowException- in case the history item retrieval fails
-
updateWorkflowData
Updates the workflow data of a running workflow instance to the givenWorkflowData.- Parameters:
instance- Theinstance for which to update the data.Workflowdata- Thefor the update.WorkflowData
-
logout
void logout()The logout method has to be called in order to clean up all jcr session references. -
isSuperuser
boolean isSuperuser()Checks for the workflow superuser- Returns:
trueif the user is a workflow superuser
-
restartWorkflow
This method restarts a workflow instance that is in a "stale" state. means there is no workitem around. this could happen in case the eventing which controls the the script/java processes purges an event/job (there is the depending (serialized) workitem stored). The restart tries to start the workflow at the position right before the workitem got lost. Note: This is an administrative method and can only be used by a workflow superuser!- Parameters:
workflow- workflow- Throws:
WorkflowException- in case an error occurs
-