By the end of this chapter you will have learned: • The advantages of workflow • How to enable dynamic customization of workflow without requiring a restart of the Alfresco server • The
Trang 2Dynamic Deployment and
Customizations The dynamic model feature enables dynamic customization of models without
requiring a restart of the Alfresco server, and is also applicable to a
multi-tenant environment This also includes dynamic reloading of the web client UI
customizations Customizations of workflows can be done easily
By the end of this chapter you will have learned:
• The advantages of workflow
• How to enable dynamic customization of workflow without requiring a restart of the Alfresco server
• The process of customizing an existing workflow
• How to remove workflow for a specific staging submission
• How to configure a ZERO workflow
• How to implement workflow viewer to see the pending list of workflows
Dynamic deployment
You are able to dynamically deploy workflow in Alfresco WCM by using workflow types, workflow definitions, web client configurations, and property files Since
version 3.0, Alfresco supports dynamic deploy of models, workflows, messages, and web-client configuration changes to facilitate dynamic customization without requiring a restart of the Alfresco server Let's discuss how to dynamically deploy models, workflows, messages, and web-client changes
Trang 3Dynamic Deployment and Customizations
[ 204 ]
The following are the advantages of dynamic deployment:
• There is no need to restart the Alfresco server every time you make changes
to the files
• Both the content as well as the files are stored in the repository It is easier to maintain and move content along with the files
• You can activate and inactivate the dynamic models by keeping the model XML file in the repository
• You can deploy and undeploy the workflow definitions as and when required
• In a multi-tenant setup, the files that are defined in the <extension> folder are available to all tenants If you would like to customize workflow for a specific tenant only, then a dynamic deployment is the best choice
Dynamic models
Dynamic models are nothing but XML-based model files Creating a dynamic custom model is the same as creating a regular custom model For this example, create a custom content type that has two properties Create a file named
dynamicWCMWorkflowModel on your personal computer with the
downloaded content
Download the complete code sample from Packt's website
Deploying a model file
The Task Model can also be dynamically deployed without restarting the server This can be achieved by two ways:
• Uploading or creating the model file in the new 'Models' space (Company
Home | Data Dictionary | Models).
• Using pre-registered URLs provided by the Alfresco Repository
Admin Console
Trang 4First approach
Dynamic workflow models are stored in the new 'Models' space (Company Home |
Data Dictionary | Models).
Upload a custom XML model file, dynamicWCMWorkflowModel, to the 'Models' space
By default, the model will not be active unless the Model Active checkbox is selected during the upload To activate a previously inactive model, select View Details and then select the Modify properties icon In the Modify Content Properties page, select the Model Active checkbox.
To deactivate a model, select View Details and then select the Modify properties icon In the Modify Content Properties page, unselect the Model Active checkbox.
Follow these steps to deploy a model dynamically:
1 Go to Company Home | Data Dictionary | Models.
2 In the header click on Add Content.
3 The Add Content Wizard is displayed Upload the custom XML file.
4 In the Name textbox type dynamicWCMWorkflowModel.
5 Click on OK.
6 The Modify Content Properties dialog is displayed Check the Model Active
property, as shown in the following screenshot:
Trang 5Dynamic Deployment and Customizations
[ 206 ]
To verify the changes, log out and log in if required
Updating a custom model
You can directly edit or update the XML model file If the model is active, then it will
be reloaded If the file is checked out, then the working copy will be ignored until such a time as the file is checked in
Second approach
Deployment of model files can be achieved as an administrator using the URL
http://<server-name>:<port>/alfresco/faces/jsp/admin/
repoadmin-console.jsp
You can use the following commands to activate or deploy the model
activate model dynamicWCMWorkflowModel.xml: This command is used to set the repository model to active and load into runtime data dictionary
deploy model alfresco/extension/dynamicWCMWorkflowModel.xml: This
command uploads the model to the repository and loads it into runtime data
dictionary This will also set the repository model as active
Dynamic Resource Bundles
Creating a Dynamic Resource Bundle is the same as creating a regular property file For this example, create labels for two properties that are defined in the model file Create a file named dynamicWCMWorkflowMessages on your personal computer with the following content:
dynamic_processTask.workflow.title=Dynamic Workflow
dynamic_processTask.workflow.description=Dynamic Workflow for approval
Deploying a Resource Bundle
The Resource Bundle can also be dynamically deployed without restarting
the server
This can be achieved by two ways:
• Uploading or creating the message file in the new Messages space (Company
Home | Data Dictionary | Messages).
• Using the Repository Admin Console provided by Alfresco
Trang 6First approach
The associated message Resource Bundles are stored in the new Messages space (Company Home | Data Dictionary | Messages) Upload the custom Resource
Bundle by uploading each of the message property files (for all locales) to the
Messages space The messages will not be applied until they are explicitly reloaded
or when the server is restarted
Follow these steps to create a message:
1 Go to Company Home | Data Dictionary | Messages.
2 In the header, click on Add Content.
3 The Add Content Wizard is displayed Upload the custom property file.
4 In the Name textbox type dynamicWCMWorkflowMessages.properties.
5 Click on OK.
The custom configuration will not be applied until it is explicitly reloaded (refer to the following section) or the server is restarted
Trang 7Dynamic Deployment and Customizations
[ 208 ]
Reloading the Resource Bundle
If the Resource Bundle file has been added, edited, or updated, it can be dynamically reloaded by using the Alfresco Repository Admin Console via:
http://<server-name>:<port>/alfresco/faces/jsp/admin/
repoadmin-console.jsp
This has a single command, reload, which will cause the Resource Bundle to
be reloaded
reload messages dynamicWCMWorkflowMessages
Updating a Resource Bundle
You can directly edit or update the Resource Bundle file Use the reload command
to reflect the changes If the file is checked out, then the working copy will be ignored until such a time as the file is checked in
Second approach
They can be dynamically reloaded by using the Alfresco Repository Admin
Console via: http://<server-name>:<port>/alfresco/faces/jsp/admin/
repoadmin-console.jsp
The command deploy messages <resource bundle base name> will cause the message resource to be re-registered
deploy messages alfresco/extension/dynamicWCMWorkflowMessages
Dynamic workflows
Dynamic workflows are nothing but XML-based Process Definition files Creating
a dynamic Process Definition is the same as creating a regular Process Definition file For this example, create a custom Process Definition Create a file named
dynamicProcessDefinition on your personal computer with the
downloaded content
Download the code samples from Packt publisher's book website
Deploying a Process Definition file
The Process Definition can also be dynamically deployed without restarting the server
Trang 8This can be achieved by three ways:
• Uploading or creating the Process Definition file in the new
Workflow Definitions space (Company Home | Data Dictionary |
Workflow Definitions).
• Using JBoss jBPM Process Designer tool
• Using pre-registered URLs provided by Alfresco workflow console
First approach
The Process Definitions are stored in the new Workflow Definitions space
(Company Home | Data Dictionary | Workflow Definitions) Upload a custom XML Process Definition file to the Workflow Definitions space By default, the Process Definition will not be deployed unless the Workflow Deployed checkbox is
selected during the upload
Follow these steps to create a Process Definition:
1 Go to Company Home | Data Dictionary | Workflow Definitions.
2 In the header click on Add Content.
3 The Add Content Wizard is displayed Upload the custom XML file.
4 In the Name textbox type dynamicProcessdefinition.xml Click on OK.
5 Select the Workflow Deployed checkbox By default, the Process Definition will not be deployed unless the Workflow Deployed checkbox is selected
during the upload
6 In the Workflow Engine Id type jbpm The completed definition is shown in
the following screenshot:
Trang 9Dynamic Deployment and Customizations
[ 210 ]
7 Click on OK.
To verify the changes, log out and log in
To undeploy a Process Definition, select View Details and then select the Modify
properties icon In the Modify Content Properties page, unselect the Workflow Deployed checkbox.
Second approach
JBoss jBPM also includes a graphical designer tool for authoring business processes The most important feature of the graphical designer tool is that it includes support for both the tasks—that of the business analyst as well as the technical developer This enables a smooth transition from business process modeling to the
practical implementation
Follow these steps for configuring the jBPM:
1 To implement this you have to download jBPM plugins from:
http://sourceforge.net/projects/jbpm/files/jBPM%20Process%20 Designer/jbpm-jpdl-designer-3.1.7
2 Once the installation is over, restart Eclipse
3 Go to File | New | Project Expand jBoss JBPM and select Process Project
as shown in the following screenshot:
Trang 104 Enter the Project Name and click on Next.
5 Select the jBPM location as mentioned in the following screenshot and click
on Finish:
6 Copy the Process Definition code and paste it in the src/main/jpd package.
7 The process should look like the next screenshot: