Package com.day.cq.workflow
Interface WorkflowSession
-
public interface WorkflowSession
TheWorkflowSession
class provides all functionality (depending on the users rights) for managingWorkflowModel
s,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
WorkItem
s assigned to a user/group
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
complete(WorkItem item, Route route)
Completes the
for the assignedWorkItem
instance and assign to the nextWorkflow
according to the givenWorkflowNode
.Route
WorkflowModel
createNewModel(java.lang.String title)
Creates a new blank
.WorkflowModel
WorkflowModel
createNewModel(java.lang.String title, java.lang.String id)
Creates a new blank
under the given path.WorkflowModel
void
delegateWorkItem(WorkItem item, Authorizable participant)
Delegates theWorkItem
to the specifiedAuthorizable
.void
deleteModel(java.lang.String id)
Deletes the given
.WorkflowModel
void
deployModel(WorkflowModel model)
Deploys a new or modified
.WorkflowModel
boolean
evaluate(WorkflowData data, java.lang.String rule)
Evaluate the passed rule by choosing the right rule engine.WorkItem[]
getActiveWorkItems()
ResultSet<WorkItem>
getActiveWorkItems(long start, long limit)
ResultSet<WorkItem>
getActiveWorkItems(long start, long limit, WorkItemFilter filter)
Workflow[]
getAllWorkflows()
Returns allWorkflow
s which the
has access to.WorkflowSession
WorkItem[]
getAllWorkItems()
ResultSet<WorkItem>
getAllWorkItems(long start, long limit)
java.util.List<Route>
getBackRoutes(WorkItem item)
All
to all possible already passed destinations will be returned.Route
java.util.List<Route>
getBackRoutes(WorkItem item, boolean expand)
All
to all possible already passed destinations will be returned.Route
java.util.List<Authorizable>
getDelegatees(WorkItem item)
Returns alldelegatees
asAuthorizable
who are allowed to take over theWorkItem
java.util.List<HistoryItem>
getHistory(Workflow instance)
The complete ordered list ofHistoryItem
s is returned for the givenWorkflow
instance.WorkflowModel
getModel(java.lang.String id)
Returns newest version of the
with the given ID.WorkflowModel
WorkflowModel
getModel(java.lang.String id, java.lang.String version)
Returns the
with the given ID and version.WorkflowModel
WorkflowModel[]
getModels()
Returns newest versions of all deployed
s.WorkflowModel
ResultSet<WorkflowModel>
getModels(long start, long limit)
Returns newest versions of all deployed
s.WorkflowModel
ResultSet<WorkflowModel>
getModels(long start, long limit, WorkflowModelFilter filter)
Returns newest versions of all deployed
s.WorkflowModel
WorkflowModel[]
getModels(WorkflowModelFilter filter)
Returns newest versions of all deployed
s.WorkflowModel
java.util.List<Route>
getRoutes(WorkItem item)
All
to all possible destinations will be returned.Route
java.util.List<Route>
getRoutes(WorkItem item, boolean expand)
All
to all possible destinations will be returned.Route
Session
getSession()
Returns the JCR
assigned to theSession
WorkflowSession
instance.Authorizable
getUser()
Returns the user that owns theWorkflowSession
.Workflow
getWorkflow(java.lang.String id)
Retrieve the
instance with the given ID.Workflow
Workflow[]
getWorkflows(java.lang.String[] states)
Returns all
instances that are in one of the given states and to which theWorkflow
has access to.WorkflowSession
ResultSet<Workflow>
getWorkflows(java.lang.String[] states, long start, long limit)
Returns all
s instances that are in one of the given states and to which theWorkflow
has access to.WorkflowSession
WorkflowService
getWorkflowService()
Returns the
that was used to create theWorkflowService
WorkflowSession
instance.WorkItem
getWorkItem(java.lang.String id)
boolean
isSuperuser()
Checks for the workflow superuservoid
logout()
The logout method has to be called in order to clean up all jcr session references.WorkflowData
newWorkflowData(java.lang.String payloadType, java.lang.Object payload)
Creates a new
instance based on the given data.WorkflowData
void
restartWorkflow(Workflow workflow)
This method restarts a workflow instance that is in a "stale" state.void
resumeWorkflow(Workflow instance)
Resumes the givenWorkflow
instance.Workflow
startWorkflow(WorkflowModel model, WorkflowData data)
Workflow
startWorkflow(WorkflowModel model, WorkflowData data, java.util.Dictionary<java.lang.String,java.lang.String> metaData)
Deprecated.It is recommended to use startWorkflow(WorkflowModel, WorkflowData, Map) instead.Workflow
startWorkflow(WorkflowModel model, WorkflowData data, java.util.Map<java.lang.String,java.lang.Object> metaData)
void
suspendWorkflow(Workflow instance)
Suspends the givenWorkflow
instance.void
terminateWorkflow(Workflow instance)
Terminates the givenWorkflow
instance.void
updateWorkflowData(Workflow instance, WorkflowData data)
Updates the workflow data of a running workflow instance to the givenWorkflowData
.
-
-
-
Method Detail
-
getWorkflowService
WorkflowService getWorkflowService()
Returns the
that was used to create theWorkflowService
WorkflowSession
instance.- Returns:
- The
that was used to create theWorkflowService
WorkflowSession
instance.
-
getSession
Session getSession()
Returns the JCR
assigned to theSession
WorkflowSession
instance.- Returns:
- The JCR
assigned to theSession
WorkflowSession
instance.
-
getUser
Authorizable getUser()
Returns the user that owns theWorkflowSession
.- Returns:
- The user that owns the
WorkflowSession
.
-
evaluate
boolean evaluate(WorkflowData data, java.lang.String rule)
Evaluate the passed rule by choosing the right rule engine.- Parameters:
data
- workflow data to apply the rulerule
- rule to execute- Returns:
true
if rule evaluation is true or the rule isnull
-
deployModel
void deployModel(WorkflowModel model) throws WorkflowException
Deploys a new or modified
.WorkflowModel
- Parameters:
model
- The
to 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 blank
under the given path.WorkflowModel
- Parameters:
title
- The title of the newly created
.WorkflowModel
id
- 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 WorkflowException
Deletes the given
.WorkflowModel
- Parameters:
id
- The ID of the
to 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 deployed
s.WorkflowModel
- Returns:
- All deployed
at their newest versions.WorkflowModel
- Throws:
WorkflowException
- Thrown in case an error occurs while fetching the
s.WorkflowModel
-
getModels
WorkflowModel[] getModels(WorkflowModelFilter filter) throws WorkflowException
Returns newest versions of all deployed
s.WorkflowModel
- Parameters:
filter
- The
used 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
ResultSet<WorkflowModel> getModels(long start, long limit) throws WorkflowException
Returns newest versions of all deployed
s.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 the
s.WorkflowModel
-
getModels
ResultSet<WorkflowModel> getModels(long start, long limit, WorkflowModelFilter filter) throws WorkflowException
Returns newest versions of all deployed
s.WorkflowModel
- Parameters:
start
- Start index of the result set.limit
- Limit of the result set.filter
- The
used for getting workflow modelsWorkflowModelFilter
- Returns:
- All deployed
at their newest versions.WorkflowModel
- Throws:
WorkflowException
- Thrown in case an error occurs while fetching the
s.WorkflowModel
-
getModel
WorkflowModel getModel(java.lang.String id) throws WorkflowException
Returns newest version of the
with the given ID.WorkflowModel
- Parameters:
id
- The ID of theWorkflowModel
.- Returns:
- The newest version of the
with the given ID or null, if noWorkflowModel
with 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 the
with 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 noWorkflowModel
matches the given ID and/or version.WorkflowModel
- Throws:
WorkflowException
- Thrown in case an error occurs while fetching the
.WorkflowModel
VersionException
- 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 newWorkflowModel
Workflow
instance.data
-
to be attached to the new workflow instance.WorkflowData
- Returns:
- The
of the newly startedWorkflow
Workflow
instance. - Throws:
WorkflowException
- Thrown in case the workflow process cannot be started.
-
startWorkflow
Workflow startWorkflow(WorkflowModel model, WorkflowData data, java.util.Dictionary<java.lang.String,java.lang.String> metaData) throws WorkflowException
Deprecated.It is recommended to use startWorkflow(WorkflowModel, WorkflowData, Map) instead.- Parameters:
model
-
to be used for the newWorkflowModel
Workflow
instance.data
-
to be attached to the new workflow instance.WorkflowData
metaData
- Meta data assigned to the new
.Workflow
- Returns:
- The
of the newly startedWorkflow
Workflow
instance. - 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 newWorkflowModel
Workflow
instance.data
-
to be attached to the new workflow instance.WorkflowData
metaData
- Meta data assigned to the new
.Workflow
- Returns:
- The
of the newly startedWorkflow
Workflow
instance. - Throws:
WorkflowException
- Thrown in case the workflow process cannot be started.
-
terminateWorkflow
void terminateWorkflow(Workflow instance) throws WorkflowException
Terminates the givenWorkflow
instance.- Parameters:
instance
- The
instance 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 givenWorkflow
instance.- Parameters:
instance
- The
instance 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 givenWorkflow
instance.- Parameters:
instance
- The
of the workflow instance that shall be suspended.Workflow
- Throws:
WorkflowException
- Thrown in case the workflow instance cannot be suspended.
-
getActiveWorkItems
WorkItem[] getActiveWorkItems() throws WorkflowException
All
s assigned to an activeWorkItem
Workflow
instance and the respective user of theWorkflowSession
will be returned.- Returns:
- All
s assigned to an active workflow and the respective usersWorkItem
WorkflowSession
. - Throws:
WorkflowException
- Thrown in case an exception occurs while fetching the active
s.WorkItem
-
getActiveWorkItems
ResultSet<WorkItem> getActiveWorkItems(long start, long limit) throws WorkflowException
All
s assigned to an activeWorkItem
Workflow
instance and the respective user of theWorkflowSession
will 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 usersWorkItem
WorkflowSession
. - Throws:
WorkflowException
- Thrown in case an exception occurs while fetching the active
s.WorkItem
-
getActiveWorkItems
ResultSet<WorkItem> getActiveWorkItems(long start, long limit, WorkItemFilter filter) throws WorkflowException
All
s assigned to an activeWorkItem
Workflow
instance and the respective user of theWorkflowSession
will 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 usersWorkItem
WorkflowSession
. - Throws:
WorkflowException
- Thrown in case an exception occurs while fetching the active
s.WorkItem
-
getAllWorkItems
WorkItem[] getAllWorkItems() throws WorkflowException
All
s assigned to aWorkItem
Workflow
instance and assigned to the respective user of theWorkflowSession
will be returned.- Returns:
- All
s assigned to aWorkItem
Workflow
instance and the respective usersWorkflowSession
. - Throws:
WorkflowException
- Thrown in case an exception occurs while fetching all
s.WorkItem
-
getAllWorkItems
ResultSet<WorkItem> getAllWorkItems(long start, long limit) throws WorkflowException
All
s assigned to aWorkItem
Workflow
instance and assigned to the respective user of theWorkflowSession
will be returned.- Parameters:
start
- Start index of the result set.limit
- Limit of the result set.- Returns:
- All
s assigned to aWorkItem
Workflow
instance and the respective usersWorkflowSession
. - Throws:
WorkflowException
- Thrown in case an exception occurs while fetching all
s.WorkItem
-
getWorkItem
WorkItem getWorkItem(java.lang.String id) throws WorkflowException
Returns the
with the given ID assigned to aWorkItem
Workflow
instance, 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
Workflow[] getWorkflows(java.lang.String[] states) throws WorkflowException
Returns all
instances that are in one of the given states and to which theWorkflow
has access to.WorkflowSession
- Parameters:
states
- The list of states used to select the
instances.Workflow
- Returns:
- All
s that are in one of the given states and to which theWorkflow
has access to.WorkflowSession
- Throws:
WorkflowException
- Thrown in case an error occurred while retrieving the
s.Workflow
-
getWorkflows
ResultSet<Workflow> getWorkflows(java.lang.String[] states, long start, long limit) throws WorkflowException
Returns all
s instances that are in one of the given states and to which theWorkflow
has access to.WorkflowSession
- Parameters:
states
- The list of states used to select the
instances.Workflow
start
- 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 theWorkflow
has access to.WorkflowSession
- Throws:
WorkflowException
- Thrown in case an error occurred while retrieving the
s.Workflow
-
getAllWorkflows
Workflow[] getAllWorkflows() throws WorkflowException
Returns allWorkflow
s which the
has access to.WorkflowSession
- Returns:
- All
s theWorkflow
has access to.WorkflowSession
- Throws:
WorkflowException
- Thrown in case an error occurred while retrieving the
s.Workflow
-
getWorkflow
Workflow getWorkflow(java.lang.String id) throws WorkflowException
Retrieve the
instance with the given ID.Workflow
- Parameters:
id
- The ID of the
instance that should be returned.Workflow
- Returns:
- The
instance with the given ID or null, if noWorkflow
instance 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 the
for the assignedWorkItem
instance and assign to the nextWorkflow
according to the givenWorkflowNode
.Route
- Parameters:
item
- The
to be completed.WorkItem
route
- The
to 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) throws WorkflowException
All
to all possible destinations will be returned. Rules will be already executed, thus all routes that are active can be selected.Route
- Parameters:
item
- The
to retrieve routes from.WorkItem
- Returns:
- All
s to advance.Route
- Throws:
WorkflowException
- Thrown in case an error is occurs while evaluating the
s.Route
-
getRoutes
java.util.List<Route> getRoutes(WorkItem item, boolean expand) throws WorkflowException
All
to all possible destinations will be returned. Rules will be already executed, thus all routes that are active can be selected.Route
- Parameters:
item
- The
to retrieve routes from.WorkItem
expand
- 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 the
s.Route
-
getBackRoutes
java.util.List<Route> getBackRoutes(WorkItem item) throws WorkflowException
All
to 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
- The
to retrieve back routes from.WorkItem
- Returns:
- All
s to advance (back).Route
- Throws:
WorkflowException
- Thrown in case an error is occurs while evaluating the
s.Route
-
getBackRoutes
java.util.List<Route> getBackRoutes(WorkItem item, boolean expand) throws WorkflowException
All
to 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
- The
to retrieve back routes from.WorkItem
expand
- 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 the
s.Route
-
newWorkflowData
WorkflowData newWorkflowData(java.lang.String payloadType, java.lang.Object payload)
Creates a new
instance based on the given data.WorkflowData
- Parameters:
payloadType
- The type of payload for the new
instance.WorkflowData
payload
- The payload object used for creating the new
instance.WorkflowData
instance.WorkflowData
- Returns:
- The new
instance.WorkflowData
-
getDelegatees
java.util.List<Authorizable> getDelegatees(WorkItem item) throws WorkflowException
Returns alldelegatees
asAuthorizable
who are allowed to take over theWorkItem
- Parameters:
item
- The workitem- Returns:
- The list of
Authorizable
s 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, java.security.AccessControlException
Delegates theWorkItem
to the specifiedAuthorizable
.- 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 ofHistoryItem
s is returned for the givenWorkflow
instance.- Parameters:
instance
-Workflow
instance- Returns:
List
ofHistoryItem
s- 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
- The
instance for which to update the data.Workflow
data
- The
for 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:
true
if 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
-
-