Class WorkflowManager

  • All Implemented Interfaces:
    IWorkflowManager

    public class WorkflowManager
    extends java.lang.Object
    implements IWorkflowManager
    The default implementation for IWorkflowManager.
    Since:
    4.0.0
    Version:
    $Revision: 25082 $ $Date: 2022-06-17 13:20:15 -0300 (Fri, 17 Jun 2022) $
    See Also:
    IWorkflowManager
    • Constructor Detail

      • WorkflowManager

        public WorkflowManager()
    • Method Detail

      • registerOrUpdate

        public void registerOrUpdate​(SessionConfig sessionConfig,
                                     java.lang.String workflowConfigPath,
                                     ITransaction transaction)
                              throws ManagerException,
                                     PortalException
        Register if workflow not exists. Otherwise, update. WARN, this method is accessed by reflection.
        Parameters:
        sessionConfig - the session configuration.
        workflowConfigPath - the workflow configuration path.
        transaction - the transaction.
        Throws:
        ManagerException
        PortalException
        Since:
        12.4.0
      • getTransitionsByStateId

        public java.util.List<WorkflowTransitionConfig> getTransitionsByStateId​(SessionConfig sessionConfig,
                                                                                java.lang.String workflowId,
                                                                                java.lang.String stateId,
                                                                                ITransaction transaction)
                                                                         throws PortalException
        Description copied from interface: IWorkflowManager
        Returns the transitions for a workflow state.
        Specified by:
        getTransitionsByStateId in interface IWorkflowManager
        Parameters:
        sessionConfig - the user session information.
        workflowId - the identifier of the state's workflow.
        stateId - the state's identifier.
        transaction - the transaction for persistence access.
        Returns:
        a list with the state's transitions.
        Throws:
        PortalException
      • hasStatePermission

        protected boolean hasStatePermission​(SessionConfig sessionConfig,
                                             java.util.Collection<java.lang.String> roles,
                                             WorkflowStateConfig state,
                                             java.util.EnumSet<StateScope> scopes,
                                             ITransaction transaction)
                                      throws PortalException
        Checks if any of the roles have permission to the specified workflow state.
        Parameters:
        sessionConfig - the current session information.
        roles - a collection with the roles ids.
        state - the workflow state.
        scopes - the scopes to have the permission verified
        transaction - the transaction for persistence access.
        Returns:
        true if any roles has permission to the specified workflow resource, false otherwise.
        Throws:
        PortalException
        Since:
        6.0.2
      • hasTransitionPermission

        protected boolean hasTransitionPermission​(SessionConfig sessionConfig,
                                                  java.util.Collection<java.lang.String> roles,
                                                  WorkflowTransitionConfig transition,
                                                  java.util.EnumSet<TransitionScope> transitionScopes,
                                                  ITransaction transaction)
                                           throws PortalException
        Checks if any of the roles have permission to the specified workflow transition.
        Parameters:
        sessionConfig - the current session information.
        roles - a collection with the roles ids.
        transition - the workflow transition.
        scopes - the scopes to have the permission verified
        transaction - the transaction for persistence access.
        Returns:
        true if any roles has permission to the specified workflow resource, false otherwise.
        Throws:
        PortalException
        Since:
        6.0.2
      • hasTransitionPermission

        protected boolean hasTransitionPermission​(SessionConfig sessionConfig,
                                                  java.lang.String principalId,
                                                  WorkflowTransitionConfig transition,
                                                  ContentLocale contentLocale,
                                                  java.lang.String serviceInstanceId,
                                                  ITransaction transaction)
                                           throws PortalException
        Checks if any of the principal have permission to the specified workflow transition.
        Parameters:
        sessionConfig - the current session information.
        principalId - the principal id.
        transition - the workflow transition.
        contentLocale - the content locale specific object. If null, assignedTo scoped permissions will be ignored.
        serviceInstanceId - the content service instance id.
        transaction - the transaction for persistence access.
        Returns:
        true if the principal has permission to access the specified workflow resource, false otherwise.
        Throws:
        PortalException
        Since:
        6.0.2
      • getAccessibleTransitions

        @Deprecated
        public java.util.Collection<WorkflowTransitionConfig> getAccessibleTransitions​(SessionConfig sessionConfig,
                                                                                       java.lang.String itemId,
                                                                                       java.lang.String serviceInstanceId,
                                                                                       java.lang.String sourceId,
                                                                                       ITransaction transaction)
                                                                                throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Returns the transitions that are accessible by the sessionConfig's user for a specified content.
        Specified by:
        getAccessibleTransitions in interface IWorkflowManager
        Parameters:
        sessionConfig - the user session information.
        itemId - the content's itemId.
        serviceInstanceId - the content's service instance identifier.
        sourceId - the content's source identifier.
        transaction - the transaction for persistence access.
        Returns:
        a collection with the transitions.
        Throws:
        PortalException
      • getAccessibleTransitions

        @Deprecated
        public java.util.Collection<WorkflowTransitionConfig> getAccessibleTransitions​(SessionConfig sessionConfig,
                                                                                       WorkflowStateConfig state,
                                                                                       java.lang.String serviceInstanceId,
                                                                                       boolean includeScopeAssignedTo,
                                                                                       ITransaction transaction)
                                                                                throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Returns the transitions that are accessible by the sessionConfig's user, originating from a specific workflow state in the specified service instance.
        Specified by:
        getAccessibleTransitions in interface IWorkflowManager
        Parameters:
        sessionConfig - the user session information.
        state - the transition state origin.
        serviceInstanceId - the service instance identifier.
        includeScopeAssignedTo - if true, transitions that the user has permission to access only when the content is assigned to him are also included in the returned collection.
        transaction - the transaction for persistence access.
        Returns:
        a collection with the transitions.
        Throws:
        PortalException
      • getAccessibleStates

        @Deprecated
        public java.util.Collection<WorkflowStateConfig> getAccessibleStates​(SessionConfig sessionConfig,
                                                                             java.lang.String serviceInstanceId,
                                                                             boolean includeScopeAll,
                                                                             boolean includeScopeAssignedTo,
                                                                             ITransaction transaction)
                                                                      throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Returns a collection of workflow's accessible states.
        Specified by:
        getAccessibleStates in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        serviceInstanceId - the content service instance id.
        includeScopeAll - if the states with permission scope all are to be included.
        includeScopeAssignedTo - if the states with permission scope assigned to are to be included.
        transaction - the transaction for persistence access.
        Returns:
        a collection with the workflow's accessible states.
        Throws:
        PortalException
      • setServiceInstanceWorkflow

        public void setServiceInstanceWorkflow​(SessionConfig sessionConfig,
                                               java.lang.String serviceInstanceId,
                                               java.lang.String workflowId,
                                               ITransaction transaction)
                                        throws PortalException
        Description copied from interface: IWorkflowManager
        Sets the workflow to be used in a service instance.
        Specified by:
        setServiceInstanceWorkflow in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        serviceInstanceId - the service instance's id.
        workflowId - the workflow's id.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • destroyServiceInstanceWorkflow

        public void destroyServiceInstanceWorkflow​(SessionConfig sessionConfig,
                                                   java.lang.String serviceInstanceId,
                                                   ITransaction transaction)
                                            throws PortalException
        Description copied from interface: IWorkflowManager
        Destroys the service instance workflow, so that the service instance can be correctly removed. This method should be called only prior to a service instance removal.
        Specified by:
        destroyServiceInstanceWorkflow in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        serviceInstanceId - the service instance's id.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • deleteAllContentWorkflowMetaData

        public void deleteAllContentWorkflowMetaData​(SessionConfig sessionConfig,
                                                     java.lang.String serviceInstanceId,
                                                     ITransaction transaction)
                                              throws PortalException
        Description copied from interface: IWorkflowManager
        Deletes all the workflow metadata that is assocated to a specified service instance.
        Specified by:
        deleteAllContentWorkflowMetaData in interface IWorkflowManager
        Parameters:
        sessionConfig - the user session information.
        serviceInstanceId - the service instance identifier.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • setWorkflowPermissions

        public void setWorkflowPermissions​(SessionConfig sessionConfig,
                                           java.lang.String serviceInstanceId,
                                           java.util.Collection<WorkflowPermission> permissions,
                                           ITransaction transaction)
                                    throws PortalException
        Description copied from interface: IWorkflowManager
        Updates the workflow permissions in a service instance.
        Specified by:
        setWorkflowPermissions in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        serviceInstanceId - the service instance's id.
        permissions - the set of permissions to be set in the service instance. All previous permissions will be deleted.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • getContentWorkflowMetaData

        @Deprecated
        public ContentWorkflowMetaData getContentWorkflowMetaData​(SessionConfig sessionConfig,
                                                                  java.lang.String itemId,
                                                                  java.lang.String serviceInstanceId,
                                                                  java.lang.String sourceId,
                                                                  ITransaction transaction)
                                                           throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Returns the content workflow metadata for a content.
        Specified by:
        getContentWorkflowMetaData in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        itemId - the content's item id.
        serviceInstanceId - the content's service instance id.
        sourceId - the content's source id.
        transaction - the transaction for persistence access.
        Returns:
        the content workflow metadata.
        Throws:
        PortalException
      • createNewContentWorkflowMetaData

        @Deprecated
        public void createNewContentWorkflowMetaData​(SessionConfig sessionConfig,
                                                     java.lang.String itemId,
                                                     java.lang.String serviceInstanceId,
                                                     java.lang.String sourceId,
                                                     java.lang.String assignedTo,
                                                     ITransaction transaction)
                                              throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Creates the content workflow metadata for a new content.
        Specified by:
        createNewContentWorkflowMetaData in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        itemId - the content's item id.
        serviceInstanceId - the content's service instance id.
        sourceId - the content's source id.
        assignedTo - the principal identifier to be assigned to.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • deleteContentWorkflowMetaData

        @Deprecated
        public void deleteContentWorkflowMetaData​(SessionConfig sessionConfig,
                                                  java.lang.String itemId,
                                                  java.lang.String serviceInstanceId,
                                                  java.lang.String sourceId,
                                                  ITransaction transaction)
                                           throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Deletes the content workflow metadata of the given content.
        Specified by:
        deleteContentWorkflowMetaData in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        itemId - the content's item id.
        serviceInstanceId - the content's service instance id.
        sourceId - the content's source id.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • executeAction

        @Deprecated
        public void executeAction​(SessionConfig sessionConfig,
                                  java.lang.String itemId,
                                  java.lang.String serviceInstanceId,
                                  java.lang.String sourceId,
                                  java.lang.String performedTransitionId,
                                  java.lang.String newAssignedTo,
                                  ITransaction transaction)
                           throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Executes an action on a content's workflow.
        Specified by:
        executeAction in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        itemId - the content's item id.
        serviceInstanceId - the content's service instance id.
        sourceId - the content's source id.
        performedTransitionId - the transition action performed. If null, no transition is performed.
        newAssignedTo - the new assigned to principal id.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • executeAction

        public void executeAction​(SessionConfig sessionConfig,
                                  ContentLocale contentLocale,
                                  java.lang.String performedTransitionId,
                                  java.lang.String newAssignedTo,
                                  ITransaction transaction)
                           throws PortalException
        Description copied from interface: IWorkflowManager
        Executes an action on a content's workflow.

        After the action is executed, this method sends a WorkflowActionExecutedEvent.

        Specified by:
        executeAction in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        contentLocale - the content locale specific object.
        performedTransitionId - the transition action performed. If null, no transition is performed.
        newAssignedTo - the new assigned to principal id.
        transaction - the transaction for persistence access.
        Throws:
        PortalException
      • hasEditPermission

        @Deprecated
        public boolean hasEditPermission​(SessionConfig sessionConfig,
                                         java.lang.String itemId,
                                         java.lang.String serviceInstanceId,
                                         java.lang.String sourceId,
                                         ITransaction transaction)
                                  throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Returns true if the sessionConfig's user has edit permission to the specified item, according to the workflow's definition, state and assigned to.

        If there is no workflow, or no content workflow metadata, true is returned.

        Specified by:
        hasEditPermission in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        itemId - the content's item id.
        serviceInstanceId - the content's service instance id.
        sourceId - the content's source id.
        transaction - the transaction for persistence access.
        Returns:
        true if the user has the permission, false otherwise.
        Throws:
        PortalException
      • hasEditPermission

        public boolean hasEditPermission​(SessionConfig sessionConfig,
                                         ContentLocale contentLocale,
                                         ITransaction transaction)
                                  throws PortalException
        Description copied from interface: IWorkflowManager
        Returns true if the sessionConfig's user has edit permission to the specified content, according to the workflow's definition, state and assigned to.

        If there is no workflow, or no content workflow metadata, true is returned.

        Specified by:
        hasEditPermission in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        contentLocale - the content.
        transaction - the transaction for persistence access.
        Returns:
        true if the user has the permission, false otherwise.
        Throws:
        PortalException
      • getPossibleAssignedToForAction

        @Deprecated
        public java.util.Collection<java.lang.String> getPossibleAssignedToForAction​(SessionConfig sessionConfig,
                                                                                     java.lang.String itemId,
                                                                                     java.lang.String serviceInstanceId,
                                                                                     java.lang.String sourceId,
                                                                                     java.lang.String transitionId,
                                                                                     ITransaction transaction)
                                                                              throws PortalException
        Deprecated.
        Description copied from interface: IWorkflowManager
        Returns the possible assignedTo values for a workflow transition.
        Specified by:
        getPossibleAssignedToForAction in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        serviceInstanceId - the content's service instance id.
        sourceId - the content's source id.
        transitionId - the workflow's transition id.
        transaction - the transaction for persistence access.
        Returns:
        a collection of principals ids that may be assigned to a content in the given workflow state.
        Throws:
        PortalException
      • getPossibleAssignedTo

        public java.util.Collection<java.lang.String> getPossibleAssignedTo​(SessionConfig sessionConfig,
                                                                            java.lang.String serviceInstanceId,
                                                                            WorkflowStateConfig workflowState,
                                                                            ITransaction transaction)
                                                                     throws PortalException
        Description copied from interface: IWorkflowManager
        Returns the possible assignedTo values for a workflow state.
        Specified by:
        getPossibleAssignedTo in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        serviceInstanceId - the service instance identifier.
        workflowState - the workflow's state.
        transaction - the transaction for persistence access.
        Returns:
        a collection of principals identifiers that may be assigned to a content in the specified state.
        Throws:
        PortalException
      • contentMayBePublished

        @Deprecated
        public boolean contentMayBePublished​(SessionConfig sessionConfig,
                                             java.lang.String itemId,
                                             java.lang.String serviceInstanceId,
                                             java.lang.String sourceId,
                                             ITransaction transaction)
                                      throws PortalException
        Deprecated.
        Specified by:
        contentMayBePublished in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        itemId - the content's item id.
        serviceInstanceId - the content's service instance id.
        sourceId - the content's source id.
        transaction - the transaction for persistence access.
        Returns:
        true if the content may be published, according to its workflow state, false otherwise.
        Throws:
        PortalException
      • contentMayBePublished

        public boolean contentMayBePublished​(SessionConfig sessionConfig,
                                             ContentLocale contentLocale,
                                             ITransaction transaction)
                                      throws PortalException
        Description copied from interface: IWorkflowManager
        Indicates if a content version may be published according to its workflow state.
        Specified by:
        contentMayBePublished in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        contentLocale - the content version.
        transaction - the transaction for persistence access.
        Returns:
        true if it may be published, according to its workflow state, false otherwise.
        Throws:
        PortalException
      • autoArchivePublishedContent

        public boolean autoArchivePublishedContent​(ContentLocale contentLocale,
                                                   ITransaction transaction)
                                            throws PortalException
        Description copied from interface: IWorkflowManager
        Used for the automatic content archiving process. Performs a transition to a directly reachable archival state, if any.

        If the given content version is not in a published state or is already in an archived state or is not after its publishing period then nothing is done.

        Specified by:
        autoArchivePublishedContent in interface IWorkflowManager
        Parameters:
        contentLocale - the content version.
        transaction - the transaction for persistence access.
        Returns:
        true if the content version was archived, or false if nothing was done.
        Throws:
        PortalException
      • removeWorkflowPermissionsWithoutAcl

        public void removeWorkflowPermissionsWithoutAcl()
                                                 throws PortalException
        Removes all workflow permissions entries where there does not exist an ACL entry for the same principal in the same service instance. Called when ACLs are updated.
        Throws:
        PortalException
        Since:
        5.0.0
      • getMetadataPrincipals

        public java.util.Map<java.lang.String,​java.lang.String> getMetadataPrincipals​(SessionConfig sessionConfig,
                                                                                            java.lang.String serviceInstanceId,
                                                                                            ITransaction transaction)
                                                                                     throws PortalException
        Returns a map of distinct principals that is assigned to content metadata in the given service instance.
        Parameters:
        sessionConfig - the user session information.
        serviceInstanceId - the service instance's id.
        transaction - the transaction for persistence access.
        Returns:
        map of principals.
        Throws:
        PortalException
        Since:
        5.6.1
      • getAccessibleStates

        public java.util.Collection<WorkflowStateConfig> getAccessibleStates​(SessionConfig sessionConfig,
                                                                             java.lang.String serviceInstanceId,
                                                                             java.util.EnumSet<StateScope> scopes,
                                                                             ITransaction transaction)
                                                                      throws PortalException
        Description copied from interface: IWorkflowManager
        Returns a collection of workflow's accessible states.
        Specified by:
        getAccessibleStates in interface IWorkflowManager
        Parameters:
        sessionConfig - user session information.
        serviceInstanceId - the content service instance id.
        scopes - states scope that the user has permission to access StateScope}
        transaction - the transaction for persistence access.
        Returns:
        a collection with the workflow's accessible states.
        Throws:
        PortalException