Our first blog post will talk about workflows in Liferay, specific to the 6.1 release. We expect 6.2 to be generally available after the Liferay Symposium next week. If you are attending, please stop by and say hello at our exhibit!
Workflow. First, let's explain exactly what we mean when we talk about workflow. A workflow consists of a sequence of connected steps. It is a depiction of a sequence of operations, defined as the work of a person, a group, an organization, or one or more simple or complex mechanisms.
Workflow may be seen as any abstraction of real work, segregated in workshare, work split or other types of ordering. For control purposes, workflow may be a view on real work under a chosen aspect. A workflow is a model to represent real work for further assessment. For example, describing a repeatable sequence of operations. More abstractly, a workflow is a pattern of activity enabled by a systematic organization of resources defined roles and mass, energy and information flows, into a work process.
Liferay 6.1 integrates workflow engines like jBPM or Kaleo on any asset. With this feature, users are able to manage the content creation process with a workflow, helping content creators collaborate for higher quality assets. Within a workflow, assets such as a Document Library document, wiki entry or web content can go through a review-approval process.
- Liferay 6.1 bundled with Tomcat Vanilla Instance
- Kaleo Workflow Web Plugin
- Liferay Installation:
Please refer to Liferay website for instructions.
- Kaleo Workflow:
If you are using Liferay 6.x or above then Kaleo Web plugin will come pre-installed. Look inside the “webapps” folder and if you see a folder named “kaleo-web” it indicates that Kaleo is already installed.
In case you don’t see the folder, you can download the war file from this link for CE version. If you are running a EE server then you can download this plugin by accessing the Customer Portal.
Once you have downloaded the war file, place that file in the deploy folder and the plugin will get deployed.
Understanding Kaleo Workflow:
Liferay’s Kaleo workflow plugin is driven by XML files and configured for the users of the portal. Portal administrators can configure the whole workflow from the control panel itself. Once we install the plugin, the following options get added to the control panel:
- My Workflow Tasks
- Workflow Configuration
- My Submissions
My Workflow Tasks: This option appears for those users who have a specific role which is a part of approval process. This option lists shows two sections “Assigned to Me” and “Assigned to My Role” as shown below.
The first section displays a list of all the workflow tasks assigned to the logged in user and the second section lists all the workflow tasks assigned to the role to which user is assigned.
My Submissions: This option is provided to the user submitting content for approval. So whenever a user submits content or a document which falls under workflow, the user can track the approval process.
If no submissions are pending then the user sees the following screen:
This option provides various options to set workflow configurations for the site currently accessed in the control panel. following is the screenshot of workflow configuration screen:
The Administrator can select which workflow is to be applied for what type of content. By selecting the workflow from the dropdown, the Admin can then apply a different workflow to the different types of content.
This is a portal level option available to users having Administrator or similar roles. This section allows the Admin to add new workflow configurations. Under this section the Admin can manage the workflows currently installed with the Kaleo Web Plugin.
Administrators can add/edit/deactivate/remove a workflow definition under this section. The process of adding new workflow definition is pretty simple. Click on the Add button to view the following form, provide a name for the workflow and upload a workflow XML file.
There is one default workflow that is bundled with the Kaleo-web plugin: Single Approver Workflow. This workflow requires one approval before an asset can be published. One of the conveniences of using Liferay's workflow engine is that any roles specified in the workflow definition are created automatically when the definition is deployed. This provides a level of integration with the portal that third party engines cannot match. The Single Approver Workflow contains three roles each with different scopes. The scope of each role can be easily determined by their names - Community Content Reviewer, Organization Content Reviewer, and Portal Content Reviewer.
In this article we are not going to explore the default workflow, rather we will work on a use case and try to understand each element of the workflow XML.
Use Case: Multiple Approval Workflow for Blogs
So for the use case, we have a blog that needs to be approved on two levels before it is published. A user Blog Writer who has permission to create a blog submits one for publication and it is sent for First review to a user with permission to review it. Once the Blog Reviewer reviews the content, it can be approved or rejected. If the content is approved the content is sent as a workflow task to those users having the role of Blog Publisher. Once the content Blog is approved then the portal administrator or site admin can configure the blog to be published on the specific portlets.
Please take a look at the workflow XML attached with the article which has been programmed to support a multiple approval workflow.
Workflow definition schema configuration:
<workflow-definition xmlns="urn:liferay.com:liferay-workflow_6.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
We can define name, provide a description and version of the workflow definition in the following way:
<description>A Multiple approver can approve Blogs through workflow definitions.</description>
After that, we need to define our initial state. States can contain actions and transitions. Let’s examine the initial state for our use case:
So in the above, state transitions provide moving from one task to another. Like the above, state tells that when a new content is created send it to review task.
Let have a closer look at the “update” task:
This task is activated if the content is rejected at any level of review. It will be a default task triggered when the workflow process is reset.
The first task in the workflow process is the “review” task which appears once a content is created and assigned to the user with roles mentioned in the role section of the task. You'll notice that this task transitions into another task called “second_review” and this provides us one more level of approval. While the tasks “review” and “second_review” are similar, make sure you include the roles which will be responsible for the second_review task.
Once the second_review task is completed, the flow transitions to “approved” state, which executes a script to update the state of the content to “Approved”.
Once we have created the workflow definition xml, we need to follow the steps mentioned below for configuring the portal to fulfill our use case:
- Create Users
Create three users like Blog Writer, Blog Reviewer and Blog Publisher
- Create User Groups
Create three user groups like Blog Writer, Blog Reviewer and Blog Publisher. You can pick your own name to avoid confusion. After creating the user groups assign them to the site for which you are configuring workflow.
- Create Custom Role
Create a custom role named “Blog Writer” of type “Site”. Once the role is created define the permissions as shown in the screenshot below:
- Add Workflow Definition
Go to the portal section of the control panel and open workflow section. Click on “Add” button and provide a name to the workflow definition like “Multiple Approval”. Then browse to the workflow definition XML file and click on save. Before saving your screen should look similar to the following:
Once the workflow definition gets uploaded successfully, it will auto generate the roles mentioned in the workflow definition XML file.
- Assigning Role to User Groups
Navigate to the Site Membership section and open the User Group Tab- you should see something similar to the following screenshot:
Click on “Assign Site Role” and assign the role Blog_Writer to user group Blog_Writer user group, and so the same for the other two user groups.
After assigning the roles you will see following screen:
- Associate User with User Group
In this step we will be associating the users with a specific user group so that the users inherit the roles associated with their groups.
For our case, let’s associate Blog Writer with Blog_Writer User Group, Blog Reviewer user with Blog_Reviewer User Group and Blog Publisher with Blog Publisher User Group.
- Workflow Configuration
Now we need to enable the workflow definition for the Blogs Entry. Navigate to the “Workflow Configuration” section and select the “Multiple Approver (Version 1)” option from the combo box in front of “Blogs Entry” as shown below:
After selecting, Click on the Save button.
After completing all the above steps you are good to start testing the configurations.
And this is how you achieve a multiple workflow process using the Kaleo Web Plugin. Please let us know how it works for you.