Interface DocumentRoutingService
- All Known Implementing Classes:
DocumentRoutingServiceImpl
DocumentRoutes
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelTask
(CoreSession session, String taskId) Cancels an open task.boolean
canCreateInstance
(CoreSession session, List<String> documentIds, String worflowModelName) Returnstrue
if the workflow model can be started on the document list.boolean
canValidateRoute
(DocumentModel documentRoute, CoreSession coreSession) Checks if the principal that created the client session can validate the routevoid
cleanupDoneAndCanceledRouteInstances
(String repositoryName, int limit) Deprecated.void
cleanupRouteInstances
(String repositoryName) Remove the routes in state 'done' or 'canceled' of the given repository.void
completeTask
(String routeId, String taskId, Map<String, Object> data, String status, CoreSession session) Completes a task on a give node.createNewInstance
(String routeModelId, List<String> docIds, Map<String, Serializable> map, CoreSession session, boolean startInstance) Creates a new route instance and optionally starts it.createNewInstance
(String routeModelId, List<String> docIds, CoreSession session, boolean startInstance) Creates a new route instance and optionally starts it.createNewInstance
(DocumentRoute model, List<String> documentIds, CoreSession session, boolean startInstance) Create a newDocumentRoute
instance from thisDocumentRoute
model.void
delegateTask
(CoreSession session, String taskId, List<String> delegatedActors, String comment) Reassigns the given task to the list of actors.int
doCleanupDoneAndCanceledRouteInstances
(String reprositoryName, int limit) Deprecated.since 2023, use GarbageCollectRoutesAction insteadvoid
Ends a task.getAvailableDocumentRoute
(CoreSession session) Return the list of availableDocumentRoute
document route.Return the list of availableDocumentRoute
model the user can start.getDocumentRelatedWorkflows
(DocumentModel document, CoreSession session) getDocumentRoutesForAttachedDocument
(CoreSession session, String attachedDocId) getDocumentRoutesForAttachedDocument
(CoreSession session, String attachedDocId, List<DocumentRouteElement.ElementLifeCycleState> states) Return the list of relatedDocumentRoute
in a state for a given attached document.getRouteModelDocIdWithId
(CoreSession session, String id) Returns the doc id of the route model with the given idReturns all the route models resource templates.getRouteModelWithId
(CoreSession session, String id) Returns the route model with the given idgetRunnableWorkflows
(CoreSession session, List<String> documentIds) Returns a list of runnable document routes for the input document IDs.getRunningWorkflowInstancesLaunchedByCurrentUser
(CoreSession session, String worflowModelName) getTasks
(DocumentModel document, String actorId, String workflowInstanceId, String workflowModelName, CoreSession session) Deprecated.since 11.1 this method does not scale as it does not paginate results.getWorkflowInputDocuments
(CoreSession session, Task task) Gets the documents following the workflow to which the given task belongsvoid
grantPermissionToTaskAssignees
(CoreSession session, String permission, List<DocumentModel> docs, Task task) Grants on these documents the specified assignees permissions for this task.void
grantPermissionToTaskDelegatedActors
(CoreSession session, String permission, List<DocumentModel> docs, Task task) Grants on these documents the specified assignees permissions for this task to the tasks delegated actors.void
importAllRouteModels
(CoreSession session) Imports all the route models resource templates.importRouteModel
(URL templateResource, boolean overwrite, CoreSession session) Creates a route model in the root models folder defined by the current persister.void
boolean
isLockedByCurrentUser
(DocumentRoute routeModel, CoreSession session) Verify is thisDocumentRoute
is already locked by the current user.boolean
isRoutable
(DocumentModel doc) Checks if the given document can be associated to a DocumentRoute.boolean
isWorkflowModel
(DocumentRoute documentRoute) Returns true if the document route is a model, false if it is just an instance i.e. a running workflow.void
lockDocumentRoute
(DocumentRoute routeModel, CoreSession session) Locks thisDocumentRoute
if not already locked by the current user.void
makeRoutingTasks
(CoreSession session, List<Task> tasks) Deprecated.The facet RoutingTask is statically attached to the new RoutingTask Document type since 7.1boolean
purgeDocumentRoute
(CoreSession session, DocumentRoute route) Remove the workflow instance if it is canceled, done or orphan.void
reassignTask
(CoreSession session, String taskId, List<String> actors, String comment) Reassigns the given task to the list of actors.void
registerRouteResource
(RouteModelResourceType resource, RuntimeContext extensionContext) Registers a new route model template to be imported at application startup.void
removePermissionFromTaskAssignees
(CoreSession session, List<DocumentModel> docs, Task task) Removes on these documents the specified assignees permissions for this task.void
removePermissionsForTaskActors
(CoreSession session, List<DocumentModel> docs, String taskId) Removes on these documents the specified assignees permissions for the task actors and also tasks delegated actors if this task was delegatedvoid
removePermissionsForTaskActors
(CoreSession session, List<DocumentModel> docs, Task task) Removes on these documents the specified assignees permissions for the task actors and also tasks delegated actors if this task was delegatedvoid
resumeInstance
(String routeId, String nodeId, Map<String, Object> data, String status, CoreSession session) Resumes a route instance on a give node.saveRouteAsNewModel
(DocumentRoute route, CoreSession session) Save a route instance as a new model of route.searchRouteModels
(CoreSession session, String searchString) Returns the route models matching thesearchString
.void
startInstance
(String routeInstanceId, List<String> docIds, Map<String, Serializable> map, CoreSession session) Starts an instance that was created withcreateNewInstance(java.lang.String, java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.io.Serializable>, org.nuxeo.ecm.core.api.CoreSession, boolean)
but withstartInstance = false
.void
unlockDocumentRoute
(DocumentRoute routeModel, CoreSession session) Unlocks thisDocumentRoute
.If the document is not locked throws aDocumentRouteNotLockedException
unlockDocumentRouteUnrestrictedSession
(DocumentRoute routeModel, CoreSession userSession) Unlock the givenDocumentRoute
model under unrestricted session.void
updateRouteElement
(DocumentRouteElement routeModel, CoreSession session) Update the given route elementvalidateRouteModel
(DocumentRoute routeModel, CoreSession session) Validates the givenDocumentRoute
model by changing its lifecycle state and setting it and all its children in ReadOnly.
-
Method Details
-
createNewInstance
String createNewInstance(String routeModelId, List<String> docIds, Map<String, Serializable> map, CoreSession session, boolean startInstance) Creates a new route instance and optionally starts it.If
startInstance = false
, then the route can be started later by callingstartInstance(java.lang.String, java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.io.Serializable>, org.nuxeo.ecm.core.api.CoreSession)
.- Parameters:
routeModelId
- the route model iddocIds
- the list of document bound to the instancemap
- the values to pass as initial workflow variablessession
- the sessionstartInstance
- if the route is automatically started- Returns:
- the created route instance id
-
createNewInstance
String createNewInstance(String routeModelId, List<String> docIds, CoreSession session, boolean startInstance) Creates a new route instance and optionally starts it.If
startInstance = false
, then the route can be started later by callingstartInstance(java.lang.String, java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.io.Serializable>, org.nuxeo.ecm.core.api.CoreSession)
.- Parameters:
routeModelId
- the route model iddocIds
- The list of document bound to the instance.session
- the sessionstartInstance
- if the route is automatically started- Returns:
- the created route instance id
-
createNewInstance
DocumentRoute createNewInstance(DocumentRoute model, List<String> documentIds, CoreSession session, boolean startInstance) Create a newDocumentRoute
instance from thisDocumentRoute
model.- Parameters:
model
- The model used to create the instance.documentIds
- The list of document bound to the instance.startInstance
- if theDocumentRoute
is automatically started.- Returns:
- the created
DocumentRoute
instance.
-
startInstance
void startInstance(String routeInstanceId, List<String> docIds, Map<String, Serializable> map, CoreSession session) Starts an instance that was created withcreateNewInstance(java.lang.String, java.util.List<java.lang.String>, java.util.Map<java.lang.String, java.io.Serializable>, org.nuxeo.ecm.core.api.CoreSession, boolean)
but withstartInstance = false
.- Parameters:
routeInstanceId
- the route instance iddocIds
- the list of document bound to the instancemap
- the values to pass as initial workflow variablessession
- the session- Since:
- 5.7.2
-
resumeInstance
void resumeInstance(String routeId, String nodeId, Map<String, Object> data, String status, CoreSession session) Resumes a route instance on a give node. Any remaining tasks on this node will be cancelled.Called by the UI action corresponding to a task button.
If all attached documents of the workflow instance have been deleted then the workflow is cancelled.
- Parameters:
routeId
- the id of the route instancenodeId
- the node id to resume ondata
- the data coming from UI formstatus
- the status coming from UI formsession
- the session- Since:
- 5.6
-
completeTask
void completeTask(String routeId, String taskId, Map<String, Object> data, String status, CoreSession session) Completes a task on a give node. If this is the last task the workflow will continue.Called by the UI action corresponding to a task button.
- Parameters:
routeId
- the id of the route instancetaskId
- the id of the taskdata
- the data coming from UI formstatus
- the status coming from UI formsession
- the session- Since:
- 5.6
-
saveRouteAsNewModel
Save a route instance as a new model of route.The place in which the new instance is persisted and its name depends on
DocumentRoutingPersister
. The route instance should be in either running, done or ready state. The new route model will be in draft state and won't have any attached documents.- Parameters:
route
- the instance from which we create a new model.- Returns:
- the new model in draft state.
-
getAvailableDocumentRouteModel
Return the list of availableDocumentRoute
model the user can start.- Parameters:
session
- The session of the user.- Returns:
- A list of available
DocumentRoute
-
getAvailableDocumentRoute
Return the list of availableDocumentRoute
document route.- Parameters:
session
- The session of the user.- Returns:
- A list of available
DocumentRoute
- Since:
- 7.2
-
validateRouteModel
DocumentRoute validateRouteModel(DocumentRoute routeModel, CoreSession session) throws DocumentRouteNotLockedException Validates the givenDocumentRoute
model by changing its lifecycle state and setting it and all its children in ReadOnly.- Returns:
- The validated route.
- Throws:
DocumentRouteNotLockedException
-
unlockDocumentRouteUnrestrictedSession
DocumentRoute unlockDocumentRouteUnrestrictedSession(DocumentRoute routeModel, CoreSession userSession) Unlock the givenDocumentRoute
model under unrestricted session.- Returns:
- The unlocked route.
- Since:
- 1.9
-
getDocumentRoutesForAttachedDocument
List<DocumentRoute> getDocumentRoutesForAttachedDocument(CoreSession session, String attachedDocId, List<DocumentRouteElement.ElementLifeCycleState> states) Return the list of relatedDocumentRoute
in a state for a given attached document.- Parameters:
session
- The session used to query theDocumentRoute
.states
- the list of states.- Returns:
- A list of available
DocumentRoute
-
getDocumentRoutesForAttachedDocument
- See Also:
-
canValidateRoute
Checks if the principal that created the client session can validate the route -
lockDocumentRoute
void lockDocumentRoute(DocumentRoute routeModel, CoreSession session) throws DocumentRouteAlredayLockedException Locks thisDocumentRoute
if not already locked by the current user. If the document is already locked by another user andDocumentRouteAlredayLockedException
is thrown- Parameters:
session
- The session used to lock theDocumentRoute
.- Throws:
DocumentRouteAlredayLockedException
-
unlockDocumentRoute
void unlockDocumentRoute(DocumentRoute routeModel, CoreSession session) throws DocumentRouteNotLockedException Unlocks thisDocumentRoute
.If the document is not locked throws aDocumentRouteNotLockedException
- Parameters:
session
- The session used to lock theDocumentRoute
.- Throws:
DocumentRouteNotLockedException
-
updateRouteElement
void updateRouteElement(DocumentRouteElement routeModel, CoreSession session) throws DocumentRouteNotLockedException Update the given route element- Throws:
DocumentRouteNotLockedException
-
isLockedByCurrentUser
Verify is thisDocumentRoute
is already locked by the current user. -
isRoutable
Checks if the given document can be associated to a DocumentRoute.- Parameters:
doc
- the document- Returns:
true
if the document can be routed
-
importAllRouteModels
Imports all the route models resource templates.- Parameters:
session
- the core session to use- Since:
- 7.3
-
importRouteModel
Creates a route model in the root models folder defined by the current persister. The templateResource is a zip tree xml export of a route document and it is imported using the core-io importer.- Since:
- 5.6
-
registerRouteResource
Registers a new route model template to be imported at application startup.- Parameters:
resource
- the resource- Since:
- 5.6
-
getRouteModelTemplateResources
Returns all the route models resource templates. Use therouteModelImporter
extension point to contribute new resources.- Since:
- 5.6
-
searchRouteModels
Returns the route models matching thesearchString
.- Since:
- 5.6
-
getRouteModelWithId
Returns the route model with the given id- Since:
- 5.6
-
getRouteModelDocIdWithId
Returns the doc id of the route model with the given id- Since:
- 5.7
-
makeRoutingTasks
Deprecated.The facet RoutingTask is statically attached to the new RoutingTask Document type since 7.1Marks the tasks as Routing tasks.This allows the related documents to be adapted to
RoutingTask
.- Parameters:
session
- the sessiontasks
- the tasks- Since:
- 5.6, was on RoutingTaskService before
-
endTask
Ends a task. If this is the last task the workflow will continue.- Parameters:
status
- name of the button clicked to submit the task form- Since:
- 5.6, was on RoutingTaskService before
-
grantPermissionToTaskAssignees
void grantPermissionToTaskAssignees(CoreSession session, String permission, List<DocumentModel> docs, Task task) Grants on these documents the specified assignees permissions for this task.- Parameters:
session
- the sessionpermission
- the permissiondocs
- the documentstask
- the task- Since:
- 5.6
-
removePermissionFromTaskAssignees
Removes on these documents the specified assignees permissions for this task.- Parameters:
session
- the sessiondocs
- the documentstask
- the task- Since:
- 5.6
-
getWorkflowInputDocuments
Gets the documents following the workflow to which the given task belongs- Since:
- 5.6, was on RoutingTaskService before
-
cancelTask
Cancels an open task. If the task was created by an workflow, all permissions granted to the tasks assignees on the document following the worklflow are removed. Doesn't resume the workflow as thecompleteTask
method.- Throws:
DocumentRouteException
- Since:
- 5.7.3
-
reassignTask
void reassignTask(CoreSession session, String taskId, List<String> actors, String comment) throws DocumentRouteException Reassigns the given task to the list of actors. Removes the permissions granted on the document following the workflow to the current task assignees and grants them to the new actors.- Throws:
DocumentRouteException
- Since:
- 5.7.3
-
delegateTask
void delegateTask(CoreSession session, String taskId, List<String> delegatedActors, String comment) throws DocumentRouteException Reassigns the given task to the list of actors. Grants to new delegated actors the same permissions as the task assignees on the document following the workflow .- Throws:
DocumentRouteException
- Since:
- 5.8
-
grantPermissionToTaskDelegatedActors
void grantPermissionToTaskDelegatedActors(CoreSession session, String permission, List<DocumentModel> docs, Task task) Grants on these documents the specified assignees permissions for this task to the tasks delegated actors.- Parameters:
session
- the sessionpermission
- the permissiondocs
- the documentstask
- the task- Since:
- 5.8
-
removePermissionsForTaskActors
Removes on these documents the specified assignees permissions for the task actors and also tasks delegated actors if this task was delegated- Parameters:
session
- the sessiondocs
- the documentstask
- the task- Since:
- 5.8
-
removePermissionsForTaskActors
Removes on these documents the specified assignees permissions for the task actors and also tasks delegated actors if this task was delegated- Parameters:
session
- the sessiondocs
- the documentstaskId
- the taskId- Since:
- 7.4
-
cleanupDoneAndCanceledRouteInstances
Deprecated.since 2023, use #cleanupRouteInstances(String)
instead.Query for the routes 'done' or 'canceled' and delete them. The max no of the routes that will be deleted is specified by the 'limit' parameter. When the limit is '0' all the completed routes are deleted.- Since:
- 5.8
-
cleanupRouteInstances
Remove the routes in state 'done' or 'canceled' of the given repository.If 'nuxeo.routing.cleanup.workflow.instances.orphan' framework property is set to true, orphan routes (for which all associated documents have been removed) will also be removed.
- Parameters:
repositoryName
- the repository name to clean up- Since:
- 2023
-
invalidateRouteModelsCache
void invalidateRouteModelsCache()- Since:
- 5.9.3
-
doCleanupDoneAndCanceledRouteInstances
Deprecated.since 2023, use GarbageCollectRoutesAction insteadQuery for the routes 'done' or 'canceled' and delete them. The max no of the routes that will be deleted is specified by the 'limit' parameter. When the limit is '0' all the completed routes are deleted. The routes to be deleted are ordered ascending by their creation date.- Returns:
- always -1
- Since:
- 7.1
-
getTasks
@Deprecated List<Task> getTasks(DocumentModel document, String actorId, String workflowInstanceId, String workflowModelName, CoreSession session) Deprecated.since 11.1 this method does not scale as it does not paginate results. Useorg.nuxeo.ecm.platform.routing.core.provider.RoutingTaskPageProvider#getCurrentPage()
instead.- Since:
- 7.2
-
getDocumentRelatedWorkflows
- Since:
- 7.2
-
getRunningWorkflowInstancesLaunchedByCurrentUser
- Since:
- 7.2
-
getRunningWorkflowInstancesLaunchedByCurrentUser
List<DocumentRoute> getRunningWorkflowInstancesLaunchedByCurrentUser(CoreSession session, String worflowModelName) - Since:
- 7.2
-
isWorkflowModel
Returns true if the document route is a model, false if it is just an instance i.e. a running workflow.- Since:
- 7.2
-
canCreateInstance
Returnstrue
if the workflow model can be started on the document list.- Since:
- 11.4
-
getRunnableWorkflows
Returns a list of runnable document routes for the input document IDs.- Since:
- 11.4
-
purgeDocumentRoute
Remove the workflow instance if it is canceled, done or orphan. An orphan instance has all its attached document already removed.- Returns:
- true if the route has been deleted, false otherwise
- Since:
- 2023
-
cleanupRouteInstances(String)
instead.