Chapter 22. Portal Workflow
Prev |  | Next

## Chapter 22. Portal Workflow

### Sohil Shah

`<sshah @ redhat dot com>`

JBoss Portal packages a Workflow Service based on JBPM. This service provides you with the JBPM services that your portal can use to build out the end-user/application workflows that should meet your portal's requirements.

## 22.1. JBPM Workflow Engine Integration

The JBPM Workflow service is packaged as an mbean and takes care of all the low-level JBPM related functions. The configuration is found in jboss-portal.sar/portal-cms.sar/portal-workflow.sar/META-INF/jboss-service.xml. The mbean service configuration is as follows:

    <!-- Hibernate service -->
    <mbean
       code="org.jboss.portal.jems.hibernate.SessionFactoryBinder"
       name="portal:service=Hibernate,type=Workflow"
       xmbean-dd=""
       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
       <xmbean/>
       <depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
       <attribute name="DoChecking">true</attribute>
       <attribute name="ConfigLocation">conf/hibernate/workflow/hibernate.cfg.xml</attribute>
       <attribute name="JNDIName">java:/portal/workflow/WorkFlowSessionFactory</attribute>
    </mbean>

    <!-- Workflow service -->
    <mbean
       code="org.jboss.portal.workflow.service.WorkflowServiceImpl"
       name="portal:service=Workflow,type=WorkflowService"
       xmbean-dd=""
       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
       <xmbean/>
       <depends>portal:service=Hibernate,type=Workflow</depends>
       <attribute name="JbpmConfigurationXml">
          <jbpm-configuration>
             <jbpm-context>
                <service name="persistence"
                   factory="org.jbpm.persistence.db.DbPersistenceServiceFactory"/>
             </jbpm-context>
             <string name="resource.hibernate.cfg.xml"
                value="conf/hibernate/workflow/hibernate.cfg.xml"/>
             <string name="resource.business.calendar"
                value="org/jbpm/calendar/jbpm.business.calendar.properties"/>
             <string name="resource.default.modules"
                value="org/jbpm/graph/def/jbpm.default.modules.properties"/>
             <string name="resource.converter"
                value="org/jbpm/db/hibernate/jbpm.converter.properties"/>
             <string name="resource.action.types" value="org/jbpm/graph/action/action.types.xml"/>
             <string name="resource.node.types" value="org/jbpm/graph/node/node.types.xml"/>
             <string name="resource.varmapping" value="org/jbpm/context/exe/jbpm.varmapping.xml"/>
          </jbpm-configuration>
       </attribute>
    </mbean>

## 22.2. CMS Publish/Approve Workflow Service

The CMS Publish/Approval Workflow feature can be optionally turned on so that, every file that is created or updated needs to go through an Approval process before it can be published to go Live. The current implementation, creates a pending queue for managers. The managers can then either approve or reject the publishing of the document in question.

## 1. How activate this feature?

In the following file, jboss-portal.sar/portal-cms.sar/META-INF/jboss-service.xml, activate this feature on the org.jboss.portal.cms.impl.jcr.JCRCMS MBean

    <mbean
       code="org.jboss.portal.cms.impl.jcr.JCRCMS"
       name="portal:service=CMS"
       xmbean-dd=""
       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
       <xmbean/>
       <!-- The datasource hibernate depends on,
            it can be commented when the file store is used -->
       <depends>jboss.jca:service=DataSourceBinding,name=PortalDS</depends>
       <depends>portal:service=JAASLoginModule</depends>
       <depends>portal:service=Hibernate,type=CMS</depends>
       <depends>portal:service=Module,type=IdentityServiceController</depends>

       <!-- Uncomment this to activate publish/approval workflow integration -->
       <depends optional-attribute-name="ApprovePublishWorkflow"
          proxy-type="attribute">portal:service=ApprovePublish,type=Workflow</depends>

       <depends optional-attribute-name="StackFactory" proxy-type="attribute">
          portal:service=InterceptorStackFactory,type=Cms
       </depends>
       <attribute name="DoChecking">true</attribute>
       <attribute name="DefaultContentLocation">
                                           portal/cms/conf/default-content/default/</attribute>
       <attribute name="DefaultLocale">en</attribute>
       <attribute name="RepositoryName">PortalRepository</attribute>
       <attribute name="HomeDir">${jboss.server.data.dir}${/}portal${/}cms${/}conf</attribute>
       <attribute name="Config">

## 2. How to configure this feature?

The configuration for this workflow service is found in the jboss-portal.sar/portal-cms.sar/portal-workflow.sar/META-INF/jboss-service.xml file

    <!-- ApprovePublish workflow service -->
    <mbean
       code="org.jboss.portal.workflow.cms.ApprovePublishImpl"
       name="portal:service=ApprovePublish,type=Workflow"
       xmbean-dd=""
       xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
       <xmbean/>
       <depends optional-attribute-name="WorkflowService" proxy-type="attribute">
          portal:service=Workflow,type=WorkflowService
       </depends>
       <depends optional-attribute-name="IdentityServiceController" proxy-type="attribute">
          portal:service=Module,type=IdentityServiceController
       </depends>
       <!-- JBPM process definition -->
       <attribute name="Process">
          <!-- cms approval workflow -->
          <process-definition name="approval_workflow">
             <start-state>
                <transition to="request_approval"/>
             </start-state>
             <task-node name="request_approval" signal="first">
                <task name="approve_publish">
                   <assignment class="org.jboss.portal.cms.workflow.PublishAssignmentHandler"/>
                   <event type="task-start">
                      <action class="org.jboss.portal.cms.workflow.FinalizePublish"/>
                   </event>
                   <exception-handler>
                      <action class="org.jboss.portal.workflow.cms.TaskExceptionHandler"/>
                   </exception-handler>
                </task>
                <transition name="approval" to="end"/>
                <transition name="rejection" to="end"/>
             </task-node>
             <end-state name="end"/>
          </process-definition>
       </attribute>
       <!--
       overwrite = false creates the process first time if does not exist, for
       subsequent server restarts, this process definition remains in tact

       overwrite = true creates the process first time if does not exist,
       for subsequent server restarts, it creates a new version of the process definition
       which will be used for processes created from then onwards. Old processes created
       for an older version of the definition remain in tact and use their corresponding
       process definition.

       Typically use overwrite=false and overwrite=true only when a new process definition
       elated to this workflow needs to be deployed
          -->
       <attribute name="Overwrite">false</attribute>
       <!--
    a comma separated list of portal roles that are designated
    to act as workflow managers. They are allowed to
    approve/reject content publish requests
       -->
       <attribute name="ManagerRoles">Admin</attribute>
       <attribute name="JNDIName">java:portal/ApprovePublishWorkflow</attribute>
    </mbean>

Prev | Up | Next
Chapter 21. CMS Portlet | Home | Chapter 23. Navigation Tabs