Author: sohil.shah(a)jboss.com
Date: 2009-01-06 22:22:13 -0500 (Tue, 06 Jan 2009)
New Revision: 12434
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublishImpl.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/CMSWorkflowUtil.java
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/FinalizePublish.java
Log:
JBPORTAL-2266 - CMS JBPM Workflow affected by the JBPM Value Serialization Bug
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublishImpl.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublishImpl.java 2009-01-06
20:19:30 UTC (rev 12433)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublishImpl.java 2009-01-07
03:22:13 UTC (rev 12434)
@@ -524,7 +524,7 @@
//iterate through a list of currently pending approval tasks
if (!processInstance.hasEnded())
{
- Content content =
(Content)processInstance.getContextInstance().getVariable("content");
+ Content content = this.getContent(processInstance);
//apply proper criteria to extract pending content only for the
specified file
if (content != null)
@@ -542,6 +542,11 @@
}
}
}
+ catch(Exception e)
+ {
+ log.error(this, e);
+ throw new WorkflowException(e);
+ }
finally
{
IOTools.safeClose(jbpmContext);
@@ -576,7 +581,7 @@
//iterate through a list of currently pending approval tasks
if (!processInstance.hasEnded())
{
- Content content =
(Content)processInstance.getContextInstance().getVariable("content");
+ Content content = this.getContent(processInstance);
//apply proper criteria to extract pending content only for the
specified file
if (content != null)
@@ -588,6 +593,11 @@
}
}
}
+ catch(Exception e)
+ {
+ log.error(this, e);
+ throw new WorkflowException(e);
+ }
finally
{
IOTools.safeClose(jbpmContext);
@@ -631,4 +641,14 @@
return isManager;
}
+
+ private Content getContent(ProcessInstance processInstance) throws Exception
+ {
+ Content content = null;
+
+ Object object =
processInstance.getContextInstance().getVariable("content");
+ content = CMSWorkflowUtil.deserializeContent(object);
+
+ return content;
+ }
}
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/CMSWorkflowUtil.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/CMSWorkflowUtil.java 2009-01-06
20:19:30 UTC (rev 12433)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/CMSWorkflowUtil.java 2009-01-07
03:22:13 UTC (rev 12434)
@@ -22,6 +22,8 @@
******************************************************************************/
package org.jboss.portal.cms.workflow;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
import java.util.List;
import java.util.Locale;
@@ -36,6 +38,7 @@
import org.jboss.portal.cms.model.Content;
import org.jboss.portal.cms.model.File;
import org.jboss.portal.cms.impl.interceptors.ACLInterceptor;
+import org.jbpm.bytes.ByteArray;
/**
* @author Sohil Shah - sshah(a)redhat.com
@@ -129,4 +132,23 @@
}
return cms;
}
+
+ public static org.jboss.portal.cms.workflow.Content deserializeContent(Object object)
throws Exception
+ {
+ org.jboss.portal.cms.workflow.Content content = null;
+
+ if(object instanceof ByteArray)
+ {
+ //JBPM bug workaround:
https://jira.jboss.org/jira/browse/JBPM-1914
+ byte[] objectBytes = ((ByteArray)object).getBytes();
+
+ content = (org.jboss.portal.cms.workflow.Content)(new ObjectInputStream(new
ByteArrayInputStream(objectBytes))).readObject();
+ }
+ else if(object instanceof org.jboss.portal.cms.workflow.Content)
+ {
+ content = (org.jboss.portal.cms.workflow.Content)object;
+ }
+
+ return content;
+ }
}
Modified:
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/FinalizePublish.java
===================================================================
---
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/FinalizePublish.java 2009-01-06
20:19:30 UTC (rev 12433)
+++
modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/FinalizePublish.java 2009-01-07
03:22:13 UTC (rev 12434)
@@ -52,7 +52,7 @@
*/
public void execute(ExecutionContext executionContext)
{
- Content content =
(Content)executionContext.getContextInstance().getVariable("content");
+ Content content = this.readContent(executionContext);
boolean approved =
((Boolean)executionContext.getContextInstance().getVariable("approved")).booleanValue();
byte[] modifiedContent =
(byte[])executionContext.getContextInstance().getVariable("modifiedContent");
long processId = executionContext.getProcessInstance().getId();
@@ -187,4 +187,21 @@
throw new RuntimeException(e);
}
}
+
+ private Content readContent(ExecutionContext executionContext)
+ {
+ try
+ {
+ Content content = null;
+
+ Object object =
executionContext.getContextInstance().getVariable("content");
+ content = CMSWorkflowUtil.deserializeContent(object);
+
+ return content;
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ }
}