Package com.adobe.granite.workflow
Interface WorkflowSession
-
- All Superinterfaces:
Adaptable
@ProviderType public interface WorkflowSession extends Adaptable
The
WorkflowSessionclass provides all functionality (depending on the users rights) for managingWorkflowModels,Workflowinstances 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
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidcomplete(WorkItem item, Route route)Completes thefor the assignedWorkIteminstance and assign to the nextWorkflowaccording to the givenWorkflowNode.RouteWorkflowModelcreateNewModel(java.lang.String title)Creates a new blank.WorkflowModelWorkflowModelcreateNewModel(java.lang.String title, java.lang.String id)Creates a new blankunder the given path.WorkflowModelvoiddelegateWorkItem(WorkItem item, Participant participant)Delegates theWorkItemto the specifiedPrincipal.voiddeleteModel(java.lang.String id)Deletes the given.WorkflowModelvoiddeployModel(WorkflowModel model)Deploys a new or modified.WorkflowModelResultSet<InboxItem>getActiveInboxItems(long start, long limit, InboxItemFilter filter)Retrieves all the activeInboxItems assigned to user for thisWorkflowSessioninstance.ResultSet<InboxItem>getActiveInboxItems(long start, long limit, java.lang.String itemSubType, InboxItemFilter filter)Retrieves all the activeInboxItems assigned to user for thisWorkflowSessioninstance.WorkItem[]getActiveWorkItems()ResultSet<WorkItem>getActiveWorkItems(long start, long limit)ResultSet<WorkItem>getActiveWorkItems(long start, long limit, WorkItemFilter filter)Workflow[]getAllWorkflows()Returns allWorkflows which thehas access to.WorkflowSessionWorkItem[]getAllWorkItems()ResultSet<WorkItem>getAllWorkItems(long start, long limit)java.util.List<Route>getBackRoutes(WorkItem item, boolean expand)Allto all possible already passed destinations will be returned.Routejava.util.Iterator<Participant>getDelegates(WorkItem item)Returns alldelegatesasParticipantwho are allowed to take over theWorkItemjava.util.List<HistoryItem>getHistory(Workflow instance)The complete ordered list ofHistoryItems is returned for the givenWorkflowinstance.WorkflowModelgetModel(java.lang.String id)Returns newest version of thewith the given ID.WorkflowModelWorkflowModelgetModel(java.lang.String id, java.lang.String version)Returns thewith the given ID and version.WorkflowModelWorkflowModel[]getModels()Returns newest versions of all deployeds.WorkflowModelResultSet<WorkflowModel>getModels(long start, long limit)Returns newest versions of all deployeds.WorkflowModelResultSet<WorkflowModel>getModels(long start, long limit, WorkflowModelFilter filter)Returns newest versions of all deployeds.WorkflowModelWorkflowModel[]getModels(WorkflowModelFilter filter)Returns newest versions of all deployeds.WorkflowModeljava.util.List<Route>getRoutes(WorkItem item, boolean expand)Allto all possible destinations will be returned.Routedefault java.util.Set<java.lang.String>getUsersExplicitlySharingItems()Provides the set of users, who have explicitly shared some of their inbox items with the current user Returns null if there is no user matching above criteriondefault java.util.Set<java.lang.String>getUsersSharingInbox()Provides the set of users, who have shared their entire inbox with the current user Returns null if there is no user matching above criterionWorkflowgetWorkflow(java.lang.String id)Retrieve theinstance with the given ID.Workflowdefault ResultSet<Workflow>getWorkflows(long start, long limit, WorkflowFilter workflowFilter)Returns allWorkflowinstances that the user has access to based on the filter.Workflow[]getWorkflows(java.lang.String[] states)Returns allWorkflowinstances that are in one of the given states and to which theWorkflowSessionhas access to.ResultSet<Workflow>getWorkflows(java.lang.String[] states, long start, long limit)Returns allWorkflows instances that are in one of the given states and to which theWorkflowSessionhas access to.WorkItemgetWorkItem(java.lang.String id)Returns theWorkItemwith the given ID assigned to aWorkflowinstance, but only if the respective usersWorkflowSessionhas access to it.booleanisSuperuser()Checks for the workflow superuserdefault voidlock(InboxItem item)Locks the shared InboxItem.voidlogout()The logout method has to be called in order to clean up all jcr session references.WorkflowDatanewWorkflowData(java.lang.String payloadType, java.lang.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.default voidreturnItem(InboxItem item)Returns the inbox item to previous assigneedefault voidshare(InboxItem item, java.util.Set<java.lang.String> userIds)Shares the InboxItem with provided list of users.WorkflowstartWorkflow(WorkflowModel model, WorkflowData data)WorkflowstartWorkflow(WorkflowModel model, WorkflowData data, java.util.Map<java.lang.String,java.lang.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 Detail
-
deployModel
void deployModel(WorkflowModel model) throws WorkflowException
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
WorkflowModel createNewModel(java.lang.String title) throws WorkflowException
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
WorkflowModel createNewModel(java.lang.String title, java.lang.String id) throws WorkflowException
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
void deleteModel(java.lang.String id) throws WorkflowExceptionDeletes 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
WorkflowModel[] getModels() throws WorkflowException
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
WorkflowModel[] getModels(WorkflowModelFilter filter) throws WorkflowException
Returns newest versions of all deployeds.WorkflowModel- Parameters:
filter- for workflow models- 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) throws WorkflowException
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:
filter- for workflow modelsstart- 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
-
getModel
WorkflowModel getModel(java.lang.String id) throws WorkflowException
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
WorkflowModel getModel(java.lang.String id, java.lang.String version) throws WorkflowException, VersionException
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
Workflow startWorkflow(WorkflowModel model, WorkflowData data) throws WorkflowException
- 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, java.util.Map<java.lang.String,java.lang.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. e - Throws:
WorkflowException- Thrown in case the workflow process cannot be started.
-
terminateWorkflow
void terminateWorkflow(Workflow instance) throws WorkflowException
Terminates the givenWorkflowinstance.- Parameters:
instance- Theinstance that shall be terminated.Workflow- Throws:
WorkflowException- Thrown in case the workflow instance cannot be terminated.
-
resumeWorkflow
void resumeWorkflow(Workflow instance) throws WorkflowException
Resumes the givenWorkflowinstance.- Parameters:
instance- Theinstance that shall be resumed.Workflow- Throws:
WorkflowException- Thrown in case the workflow instance cannot be resumed.
-
suspendWorkflow
void suspendWorkflow(Workflow instance) throws WorkflowException
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
WorkItem[] getActiveWorkItems() throws WorkflowException
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
ResultSet<WorkItem> getActiveWorkItems(long start, long limit) 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.- 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
-
getActiveInboxItems
ResultSet<InboxItem> getActiveInboxItems(long start, long limit, InboxItemFilter filter) throws WorkflowException
Retrieves all the activeInboxItems assigned to user for thisWorkflowSessioninstance. Use this method instead ofgetActiveWorkItems(long, long, com.adobe.granite.workflow.exec.filter.WorkItemFilter)()} if you wish to retrieve both WorkItems (which is an InboxItem) and InboxItems from other InboxItem providers- Parameters:
start- Start index of the result set. zero based, pass 0 to start at beginninglimit- Limit of the result set. pass -1 for no limit.filter- filter for inbox items- Returns:
- a ResultSet of Inbox Items
- Throws:
WorkflowException- Thrown in case an exception occurs while fetching alls.InboxItem
-
getActiveInboxItems
ResultSet<InboxItem> getActiveInboxItems(long start, long limit, java.lang.String itemSubType, InboxItemFilter filter) throws WorkflowException
Retrieves all the activeInboxItems assigned to user for thisWorkflowSessioninstance. The provided filter can also specify user whose items the current user has access to. Use this method instead ofgetActiveWorkItems(long, long, com.adobe.granite.workflow.exec.filter.WorkItemFilter)()} if you wish to retrieve both WorkItems (which is an InboxItem) and InboxItems from other InboxItem providers- Parameters:
start- Start index of the result set. zero based, pass 0 to start at beginninglimit- Limit of the result set. pass -1 for no limit.itemSubType- The sub-type of the inbox item.filter- filter for inbox items- Returns:
- a ResultSet of Inbox Items
- Throws:
WorkflowException- Thrown in case an exception occurs while fetching alls.InboxItem
-
getAllWorkItems
WorkItem[] getAllWorkItems() throws WorkflowException
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
ResultSet<WorkItem> getAllWorkItems(long start, long limit) throws WorkflowException
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
WorkItem getWorkItem(java.lang.String id) throws WorkflowException
Returns theWorkItemwith the given ID assigned to aWorkflowinstance, but only if the respective usersWorkflowSessionhas access to it.- Parameters:
id- The ID of theWorkItem.- Returns:
- The
WorkItemwith the given ID. - Throws:
WorkflowException- Thrown in case an exception is occurs while fetching theWorkItem.
-
getWorkflows
Workflow[] getWorkflows(java.lang.String[] states) throws WorkflowException
Returns allWorkflowinstances that are in one of the given states and to which theWorkflowSessionhas access to.- Parameters:
states- The list of states used to select theWorkflowinstances.- Returns:
- All
Workflows that are in one of the given states and to which theWorkflowSessionhas access to. - Throws:
WorkflowException- Thrown in case an error occurred while retrieving theWorkflows.
-
getWorkflows
ResultSet<Workflow> getWorkflows(java.lang.String[] states, long start, long limit) throws WorkflowException
Returns allWorkflows instances that are in one of the given states and to which theWorkflowSessionhas access to.- Parameters:
states- The list of states used to select theWorkflowinstances.start- Start index of the result set.limit- Limit of the result set.- Returns:
- All
Workflows that are in one of the given states and to which theWorkflowSessionhas access to. - Throws:
WorkflowException- Thrown in case an error occurred while retrieving theWorkflows.
-
getAllWorkflows
Workflow[] getAllWorkflows() throws WorkflowException
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
Workflow getWorkflow(java.lang.String id) throws WorkflowException
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
void complete(WorkItem item, Route route) throws WorkflowException
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
java.util.List<Route> getRoutes(WorkItem item, boolean expand) throws WorkflowException
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 returned 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
java.util.List<Route> getBackRoutes(WorkItem item, boolean expand) throws WorkflowException
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 returned 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
WorkflowData newWorkflowData(java.lang.String payloadType, java.lang.Object payload)
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
-
getDelegates
java.util.Iterator<Participant> getDelegates(WorkItem item) throws WorkflowException
Returns alldelegatesasParticipantwho are allowed to take over theWorkItem- Parameters:
item- The workitem- Returns:
- The list of
Participants who are allowed to act as delegates. - Throws:
WorkflowException- in case the delegates could not be retrieved for some reason
-
delegateWorkItem
void delegateWorkItem(WorkItem item, Participant participant) throws WorkflowException, java.security.AccessControlException
Delegates theWorkItemto the specifiedPrincipal.- Parameters:
item- the corresponding workitemparticipant- the participant to delegate- Throws:
java.security.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
java.util.List<HistoryItem> getHistory(Workflow instance) throws WorkflowException
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
void updateWorkflowData(Workflow instance, WorkflowData data)
Updates the workflow data of a running workflow instance to the givenWorkflowData.- Parameters:
instance- TheWorkflowinstance for which to update the data.data- TheWorkflowDatafor the update.
-
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
void restartWorkflow(Workflow workflow) throws WorkflowException
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
-
getUsersSharingInbox
default java.util.Set<java.lang.String> getUsersSharingInbox() throws WorkflowExceptionProvides the set of users, who have shared their entire inbox with the current user Returns null if there is no user matching above criterion- Returns:
- A set containing ids of users
- Throws:
WorkflowException
-
getUsersExplicitlySharingItems
default java.util.Set<java.lang.String> getUsersExplicitlySharingItems() throws WorkflowExceptionProvides the set of users, who have explicitly shared some of their inbox items with the current user Returns null if there is no user matching above criterion- Returns:
- A set containing ids of users
- Throws:
WorkflowException
-
share
default void share(InboxItem item, java.util.Set<java.lang.String> userIds) throws WorkflowException
Shares the InboxItem with provided list of users. Only the current assignee can share the provided inbox item. This method should be used for explicitly sharing an inbox item.- Parameters:
item- The inbox item to be shared.userIds- The list of authorizableIds of the users with whom item has to be shared.- Throws:
WorkflowException- Thrown in case an error occurs while sharing the inbox item.
-
lock
default void lock(InboxItem item) throws WorkflowException
Locks the shared InboxItem. The item should not be already locked and the current user should have sufficient access to lock the item (i.e. it should be assigned to the current user or it should be shared with the current user)- Parameters:
item- The inbox item to be locked.- Throws:
WorkflowException- Thrown in case an error occurs while locking the inbox item.
-
returnItem
default void returnItem(InboxItem item) throws WorkflowException
Returns the inbox item to previous assignee- Parameters:
item- The inbox item to be returned.- Throws:
WorkflowException- Thrown in case an error occurs while returning the inbox item.
-
getWorkflows
default ResultSet<Workflow> getWorkflows(long start, long limit, WorkflowFilter workflowFilter) throws WorkflowException
Returns allWorkflowinstances that the user has access to based on the filter.- Parameters:
start- Start index of the result set.limit- Limit of the result set.workflowFilter- filter for workflow.- Returns:
- All
Workflows that satisfies the request filter and to which theWorkflowSessionhas access to. - Throws:
WorkflowException- Thrown in case an error occurred while retrieving theWorkflows.
-
-