Interface DocumentRoutingService

All Known Implementing Classes:
DocumentRoutingServiceImpl

public interface DocumentRoutingService
The DocumentRoutingService allows manipulation of DocumentRoutes.
  • 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 calling startInstance(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 id
      docIds - the list of document bound to the instance
      map - the values to pass as initial workflow variables
      session - the session
      startInstance - 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 calling startInstance(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 id
      docIds - The list of document bound to the instance.
      session - the session
      startInstance - 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 new DocumentRoute instance from this DocumentRoute model.
      Parameters:
      model - The model used to create the instance.
      documentIds - The list of document bound to the instance.
      startInstance - if the DocumentRoute is automatically started.
      Returns:
      the created DocumentRoute instance.
    • startInstance

      void startInstance(String routeInstanceId, List<String> docIds, Map<String,Serializable> map, CoreSession session)
      Parameters:
      routeInstanceId - the route instance id
      docIds - the list of document bound to the instance
      map - the values to pass as initial workflow variables
      session - 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 instance
      nodeId - the node id to resume on
      data - the data coming from UI form
      status - the status coming from UI form
      session - 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 instance
      taskId - the id of the task
      data - the data coming from UI form
      status - the status coming from UI form
      session - the session
      Since:
      5.6
    • saveRouteAsNewModel

      DocumentRoute saveRouteAsNewModel(DocumentRoute route, CoreSession session)
      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

      List<DocumentRoute> getAvailableDocumentRouteModel(CoreSession session)
      Return the list of available DocumentRoute model the user can start.
      Parameters:
      session - The session of the user.
      Returns:
      A list of available DocumentRoute
    • getAvailableDocumentRoute

      List<DocumentRoute> getAvailableDocumentRoute(CoreSession session)
      Return the list of available DocumentRoute 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 given DocumentRoute 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 given DocumentRoute 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 related DocumentRoute in a state for a given attached document.
      Parameters:
      session - The session used to query the DocumentRoute.
      states - the list of states.
      Returns:
      A list of available DocumentRoute
    • getDocumentRoutesForAttachedDocument

      List<DocumentRoute> getDocumentRoutesForAttachedDocument(CoreSession session, String attachedDocId)
      See Also:
    • canValidateRoute

      boolean canValidateRoute(DocumentModel documentRoute, CoreSession coreSession)
      Checks if the principal that created the client session can validate the route
    • lockDocumentRoute

      void lockDocumentRoute(DocumentRoute routeModel, CoreSession session) throws DocumentRouteAlredayLockedException
      Locks this DocumentRoute if not already locked by the current user. If the document is already locked by another user and DocumentRouteAlredayLockedException is thrown
      Parameters:
      session - The session used to lock the DocumentRoute.
      Throws:
      DocumentRouteAlredayLockedException
    • unlockDocumentRoute

      void unlockDocumentRoute(DocumentRoute routeModel, CoreSession session) throws DocumentRouteNotLockedException
      Unlocks this DocumentRoute.If the document is not locked throws a DocumentRouteNotLockedException
      Parameters:
      session - The session used to lock the DocumentRoute.
      Throws:
      DocumentRouteNotLockedException
    • updateRouteElement

      void updateRouteElement(DocumentRouteElement routeModel, CoreSession session) throws DocumentRouteNotLockedException
      Update the given route element
      Throws:
      DocumentRouteNotLockedException
    • isLockedByCurrentUser

      boolean isLockedByCurrentUser(DocumentRoute routeModel, CoreSession session)
      Verify is this DocumentRoute is already locked by the current user.
    • isRoutable

      boolean isRoutable(DocumentModel doc)
      Checks if the given document can be associated to a DocumentRoute.
      Parameters:
      doc - the document
      Returns:
      true if the document can be routed
    • importAllRouteModels

      void importAllRouteModels(CoreSession session)
      Imports all the route models resource templates.
      Parameters:
      session - the core session to use
      Since:
      7.3
    • importRouteModel

      DocumentRoute importRouteModel(URL templateResource, boolean overwrite, CoreSession session)
      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

      void registerRouteResource(RouteModelResourceType resource, RuntimeContext extensionContext)
      Registers a new route model template to be imported at application startup.
      Parameters:
      resource - the resource
      Since:
      5.6
    • getRouteModelTemplateResources

      List<URL> getRouteModelTemplateResources()
      Returns all the route models resource templates. Use the routeModelImporter extension point to contribute new resources.
      Since:
      5.6
    • searchRouteModels

      List<DocumentModel> searchRouteModels(CoreSession session, String searchString)
      Returns the route models matching the searchString.
      Since:
      5.6
    • getRouteModelWithId

      DocumentRoute getRouteModelWithId(CoreSession session, String id)
      Returns the route model with the given id
      Since:
      5.6
    • getRouteModelDocIdWithId

      String getRouteModelDocIdWithId(CoreSession session, String id)
      Returns the doc id of the route model with the given id
      Since:
      5.7
    • makeRoutingTasks

      @Deprecated void makeRoutingTasks(CoreSession session, List<Task> tasks)
      Deprecated.
      The facet RoutingTask is statically attached to the new RoutingTask Document type since 7.1
      Marks the tasks as Routing tasks.

      This allows the related documents to be adapted to RoutingTask.

      Parameters:
      session - the session
      tasks - the tasks
      Since:
      5.6, was on RoutingTaskService before
    • endTask

      void endTask(CoreSession session, Task task, Map<String,Object> data, String status)
      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 session
      permission - the permission
      docs - the documents
      task - the task
      Since:
      5.6
    • removePermissionFromTaskAssignees

      void removePermissionFromTaskAssignees(CoreSession session, List<DocumentModel> docs, Task task)
      Removes on these documents the specified assignees permissions for this task.
      Parameters:
      session - the session
      docs - the documents
      task - the task
      Since:
      5.6
    • getWorkflowInputDocuments

      List<DocumentModel> getWorkflowInputDocuments(CoreSession session, Task task)
      Gets the documents following the workflow to which the given task belongs
      Since:
      5.6, was on RoutingTaskService before
    • cancelTask

      void cancelTask(CoreSession session, String taskId) throws DocumentRouteException
      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 the completeTask 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 session
      permission - the permission
      docs - the documents
      task - the task
      Since:
      5.8
    • removePermissionsForTaskActors

      void 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 delegated
      Parameters:
      session - the session
      docs - the documents
      task - the task
      Since:
      5.8
    • removePermissionsForTaskActors

      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 delegated
      Parameters:
      session - the session
      docs - the documents
      taskId - the taskId
      Since:
      7.4
    • cleanupDoneAndCanceledRouteInstances

      @Deprecated void cleanupDoneAndCanceledRouteInstances(String repositoryName, int limit)
      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

      void cleanupRouteInstances(String repositoryName)
      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 int doCleanupDoneAndCanceledRouteInstances(String reprositoryName, int limit)
      Deprecated.
      since 2023, use GarbageCollectRoutesAction 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. 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. Use org.nuxeo.ecm.platform.routing.core.provider.RoutingTaskPageProvider#getCurrentPage() instead.
      Since:
      7.2
    • getDocumentRelatedWorkflows

      List<DocumentRoute> getDocumentRelatedWorkflows(DocumentModel document, CoreSession session)
      Since:
      7.2
    • getRunningWorkflowInstancesLaunchedByCurrentUser

      List<DocumentRoute> getRunningWorkflowInstancesLaunchedByCurrentUser(CoreSession session)
      Since:
      7.2
    • getRunningWorkflowInstancesLaunchedByCurrentUser

      List<DocumentRoute> getRunningWorkflowInstancesLaunchedByCurrentUser(CoreSession session, String worflowModelName)
      Since:
      7.2
    • isWorkflowModel

      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.
      Since:
      7.2
    • canCreateInstance

      boolean canCreateInstance(CoreSession session, List<String> documentIds, String worflowModelName)
      Returns true if the workflow model can be started on the document list.
      Since:
      11.4
    • getRunnableWorkflows

      List<DocumentRoute> getRunnableWorkflows(CoreSession session, List<String> documentIds)
      Returns a list of runnable document routes for the input document IDs.
      Since:
      11.4
    • purgeDocumentRoute

      boolean purgeDocumentRoute(CoreSession session, DocumentRoute route)
      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