Class DefaultWorkflowManager

    • Constructor Detail

      • DefaultWorkflowManager

        public DefaultWorkflowManager()
        Constructs a new WorkflowManager, with an empty workflow cache.
    • Method Detail

      • initialize

        public void initialize​(Engine engine,
                               java.util.Properties props)

        Initializes this Engine component. Note that the engine is not fully initialized at this point, so don't do anything fancy here - use lazy init, if you have to.
         

        Any properties that begin with WorkflowManager.PROPERTY_APPROVER_PREFIX will be assumed to be Decisions that require approval. For a given property key, everything after the prefix denotes the Decision's message key. The property value indicates the Principal (Role, GroupPrincipal, WikiPrincipal) that must approve the Decision. For example, if the property key/value pair is jspwiki.approver.workflow.saveWikiPage=Admin, the Decision's message key is workflow.saveWikiPage. The Principal Admin will be resolved via AuthorizationManager.resolvePrincipal(String).
        Specified by:
        initialize in interface Initializable
        Parameters:
        engine - Engine performing the initialization.
        props - Properties for setup.
      • requiresApproval

        public boolean requiresApproval​(java.lang.String messageKey)
        Returns true if a workflow matching a particular key contains an approval step.
        Specified by:
        requiresApproval in interface WorkflowManager
        Parameters:
        messageKey - the name of the workflow; corresponds to the value returned by Workflow.getMessageKey().
        Returns:
        the result
      • getApprover

        public java.security.Principal getApprover​(java.lang.String messageKey)
                                            throws WikiException
        Looks up and resolves the actor who approves a Decision for a particular Workflow, based on the Workflow's message key. If not found, or if Principal is Unresolved, throws WikiException. This particular implementation always returns the GroupPrincipal Admin
        Specified by:
        getApprover in interface WorkflowManager
        Parameters:
        messageKey - the Decision's message key
        Returns:
        the actor who approves Decisions
        Throws:
        WikiException - if the message key was not found, or the Principal value corresponding to the key could not be resolved
      • getEngine

        protected Engine getEngine()
        Protected helper method that returns the associated Engine
        Returns:
        the wiki engine
      • getOwnerWorkflows

        public java.util.List<WorkflowgetOwnerWorkflows​(Session session)
        Returns the current workflows a wiki session owns. These are workflows whose Workflow.getOwner() method returns a Principal also possessed by the wiki session (see Session.getPrincipals()). If the wiki session is not authenticated, this method returns an empty Collection.
        Specified by:
        getOwnerWorkflows in interface WorkflowManager
        Parameters:
        session - the wiki session
        Returns:
        the collection workflows the wiki session owns, which may be empty
      • add

        protected void add​(Workflow workflow)
        Protected helper method that adds a newly created Workflow to the cache, and sets its workflowManager and Id properties if not set.
        Parameters:
        workflow - the workflow to add
      • remove

        protected void remove​(Workflow workflow)
        Protected helper method that removes a specified Workflow from the cache, and moves it to the workflow history list. This method defensively checks to see if the workflow has not yet been removed.
        Parameters:
        workflow - the workflow to remove