Chapter 6. Dynamic 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.

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.

Note

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.

First 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:
    First approach
  7. Click on OK.

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.

First 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.
    First approach

The custom configuration will not be applied until it is explicitly reloaded (refer to the following section) or the server is restarted.

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.

Note

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.

This 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:
    First approach
  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%20Designer/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:
    Second approach
  4. Enter the Project Name and click on Next.
  5. Select the jBPM location as mentioned in the following screenshot and click on Finish:
    Second approach
  6. Copy the Process Definition code and paste it in the src/main/jpd package.
  7. The process should look like the next screenshot:
    Second approach
  8. Deploy it as mentioned ahead.

Following are the steps to be followed to deploy a workflow via JBoss jBPM Process Designer. This will deploy workflow without restart of the server.

  1. Ensure the Alfresco server is up and running.
  2. Click on the source tab and copy the content of the file dynamicProcessdefinition.
  3. Click on the Deployment tab and enter the following information:
    • Server Name = machine name where Alfresco is installed
    • Server Port = port number assigned to Alfresco (default: 8080)
    • Server Deployer = /alfresco/jbpm/deployprocess
  4. Click on Test Connection....
  5. If all is OK, click on Deploy Process Archive....

The following screenshot shows the details provided earlier:

Second approach
Display of workflow images

If Hot Deployment is done, then we can see the workflow images that show the current status of workflow in Alfresco Explorer under the workflow outline section. The screenshots can be seen in the following sections when you test the workflows that are deployed through jPDL.

Modify these files:

  • /jsp/workflow/start-workflow-wizard/workflow-options.jsp
  • /jsp/workflow/manage-task-dialog.jsp

Change the rendered and expanded value to true as highlighted.

The modified code is as follows:

<a:panel rendered="true" id="workflow-outline" label="#{msg.workflow_outline}" progressive="true" expanded="true" border="white" bgcolor="white" titleBorder="lbgrey" expandedTitleBorder="dotted" titleBgcolor="white" styleClass="mainSubTitle">

Third approach

The workflow console can be used (as an alternative to the Alfresco Explorer) to deploy and undeploy Process Definitions. Its primary use is to test newly-developed workflow definitions. However, it also supports the debugging/diagnosis of current "in-flight" workflows. This can be deployed via http://<server-name>:<port>/alfresco/faces/jsp/admin/workflow-console.jsp.

The command deploy <workflow-name> will cause the workflow to be deployed.

deploy alfresco/extension/dynamicProcessdefinition.xml

Dynamic Alfresco Explorer

A dynamic web client configuration file will have the same name as a custom web client configuration file. For example, create a web-client-config-custom.xml file, with the following content, to support the dynamic content type that you created earlier:

<config evaluator="node-type" condition="dynamic:initializeTask"
replace="true">
<property-sheet>
<separator name="sep2" display-label-id="users_and_roles"
component-generator="HeaderSeparatorGenerator" />
<show-property name="dynamic:property" />
<show-association name="bpm:assignee"
display-label-id="wf_reviewers" />
</property-sheet>
</config>
<config evaluator="node-type" condition="dynamic:reviewTask" replace="true">
<property-sheet>
<separator name="sep1" display-label-id="general"
component-generator="HeaderSeparatorGenerator" />
<show-property name="bpm:taskId" />
<show-property name="bpm:description"
component-generator="TextAreaGenerator" read-only="true"/>
<show-property name="bpm:comment"
component-generator="TextAreaGenerator" />
<separator name="sep2" display-label-id="wf_reviewers"
component-generator="HeaderSeparatorGenerator" />
<show-association name="bpm:assignee" display-label-id="wf_reviewers"
read-only="true"/>
</property-sheet>
</config>

Deploying Alfresco Explorer customizations

The web client configurations can also be dynamically deployed without restarting the server.

This can be achieved by two ways:

  • Upload or create the Process Definition file in the new Workflow Definitions space (Company Home | Data Dictionary | Workflow Definitions).
  • Using the pre-registered URLs provided.

Dynamic Alfresco Explorer customizations are stored in the new Web Client Extension space (Company Home | Data Dictionary | Web Client Extension).

Upload a custom web-client-config-custom.xml file to the Web Client Extension space.

Deploying Alfresco Explorer customizations

The custom configuration will not be applied until it is explicitly reloaded or when the server is restarted.

Reloading web client customizations

If the web-client-config-custom.xml file has been added, edited, or updated, it can be dynamically reloaded by using the Alfresco Explorer configuration console via: http://<server-name>:<port>/alfresco/faces/jsp/admin/webclientconfig-console.jsp.

This has a single command reload, which will cause the Alfresco Explorer configuration to be reloaded.

Note

Using the dynamic approach you can deploy workflow in DM. In order to deploy it in WCM you have to make the change manually in web-client-config-wcm.xml, as discussed earlier (see the Deploying into WCM Project section) in Chapter 5, WCM Workflows and then restart the server once. The dynamic approach can also be used if some changes are required after deployments so, no need to restart the server.

Testing the workflow

To assign workflow for a specific project, refer to the Associating workflows to web project section in Chapter 5. While submitting, the content task appears in user's dashlet. On clicking on the task, you find the screen shown in the following screenshot. The highlighted section, Workflow Outline, displays the diagram of the deployed Process Definition. This is visible since we have made hot deployment of the workflow. Now you can approve or reject the workflow:

Testing the workflow
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset