Weblogic Portal - Create Custom WorkFlow

Please find Creating Custom Workflow documentation. But in the documentation you will not find the code in detail level. Now we are going to see that in detail.

If you are using a WLP repository and library services-enabled, you can enforce a workflow process when users add and publish content in the repository. WLP repositories include one default content workflow. You can create additional content workflows or customize content workflows to suit your business needs.

Refer Adding WorkFlow for adding the custom workflow. Please download the Default Workflow for your later reference. Once you add custom workflow, you may loose the default workflow.

Follow the below Steps before overwriting Default Workflow:

1. Create 4 users in User Management of PortalAdminConsole as: author, reviewer, approver, publisher
2. Create 4 roles. Click User, Group, Others-> Delegated Administration and create 4 roles PortalSystemDelegator : AuthorDelegator, ReviewerDelegator, ApproverDelegator, PublisherDelegator.
3. Add users to Roles.
add author to AuthorDelegator
add reviewer to ReviewerDelegator
add approver to ApproverDelegator
add publisher to PublisherDelegator
4. Enable Library Services
5. Go to Content -> Content Management->Repositories->Workflows->Default.Click on Replace File button and provide the xml file provided below.
6. Go to Content -> Content Management->Content->Virtual Content Repository->WLP Repository->Delegated Admin tab->Add Role, and give following capabilities

AuthorDelegator: Create, View, Update, Assign Workflow capabilities
ApproverDelegator: View, Update, Delete, Assign Workflow capabilities
PublisherDelegator: View, Update, Publish, Assign Workflow capabilities
ReviewerDelegator: View, Update, Assign Workflow capabilities

7. Go to Content -> Content Management->Types->WLP Repository->Delegated Admin tab->Add Role, and give Instantiate capabilities to AuthorDelegator role
8. Go to Content -> Content Management->Repository->WLP Repository->Delegated Admin tab->Add Role, give Manage capabilities to AuthorDelegator,PublisherDelegator,ReviewerDelegator, AuthorDelegator roles

Modified_Default.xml (WorkFlow xml)
===================================

 <?xml version="1.0" encoding="UTF-8"?>  
 <workflow xmlns="http://schema.workflow.virtual.content.bea.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schema.workflow.virtual.content.bea.com">  
 <transition>  
 <from-status id=”1″/>  
 <!– to reviewer –>  
 <to-status id=”101″>  
 <capabilityConstraint>can_associate</capabilityConstraint>  
 <action class="com.test.SubmitForReviewAction"/>  
 </to-status>  
 <to-status id=”4″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.PublishAction"/>  
 </to-status>  
 <to-status id=”5″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.RetireAction"/>  
 </to-status>  
 </transition>  
 <!– reviewer’s action –>  
 <transition>  
 <from-status id=”101″/>  
 <to-status id=”101″>  
 <capabilityConstraint>can_associate</capabilityConstraint>  
 <action class="com.test.SubmitForReviewAction"/>  
 </to-status>  
 <to-status id=”2″>  
 <capabilityConstraint>can_associate</capabilityConstraint>  
 <capabilityConstraint>can_delete</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.ReadyAction"/>  
 </to-status>  
 <to-status id=”3″>  
 <capabilityConstraint>can_associate</capabilityConstraint>  
 <capabilityConstraint>can_delete</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.RejectAction"/>  
 </to-status>  
 <to-status id=”4″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.PublishAction"/>  
 </to-status>  
 <to-status id=”1″>  
 <capabilityConstraint>can_create</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.DraftAction"/>  
 </to-status>  
 </transition>  
 <transition>  
 <from-status id=”2″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 </from-status>  
 <to-status id=”3″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.RejectAction"/>  
 </to-status>  
 <to-status id=”4″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.PublishAction"/>  
 </to-status>  
 <to-status id=”5″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.RetireAction"/>  
 </to-status>  
 </transition>  
 <transition>  
 <from-status id=”3″/>  
 <to-status id=”1″>  
 <action class="com.bea.content.virtual.workflow.DraftAction"/>  
 </to-status>  
 <to-status id=”101″>  
 <action class="com.test.SubmitForReviewAction"/>  
 </to-status>  
 <to-status id=”5″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.RetireAction"/>  
 </to-status>  
 </transition>  
 <transition>  
 <from-status id=”4″/>  
 <to-status id=”1″>  
 <action class="com.bea.content.virtual.workflow.DraftAction"/>  
 </to-status>  
 <to-status id=”5″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.RetireAction"/>  
 </to-status>  
 </transition>  
 <transition>  
 <from-status id=”5″/>  
 <to-status id=”1″>  
 <action class="com.bea.content.virtual.workflow.DraftAction"/>  
 </to-status>  
 <to-status id=”4″>  
 <capabilityConstraint>can_publish</capabilityConstraint>  
 <action class="com.bea.content.virtual.workflow.PublishAction"/>  
 </to-status>  
 </transition>  
 <!– undefined transition. This is used when we change the workflow of a  
 node and the current status of the node  
 is not a valid from-status in any of the transitions in this workflow. –>  
 <transition>  
 <from-status id=”-1″/>  
 <to-status id=”1″>  
 <action class="com.bea.content.virtual.workflow.DraftAction"/>  
 </to-status>  
 </transition>  
 <beginStatus id=”1″ />  
 <status id=”1″ text=”Draft” />  
 <status id=”101″ text=”Ready for Reviewer” />  
 <status id=”2″ text=”Ready for Approval” />  
 <status id=”3″ text=”Rejected” />  
 <status id=”4″ text=”Published” />  
 <status id=”5″ text=”Retired” />  
 </workflow>   

The best way to write a new class is using an Utility project in Workshop for WebLogic. This way will automatically compile and redeploy the classes as needed and you do not have to add the class to enterprise’s classpath. You should put any custom workflow actions should in the enterprise application’s classpath (APP-INF/classes). For information about creating Utility projects, see New Utility Project Wizard in Workshop for WebLogic Product Family Documentation.

Please find below the custom action class:

 package com.test;  
 import java.util.ArrayList;  
 import java.util.List;  
 import com.bea.content.virtual.workflow.StandardAction;  
 import com.bea.content.virtual.workflow.WorkflowActionContext;  
 import com.bea.content.virtual.workflow.WorkflowException;  
 public class SubmitForReviewAction extends StandardAction {  
 private static final long serialVersionUID = 1L;  
 @Override  
 public void execute(WorkflowActionContext actionContext)  
 throws WorkflowException {  
 List<String> roleList=new ArrayList<String>();  
 roleList.add("ReviewerDelegator");  
 assignNodeToRoles(actionContext, roleList.iterator(), actionContext.getVirtualNode().getId());  
 super.execute(actionContext);  
 }  
 }   


Note : SubmitForReviewAction.class should be in class path.


Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today