![Page 1: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/1.jpg)
LEAH EINECKER
ENHANCED WORKFLOWS IN CASCADE SERVER
![Page 2: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/2.jpg)
WORKFLOWS AT PCC
We love workflow!
Pages edited by subject matter experts
Content must be approved by administrator responsible for content area
Nobody gets publish permissions -- all publishing done by workflow
![Page 3: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/3.jpg)
NIFTY FEATURE: WORKFLOW REPORT
Created from index block and format
This came with the system install
![Page 4: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/4.jpg)
WORKFLOW INDEX
![Page 5: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/5.jpg)
NIFTY FEATURE #2: APPROVER EDITS
• What if the approver wants to make a simple change to a page?
• The page is locked, so they can only send it to another step in the workflow
• Don't want to generate emails to any other user or have the chance that another user will jump on the file
• With the right trigger, you can send a workflow exclusively to yourself
![Page 6: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/6.jpg)
APPROVER EDITS
<action identifier="approver-edits" label="Send to myself for edits" next-id="approver-edits" move="next_id"> <trigger name="com.cms.workflow.function.preserveCurrentUser"/></action>
![Page 7: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/7.jpg)
NIFTY FEATURE #3: ESCALATIONS
• Escalations - If a workflow is ignored for a set period of time, automatically send it to the webmaster
• This is not the same as the due-date / end-date on a workflow
<step type="transition" identifier="review" label="Approver review" default-group="Administrators" escalate-to="escalate" escalation-hours="336">
![Page 8: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/8.jpg)
ESCALATION DETAILS
![Page 9: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/9.jpg)
CUSTOM FEATURE: WORKFLOW EMAILS
• Our users go through a lot of workflows
• Notfication email needs more information than that a workflow "needs attention" • Need to re-edit one I submitted?• Approve one sent by someone else?
• Not very helpful to say that a workflow has ended• Do I really have to log into CMS just to see if it was
approved or rejected?
![Page 10: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/10.jpg)
SAMPLE EMAILS
![Page 11: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/11.jpg)
CUSTOM WORKFLOW TRIGGERS
Create a new class:public class EmailProvider2 extends com.cms.workflow.function.EmailProvider
We put this class in a JAR file that contains all our custom Java (pccCustom.jar)
Put new JAR in:[cascade home]/tomcat/webapps/ROOT/WEB-INF/lib/
![Page 12: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/12.jpg)
WRITING A CUSTOM TRIGGER
Calling any trigger executes:public boolean process() throws TriggerProviderException, FatalTriggerProviderException
Override the process() method, while allowing most everything else to be inherited from superclass
Useful variables available inside process() method:com.hannonhill.cascade.model.workflow.adapter.PublicWorkflowAdapter workflowcom.hannonhill.commons.util.string.StringMap parameters
String mode = parameters.get("mode");
![Page 13: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/13.jpg)
ADD TRIGGER TO WORKFLOW DEFINITION
• Triggers are defined in the <triggers> section of each workflow definition• Cannot be added in GUI workflow builder, must
edit XML
<!-- default trigger --><trigger class="com.cms.workflow.function.EmailProvider" name="EmailProvider"/> <!-- custom trigger --><trigger name="email" class="edu.pima.cascade.workflow.EmailProvider2" />
![Page 14: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/14.jpg)
CUSTOM TRIGGER IN WORKFLOW DEFINITION
<trigger name="email" ><parameter>
<name>mode</name> <value>was-approved</value> </parameter></trigger>
![Page 15: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/15.jpg)
DEFINING EMAIL MESSAGES
• Messages are defined in a Java properties file• Could just as well have been text, XML, etc…
• Use placeholders for common fields like workflow name and generating HTML links to the CMS
• Depending on workflow step type, emails are targeted to workflow owner (submitter) or the group owning the asset• Messages about approval being required go to the group
owning the asset, but limited to the Approval role
![Page 16: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/16.jpg)
SAMPLE EMAIL DEFINITIONS
email.needs-approval.mailApproversOnly = 1email.needs-approval.subj = Web page needs approval - [WORKFLOW_NAME]email.needs-approval.msg = <p>A web page or document is waiting \ for your review and approval - [WORKFLOW_NAME]</p> \ <p>Use the link below to access the web workflow:<br /> \ <a href="[VIEW_WORKFLOW_URL]">View the workflow screen</a></p>
email.was-approved.subj = Web page was approved - [WORKFLOW_NAME]email.was-approved.msg = <p>A web page or document that you \ submitted to CMS workflow has been approved - [WORKFLOW_NAME]</p> \ <p>Use the link below to view the document in the web content \ management system:<br /> \ <a href="[VIEW_ASSET_URL]">View document</a></p>
![Page 17: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/17.jpg)
CUSTOM FEATURE: ESCALATIONS
• What if you know an approver is on vacation, and you don't want to wait for the escalation timeout?
• Want to be able to find and "steal" their workflows
• The webmaster should be able to take any workflow at any time!
![Page 18: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/18.jpg)
ON DEMAND ESCALATIONS
![Page 19: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/19.jpg)
ESCALATION TOOL UI
• Written in JSP
• Placed in:• [cascade install]/tomcat/webapps/ROOT/pccCustom/wkflow
• Access at:• https://your.cms/pccCustom/wkflow
• Putting custom components in separate directory for safety during upgrades
![Page 20: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/20.jpg)
ACCESS CONTROL
LoginInformationBean login = (LoginInformationBean)session.getAttribute("user");
if (!ServiceProviderHolderBean.getServiceProvider().getRoleService().userHasRoleByRolename(login.getUsername(), "Administrator"))
{ errMsg = "Only administrators can do that!";}
![Page 21: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/21.jpg)
SEARCHING WORKFLOWS FOR USER
Results powered by com.hannonhill.cascade.model.service.WorkflowService
Must fetch both active and waiting workflows for user
List<Workflow> wkflows = wkflowService.getActiveWorkflowsForUser(username);
wkflows.addAll(wkflowService.getWaitingWorkflowsForUser( username));
![Page 22: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/22.jpg)
HAVE WORKFLOW, WILL ESCALATE
WorkflowService has method to escalate all overdue workflows, but no method to escalate just one
We will have to do the escalation ourselves!
Find current step of the workflow
Find escalation step of current step
Advance workflow to the escalation step
![Page 23: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/23.jpg)
AND NOW, A WORD ABOUT HIBERNATE
• By default, Hibernate uses lazy collection fetching
• If an object has an associated collection, the collection is retrieved from DB only when it is specifically requested
• If property is "many-to-one" in Hibernate XML config, it is affected unless we override lazy fetching
• The current step of a workflow is many-to-one
• As is the escalation step of a workflow step
![Page 24: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/24.jpg)
SO WE HAVE TO MESS WITH HIBERNATE?
• We could alter the Hibernate configuration XML files• Set lazy="false" on chosen properties
• But this affects every workflow/step load in the system
• And is likely to be overwritten in an upgrade
• But it's easy to do
![Page 25: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/25.jpg)
OR…
• Generate additional DB queries for properties as needed• How often will you manually escalate a workflow?
• No performance hit to system in general
• No modifications to existing CMS components
• This is more complicated to do!
![Page 26: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/26.jpg)
USING JOINS
• Bean getters get lazily-initialized objects• workflow.getCurrentStep()• workflowStep.getEscalationStep()• By default both of these will yield LazyInitializationException!
• We can request objects with additional properties joined from most DAOs• HashSet<Join> joins = new HashSet<Join>();joins.add(new Join(Workflow.PROPERTY_CURRENT_STEP));workflow = workflowDao.get(workflowId, joins);
step = workflow.getCurrentStep(); // success!
![Page 27: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/27.jpg)
EXCEPT…
The Hibernate DAO for workflow steps does not expose a way to join properties.
package edu.pima.cascade.model.dao.hibernate;public class HibernateWorkflowStepDAO extends com.hannonhill.cascade.model.dao.hibernate.HibernateWorkflowStepDAO
implements WorkflowStepDAO {/*************************************************** * Parent class assumes you would not want to join
* wkflow steps. This is probably just an oversight. */public WorkflowStep get(String id, Set<Join> joins){
//fetch() is a protected method on BaseHibernateDAO.return ((WorkflowStep)fetch(id, WorkflowStep.class, joins));
}}
![Page 28: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/28.jpg)
ADD NEW BEAN TO CASCADE
• Spring looks for configuration files in the classpath:• com.hannonhill.cascade.config.spring.applicationContext*.xml
• Add a new configuration file • applicationContextPcc.xml• Not overwritten when upgrading Cascade Server• Want to remove all the custom components? Just remove
the XML config file from the classpath
<bean id="pccWorkflowStepDAO" class="edu.pima.cascade.model.dao.hibernate.HibernateWorkflowStepDAO" />
![Page 29: Enhanced Workflows in Cascade Server by Leah Einecker](https://reader038.vdocuments.mx/reader038/viewer/2022102923/54c853bd4a7959de0b8b45b2/html5/thumbnails/29.jpg)
FINALLY: ESCALATE THE WORKFLOW
• Since we are forcing early escalation, reset the "normal" escalation timeoutescalateStep.setStartedOn(Long.valueOf(System.currentTimeMillis()));
• Do the actual escalationworkflow.setCurrentStep(escalateStep);workflowService.save(workflow); workflowMgmtService.advanceWorkflow(workflow.getId(),
"system", null, "Workflow escalation forced by administrator");