Author: sohil.shah(a)jboss.com
Date: 2006-12-22 15:15:42 -0500 (Fri, 22 Dec 2006)
New Revision: 5929
Added:
trunk/cms/src/main/org/jboss/portal/cms/workflow/
trunk/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java
trunk/core/src/main/org/jboss/portal/core/workflow/
trunk/core/src/main/org/jboss/portal/core/workflow/cms/
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java
trunk/workflow/
trunk/workflow/build.bat
trunk/workflow/build.log
trunk/workflow/build.sh
trunk/workflow/build.xml
trunk/workflow/src/
trunk/workflow/src/etc/
trunk/workflow/src/etc/portal-workflow-lib-jar.mf
trunk/workflow/src/main/
trunk/workflow/src/main/org/
trunk/workflow/src/main/org/jboss/
trunk/workflow/src/main/org/jboss/portal/
trunk/workflow/src/main/org/jboss/portal/workflow/
trunk/workflow/src/main/org/jboss/portal/workflow/WorkflowException.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublish.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishServlet.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/Content.java
trunk/workflow/src/main/org/jboss/portal/workflow/cms/TaskExceptionHandler.java
trunk/workflow/src/main/org/jboss/portal/workflow/service/
trunk/workflow/src/main/org/jboss/portal/workflow/service/WorkflowService.java
trunk/workflow/src/main/org/jboss/portal/workflow/service/WorkflowServiceImpl.java
trunk/workflow/src/main/org/jboss/portal/workflow/test/
trunk/workflow/src/main/org/jboss/portal/workflow/test/Finalize.java
trunk/workflow/src/main/org/jboss/portal/workflow/test/HelloWorldDbTest.java
trunk/workflow/src/main/org/jboss/portal/workflow/test/PortalCMSPublish.java
trunk/workflow/src/main/org/jboss/portal/workflow/test/PublishAssignmentHandler.java
trunk/workflow/src/resources/
trunk/workflow/src/resources/portal-workflow-jar/
trunk/workflow/src/resources/portal-workflow-sar/
trunk/workflow/src/resources/portal-workflow-sar/META-INF/
trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml
trunk/workflow/src/resources/portal-workflow-sar/conf/
trunk/workflow/src/resources/portal-workflow-sar/conf/hibernate.cfg.xml
trunk/workflow/src/resources/portal-workflow-war/
trunk/workflow/src/resources/portal-workflow-war/WEB-INF/
trunk/workflow/src/resources/portal-workflow-war/WEB-INF/jboss-web.xml
trunk/workflow/src/resources/portal-workflow-war/WEB-INF/web.xml
trunk/workflow/src/resources/test/
trunk/workflow/src/resources/test/conf/
trunk/workflow/src/resources/test/conf/hibernate.cfg.xml
Modified:
trunk/build/build-thirdparty.xml
trunk/build/build.xml
trunk/cms/build.xml
trunk/cms/src/main/org/jboss/portal/cms/CommandFactory.java
trunk/cms/src/main/org/jboss/portal/cms/impl/ContentImpl.java
trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandContext.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateCommand.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateNewVersionCommand.java
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java
trunk/cms/src/main/org/jboss/portal/cms/model/Content.java
trunk/core/build.xml
trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp
trunk/tools/etc/buildfragments/modules.ent
Log:
[JBPORTAL-931],[JBPORTAL-372] - CMS Approval Workflow using JBPM
Modified: trunk/build/build-thirdparty.xml
===================================================================
--- trunk/build/build-thirdparty.xml 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/build/build-thirdparty.xml 2006-12-22 20:15:42 UTC (rev 5929)
@@ -110,7 +110,7 @@
<componentref name="sun-opends" version="snapshot"/>
<componentref name="sun-servlet" version="2.4"/>
<componentref name="xdoclet" version="1.2.3"/>
-
+ <componentref name="jbpm" version="3.1.2"/>
</build>
Modified: trunk/build/build.xml
===================================================================
--- trunk/build/build.xml 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/build/build.xml 2006-12-22 20:15:42 UTC (rev 5929)
@@ -129,16 +129,17 @@
<module name="core"/>
<module name="wsrp"/>
<module name="registration"/>
+ <module name="workflow"/>
<!-- Module groups -->
<group name="portal">
<include
- modules="common, test, api, faces, jems, server, security, identity,
format, portlet, federation, theme, cms, bridge, samples, registration, wsrp,
core"/>
+ modules="common, test, api, faces, jems, server, security, identity,
format, portlet, federation, theme, workflow, cms, bridge, samples, registration, wsrp,
core"/>
</group>
<group name="cms">
- <include modules="common, test, jems, cms"/>
+ <include modules="common, test, jems, workflow, cms"/>
</group>
<group name="security">
Modified: trunk/cms/build.xml
===================================================================
--- trunk/cms/build.xml 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/cms/build.xml 2006-12-22 20:15:42 UTC (rev 5929)
@@ -110,6 +110,8 @@
<!-- cms optimization integration -->
<path refid="jgroups.jgroups.classpath"/>
<path refid="sun.servlet.classpath"/>
+ <!-- jbpm integration -->
+ <path refid="jbpm.jbpm.classpath"/>
</path>
@@ -132,6 +134,8 @@
<!-- clustered testcases related -->
<path refid="jboss.portal-portlet.classpath"/>
<path refid="jboss.portlet-api.classpath"/>
+ <!-- workflow integration -->
+ <path refid="jboss.portal-workflow.classpath"/>
</path>
Modified: trunk/cms/src/main/org/jboss/portal/cms/CommandFactory.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2006-12-22 14:04:02 UTC
(rev 5928)
+++ trunk/cms/src/main/org/jboss/portal/cms/CommandFactory.java 2006-12-22 20:15:42 UTC
(rev 5929)
@@ -82,5 +82,5 @@
Command createFileGetListCommand(String sFilePath);
- Command createGetArchiveCommand(String sRootPath, String sLanguage);
+ Command createGetArchiveCommand(String sRootPath, String sLanguage);
}
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/ContentImpl.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/ContentImpl.java 2006-12-22 14:04:02 UTC
(rev 5928)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/ContentImpl.java 2006-12-22 20:15:42 UTC
(rev 5929)
@@ -61,6 +61,9 @@
protected String mimeType;
protected int size;
+
+ protected boolean isWaitingForPublishApproval = false;
+ protected String approvalProcessId = null;
public String getTitle()
{
@@ -182,6 +185,39 @@
{
this.size = size;
}
+
+ /**
+ *
+ */
+ public boolean isWaitingForPublishApproval()
+ {
+ return this.isWaitingForPublishApproval;
+ }
+
+ /**
+ *
+ * @param isWaitingForPublishApproval
+ */
+ public void setWaitingForPublishApproval(boolean isWaitingForPublishApproval)
+ {
+ this.isWaitingForPublishApproval = isWaitingForPublishApproval;
+ }
+
+ /**
+ * @return the approvalProcessId
+ */
+ public String getApprovalProcessId()
+ {
+ return approvalProcessId;
+ }
+
+ /**
+ * @param approvalProcessId the approvalProcessId to set
+ */
+ public void setApprovalProcessId(String approvalProcessId)
+ {
+ this.approvalProcessId = approvalProcessId;
+ }
}
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java
===================================================================
---
trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/cms/src/main/org/jboss/portal/cms/impl/interceptors/ACLInterceptor.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -177,38 +177,46 @@
*
*/
protected Object invoke(JCRCommand invocation) throws Exception, InvocationException
- {
- Session session = Tools.getOpenSession();
- Transaction tx = session.beginTransaction();
-
- //make the acl check before this command is executed
- User user = (User)JCRCMS.getUserInfo().get();
-
-
- //setup the security context with enough information for the authorization
provider
- //to be able to make an enforcement decision
- PortalSecurityContext securityContext = new PortalSecurityContext(user);
- securityContext.setAttribute("command",invocation);
-
-
- //perform access check
- boolean allowAccess = this.authorizationProvider.hasAccess(securityContext);
- tx.commit();
- Tools.closeSession(session);
-
- if(allowAccess)
- {
- Object response = invocation.invokeNext();
-
- //also filter lists of files and folders based on access allowed on these
resources
- response = this.applyFilter(response,securityContext);
-
- return response;
- }
- else
- {
- throw new CMSException("Access to this resource is denied");
- }
+ {
+ if(ACLInterceptor.turnOff.get()==null )
+ {
+ Session session = Tools.getOpenSession();
+ Transaction tx = session.beginTransaction();
+
+ //make the acl check before this command is executed
+ User user = (User)JCRCMS.getUserInfo().get();
+
+
+ //setup the security context with enough information for the authorization
provider
+ //to be able to make an enforcement decision
+ PortalSecurityContext securityContext = new PortalSecurityContext(user);
+ securityContext.setAttribute("command",invocation);
+
+
+ //perform access check
+ boolean allowAccess = this.authorizationProvider.hasAccess(securityContext);
+ tx.commit();
+ Tools.closeSession(session);
+
+ if(allowAccess)
+ {
+ Object response = invocation.invokeNext();
+
+ //also filter lists of files and folders based on access allowed on these
resources
+ response = this.applyFilter(response,securityContext);
+
+ return response;
+ }
+ else
+ {
+ throw new CMSException("Access to this resource is denied");
+ }
+ }
+ else
+ {
+ //this is turned off for this thread that is trying to integrate with the CMS
+ return invocation.invokeNext();
+ }
}
/**
@@ -461,4 +469,22 @@
return bootRequired;
}
+
+ /**
+ * This turns off acl security only for a particular thread.
+ * This is used by system level operations that need to integrate with the CMS
+ *
+ * Example is: the workflow daemon that publishes a content as live when a manager
+ * approves it. Without turning this off, the daemon thread is running in Anonymous
mode
+ * which obviously does not have the rights to publish the content
+ */
+ private static ThreadLocal turnOff = new ThreadLocal();
+ public static void turnOff()
+ {
+ ACLInterceptor.turnOff.set(new Boolean(true));
+ }
+ public static void turnOn()
+ {
+ ACLInterceptor.turnOff.set(null);
+ }
}
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2006-12-22 14:04:02 UTC
(rev 5928)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCMS.java 2006-12-22 20:15:42 UTC
(rev 5929)
@@ -25,6 +25,7 @@
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.jboss.cache.Version;
+import org.jboss.naming.NonSerializableFactory;
import org.jboss.portal.cms.CMS;
import org.jboss.portal.cms.CMSException;
import org.jboss.portal.cms.CMSMimeMappings;
@@ -49,6 +50,9 @@
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import org.jboss.portal.workflow.cms.ApprovePublish;
+
import org.jboss.util.StopWatch;
import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
@@ -58,10 +62,10 @@
import javax.jcr.Session;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
+import javax.naming.CompositeName;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.io.ByteArrayOutputStream;
-import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Date;
@@ -96,6 +100,10 @@
private Element config;
private UserModule userModule = null;
+
+ private ApprovePublish approvePublishWorkflow = null;
+
+ private String jndiName = null;
private InvocationHandler handler = new InvocationHandler()
@@ -115,6 +123,20 @@
{
return JCRCMS.userInfo;
}
+
+ /**
+ * This is used to turnoff workflow triggering only
+ * for this particular request through the CMS commands
+ */
+ protected static ThreadLocal turnOffWorkflow = new ThreadLocal();
+ public static void turnOffWorkflow()
+ {
+ turnOffWorkflow.set(new Boolean(true));
+ }
+ public static void turnOnWorkflow()
+ {
+ turnOffWorkflow.set(null);
+ }
public JCRCMS()
{
@@ -185,8 +207,26 @@
{
this.doChecking = doChecking;
}
+
- /**
+
+ /**
+ * @return the approvePublishWorkflow
+ */
+ public ApprovePublish getApprovePublishWorkflow()
+ {
+ return approvePublishWorkflow;
+ }
+
+ /**
+ * @param approvePublishWorkflow the approvePublishWorkflow to set
+ */
+ public void setApprovePublishWorkflow(ApprovePublish approvePublishWorkflow)
+ {
+ this.approvePublishWorkflow = approvePublishWorkflow;
+ }
+
+ /**
*
* @return
*/
@@ -203,19 +243,42 @@
{
this.userModule = userModule;
}
+
+ /**
+ *
+ * @return
+ */
+ public String getJNDIName()
+ {
+ return this.jndiName;
+ }
+
+ /**
+ *
+ * @param jndiName
+ */
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
/** CMS Start */
public void startService() throws Exception
{
try
- {
+ {
this.userModule = (UserModule)new
InitialContext().lookup("java:portal/UserModule");
- }
- catch (NamingException e)
- {
+ }
+ catch (NamingException e)
+ {
log.error("Cannot obtain UserModule from JNDI: ", e);
throw e;
- }
+ }
+
+ if (this.jndiName != null)
+ {
+ NonSerializableFactory.rebind(new CompositeName(this.jndiName), this, true);
+ }
//check the version of jbosscache being run
String cacheVersion = Version.getVersionString(Version.getVersionShort());
@@ -226,6 +289,7 @@
cacheLogger.setLevel(Level.ERROR);
Logger groupsLogger = Logger.getLogger("org.jgroups");
groupsLogger.setLevel(Level.ERROR);
+
// See how long it takes us to start up
StopWatch watch = new StopWatch(true);
@@ -240,6 +304,17 @@
/** Shuts down the repo and unregisters it */
public void stopService()
{
+ try
+ {
+ if (this.jndiName != null)
+ {
+ NonSerializableFactory.unbind(this.jndiName);
+ }
+ }
+ catch(Exception e)
+ {
+ log.error(this, e);
+ }
log.info("Stopping JCR CMS");
stopJCR();
// removeInterceptors();
@@ -430,6 +505,7 @@
file.setContent(new Locale(getDefaultLocale()), content);
Command newFileCMD = getCommandFactory().createNewFileCommand(file,
content);
+ JCRCMS.turnOffWorkflow();
execute(newFileCMD);
}
@@ -503,6 +579,16 @@
JCRCommand jcrCmd = (JCRCommand)cmd;
JCRCommandContext ctx = new JCRCommandContext(session, commandFactory,
defaultLocale);
jcrCmd.setContext(ctx);
+
+ ctx.setAttribute(ctx.scope, "user", JCRCMS.getUserInfo().get());
+ Object isWorkflowOff = JCRCMS.turnOffWorkflow.get();
+ if( this.approvePublishWorkflow!=null //this checks and makes sure workflow is
activated for the CMS
+ &&
+ isWorkflowOff==null //this checks and makes sure workflow is not turned off
only for this particular request
+ )
+ {
+ ctx.setAttribute(ctx.scope, "approvePublishWorkflow",
this.approvePublishWorkflow);
+ }
if ((stackFactory != null) &&
(stackFactory.getInterceptorStack().getLength() != 0))
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandContext.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandContext.java 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandContext.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -24,6 +24,8 @@
import org.jboss.portal.cms.CMSException;
import org.jboss.portal.common.invocation.AbstractInvocationContext;
+import org.jboss.portal.server.impl.MapAttributeResolver;
+import org.jboss.portal.common.invocation.Scope;
import javax.jcr.Session;
import java.util.Locale;
@@ -34,7 +36,8 @@
*/
public class JCRCommandContext extends AbstractInvocationContext
{
-
+ public static final Scope scope = new Scope("Thread");
+
private final Session session;
private final JCRCommandFactory commandFactory;
@@ -46,6 +49,7 @@
this.session = session;
this.commandFactory = factory;
this.locale = locale;
+ this.addResolver(JCRCommandContext.scope, new MapAttributeResolver());
}
public JCRCommandFactory getCommandFactory()
Modified: trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/JCRCommandFactory.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -177,5 +177,4 @@
{
return new GetArchiveCommand(sRootPath, sLanguage);
}
-
}
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateCommand.java
===================================================================
---
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateCommand.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateCommand.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -62,7 +62,7 @@
contentNode.setProperty("portalcms:description", new
StringValue(mFile.getContent().getDescription()));
contentNode.setProperty("portalcms:title", new
StringValue(mFile.getContent().getTitle()));
contentNode.setProperty("portalcms:language", new
StringValue(mFile.getContent().getLocale().getLanguage()));
- contentNode.setProperty("portalcms:size", new
StringValue(String.valueOf(mFile.getContent().getBytes().length)));
+
if (mFile.getContent().getMimeType() != null)
{
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateNewVersionCommand.java
===================================================================
---
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateNewVersionCommand.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentCreateNewVersionCommand.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -22,19 +22,27 @@
******************************************************************************/
package org.jboss.portal.cms.impl.jcr.command;
+import org.apache.jackrabbit.value.StringValue;
import org.jboss.portal.cms.impl.jcr.JCRCommand;
import org.jboss.portal.cms.impl.jcr.util.VersionUtil;
import org.jboss.portal.cms.model.Content;
+import org.jboss.portal.common.invocation.Scope;
+import org.jboss.portal.identity.User;
+
+import org.jboss.portal.workflow.cms.ApprovePublish;
+
import javax.jcr.Node;
import java.util.ArrayList;
import java.util.List;
+import java.util.Date;
/**
* Creates a new version of the content and labels it "LIVE".
*
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
+ * @author Sohil Shah - sohil.shah(a)jboss.com
*/
public class ContentCreateNewVersionCommand extends JCRCommand
{
@@ -59,24 +67,93 @@
this.bMakeLive = bMakeLive;
}
+ /**
+ *
+ */
public Object execute()
{
try
{
+ Scope scope = this.context.scope;
// create versions
for (int i = 0; i < mContents.size(); i++)
{
Content content = (Content)mContents.get(i);
Node contentNode =
(Node)context.getSession().getItem(content.getBasePath());
- VersionUtil.createVersion(contentNode, this.bMakeLive);
+
+ //if the creator of this content is known, record it
+ User user = (User)this.context.getAttribute(scope,"user");
+ if(user != null)
+ {
+ contentNode.setProperty("portalcms:user", user.getUserName());
+ }
+
+ contentNode.setProperty("portalcms:size", new
StringValue(String.valueOf(content.getBytes().length)));
+ context.getSession().save();
+
+ ApprovePublish approvePublishWorkflow =
(ApprovePublish)this.context.getAttribute(scope, "approvePublishWorkflow");
+
+ //integration of publish/approval workflow
+ if(this.bMakeLive)
+ {
+ if(approvePublishWorkflow!=null)
+ {
+ //call the workflow service here
+ org.jboss.portal.workflow.cms.Content workflowContent =
+ new org.jboss.portal.workflow.cms.Content();
+ workflowContent.setPath(content.getBasePath());
+ workflowContent.setUserName(user.getUserName());
+ workflowContent.setMimeType(content.getMimeType());
+ if(content.getBytes()!=null)
+ {
+ workflowContent.setSize(content.getBytes().length);
+ }
+ workflowContent.setCreationDate(new Date());
+
+ long processId = approvePublishWorkflow.requestApproval(workflowContent);
+
+ if(processId > 0)
+ {
+ //now save workflow related meta data on this version
+ //so that this version can be processed later in the execution
+ //of the workflow
+
contentNode.setProperty("portalcms:processid",String.valueOf(processId));
+
+ //save
+ context.getSession().save();
+
+ //create a new version, but dont make it live
+ VersionUtil.createVersion(contentNode,false);
+ }
+ }
+ else
+ {
+ //remove any processid if they are present on the node
+ contentNode.setProperty("portalcms:processid",(String)null);
+ contentNode.save();
+
+ //no workflow is activated....just publish the content straight up
+ VersionUtil.createVersion(contentNode, this.bMakeLive);
+ }
+ }
+ else
+ {
+ //remove any processid if they are present on the node
+ contentNode.setProperty("portalcms:processid",(String)null);
+ contentNode.save();
+
+ //not asking to publish the content...no workflow needed
+ //even if its activated
+ VersionUtil.createVersion(contentNode, this.bMakeLive);
+ }
}
context.getSession().save();
}
catch (Exception e)
- {
+ {
e.printStackTrace();
+ throw new RuntimeException(e);
}
return null;
}
-
}
Modified:
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java
===================================================================
---
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/cms/src/main/org/jboss/portal/cms/impl/jcr/command/ContentGetVersionsCommand.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -32,6 +32,7 @@
import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
import javax.jcr.version.VersionIterator;
+import javax.jcr.PathNotFoundException;
import java.util.Locale;
import java.util.Vector;
@@ -110,6 +111,27 @@
content.setEncoding(node.getProperty("jcr:encoding").getString());
+
+ //check if this content is waiting to be approved for publishing or
not
+ try
+ {
+ String processid =
node.getProperty("portalcms:processid").getString();
+ if(processid != null && processid.trim().length()>0)
+ {
+ content.setWaitingForPublishApproval(true);
+ content.setApprovalProcessId(processid);
+ }
+ else
+ {
+ content.setWaitingForPublishApproval(false);
+ content.setApprovalProcessId(null);
+ }
+ }
+ catch(PathNotFoundException pne)
+ {
+ content.setWaitingForPublishApproval(false);
+ content.setApprovalProcessId(null);
+ }
contents.addElement(content);
}
Modified: trunk/cms/src/main/org/jboss/portal/cms/model/Content.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/model/Content.java 2006-12-22 14:04:02 UTC
(rev 5928)
+++ trunk/cms/src/main/org/jboss/portal/cms/model/Content.java 2006-12-22 20:15:42 UTC
(rev 5929)
@@ -73,5 +73,31 @@
boolean isLive();
void setLive(boolean live);
+
+ /**
+ * this is used to signify that a content is waiting to be approved before being
published to go
+ * live
+ *
+ * @return
+ */
+ public boolean isWaitingForPublishApproval();
+
+ /**
+ *
+ *
+ */
+ public void setWaitingForPublishApproval(boolean isWaitingForPublishApproval);
+
+ /**
+ *
+ * @return
+ */
+ public String getApprovalProcessId();
+
+ /**
+ *
+ *
+ */
+ public void setApprovalProcessId(String processId);
}
Added: trunk/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java
===================================================================
--- trunk/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/cms/src/main/org/jboss/portal/cms/workflow/FinalizePublish.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,147 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.cms.workflow;
+
+import java.util.Locale;
+import java.util.List;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.apache.log4j.Logger;
+
+import org.jbpm.graph.def.*;
+import org.jbpm.graph.exe.*;
+
+import org.jboss.portal.workflow.cms.Content;
+import org.jboss.portal.cms.CMS;
+import org.jboss.portal.cms.Command;
+import org.jboss.portal.cms.model.File;
+import org.jboss.portal.cms.impl.jcr.JCRCMS;
+import org.jboss.portal.cms.impl.interceptors.ACLInterceptor;
+
+/**
+ *
+ * Created on : Dec 20, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public class FinalizePublish implements ActionHandler
+{
+ /**
+ *
+ */
+ private static Logger log = Logger.getLogger(FinalizePublish.class);
+ private static CMS cms = null;
+
+ static
+ {
+ try
+ {
+ cms = (CMS)new InitialContext().lookup("java:portal/CMS");
+ }
+ catch (NamingException e)
+ {
+ log.error("Cannot obtain CMS from JNDI: ", e);
+ cms = null;
+ }
+ }
+
+ /**
+ *
+ */
+ public void execute(ExecutionContext executionContext)
+ {
+ Content content =
(Content)executionContext.getContextInstance().getVariable("content");
+ boolean approved =
((Boolean)executionContext.getContextInstance().getVariable("approved")).booleanValue();
+ long processId = executionContext.getProcessInstance().getId();
+
+ if(approved)
+ {
+ ACLInterceptor.turnOff();
+ JCRCMS.turnOffWorkflow();
+
+ //create this content in the CMS and make it live
+ int lastIndex = content.getPath().lastIndexOf('/');
+ String path = content.getPath().substring(0,lastIndex);
+ String language = content.getPath().substring(lastIndex+1);
+
+ Command command =
cms.getCommandFactory().createContentGetVersionsCommand(content.getPath());
+ List versions = (List)cms.execute(command);
+ org.jboss.portal.cms.model.Content processContent =
this.findProcessContent(processId, versions);
+
+ /**
+ * if processContent is null, a pending version of the content was not found
+ * this could be due to an outdated link. let the process finish, but nothing
+ * new will be published
+ */
+ if(processContent != null)
+ {
+ //get the file to be updated and published live
+ command =
cms.getCommandFactory().createFileGetCommand(path,processContent.getVersionNumber(),
+ new Locale(language));
+ File file = (File)cms.execute(command);
+
+ //now publish this
+ file.getContent().setApprovalProcessId(null);
+ file.getContent().setWaitingForPublishApproval(false);
+ command = cms.getCommandFactory().createUpdateFileCommand(file, file.getContent(),
true);
+ cms.execute(command);
+ }
+
+
+ JCRCMS.turnOnWorkflow();
+ ACLInterceptor.turnOn();
+ }
+ }
+
+ /**
+ *
+ * @param processId
+ * @param versions
+ * @return
+ */
+ private org.jboss.portal.cms.model.Content findProcessContent(long processId,List
versions)
+ {
+ org.jboss.portal.cms.model.Content content = null;
+
+ if(versions != null)
+ {
+ for(int i=0;i<versions.size();i++)
+ {
+ org.jboss.portal.cms.model.Content cour =
(org.jboss.portal.cms.model.Content)versions.get(i);
+ if(cour.isWaitingForPublishApproval())
+ {
+ if( cour.getApprovalProcessId()!=null &&
+ cour.getApprovalProcessId().trim().equals(String.valueOf(processId)))
+ {
+ //not if found...the content of this version should be published to go live
+ return cour;
+ }
+ }
+ }
+ }
+
+ return content;
+ }
+}
Modified: trunk/core/build.xml
===================================================================
--- trunk/core/build.xml 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/core/build.xml 2006-12-22 20:15:42 UTC (rev 5929)
@@ -113,6 +113,8 @@
<path refid="trove.trove.classpath"/>
<path refid="qdox.qdox.classpath"/>
<pathelement location="${source.etc}/sun-jsf/jsf-example.jar"/>
+ <!-- jbpm integration -->
+ <path refid="jbpm.jbpm.classpath"/>
</path>
<!-- Configure modules -->
@@ -132,6 +134,7 @@
<path refid="jboss.portal-theme.classpath"/>
<path refid="jboss.portal-security.classpath"/>
<path refid="jboss.portal-test.classpath"/>
+ <path refid="jboss.portal-workflow.classpath"/>
</path>
<!--+=======================================+-->
@@ -366,7 +369,19 @@
<fileset dir="${portals.bridges.lib}"
includes="portals-bridges-common.jar"/>
<fileset dir="${apache.tomahawk.lib}"
includes="tomahawk.jar"/>
<fileset dir="${apache.lang.lib}"
includes="commons-lang-2.0.jar"/>
- </copy>
+ </copy>
+
+ <!-- workflow service -->
+ <copy todir="${build.resources}/jboss-portal/portal-workflow.sar">
+ <fileset dir="${jboss.portal-workflow.root}/lib"
includes="portal-workflow-lib.jar"/>
+ <fileset dir="${jbpm.jbpm.lib}"
includes="jbpm-3.1.2.jar"/>
+ <fileset dir="${jbpm.jbpm.lib}"
includes="jbpm-identity-3.1.2.jar"/>
+ <fileset
dir="${jboss.portal-workflow.root}/resources/portal-workflow-sar"/>
+ </copy>
+ <!-- workflow war packaging -->
+ <copy
todir="${build.resources}/jboss-portal/portal-workflow.sar/portal-workflow.war">
+ <fileset
dir="${jboss.portal-workflow.root}/lib/portal-workflow.war"/>
+ </copy>
</target>
Modified:
trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/core/src/main/org/jboss/portal/core/portlet/cms/admin/CMSAdminPortlet.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -61,6 +61,8 @@
import org.jboss.portal.identity.AnnonymousRole;
import org.jboss.portal.identity.MembershipModule;
+import org.jboss.portal.workflow.cms.ApprovePublish;
+import org.jboss.portal.workflow.WorkflowException;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
@@ -79,6 +81,8 @@
import java.util.ArrayList;
import java.util.HashSet;
+import javax.naming.InitialContext;
+
/**
* @author <a href="mailto:roy@jboss.org">Roy Russo</a>
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
@@ -90,6 +94,7 @@
private UserModule userModule;
private RoleModule roleModule;
private MembershipModule membershipModule;
+ private ApprovePublish approvePublish;
public void init() throws PortletException
{
@@ -114,6 +119,8 @@
{
throw new PortletException("No membership module");
}
+
+ this.initializeApprovePublishWorkflow();
}
protected void doView(final JBossRenderRequest rReq, final JBossRenderResponse rRes)
@@ -243,6 +250,20 @@
List versionList = (List)CMSService.execute(getContentVersionsCMD);
contents.add(versionList);
}
+
+ //get the unapproved content for this file
+ if(this.approvePublish!=null)
+ {
+ try
+ {
+ Collection pendingQueue = this.approvePublish.getPendingQueue(sPath);
+ rReq.setAttribute("pendingQueue",pendingQueue);
+ }
+ catch(WorkflowException we)
+ {
+ rReq.setAttribute("pendingQueue",null);
+ }
+ }
rRes.setContentType("text/html");
rReq.setAttribute("currpath", sPath);
@@ -1289,4 +1310,21 @@
return false;
}
}
+
+ /**
+ *
+ * @return
+ */
+ private void initializeApprovePublishWorkflow()
+ {
+ try
+ {
+ InitialContext context = new InitialContext();
+ this.approvePublish =
(ApprovePublish)context.lookup("java:portal/ApprovePublishWorkflow");
+ }
+ catch(Exception e)
+ {
+ this.approvePublish = null;
+ }
+ }
}
\ No newline at end of file
Added:
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,135 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.workflow.cms;
+
+import org.apache.log4j.Logger;
+
+import java.util.Collection;
+import java.net.URLEncoder;
+import java.text.MessageFormat;
+
+import javax.naming.InitialContext;
+
+import org.jbpm.graph.exe.*;
+import org.jbpm.taskmgmt.def.*;
+import org.jbpm.taskmgmt.exe.Assignable;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+
+import org.jboss.portal.core.modules.MailModule;
+import org.jboss.portal.workflow.cms.Content;
+
+
+/**
+ *
+ * Created on : Dec 20, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public class PublishAssignmentHandler implements AssignmentHandler
+{
+ private static Logger log = Logger.getLogger(PublishAssignmentHandler.class);
+
+ private static MailModule mailModule = null;
+ static
+ {
+ try
+ {
+ InitialContext context = new InitialContext();
+ mailModule = (MailModule)context.lookup("java:portal/MailModule");
+ }
+ catch(Exception e)
+ {
+ mailModule = null;
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ *
+ */
+ public void assign(Assignable assignable,ExecutionContext executionContext)
+ {
+ int taskInstances = 0;
+ Collection assignedTasks = executionContext.getTaskMgmtInstance().getTaskInstances();
+ if(assignedTasks!=null)
+ {
+ taskInstances = assignedTasks.size();
+ }
+
+ if(taskInstances == 1)
+ {
+ String[] managers =
(String[])executionContext.getContextInstance().getVariable("managers");
+ if(managers!=null && managers.length>0)
+ {
+ this.notifyManager(executionContext,managers[0]);
+ assignable.setActorId(managers[0]);
+
+ for(int i=1;i<managers.length;i++)
+ {
+ this.notifyManager(executionContext,managers[i]);
+ TaskInstance t = executionContext.getTaskMgmtInstance().
+ createTaskInstance(((TaskInstance)assignable).getTask(),executionContext);
+ t.setActorId(managers[i]);
+ }
+ }
+ }
+ }
+
+ /**
+ *
+ * @param email
+ */
+ private void notifyManager(ExecutionContext executionContext,String email)
+ {
+ try
+ {
+ long processId = executionContext.getProcessInstance().getId();
+ String from =
(String)executionContext.getContextInstance().getVariable("from");
+ String to = email;
+ String subject =
(String)executionContext.getContextInstance().getVariable("subject");
+ String body =
(String)executionContext.getContextInstance().getVariable("body");
+ Content content =
(Content)executionContext.getContextInstance().getVariable("content");
+
+ Object[] arguments =
+ {
+ content.getPath(),
+ content.getMimeType(),
+ content.getSizeStr(),
+ content.getCreationDateStr(),
+ content.getUserName(),
+ String.valueOf(processId),
+ URLEncoder.encode(email, "UTF-8"),
+ String.valueOf(processId),
+ URLEncoder.encode(email, "UTF-8")
+ };
+ body = MessageFormat.format(body, arguments);
+
+ mailModule.send(from,email,subject,body);
+ }
+ catch(Exception e)
+ {
+ //eat it for now
+ log.error(this, e);
+ }
+ }
+}
Modified: trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2006-12-22 14:04:02
UTC (rev 5928)
+++ trunk/core/src/resources/portal-cms-sar/META-INF/jboss-service.xml 2006-12-22 20:15:42
UTC (rev 5929)
@@ -58,8 +58,10 @@
<depends>portal:service=JAASLoginModule</depends>
<depends>portal:service=Hibernate,type=CMS</depends>
<depends>portal:service=Module,type=IdentityServiceController</depends>
- <depends optional-attribute-name="StackFactory"
proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends>
- <!--<depends optional-attribute-name="UserModule"
proxy-type="attribute">portal:service=Module,type=User</depends>-->
+ <!--depends optional-attribute-name="UserModule"
proxy-type="attribute">portal:service=Module,type=User</depends-->
+ <!-- add this to activate publish/approval workflow integration -->
+ <depends optional-attribute-name="ApprovePublishWorkflow"
proxy-type="attribute">portal:service=ApprovePublish,type=Workflow</depends>
+ <depends optional-attribute-name="StackFactory"
proxy-type="attribute">portal:service=InterceptorStackFactory,type=Cms</depends>
<attribute name="DoChecking">true</attribute>
<attribute
name="DefaultContentLocation">portal/cms/conf/default-content/default/</attribute>
<attribute name="DefaultLocale">en</attribute>
@@ -169,6 +171,7 @@
</Versioning>
</Repository>
</attribute>
+ <attribute name="JNDIName">java:portal/CMS</attribute>
</mbean>
<!--
Modified: trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp
===================================================================
--- trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/core/src/resources/portal-core-war/WEB-INF/jsp/cms/admin/viewfile.jsp 2006-12-22
20:15:42 UTC (rev 5929)
@@ -11,12 +11,16 @@
<%@ page import="java.util.List" %>
<%@ page import="java.util.StringTokenizer" %>
<%@ page import="java.util.Vector" %>
+<%@ page import="java.util.Collection" %>
+<%@ page import="java.util.Iterator" %>
<portlet:defineObjects/>
<%
String sCurrPath = (String)request.getAttribute("currpath");
Vector vContents = (Vector)request.getAttribute("contents");
+ Collection pendingQueue = (Collection)request.getAttribute("pendingQueue");
+
String sType = "";
if (vContents.size() > 0)
{
@@ -32,7 +36,7 @@
String createDate = "";
String modifiedDate = "";
- String rowClass = "portlet-section-body";
+ String rowClass = "portlet-section-body";
%>
<br>
@@ -182,7 +186,13 @@
<%
for (int i = 0; i < contentList.size(); i++) // cycle thru list of version nodes
{
- Content version = (Content)contentList.get(i);
+ Content version = (Content)contentList.get(i);
+
+ if(version.isWaitingForPublishApproval())
+ {
+ continue;
+ }
+
if (i % 2 == 0)
{
rowClass = "portlet-section-body";
@@ -275,3 +285,47 @@
}
%>
</table>
+
+<!-- the approval queue, content waiting for managers to signoff on -->
+<%if(pendingQueue!=null && !pendingQueue.isEmpty()){%>
+<br/><br/>
+
+<span class="portlet-table-text">Pending Approval Queue:</span>
+<br/>
+<table width="100%" border="0" cellspacing="0"
cellpadding="0">
+<tr>
+ <td
class="portlet-table-text"><b>${n:i18n("CMS_TYPE")}</b></td>
+ <td
class="portlet-table-text"><b>${n:i18n("CMS_SIZE")}</b></td>
+ <td
class="portlet-table-text"><b>${n:i18n("CMS_CREATED")}</b></td>
+ <td class="portlet-table-text"><b>User</b></td>
+</tr>
+<%int i=0;%>
+<%for(Iterator itr=pendingQueue.iterator();itr.hasNext();){%>
+ <%
+ org.jboss.portal.workflow.cms.Content cour =
(org.jboss.portal.workflow.cms.Content)itr.next();
+ if (i % 2 == 0)
+ {
+ rowClass = "portlet-section-body";
+ }
+ else
+ {
+ rowClass = "portlet-section-alternate";
+ }
+ i++;
+ %>
+<tr onmouseover="this.className='portlet-section-selected';"
onmouseout="this.className='<%= rowClass %>';"
+class="<%= rowClass %>">
+ <!-- Mime Type -->
+ <td><%= cour.getMimeType() %></td>
+ <!-- Size -->
+ <td><%= cour.getSizeStr() %></td>
+ <!-- Creation Date -->
+ <td>
+ <%= cour.getCreationDateStr() %>
+ </td>
+ <!-- User who requested approval -->
+ <td><%= cour.getUserName() %></td>
+</tr>
+<%}%>
+</table>
+<%}%>
Modified: trunk/tools/etc/buildfragments/modules.ent
===================================================================
--- trunk/tools/etc/buildfragments/modules.ent 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/tools/etc/buildfragments/modules.ent 2006-12-22 20:15:42 UTC (rev 5929)
@@ -129,6 +129,13 @@
<pathelement
path="${jboss.portal-identity.lib}/portal-identity-lib.jar"/>
</path>
+ <!-- workflow -->
+ <property name="jboss.portal-workflow.root"
value="${project.root}/workflow/output"/>
+ <property name="jboss.portal-workflow.lib"
value="${jboss.portal-workflow.root}/lib"/>
+ <path id="jboss.portal-workflow.classpath">
+ <pathelement
path="${jboss.portal-workflow.lib}/portal-workflow-lib.jar"/>
+ </path>
+
<!-- samples -->
<property name="jboss.portal-samples.root"
value="${project.root}/samples/output"/>
<property name="jboss.portal-samples.lib"
value="${jboss.portal-samples.root}/lib"/>
Added: trunk/workflow/build.bat
===================================================================
--- trunk/workflow/build.bat 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/workflow/build.bat 2006-12-22 20:15:42 UTC (rev 5929)
@@ -0,0 +1,54 @@
+@echo off
+rem
+rem Invokes a script of the same name in the 'tools' module.
+rem
+rem The 'tools' module is expected to be a peer directory of the directory
+rem in which this script lives.
+rem
+rem @author Jason Dillon <jason(a)planet57.com>
+rem
+
+rem $Id: build.bat 2 2005-01-14 23:01:32Z vietj $
+
+setlocal
+
+set PROGNAME=%~nx0
+set DIRNAME=%~dp0
+
+rem Legacy shell support
+if x%PROGNAME%==x set PROGNAME=build.bat
+if x%DIRNAME%==x set DIRNAME=.\
+
+set MODULE_ROOT=%DIRNAME%
+if x%TOOLS_ROOT%==x set TOOLS_ROOT=%DIRNAME%..\tools
+set TARGET=%TOOLS_ROOT%\bin\build.bat
+set ARGS=%*
+
+rem Start'er up yo
+goto main
+
+:debug
+if not x%DEBUG%==x echo %PROGNAME%: %*
+goto :EOF
+
+:main
+call :debug PROGNAME=%PROGNAME%
+call :debug DIRNAME=%DIRNAME%
+call :debug TOOLS_ROOT=%TOOLS_ROOT%
+call :debug TARGET=%TARGET%
+
+if exist %TARGET% call :call-script & goto :EOF
+rem else fail, we can not go on
+
+echo %PROGNAME%: *ERROR* The target executable does not exist:
+echo %PROGNAME%:
+echo %PROGNAME%: %TARGET%
+echo %PROGNAME%:
+echo %PROGNAME%: Please make sure you have checked out the 'tools' module
+echo %PROGNAME%: and make sure it is up to date.
+goto :EOF
+
+:call-script
+call :debug Executing %TARGET% %ARGS%
+call %TARGET% %ARGS%
+goto :EOF
Added: trunk/workflow/build.log
===================================================================
--- trunk/workflow/build.log 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/workflow/build.log 2006-12-22 20:15:42 UTC (rev 5929)
@@ -0,0 +1,72 @@
+
+configure:
+Overriding previous definition of reference to apache.ant.classpath
+
+configure-modules:
+
+configure-defaults:
+Overriding previous definition of reference to javac.classpath
+
+configure-tools:
+
+_configure:jbossaop:task:
+
+_configure:xdoclet:task:
+
+_configure:xdoclet:ejbdoclet:
+
+_configure:xdoclet:jmxdoclet:
+
+init:
+
+tests:
+ [echo]
+
build.reports=C:\projects\core-portal\jboss-portal-trunk\workflow/output/reports
+ test.reports=C:\projects\core-portal\jboss-portal-trunk\workflow/output/tests
+ module.output=C:\projects\core-portal\jboss-portal-trunk\workflow/output
+
driver.path=C:\projects\core-portal\jboss-portal-trunk/thirdparty/hsqldb/lib//hsqldb.jar
+ junit.printsummary=true
+ junit.batchtest.haltonerror=false
+ junit.batchtest.haltonfailure=false
+ junit.batchtest.fork=true
+ junit.timeout=600000
+ junit.jvm=java
+ junit.jvm.options=-Ddummy
+ junit.formatter.usefile=true
+
+ [mkdir] Created dir:
C:\projects\core-portal\jboss-portal-trunk\workflow\output\reports
+ [mkdir] Created dir:
C:\projects\core-portal\jboss-portal-trunk\workflow\output\tests
+ [junit_] Running org.jboss.portal.workflow.test.HelloWorldDbTest
+ [junit_] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.11 sec
+ [junit_] Testsuite: org.jboss.portal.workflow.test.HelloWorldDbTest
+ [junit_] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.11 sec
+ [junit_] ------------- Standard Error -----------------
+ [junit_] log4j:WARN No appenders could be found for logger
(org.jbpm.JbpmConfiguration).
+ [junit_] log4j:WARN Please initialize the log4j system properly.
+ [junit_] ------------- ---------------- ---------------
+ [junit_]
+ [junit_] Testcase: testSimplePersistence took 6.079 sec
+ [junit_] Running org.jboss.portal.workflow.test.PortalCMSPublish
+ [junit_] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.828 sec
+ [junit_] Testsuite: org.jboss.portal.workflow.test.PortalCMSPublish
+ [junit_] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 6.828 sec
+ [junit_] ------------- Standard Output ---------------
+ [junit_] Assigning this task to the Managers
+ [junit_] Assigning this task to the Managers
+ [junit_] Manager=Admin(1)
+ [junit_] Manager=eric.brown(a)jboss.com(1)
+ [junit_] Manager=Admin(2)
+ [junit_] Manager=eric.brown(a)jboss.com(2)
+ [junit_] Manager=sohil.shah(a)jboss.com(1)
+ [junit_] Manager=sohil.shah(a)jboss.com(2)
+ [junit_] This publish request was approved...../default/index2.html
+ [junit_] This publish request was approved...../default/index.html
+ [junit_] ------------- ---------------- ---------------
+ [junit_] ------------- Standard Error -----------------
+ [junit_] log4j:WARN No appenders could be found for logger
(org.jbpm.JbpmConfiguration).
+ [junit_] log4j:WARN Please initialize the log4j system properly.
+ [junit_] ------------- ---------------- ---------------
+ [junit_]
+ [junit_] Testcase: testCMSPublish took 6.812 sec
+
+BUILD SUCCESSFUL
Added: trunk/workflow/build.sh
===================================================================
--- trunk/workflow/build.sh 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/workflow/build.sh 2006-12-22 20:15:42 UTC (rev 5929)
@@ -0,0 +1,49 @@
+#!/bin/sh
+##
+## Invokes a script of the same name in the 'tools' module.
+##
+## The 'tools' module is expected to be a peer directory of the directory
+## in which this script lives.
+##
+## @author Jason Dillon <jason(a)planet57.com>
+##
+
+# $Id: build.sh 2 2005-01-14 23:01:32Z vietj $
+
+PROGNAME=`basename $0`
+DIRNAME=`dirname $0`
+
+# Buss it yo
+main() {
+ if [ "x$TOOLS_ROOT" = "x" ]; then
+ TOOLS_ROOT=`cd $DIRNAME/../tools && pwd`
+ fi
+
+ MODULE_ROOT=`cd $DIRNAME; pwd`
+ export TOOLS_ROOT MODULE_ROOT DEBUG TRACE
+
+ # Where is the target script?
+ target="$TOOLS_ROOT/bin/$PROGNAME"
+ if [ ! -f "$target" ]; then
+ echo "${PROGNAME}: *ERROR* The target executable does not exist:"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: $target"
+ echo "${PROGNAME}:"
+ echo "${PROGNAME}: Please make sure you have checked out the 'tools'
module"
+ echo "${PROGNAME}: and make sure it is up to date."
+ exit 2
+ fi
+
+ # Get busy yo!
+ if [ "x$DEBUG" != "x" ]; then
+ echo "${PROGNAME}: Executing: /bin/sh $target $@"
+ fi
+ if [ "x$TRACE" = "x" ]; then
+ exec /bin/sh $target "$@"
+ else
+ exec /bin/sh -x $target "$@"
+ fi
+}
+
+# Lets get ready to rumble!
+main "$@"
Added: trunk/workflow/build.xml
===================================================================
--- trunk/workflow/build.xml 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/workflow/build.xml 2006-12-22 20:15:42 UTC (rev 5929)
@@ -0,0 +1,255 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<!DOCTYPE project [
+ <!ENTITY libraries SYSTEM "../thirdparty/libraries.ent">
+ <!ENTITY buildmagic SYSTEM
"../tools/etc/buildfragments/buildmagic.ent">
+ <!ENTITY tools SYSTEM "../tools/etc/buildfragments/tools.ent">
+ <!ENTITY modules SYSTEM "../tools/etc/buildfragments/modules.ent">
+ <!ENTITY defaults SYSTEM
"../tools/etc/buildfragments/defaults.ent">
+ <!ENTITY targets SYSTEM "../tools/etc/buildfragments/targets.ent">
+ ]>
+
+<!-- $Id: build.xml 5868 2006-12-15 02:59:56Z sohil.shah(a)jboss.com $ -->
+
+<!--+======================================================================+-->
+<!--| JBoss Portal (The OpenSource Portal) Build File |-->
+<!--| |-->
+<!--| Distributable under LGPL license. |-->
+<!--| See terms of license at
http://www.gnu.org. |-->
+<!--| |-->
+<!--| This file has been designed to work with the 'tools' module and
|-->
+<!--| Buildmagic extentions. |-->
+<!--+======================================================================+-->
+
+<project default="main" name="JBoss Portal">
+
+ <!--+====================================================================+-->
+ <!--| Setup |-->
+ <!--| |-->
+ <!--| Include the common build elements. |-->
+ <!--| |-->
+ <!--| This defines several different targets, properties and paths. |-->
+ <!--| It also sets up the basic extention tasks amoung other things. |-->
+ <!--+====================================================================+-->
+
+ &buildmagic;
+ &modules;
+ &defaults;
+ &tools;
+ &targets;
+
+ <!-- ================================================================== -->
+ <!-- Initialization -->
+ <!-- ================================================================== -->
+
+ <!--
+ | Initialize the build system. Must depend on '_buildmagic:init'.
+ | Other targets should depend on 'init' or things will mysteriously fail.
+ -->
+
+ <target name="init" unless="init.disable"
depends="_buildmagic:init">
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Configuration |-->
+ <!--| |-->
+ <!--| This target is invoked by the Buildmagic initialization logic |-->
+ <!--| and should contain module specific configuration elements. |-->
+ <!--+====================================================================+-->
+
+ <target name="configure" unless="configure.disable">
+
+ <!-- Configure some properties -->
+ <property name="jboss-junit-configuration" value=""/>
+ <property name="junit.formatter.usefile" value="true"/>
+
+ <!-- Configure thirdparty libraries -->
+ &libraries;
+ <path id="library.classpath">
+ <path refid="apache.logging.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ <path refid="apache.collections.classpath"/>
+ <path refid="beanshell.beanshell.classpath"/>
+ <path refid="hibernate.hibernate.classpath"/>
+ <path refid="ehcache.ehcache.classpath"/>
+ <path refid="junit.junit.classpath"/>
+ <path refid="dom4j.dom4j.classpath"/>
+ <path refid="asm.asm.classpath"/>
+ <path refid="cglib.cglib.classpath"/>
+ <path refid="antlr.antlr.classpath"/>
+ <path refid="jbossas/core.libs.classpath"/>
+ <path refid="sun.servlet.classpath"/>
+ <!-- jbpm integration -->
+ <path refid="jbpm.jbpm.classpath"/>
+ </path>
+
+
+
+ <path id="javac.classpath">
+ <pathelement location="${build.classes}"/>
+ </path>
+
+ <property name="javac.excludes" value="**/jdbc/**"/>
+
+ <!-- Configure modules -->
+ <call target="configure-modules"/>
+ <path id="dependentmodule.classpath">
+ <path refid="jboss.portal-jems.classpath"/>
+ </path>
+
+
+ <!--+=======================================+-->
+ <!--| Override any default properties here. |-->
+ <!--+=======================================+-->
+
+ <!-- Configure defaults & build tools -->
+ <call target="configure-defaults"/>
+ <call target="configure-tools"/>
+
+ <!--+=======================================+-->
+ <!--| Define module specific elements here. |-->
+ <!--+=======================================+-->
+ <property name="javadoc.private" value="true"/>
+ <property name="javadoc.protected" value="false"/>
+
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Compile |-->
+ <!--| |-->
+ <!--| This target should depend on other compile-* targets for each |-->
+ <!--| different type of compile that needs to be performed, short of |-->
+ <!--| documentation compiles. |-->
+ <!--+====================================================================+-->
+
+ <target name="compile"
+ description="Compile all source files."
+ depends="_default:compile-classes,
+ _default:compile-etc,
+ _default:compile-resources">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Generate Output |-->
+ <!--| |-->
+ <!--| Generates the target output for this module. Target output is |-->
+ <!--| the output which is ment to be released or used by external |-->
+ <!--| modules. |-->
+ <!--+====================================================================+-->
+
+ <target name="output"
+ description="Generate all target output."
+ depends="compile">
+ <mkdir dir="${build.lib}"/>
+
+ <jar jarfile="${build.lib}/portal-workflow-lib.jar"
manifest="${build.etc}/portal-workflow-lib-jar.mf">
+ <fileset dir="${build.classes}"/>
+ <fileset dir="${build.resources}/portal-workflow-jar"/>
+ </jar>
+
+ <!-- create the war file -->
+ <copy todir="${build.lib}/portal-workflow.war">
+ <fileset dir="${build.resources}/portal-workflow-war"/>
+ </copy>
+ </target>
+
+ <!--
+ generates artifacts used for tests, requires output to be previously run
+ -->
+ <target name="package-tests" depends="init">
+ </target>
+
+ <target name="deploy-tests"
+ description="Deploy."
+ depends="output">
+ </target>
+
+ <target name="undeploy-tests"
+ description="UnDeploy."
+ depends="output">
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Cleaning -->
+ <!-- ================================================================== -->
+
+ <!-- Clean up all build output -->
+ <target name="clean" depends="_default:clean">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!--+====================================================================+-->
+ <!--| Documents |-->
+ <!--| |-->
+ <!--| Generate all documentation for this module. |-->
+ <!--+====================================================================+-->
+
+ <target name="docs" depends="_default:docs">
+ <!-- Add module specific elements here. -->
+ </target>
+
+ <!-- ================================================================== -->
+ <!-- Misc. -->
+ <!-- ================================================================== -->
+
+ <target name="main" depends="most"/>
+ <target name="all" depends="_default:all"/>
+ <target name="most" depends="_default:most"/>
+ <target name="help" depends="_default:help"/>
+
+ <!-- ================================================================== -->
+ <!-- Test. -->
+ <!-- ================================================================== -->
+ <target name="tests" depends="init">
+ <execute-tests>
+ <x-test>
+ <!-- general jbpm unit tests -->
+ <test todir="${test.reports}"
name="org.jboss.portal.workflow.test.HelloWorldDbTest"/>
+
+ <!-- cms workflow tests -->
+ <test todir="${test.reports}"
name="org.jboss.portal.workflow.test.PortalCMSPublish"/>
+ </x-test>
+ <x-classpath>
+ <path refid="apache.logging.classpath"/>
+ <path refid="apache.log4j.classpath"/>
+ <path refid="apache.collections.classpath"/>
+ <path refid="beanshell.beanshell.classpath"/>
+ <path refid="hibernate.hibernate.classpath"/>
+ <path refid="ehcache.ehcache.classpath"/>
+ <path refid="junit.junit.classpath"/>
+ <path refid="dom4j.dom4j.classpath"/>
+ <path refid="asm.asm.classpath"/>
+ <path refid="cglib.cglib.classpath"/>
+ <path refid="antlr.antlr.classpath"/>
+ <path refid="jbossas/core.libs.classpath"/>
+ <!-- jbpm integration -->
+ <path refid="jbpm.jbpm.classpath"/>
+ <pathelement
location="${build.lib}/portal-workflow-lib.jar"/>
+ <pathelement location="${build.resources}/test"/>
+ </x-classpath>
+ </execute-tests>
+ </target>
+</project>
Added: trunk/workflow/src/etc/portal-workflow-lib-jar.mf
===================================================================
--- trunk/workflow/src/etc/portal-workflow-lib-jar.mf 2006-12-22 14:04:02 UTC (rev 5928)
+++ trunk/workflow/src/etc/portal-workflow-lib-jar.mf 2006-12-22 20:15:42 UTC (rev 5929)
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Created-By: @java.vm.version@ (@java.vm.vendor@)
+Specification-Title: @specification.title@
+Specification-Version: @specification.version@
+Specification-Vendor: @specification.vendor@
+Implementation-Title: @implementation.title@
+Implementation-URL: @implementation.url@
+Implementation-Version: @implementation.version@
+Implementation-Vendor: @implementation.vendor@
+Implementation-Vendor-Id: @implementation.vendor.id@
Added: trunk/workflow/src/main/org/jboss/portal/workflow/WorkflowException.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/WorkflowException.java 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/WorkflowException.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,58 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow;
+
+/**
+ * Created on : Dec 21, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public class WorkflowException extends Exception
+{
+ /**
+ *
+ *
+ */
+ public WorkflowException()
+ {
+ this("");
+ }
+
+ /**
+ *
+ * @param e
+ */
+ public WorkflowException(Exception e)
+ {
+ super(e);
+ }
+
+ /**
+ *
+ * @param e
+ */
+ public WorkflowException(String e)
+ {
+ super(e);
+ }
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublish.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublish.java 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublish.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,62 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.cms;
+
+import java.util.Collection;
+import org.jboss.portal.workflow.WorkflowException;
+
+/**
+ * Created on : Dec 19, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public interface ApprovePublish
+{
+ /**
+ * Called when content is added to the CMS, and needs to be approved by the managers
+ * before it can be published to go live
+ *
+ * @param content
+ * @return returns the process id of the workflow process set in motion
+ */
+ public long requestApproval(Content content) throws WorkflowException;
+
+ /**
+ * Called when a manager either approves or rejects the publishing of a specific content
to
+ * go live
+ *
+ * @param processId
+ * @param manager userId of the manager
+ * @param approved true if approved, false if rejected
+ */
+ public void processManagerResponse(long processId,String manager,boolean approved)
throws WorkflowException;
+
+ /**
+ * Retrieves a queue of unapproved content associated with the specified file in the
CMS
+ *
+ * @param filePath
+ * @return
+ * @throws WorkflowException
+ */
+ public Collection getPendingQueue(String filePath) throws WorkflowException;
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishImpl.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,503 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.cms;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.ArrayList;
+import java.util.StringTokenizer;
+import java.util.List;
+
+import javax.naming.CompositeName;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.apache.log4j.Logger;
+
+import org.jboss.naming.NonSerializableFactory;
+import org.jboss.portal.workflow.service.WorkflowService;
+import org.jboss.portal.workflow.WorkflowException;
+
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.jbpm.db.GraphSession;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Created on : Dec 19, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public class ApprovePublishImpl extends AbstractJBossService implements ApprovePublish
+{
+ /**
+ *
+ */
+ private static final Logger log = Logger.getLogger(ApprovePublishImpl.class);
+
+ /**
+ *
+ */
+ private WorkflowService workflowService = null;
+ private String process = null;
+ private String processName = null;
+ private String managerEmails = null;
+ private String[] managers = null;
+ private boolean overwrite = false;
+ private String from = null;
+ private String subject = null;
+ private String body = null;
+
+ private String jndiName = null;
+
+ /**
+ *
+ *
+ */
+ public ApprovePublishImpl()
+ {
+
+ }
+
+ /**
+ *
+ */
+ public void startService() throws Exception
+ {
+ super.startService();
+
+ if (this.jndiName != null)
+ {
+ NonSerializableFactory.rebind(new CompositeName(this.jndiName), this, true);
+ }
+
+ InputStream is = null;
+ JbpmContext jbpmContext = null;
+ try
+ {
+ is = new ByteArrayInputStream(this.process.getBytes());
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ Document document = DocumentBuilderFactory.newInstance().
+ newDocumentBuilder().parse(is);
+
+ Element root = document.getDocumentElement();
+ this.processName = root.getAttribute("name");
+ ProcessDefinition processDefinition = jbpmContext.getGraphSession().
+ findLatestProcessDefinition(this.processName);
+ if(processDefinition == null)
+ {
+ processDefinition = ProcessDefinition.
+ parseXmlString(this.process);
+ jbpmContext.deployProcessDefinition(processDefinition);
+ }
+ else
+ {
+ //a process definition already exists....should deploy a new version
+ //of the definition if overwrite is true
+ ProcessDefinition fromConfig = ProcessDefinition.parseXmlString(this.process);
+ if(this.overwrite)
+ {
+ //if the two of them are not same, create a new version
+ //of this process definition
+ jbpmContext.deployProcessDefinition(fromConfig);
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ this.stopService();
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ if(is!=null)
+ {
+ try{is.close();}catch(Exception e){}
+ }
+ if(jbpmContext!=null)
+ {
+ jbpmContext.close();
+ }
+ }
+
+ //process managers that can serve as approvers/rejecters
+ StringTokenizer st = new StringTokenizer(this.managerEmails,",");
+ this.managers = new String[st.countTokens()];
+ for(int i=0;i<managers.length;i++)
+ {
+ this.managers[i] = st.nextToken();
+ }
+ }
+
+ /**
+ *
+ */
+ public void stopService() throws Exception
+ {
+ super.stopService();
+
+ if (this.jndiName != null)
+ {
+ NonSerializableFactory.unbind(this.jndiName);
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ public WorkflowService getWorkflowService()
+ {
+ return this.workflowService;
+ }
+
+ /**
+ *
+ * @param workflowService
+ */
+ public void setWorkflowService(WorkflowService workflowService)
+ {
+ this.workflowService = workflowService;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getProcess()
+ {
+ return this.process;
+ }
+
+ /**
+ *
+ * @param process
+ */
+ public void setProcess(String process)
+ {
+ this.process = process;
+ }
+
+
+ /**
+ * @return the managerRoles
+ */
+ public String getManagerEmails()
+ {
+ return managerEmails;
+ }
+
+ /**
+ * @param managerRoles the managerRoles to set
+ */
+ public void setManagerEmails(String managerEmails)
+ {
+ this.managerEmails = managerEmails;
+ }
+
+
+
+ /**
+ * @return the overwrite
+ */
+ public boolean isOverwrite()
+ {
+ return overwrite;
+ }
+
+ /**
+ * @param overwrite the overwrite to set
+ */
+ public void setOverwrite(boolean overwrite)
+ {
+ this.overwrite = overwrite;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getJNDIName()
+ {
+ return this.jndiName;
+ }
+
+ /**
+ *
+ * @param jndiName
+ */
+ public void setJNDIName(String jndiName)
+ {
+ this.jndiName = jndiName;
+ }
+
+
+ /**
+ * @return the body
+ */
+ public String getBody()
+ {
+ return body;
+ }
+
+ /**
+ * @param body the body to set
+ */
+ public void setBody(String body)
+ {
+ this.body = body;
+ }
+
+ /**
+ * @return the from
+ */
+ public String getFrom()
+ {
+ return from;
+ }
+
+ /**
+ * @param from the from to set
+ */
+ public void setFrom(String from)
+ {
+ this.from = from;
+ }
+
+ /**
+ * @return the subject
+ */
+ public String getSubject()
+ {
+ return subject;
+ }
+
+ /**
+ * @param subject the subject to set
+ */
+ public void setSubject(String subject)
+ {
+ this.subject = subject;
+ }
+
+ //----------ApprovePublish
Implementation------------------------------------------------------------------
+ /**
+ * Called when content is added to the CMS, and needs to be approved by the managers
+ * before it can be published to go live
+ *
+ * @param content
+ * @return returns the process id of the workflow process set in motion
+ */
+ public long requestApproval(Content content) throws WorkflowException
+ {
+ long processId = 0;
+ JbpmContext jbpmContext = null;
+ ProcessInstance processInstance = null;
+ boolean success = false;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ //The next line creates one execution of the process definition.
+ // After construction, the process execution has one main path
+ // of execution (=the root token) that is positioned in the
+ // start-state.
+ processInstance = jbpmContext.newProcessInstance(this.processName);
+
+ //After construction, the process execution has one main path
+ // of execution (=the root token).
+ Token token = processInstance.getRootToken();
+
+ //set the process variables
+ processInstance.getContextInstance().setVariable("content",content);
+ processInstance.getContextInstance().setVariable("managers",
this.managers);
+ processInstance.getContextInstance().setVariable("from", this.from);
+ processInstance.getContextInstance().setVariable("subject",
this.subject);
+ processInstance.getContextInstance().setVariable("body", this.body);
+
+ //start the workflow, starts the cms publish approval workflow
+ //this creates a task to approve/reject a cms publish for the Admins
+ token.signal();
+
+ //mark as a successfull process initiation
+ success = true;
+ }
+ catch(Exception e)
+ {
+ success = false;
+ throw new WorkflowException(e);
+ }
+ finally
+ {
+ if(processInstance!=null && success)
+ {
+ jbpmContext.save(processInstance);
+ processId = processInstance.getId();
+ }
+ if(jbpmContext!=null)
+ {
+ jbpmContext.close();
+ }
+ }
+ return processId;
+ }
+
+ /**
+ * Called when a manager either approves or rejects the publishing of a specific content
to
+ * go live
+ *
+ * @param processId
+ * @param manager userId of the manager
+ * @param approved true if approved, false if rejected
+ */
+ public void processManagerResponse(long processId, String manager, boolean approved)
throws WorkflowException
+ {
+ JbpmContext jbpmContext = null;
+ ProcessInstance processInstance = null;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ //Now, we search for all process instances of this process definition.
+ processInstance = jbpmContext.loadProcessInstance(processId);
+
+ if(processInstance.hasEnded())
+ {
+ log.debug("This process has already ended...");
+ return;
+ }
+
+ processInstance.getContextInstance().setVariable("approved", new
Boolean(approved));
+
+ Collection allTasks = processInstance.getTaskMgmtInstance().getTaskInstances();
+ if(allTasks != null)
+ {
+ for(Iterator itr=allTasks.iterator();itr.hasNext();)
+ {
+ TaskInstance cour = (TaskInstance)itr.next();
+ if(cour.getActorId().equals(manager))
+ {
+
log.debug("Manager="+cour.getActorId()+"("+processId+")");
+
+ //check and make sure this task instance is not marked for deletion
+ if(cour.getVariable(processInstance.getId()+":"+cour.getId())!=null)
+ {
+ continue;
+ }
+
+ if(!approved)
+ {
+ cour.start();
+ cour.end("rejection");
+ break;
+ }
+ else
+ {
+ cour.start();
+ cour.end("approval");
+ break;
+ }
+ }
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ throw new WorkflowException(e);
+ }
+ finally
+ {
+ if(processInstance!=null)
+ {
+ jbpmContext.save(processInstance);
+ }
+ if(jbpmContext!=null)
+ {
+ jbpmContext.close();
+ }
+ }
+ }
+
+ /**
+ * Retrieves a queue of unapproved content associated with the specified file in the
CMS
+ *
+ * @param filePath
+ * @return
+ * @throws WorkflowException
+ */
+ public Collection getPendingQueue(String filePath) throws WorkflowException
+ {
+ Collection pendingQueue = new ArrayList();
+ JbpmContext jbpmContext = null;
+ try
+ {
+ jbpmContext = this.workflowService.getJbpmConfiguration().createJbpmContext();
+
+ GraphSession graphSession = jbpmContext.getGraphSession();
+ ProcessDefinition processDef =
graphSession.findLatestProcessDefinition(this.processName);
+ List processInstances = graphSession.findProcessInstances(processDef.getId());
+
+ if(processInstances != null)
+ {
+ for(int i=0;i<processInstances.size();i++)
+ {
+ ProcessInstance cour = (ProcessInstance)processInstances.get(i);
+ //iterate through a list of currently pending approval tasks
+ if(!cour.hasEnded())
+ {
+ Content content =
(Content)cour.getContextInstance().getVariable("content");
+
+ //apply proper criteria to extract pending content only for the specified file
+ if(content!=null)
+ {
+ int lastIndex = content.getPath().lastIndexOf('/');
+ String criteriaPath = content.getPath().substring(0,lastIndex);
+
+ if(criteriaPath.trim().equals(filePath.trim()))
+ {
+ pendingQueue.add(content);
+ }
+ }
+ }
+ }
+ }
+ }
+ finally
+ {
+ if(jbpmContext!=null)
+ {
+ jbpmContext.close();
+ }
+ }
+ return pendingQueue;
+ }
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishServlet.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishServlet.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/cms/ApprovePublishServlet.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,112 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.cms;
+
+import java.io.IOException;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.UnavailableException;
+
+import javax.naming.InitialContext;
+import org.jboss.portal.workflow.cms.ApprovePublish;
+
+/**
+ * Created on : Dec 20, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public class ApprovePublishServlet extends HttpServlet
+{
+ private ApprovePublish approvePublishWorkflow = null;
+ /**
+ *
+ */
+ public void init() throws ServletException
+ {
+ try
+ {
+ super.init();
+ InitialContext context = new InitialContext();
+ approvePublishWorkflow =
(ApprovePublish)context.lookup("java:portal/ApprovePublishWorkflow");
+ }
+ catch(Exception e)
+ {
+ throw new UnavailableException(e.toString());
+ }
+ }
+
+ /**
+ *
+ */
+ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
+ {
+ this.doPost(request, response);
+ }
+
+ /**
+ *
+ */
+ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException
+ {
+ try
+ {
+ String processId = request.getParameter("pId");
+ String manager = request.getParameter("manager");
+ boolean approve = false;
+ if(request.getRequestURI().indexOf("approve")!=-1)
+ {
+ approve = true;
+ }
+
+ this.approvePublishWorkflow.processManagerResponse(
+ Long.parseLong(processId),manager,approve
+ );
+
+ /**
+ * TODO: this is a hack job until a decent GUI is integrated
+ * with this workflow..Yes Yes, this will be based on JSP then
+ */
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("<html>\n");
+ if(approve)
+ {
+ buffer.append("<span>The content was successfully
published</span>\n");
+ }
+ else
+ {
+ buffer.append("<span>The content publish request was
rejected</span>\n");
+ }
+ buffer.append("</html>\n");
+
+ response.getWriter().write(buffer.toString());
+ response.getWriter().flush();
+ }
+ catch(Exception e)
+ {
+ response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,e.toString());
+ }
+ }
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/cms/Content.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/cms/Content.java 2006-12-22 14:04:02
UTC (rev 5928)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/cms/Content.java 2006-12-22 20:15:42
UTC (rev 5929)
@@ -0,0 +1,147 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.cms;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.text.Format;
+import java.text.SimpleDateFormat;
+
+/**
+ * Created on : Dec 20, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public class Content implements Serializable
+{
+ private String path = null;
+ private String userName = null;
+ private String mimeType = null;
+ private int size = 0;
+ private Date creationDate = null;
+
+ /**
+ *
+ *
+ */
+ public Content()
+ {
+
+ }
+
+ /**
+ * @return the path
+ */
+ public String getPath()
+ {
+ return path;
+ }
+
+ /**
+ * @param path the path to set
+ */
+ public void setPath(String path)
+ {
+ this.path = path;
+ }
+
+ /**
+ * @return the userName
+ */
+ public String getUserName()
+ {
+ return userName;
+ }
+
+ /**
+ * @param userName the userName to set
+ */
+ public void setUserName(String userName)
+ {
+ this.userName = userName;
+ }
+
+ /**
+ * @return the mimeType
+ */
+ public String getMimeType()
+ {
+ return mimeType;
+ }
+
+ /**
+ * @param mimeType the mimeType to set
+ */
+ public void setMimeType(String mimeType)
+ {
+ this.mimeType = mimeType;
+ }
+
+ /**
+ * @return the size
+ */
+ public int getSize()
+ {
+ return size;
+ }
+
+ /**
+ * @param size the size to set
+ */
+ public void setSize(int size)
+ {
+ this.size = size;
+ }
+
+ public String getSizeStr()
+ {
+ return String.valueOf((this.size / 1024))+"kb";
+ }
+
+ /**
+ * @return the creationDate
+ */
+ public Date getCreationDate()
+ {
+ return creationDate;
+ }
+
+ /**
+ * @param creationDate the creationDate to set
+ */
+ public void setCreationDate(Date creationDate)
+ {
+ this.creationDate = creationDate;
+ }
+
+ public String getCreationDateStr()
+ {
+ String date = "";
+ if (this.creationDate != null)
+ {
+ Format formatter = new SimpleDateFormat("MM/dd/yy HH:mm");
+ date = formatter.format(this.creationDate);
+ }
+ return date;
+ }
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/cms/TaskExceptionHandler.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/cms/TaskExceptionHandler.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/cms/TaskExceptionHandler.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,54 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.cms;
+
+import org.jbpm.graph.def.*;
+import org.jbpm.graph.exe.*;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+
+
+
+/**
+ *
+ * Created on : Dec 21, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public class TaskExceptionHandler implements ActionHandler
+{
+ /**
+ *
+ */
+ public void execute(ExecutionContext executionContext)
+ {
+ TaskInstance current = executionContext.getTaskInstance();
+
+ TaskInstance t = executionContext.getTaskMgmtInstance().
+ createTaskInstance(executionContext.getTask(),executionContext);
+ t.setActorId(current.getActorId());
+
+
current.setVariable(executionContext.getProcessInstance().getId()+":"+current.getId(),
"markAsDeleted");
+
+ throw new RuntimeException(executionContext.getException());
+ }
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/service/WorkflowService.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/service/WorkflowService.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/service/WorkflowService.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.service;
+
+import org.jbpm.JbpmConfiguration;
+
+/**
+ * Created on : Dec 19, 2006
+ * @author Sohil Shah - sohil.shah(a)jboss.com
+ *
+ */
+public interface WorkflowService
+{
+ /**
+ *
+ * @return
+ */
+ public JbpmConfiguration getJbpmConfiguration();
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/service/WorkflowServiceImpl.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/service/WorkflowServiceImpl.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/service/WorkflowServiceImpl.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.service;
+
+
+import org.apache.log4j.Logger;
+import org.jboss.portal.jems.as.system.AbstractJBossService;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.graph.def.ProcessDefinition;
+
+import java.io.StringWriter;
+import java.io.InputStream;
+import java.io.ByteArrayInputStream;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+
+/**
+ * @author sohil.shah(a)jboss.com
+ *
+ */
+public class WorkflowServiceImpl extends AbstractJBossService implements WorkflowService
+{
+ private static Logger log = Logger.getLogger(WorkflowServiceImpl.class);
+
+
+ private JbpmConfiguration jbpmConfiguration = null;
+ private String jbpmConfigurationXml = null;
+
+ /**
+ *
+ *
+ */
+ public WorkflowServiceImpl()
+ {
+
+ }
+
+ /**
+ *
+ */
+ public void startService()
+ {
+ try
+ {
+ log.debug("---------------------------------------------------");
+ log.debug("Workflow Service successfully started......");
+ log.debug("---------------------------------------------------");
+
+ //initialize the jbpm configuration
+ this.jbpmConfiguration = JbpmConfiguration.parseXmlString(this.jbpmConfigurationXml);
+ }
+ catch(Exception e)
+ {
+ this.stopService();
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ *
+ */
+ public void stopService()
+ {
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getJbpmConfigurationXml()
+ {
+ return this.jbpmConfigurationXml;
+ }
+
+ /**
+ *
+ * @param jbpmConfigurationXml
+ */
+ public void setJbpmConfigurationXml(String jbpmConfigurationXml)
+ {
+ this.jbpmConfigurationXml = jbpmConfigurationXml;
+ }
+ //---------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @return
+ */
+ public JbpmConfiguration getJbpmConfiguration()
+ {
+ return this.jbpmConfiguration;
+ }
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/test/Finalize.java
===================================================================
--- trunk/workflow/src/main/org/jboss/portal/workflow/test/Finalize.java 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/workflow/src/main/org/jboss/portal/workflow/test/Finalize.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.test;
+
+import org.jbpm.graph.def.*;
+import org.jbpm.graph.exe.*;
+
+// MyActionHandler represents a class that could execute
+// some user code during the execution of a jBPM process.
+/**
+ * @author sohil.shah(a)jboss.com
+ */
+public class Finalize implements ActionHandler
+{
+
+ private static final long serialVersionUID = 1L;
+
+ // Before each test (in the setUp), the isExecuted member
+ // will be set to false.
+ public static boolean isExecuted = false;
+
+ // The action will set the isExecuted to true so the
+ // unit test will be able to show when the action
+ // is being executed.
+ public void execute(ExecutionContext executionContext)
+ {
+ String path =
(String)executionContext.getContextInstance().getVariable("path");
+
+ Object rejection =
executionContext.getContextInstance().getVariable("rejection");
+
+ if(rejection!=null)
+ {
+ System.out.println("This publish request was rejected....."+path);
+ }
+ else
+ {
+ System.out.println("This publish request was approved....."+path);
+ }
+
+
+ isExecuted = true;
+ }
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/test/HelloWorldDbTest.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/test/HelloWorldDbTest.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/test/HelloWorldDbTest.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,232 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.test;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.JbpmContext;
+import org.jbpm.db.GraphSession;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+
+/**
+ *
+ * @author sohil.shah(a)jboss.com
+ *
+ */
+public class HelloWorldDbTest extends TestCase {
+
+ static JbpmConfiguration jbpmConfiguration = null;
+
+ static {
+ // An example configuration file such as this can be found in
+ // 'src/config.files'. Typically the configuration information is in the
+ // resource file 'jbpm.cfg.xml', but here we pass in the configuration
+ // information as an XML string.
+
+ // First we create a JbpmConfiguration statically. One JbpmConfiguration
+ // can be used for all threads in the system, that is why we can safely
+ // make it static.
+
+ jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+
+ // A jbpm-context mechanism separates the jbpm core
+ // engine from the services that jbpm uses from
+ // the environment.
+
+ " <jbpm-context>" +
+ " <service name='persistence' " +
+ "
factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
+ " </jbpm-context>" +
+
+ // Also all the resource files that are used by jbpm are
+ // referenced from the jbpm.cfg.xml
+
+ " <string name='resource.hibernate.cfg.xml' " +
+ " value='conf/hibernate.cfg.xml' />" +
+ " <string name='resource.business.calendar' " +
+ " value='org/jbpm/calendar/jbpm.business.calendar.properties'
/>" +
+ " <string name='resource.default.modules' " +
+ " value='org/jbpm/graph/def/jbpm.default.modules.properties'
/>" +
+ " <string name='resource.converter' " +
+ " value='org/jbpm/db/hibernate/jbpm.converter.properties'
/>" +
+ " <string name='resource.action.types' " +
+ " value='org/jbpm/graph/action/action.types.xml' />"
+
+ " <string name='resource.node.types' " +
+ " value='org/jbpm/graph/node/node.types.xml' />" +
+ " <string name='resource.varmapping' " +
+ " value='org/jbpm/context/exe/jbpm.varmapping.xml'
/>" +
+ "</jbpm-configuration>"
+ );
+ }
+
+ public void setUp() {
+ jbpmConfiguration.createSchema();
+ }
+
+ public void tearDown() {
+ jbpmConfiguration.dropSchema();
+ }
+
+ public void testSimplePersistence() {
+ // Between the 3 method calls below, all data is passed via the
+ // database. Here, in this unit test, these 3 methods are executed
+ // right after each other because we want to test a complete process
+ // scenario. But in reality, these methods represent different
+ // requests to a server.
+
+ // Since we start with a clean, empty in-memory database, we have to
+ // deploy the process first. In reality, this is done once by the
+ // process developer.
+ deployProcessDefinition();
+
+ // Suppose we want to start a process instance (=process execution)
+ // when a user submits a form in a web application...
+ processInstanceIsCreatedWhenUserSubmitsWebappForm();
+
+ // Then, later, upon the arrival of an asynchronous message the
+ // execution must continue.
+ theProcessInstanceContinuesWhenAnAsyncMessageIsReceived();
+ }
+
+ public void deployProcessDefinition() {
+ // This test shows a process definition and one execution
+ // of the process definition. The process definition has
+ // 3 nodes: an unnamed start-state, a state 's' and an
+ // end-state named 'end'.
+ ProcessDefinition processDefinition = ProcessDefinition.parseXmlString(
+ "<process-definition name='hello_world'>" +
+ " <start-state name='start'>" +
+ " <transition to='s' />" +
+ " </start-state>" +
+ " <state name='s'>" +
+ " <transition to='end' />" +
+ " </state>" +
+ " <end-state name='end' />" +
+ "</process-definition>"
+ );
+
+ // Lookup the pojo persistence context-builder that is configured above
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try {
+ // Deploy the process definition in the database
+ jbpmContext.deployProcessDefinition(processDefinition);
+
+ } finally {
+ // Tear down the pojo persistence context.
+ // This includes flush the SQL for inserting the process definition
+ // to the database.
+ jbpmContext.close();
+ }
+ }
+
+ public void processInstanceIsCreatedWhenUserSubmitsWebappForm() {
+ // The code in this method could be inside a struts-action
+ // or a JSF managed bean.
+
+ // Lookup the pojo persistence context-builder that is configured above
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try {
+
+ GraphSession graphSession = jbpmContext.getGraphSession();
+
+ ProcessDefinition processDefinition =
+ graphSession.findLatestProcessDefinition("hello_world");
+
+ // With the processDefinition that we retrieved from the database, we
+ // can create an execution of the process definition just like in the
+ // hello_world example (which was without persistence).
+ ProcessInstance processInstance =
+ new ProcessInstance(processDefinition);
+
+ Token token = processInstance.getRootToken();
+ assertEquals("start", token.getNode().getName());
+ // Let's start the process execution
+ token.signal();
+ // Now the process is in the state 's'.
+ assertEquals("s", token.getNode().getName());
+
+ // Now the processInstance is saved in the database. So the
+ // current state of the execution of the process is stored in the
+ // database.
+ jbpmContext.save(processInstance);
+ // The method below will get the process instance back out
+ // of the database and resume execution by providing another
+ // external signal.
+
+ } finally {
+ // Tear down the pojo persistence context.
+ jbpmContext.close();
+ }
+ }
+
+ public void theProcessInstanceContinuesWhenAnAsyncMessageIsReceived() {
+ // The code in this method could be the content of a message driven bean.
+
+ // Lookup the pojo persistence context-builder that is configured above
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try {
+
+ GraphSession graphSession = jbpmContext.getGraphSession();
+ // First, we need to get the process instance back out of the database.
+ // There are several options to know what process instance we are dealing
+ // with here. The easiest in this simple test case is just to look for
+ // the full list of process instances. That should give us only one
+ // result. So let's look up the process definition.
+
+ ProcessDefinition processDefinition =
+ graphSession.findLatestProcessDefinition("hello_world");
+
+ // Now, we search for all process instances of this process definition.
+ List processInstances =
+ graphSession.findProcessInstances(processDefinition.getId());
+
+ // Because we know that in the context of this unit test, there is
+ // only one execution. In real life, the processInstanceId can be
+ // extracted from the content of the message that arrived or from
+ // the user making a choice.
+ ProcessInstance processInstance =
+ (ProcessInstance) processInstances.get(0);
+
+ // Now we can continue the execution. Note that the processInstance
+ // delegates signals to the main path of execution (=the root token).
+ processInstance.signal();
+
+ // After this signal, we know the process execution should have
+ // arrived in the end-state.
+ assertTrue(processInstance.hasEnded());
+
+ // Now we can update the state of the execution in the database
+ jbpmContext.save(processInstance);
+
+ } finally {
+ // Tear down the pojo persistence context.
+ jbpmContext.close();
+ }
+ }
+}
Added: trunk/workflow/src/main/org/jboss/portal/workflow/test/PortalCMSPublish.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/test/PortalCMSPublish.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/test/PortalCMSPublish.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,309 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.test;
+
+import java.util.*;
+
+import org.jbpm.graph.exe.*;
+import org.jbpm.JbpmConfiguration;
+import org.jbpm.graph.def.ProcessDefinition;
+import org.jbpm.graph.exe.ProcessInstance;
+import org.jbpm.graph.exe.Token;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+import org.jbpm.JbpmContext;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @author sohil.shah(a)jboss.com
+ *
+ */
+public class PortalCMSPublish extends TestCase
+{
+ static JbpmConfiguration jbpmConfiguration = null;
+ static ProcessDefinition processDefinition = null;
+
+ static
+ {
+ // An example configuration file such as this can be found in
+ // 'src/config.files'. Typically the configuration information is in the
+ // resource file 'jbpm.cfg.xml', but here we pass in the configuration
+ // information as an XML string.
+
+ // First we create a JbpmConfiguration statically. One JbpmConfiguration
+ // can be used for all threads in the system, that is why we can safely
+ // make it static.
+
+ jbpmConfiguration = JbpmConfiguration.parseXmlString(
+ "<jbpm-configuration>" +
+
+ // A jbpm-context mechanism separates the jbpm core
+ // engine from the services that jbpm uses from
+ // the environment.
+
+ " <jbpm-context>" +
+ " <service name='persistence' " +
+ "
factory='org.jbpm.persistence.db.DbPersistenceServiceFactory' />" +
+ " </jbpm-context>" +
+
+ // Also all the resource files that are used by jbpm are
+ // referenced from the jbpm.cfg.xml
+
+ " <string name='resource.hibernate.cfg.xml' " +
+ " value='conf/hibernate.cfg.xml' />" +
+ " <string name='resource.business.calendar' " +
+ "
value='org/jbpm/calendar/jbpm.business.calendar.properties' />" +
+ " <string name='resource.default.modules' " +
+ " value='org/jbpm/graph/def/jbpm.default.modules.properties'
/>" +
+ " <string name='resource.converter' " +
+ " value='org/jbpm/db/hibernate/jbpm.converter.properties'
/>" +
+ " <string name='resource.action.types' " +
+ " value='org/jbpm/graph/action/action.types.xml' />"
+
+ " <string name='resource.node.types' " +
+ " value='org/jbpm/graph/node/node.types.xml' />" +
+ " <string name='resource.varmapping' " +
+ " value='org/jbpm/context/exe/jbpm.varmapping.xml'
/>" +
+ "</jbpm-configuration>"
+ );
+
+ processDefinition = ProcessDefinition.parseXmlString(
+ "<process-definition name='approval_workflow'>" +
+ " <start-state>" +
+ " <transition to='request_approval'/>" +
+ " </start-state>" +
+ " <task-node name='request_approval'>"+
+ " <task name='approve_publish'>" +
+ " <assignment
class='org.jboss.portal.workflow.test.PublishAssignmentHandler'/>" +
+ " </task>" +
+ " <controller>" +
+ " <variable name='path'
access='read'/>"+
+ " </controller>"+
+ " <transition name='approval' to='end'/>" +
+ " <transition name='rejection' to='end'>"
+
+ " <script name='signalRejection'>"+
+ " <variable name='rejection'/>"+
+ " <expression>"+
+ " System.out.println(\"Running the rejection
script....\");rejection=true;"+
+ " </expression>"+
+ " </script>"+
+ " </transition>"+
+ " </task-node>"+
+ " <end-state name='end'>" +
+ " <event type='node-enter'>"+
+ " <action
class='org.jboss.portal.workflow.test.Finalize'/>"+
+ " </event>"+
+ " </end-state>"+
+ "</process-definition>"
+ );
+ }
+
+ /**
+ *
+ */
+ public void setUp()
+ {
+ jbpmConfiguration.createSchema();
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ try
+ {
+ jbpmContext.deployProcessDefinition(processDefinition);
+ }
+ finally
+ {
+ jbpmContext.close();
+ }
+ }
+
+ /**
+ *
+ */
+ protected void tearDown() throws Exception
+ {
+ jbpmConfiguration.dropSchema();
+ }
+
+ public void testCMSPublish() throws Exception
+ {
+ long processId1 = this.createTask("/default/index.html");
+ long processId2 = this.createTask("/default/index2.html");
+
+ ApprovalThread t1 = new
ApprovalThread(processId1,"/default/index.html",true);
+ ApprovalThread t2 = new
ApprovalThread(processId2,"/default/index2.html",false);
+ Thread thread1 = new Thread(t1);
+ Thread thread2 = new Thread(t2);
+
+ thread1.start();
+ thread2.start();
+
+ while(!t1.done || !t2.done)
+ {
+ //busy wait here
+ }
+ }
+
+ /**
+ *
+ * @param path
+ * @return
+ */
+ private long createTask(String path)
+ {
+ long processId = 0;
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = null;
+ try
+ {
+ //The next line creates one execution of the process definition.
+ // After construction, the process execution has one main path
+ // of execution (=the root token) that is positioned in the
+ // start-state.
+ processInstance = jbpmContext.newProcessInstance("approval_workflow");
+
+ //After construction, the process execution has one main path
+ // of execution (=the root token).
+ Token token = processInstance.getRootToken();
+
+ //set the process variables
+ processInstance.getContextInstance().setVariable("path",path);
+
+ //start the workflow, starts the cms publish approval workflow
+ //this creates a task to approve/reject a cms publish for the Admins
+ token.signal();
+ }
+ finally
+ {
+ if(processInstance!=null)
+ {
+ jbpmContext.save(processInstance);
+ processId = processInstance.getId();
+ }
+ jbpmContext.close();
+ }
+ return processId;
+ }
+
+ /**
+ *
+ * @param path
+ * @param processId
+ * @param manager
+ * @param reject
+ * @throws Exception
+ */
+ private void executeTask(String path,long processId,String manager,boolean reject)
throws Exception
+ {
+ JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
+ ProcessInstance processInstance = null;
+ try
+ {
+ // Now, we search for all process instances of this process definition.
+ processInstance = jbpmContext.loadProcessInstance(processId);
+
+ if(processInstance.hasEnded())
+ {
+ System.out.println("This process has already ended...");
+ return;
+ }
+
+ //here act as an Admin and approve/reject one of the tasks
+ Collection allTasks = processInstance.getTaskMgmtInstance().getTaskInstances();
+ String[] transitions = {"approval","rejection"};
+ java.util.Random random = new java.util.Random(12343);
+ boolean markedForRejection = false;
+ for(Iterator itr=allTasks.iterator();itr.hasNext();)
+ {
+ TaskInstance cour = (TaskInstance)itr.next();
+ if(markedForRejection)
+ {
+ cour.end(transitions[1]);
+ continue;
+ }
+ if(cour.getActorId().equals(manager))
+ {
+
System.out.println("Manager="+cour.getActorId()+"("+processId+")");
+ int randomIndex = Math.abs(random.nextInt()%2);
+ if(randomIndex == 1)
+ {
+ //kill this task
+ markedForRejection = true;
+ cour.end(transitions[randomIndex]);
+ }
+ else
+ {
+ cour.end(transitions[randomIndex]);
+ break;
+ }
+ }
+ }
+ }
+ finally
+ {
+ if(processInstance!=null)
+ {
+ jbpmContext.save(processInstance);
+ }
+ jbpmContext.close();
+ }
+ }
+
+
+ /**
+ *
+ * @author sshah
+ *
+ */
+ private class ApprovalThread implements Runnable
+ {
+ long processId = 0;
+ String path = null;
+ boolean reject = false;
+ boolean done = false;
+ private ApprovalThread(long processId,String path,boolean reject)
+ {
+ this.processId = processId;
+ this.path = path;
+ this.reject = reject;
+ }
+
+ public void run()
+ {
+ try
+ {
+ String[] managers =
{"Admin","eric.brown@jboss.com","sohil.shah(a)jboss.com"};
+ for(int i=0;i<managers.length;i++)
+ {
+ executeTask(this.path,this.processId,managers[i],this.reject);
+ }
+ }
+ catch(Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ finally
+ {
+ done = true;
+ }
+ }
+ }
+}
Added:
trunk/workflow/src/main/org/jboss/portal/workflow/test/PublishAssignmentHandler.java
===================================================================
---
trunk/workflow/src/main/org/jboss/portal/workflow/test/PublishAssignmentHandler.java 2006-12-22
14:04:02 UTC (rev 5928)
+++
trunk/workflow/src/main/org/jboss/portal/workflow/test/PublishAssignmentHandler.java 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.workflow.test;
+
+import java.util.Collection;
+
+import org.jbpm.graph.exe.*;
+import org.jbpm.taskmgmt.def.*;
+import org.jbpm.taskmgmt.exe.Assignable;
+import org.jbpm.taskmgmt.exe.TaskInstance;
+
+/**
+ *
+ * @author sohil.shah(a)jboss.com
+ *
+ */
+public class PublishAssignmentHandler implements AssignmentHandler {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ *
+ */
+ public void assign(Assignable assignable,ExecutionContext executionContext)
+ {
+ int taskInstances = 0;
+ Collection assignedTasks = executionContext.getTaskMgmtInstance().getTaskInstances();
+ if(assignedTasks!=null)
+ {
+ taskInstances = assignedTasks.size();
+ }
+
+ if(taskInstances == 1)
+ {
+ System.out.println("Assigning this task to the Managers");
+ String[] managers =
{"Admin","sohil.shah@jboss.com","eric.brown(a)jboss.com"};
+ assignable.setActorId(managers[0]);
+ for(int i=1;i<managers.length;i++)
+ {
+ TaskInstance t = executionContext.getTaskMgmtInstance().
+ createTaskInstance(((TaskInstance)assignable).getTask(),executionContext);
+ t.setActorId(managers[i]);
+ }
+ }
+ }
+}
Added: trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,147 @@
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<server>
+ <!-- Hibernate service -->
+ <mbean
+ code="org.jboss.portal.jems.hibernate.SessionFactoryBinder"
+ name="portal:service=Hibernate,type=Workflow"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+
<depends>jboss.jca:service=DataSourceBinding,name=@portal.datasource.name@</depends>
+ <attribute name="DoChecking">true</attribute>
+ <attribute
name="ConfigLocation">conf/hibernate.cfg.xml</attribute>
+ <attribute
name="JNDIName">java:/portal/workflow/WorkFlowSessionFactory</attribute>
+ </mbean>
+
+ <!-- Workflow service -->
+ <mbean
+ code="org.jboss.portal.workflow.service.WorkflowServiceImpl"
+ name="portal:service=Workflow,type=WorkflowService"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends>portal:service=Hibernate,type=Workflow</depends>
+ <attribute name="JbpmConfigurationXml">
+ <![CDATA[
+ <jbpm-configuration>
+ <jbpm-context>
+ <service name="persistence"
factory="org.jbpm.persistence.db.DbPersistenceServiceFactory"/>
+ </jbpm-context>
+ <string name="resource.hibernate.cfg.xml"
value="conf/hibernate.cfg.xml"/>
+ <string name="resource.business.calendar"
value="org/jbpm/calendar/jbpm.business.calendar.properties"/>
+ <string name="resource.default.modules"
value="org/jbpm/graph/def/jbpm.default.modules.properties"/>
+ <string name="resource.converter"
value="org/jbpm/db/hibernate/jbpm.converter.properties"/>
+ <string name="resource.action.types"
value="org/jbpm/graph/action/action.types.xml"/>
+ <string name="resource.node.types"
value="org/jbpm/graph/node/node.types.xml"/>
+ <string name="resource.varmapping"
value="org/jbpm/context/exe/jbpm.varmapping.xml"/>
+ </jbpm-configuration>
+ ]]>
+ </attribute>
+ </mbean>
+
+ <!-- ApprovePublish workflow service -->
+ <mbean
+ code="org.jboss.portal.workflow.cms.ApprovePublishImpl"
+ name="portal:service=ApprovePublish,type=Workflow"
+ xmbean-dd=""
+ xmbean-code="org.jboss.portal.jems.as.system.JBossServiceModelMBean">
+ <xmbean/>
+ <depends optional-attribute-name="WorkflowService"
proxy-type="attribute">
+ portal:service=Workflow,type=WorkflowService
+ </depends>
+ <!-- JBPM process definition -->
+ <attribute name="Process">
+ <![CDATA[
+ <!-- cms approval workflow -->
+ <process-definition name="approval_workflow">
+ <start-state>
+ <transition to="request_approval"/>
+ </start-state>
+ <task-node name="request_approval" signal="first">
+ <task name="approve_publish">
+ <assignment
class="org.jboss.portal.core.workflow.cms.PublishAssignmentHandler"/>
+ <event type="task-start">
+ <action
class="org.jboss.portal.cms.workflow.FinalizePublish"/>
+ </event>
+ <exception-handler>
+ <action
class="org.jboss.portal.workflow.cms.TaskExceptionHandler"/>
+ </exception-handler>
+ </task>
+ <transition name="approval" to="end"/>
+ <transition name="rejection" to="end"/>
+ </task-node>
+ <end-state name="end"/>
+ </process-definition>
+ ]]>
+ </attribute>
+ <!--
+ overwrite = false creates the process first time if does not exist, for
+ subsequent server restarts, this process definition remains in tact
+
+ overwrite = true creates the process first time if does not exist,
+ for subsequent server restarts, it creates a new version of the process
definition
+ which will be used for processes created from then onwards. Old processes
created
+ for an older version of the definition remain in tact and use their
corresponding
+ process definition.
+
+ Typically use overwrite=false and overwrite=true only when a new process
definition
+ related to this workflow needs to be deployed
+ -->
+ <attribute name="Overwrite">false</attribute>
+ <!--
+ a comma separated list email addresses of managers that can
+ approve/reject content publish requests
+
+ TODO: once a GUI is fully integrated with the workflow
+ this will be modified to be a list of roles and then
+ the corresponding users will be treated as managers
+ -->
+ <attribute
name="ManagerEmails">sohil.shah@jboss.com,sshah(a)redhat.com</attribute>
+ <attribute name="From">do-not-reply(a)jboss.com</attribute>
+ <attribute name="Subject">Content Approval
Requested</attribute>
+ <attribute name="Body">
+ <![CDATA[
+ Approval is needed to publish the following Content:
+
+ Content Location : {0}
+
+ Content Type : {1}
+
+ Content Size : {2}
+
+ Creation Date : {3}
+
+ User : {4}
+
+
+ <a
href="http://localhost/workflow/approve?pId={5}&manager={6}">Approve</a>
+
+
+ <a
href="http://localhost/workflow/reject?pId={7}&manager={8}">Reject</a>
+ ]]>
+ </attribute>
+ <attribute
name="JNDIName">java:portal/ApprovePublishWorkflow</attribute>
+ </mbean>
+</server>
Added: trunk/workflow/src/resources/portal-workflow-sar/conf/hibernate.cfg.xml
===================================================================
--- trunk/workflow/src/resources/portal-workflow-sar/conf/hibernate.cfg.xml 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/workflow/src/resources/portal-workflow-sar/conf/hibernate.cfg.xml 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,166 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+ <!-- jdbc connection properties -->
+ <property
name="connection.datasource">java:@portal.datasource.name@</property>
+
+ <!-- other hibernate properties -->
+ <property name="show_sql">@portal.sql.show(a)</property>
+ <property name="hibernate.format_sql">true</property>
+ <property name="hibernate.use_sql_comments">true</property>
+
+ <!-- managed environment transaction configuration -->
+ <property
name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
+ <property
name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
+
+ <!--property
name="dialect">org.hibernate.dialect.MySQLInnoDBDialect</property-->
+
+ <!-- ############################################ -->
+ <!-- # mapping files with external dependencies # -->
+ <!-- ############################################ -->
+
+ <!-- following mapping file has a dependendy on -->
+ <!-- 'bsh-{version}.jar'. -->
+ <!-- uncomment this if you don't have bsh on your -->
+ <!-- classpath. you won't be able to use the -->
+ <!-- script element in process definition files -->
+ <mapping resource="org/jbpm/graph/action/Script.hbm.xml"/>
+
+ <!-- following mapping files have a dependendy on -->
+ <!-- 'jbpm-identity-{version}.jar', mapping files -->
+ <!-- of the pluggable jbpm identity component. -->
+ <!-- comment out the following 3 lines if you don't-->
+ <!-- want to use the default jBPM identity mgmgt -->
+ <!-- component -->
+ <mapping resource="org/jbpm/identity/User.hbm.xml"/>
+ <mapping resource="org/jbpm/identity/Group.hbm.xml"/>
+ <mapping resource="org/jbpm/identity/Membership.hbm.xml"/>
+
+ <!-- ###################### -->
+ <!-- # jbpm mapping files # -->
+ <!-- ###################### -->
+
+ <!-- hql queries and type defs -->
+ <mapping resource="org/jbpm/db/hibernate.queries.hbm.xml"/>
+
+ <!-- graph.def mapping files -->
+ <mapping resource="org/jbpm/graph/def/ProcessDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Node.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Transition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Event.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Action.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/SuperState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/ExceptionHandler.hbm.xml"/>
+ <mapping resource="org/jbpm/instantiation/Delegation.hbm.xml"/>
+
+ <!-- graph.node mapping files -->
+ <mapping resource="org/jbpm/graph/node/StartState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/EndState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/ProcessState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Decision.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Fork.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Join.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/State.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/TaskNode.hbm.xml"/>
+
+ <!-- context.def mapping files -->
+ <mapping resource="org/jbpm/context/def/ContextDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/context/def/VariableAccess.hbm.xml"/>
+
+ <!-- taskmgmt.def mapping files -->
+ <mapping
resource="org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Swimlane.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Task.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/TaskController.hbm.xml"/>
+
+ <!-- module.def mapping files -->
+ <mapping resource="org/jbpm/module/def/ModuleDefinition.hbm.xml"/>
+
+ <!-- bytes mapping files -->
+ <mapping resource="org/jbpm/bytes/ByteArray.hbm.xml"/>
+
+ <!-- file.def mapping files -->
+ <mapping resource="org/jbpm/file/def/FileDefinition.hbm.xml"/>
+
+ <!-- scheduler.def mapping files -->
+ <mapping
resource="org/jbpm/scheduler/def/CreateTimerAction.hbm.xml"/>
+ <mapping
resource="org/jbpm/scheduler/def/CancelTimerAction.hbm.xml"/>
+
+ <!-- graph.exe mapping files -->
+ <mapping resource="org/jbpm/graph/exe/Comment.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/ProcessInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/Token.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/RuntimeAction.hbm.xml"/>
+
+ <!-- module.exe mapping files -->
+ <mapping resource="org/jbpm/module/exe/ModuleInstance.hbm.xml"/>
+
+ <!-- context.exe mapping files -->
+ <mapping resource="org/jbpm/context/exe/ContextInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/TokenVariableMap.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/VariableInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/>
+
+ <!-- msg.db mapping files -->
+ <mapping resource="org/jbpm/msg/Message.hbm.xml"/>
+ <mapping resource="org/jbpm/msg/db/TextMessage.hbm.xml"/>
+ <mapping resource="org/jbpm/command/ExecuteActionCommand.hbm.xml"/>
+ <mapping resource="org/jbpm/command/ExecuteNodeCommand.hbm.xml"/>
+ <mapping resource="org/jbpm/command/SignalCommand.hbm.xml"/>
+ <mapping
resource="org/jbpm/command/TaskInstanceEndCommand.hbm.xml"/>
+
+ <!-- taskmgmt.exe mapping files -->
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/PooledActor.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml"/>
+
+ <!-- scheduler.exe mapping files -->
+ <mapping resource="org/jbpm/scheduler/exe/Timer.hbm.xml"/>
+
+ <!-- logging mapping files -->
+ <mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ProcessStateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/SignalLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TransitionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableDeleteLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml"/>
+
+ </session-factory>
+</hibernate-configuration>
Added: trunk/workflow/src/resources/portal-workflow-war/WEB-INF/jboss-web.xml
===================================================================
--- trunk/workflow/src/resources/portal-workflow-war/WEB-INF/jboss-web.xml 2006-12-22
14:04:02 UTC (rev 5928)
+++ trunk/workflow/src/resources/portal-workflow-war/WEB-INF/jboss-web.xml 2006-12-22
20:15:42 UTC (rev 5929)
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<jboss-web>
+ <context-root>workflow</context-root>
+</jboss-web>
Added: trunk/workflow/src/resources/portal-workflow-war/WEB-INF/web.xml
===================================================================
--- trunk/workflow/src/resources/portal-workflow-war/WEB-INF/web.xml 2006-12-22 14:04:02
UTC (rev 5928)
+++ trunk/workflow/src/resources/portal-workflow-war/WEB-INF/web.xml 2006-12-22 20:15:42
UTC (rev 5929)
@@ -0,0 +1,43 @@
+<?xml version="1.0"?>
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2006, Red Hat Middleware, LLC, and individual ~
+ ~ contributors as indicated by the @authors tag. See the ~
+ ~ copyright.txt in the distribution for a full listing of ~
+ ~ individual contributors. ~
+ ~ ~
+ ~ This is free software; you can redistribute it and/or modify it ~
+ ~ under the terms of the GNU Lesser General Public License as ~
+ ~ published by the Free Software Foundation; either version 2.1 of ~
+ ~ the License, or (at your option) any later version. ~
+ ~ ~
+ ~ This software is distributed in the hope that it will be useful, ~
+ ~ but WITHOUT ANY WARRANTY; without even the implied warranty of ~
+ ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ~
+ ~ Lesser General Public License for more details. ~
+ ~ ~
+ ~ You should have received a copy of the GNU Lesser General Public ~
+ ~ License along with this software; if not, write to the Free ~
+ ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~
+ ~ 02110-1301 USA, or see the FSF site:
http://www.fsf.org. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+
+<web-app
+
xmlns="http://java.sun.com/xml/ns/j2ee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <servlet>
+ <servlet-name>ApprovePublishServlet</servlet-name>
+
<servlet-class>org.jboss.portal.workflow.cms.ApprovePublishServlet</servlet-class>
+ <!--load-on-startup>0</load-on-startup-->
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>ApprovePublishServlet</servlet-name>
+ <url-pattern>/approve/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>ApprovePublishServlet</servlet-name>
+ <url-pattern>/reject/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: trunk/workflow/src/resources/test/conf/hibernate.cfg.xml
===================================================================
--- trunk/workflow/src/resources/test/conf/hibernate.cfg.xml 2006-12-22 14:04:02 UTC (rev
5928)
+++ trunk/workflow/src/resources/test/conf/hibernate.cfg.xml 2006-12-22 20:15:42 UTC (rev
5929)
@@ -0,0 +1,166 @@
+<?xml version='1.0' encoding='utf-8'?>
+
+<!DOCTYPE hibernate-configuration PUBLIC
+ "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
+
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
+
+<hibernate-configuration>
+ <session-factory>
+
+ <!-- jdbc connection properties -->
+ <property
name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
+ <property
name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
+ <property
name="hibernate.connection.url">jdbc:hsqldb:mem:.;sql.enforce_strict_size=true</property>
+ <property name="hibernate.connection.username">sa</property>
+ <property name="hibernate.connection.password"></property>
+
+
+ <!-- other hibernate properties -->
+ <property name="hibernate.show_sql">false</property>
+ <property name="hibernate.format_sql">true</property>
+ <property name="hibernate.use_sql_comments">true</property>
+
+ <!-- ############################################ -->
+ <!-- # mapping files with external dependencies # -->
+ <!-- ############################################ -->
+
+ <!-- following mapping file has a dependendy on -->
+ <!-- 'bsh-{version}.jar'. -->
+ <!-- uncomment this if you don't have bsh on your -->
+ <!-- classpath. you won't be able to use the -->
+ <!-- script element in process definition files -->
+ <mapping resource="org/jbpm/graph/action/Script.hbm.xml"/>
+
+ <!-- following mapping files have a dependendy on -->
+ <!-- 'jbpm-identity-{version}.jar', mapping files -->
+ <!-- of the pluggable jbpm identity component. -->
+ <!-- comment out the following 3 lines if you don't-->
+ <!-- want to use the default jBPM identity mgmgt -->
+ <!-- component -->
+ <mapping resource="org/jbpm/identity/User.hbm.xml"/>
+ <mapping resource="org/jbpm/identity/Group.hbm.xml"/>
+ <mapping resource="org/jbpm/identity/Membership.hbm.xml"/>
+
+ <!-- ###################### -->
+ <!-- # jbpm mapping files # -->
+ <!-- ###################### -->
+
+ <!-- hql queries and type defs -->
+ <mapping resource="org/jbpm/db/hibernate.queries.hbm.xml"/>
+
+ <!-- graph.def mapping files -->
+ <mapping resource="org/jbpm/graph/def/ProcessDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Node.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Transition.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Event.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/Action.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/SuperState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/def/ExceptionHandler.hbm.xml"/>
+ <mapping resource="org/jbpm/instantiation/Delegation.hbm.xml"/>
+
+ <!-- graph.node mapping files -->
+ <mapping resource="org/jbpm/graph/node/StartState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/EndState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/ProcessState.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Decision.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Fork.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/Join.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/State.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/node/TaskNode.hbm.xml"/>
+
+ <!-- context.def mapping files -->
+ <mapping resource="org/jbpm/context/def/ContextDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/context/def/VariableAccess.hbm.xml"/>
+
+ <!-- taskmgmt.def mapping files -->
+ <mapping
resource="org/jbpm/taskmgmt/def/TaskMgmtDefinition.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Swimlane.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/Task.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/def/TaskController.hbm.xml"/>
+
+ <!-- module.def mapping files -->
+ <mapping resource="org/jbpm/module/def/ModuleDefinition.hbm.xml"/>
+
+ <!-- bytes mapping files -->
+ <mapping resource="org/jbpm/bytes/ByteArray.hbm.xml"/>
+
+ <!-- file.def mapping files -->
+ <mapping resource="org/jbpm/file/def/FileDefinition.hbm.xml"/>
+
+ <!-- scheduler.def mapping files -->
+ <mapping
resource="org/jbpm/scheduler/def/CreateTimerAction.hbm.xml"/>
+ <mapping
resource="org/jbpm/scheduler/def/CancelTimerAction.hbm.xml"/>
+
+ <!-- graph.exe mapping files -->
+ <mapping resource="org/jbpm/graph/exe/Comment.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/ProcessInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/Token.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/exe/RuntimeAction.hbm.xml"/>
+
+ <!-- module.exe mapping files -->
+ <mapping resource="org/jbpm/module/exe/ModuleInstance.hbm.xml"/>
+
+ <!-- context.exe mapping files -->
+ <mapping resource="org/jbpm/context/exe/ContextInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/TokenVariableMap.hbm.xml"/>
+ <mapping resource="org/jbpm/context/exe/VariableInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/ByteArrayInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/DateInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/DoubleInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/HibernateLongInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/HibernateStringInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/LongInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/NullInstance.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/exe/variableinstance/StringInstance.hbm.xml"/>
+
+ <!-- msg.db mapping files -->
+ <mapping resource="org/jbpm/msg/Message.hbm.xml"/>
+ <mapping resource="org/jbpm/msg/db/TextMessage.hbm.xml"/>
+ <mapping resource="org/jbpm/command/ExecuteActionCommand.hbm.xml"/>
+ <mapping resource="org/jbpm/command/ExecuteNodeCommand.hbm.xml"/>
+ <mapping resource="org/jbpm/command/SignalCommand.hbm.xml"/>
+ <mapping
resource="org/jbpm/command/TaskInstanceEndCommand.hbm.xml"/>
+
+ <!-- taskmgmt.exe mapping files -->
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskMgmtInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/TaskInstance.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/PooledActor.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/exe/SwimlaneInstance.hbm.xml"/>
+
+ <!-- scheduler.exe mapping files -->
+ <mapping resource="org/jbpm/scheduler/exe/Timer.hbm.xml"/>
+
+ <!-- logging mapping files -->
+ <mapping resource="org/jbpm/logging/log/ProcessLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/MessageLog.hbm.xml"/>
+ <mapping resource="org/jbpm/logging/log/CompositeLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ActionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/NodeLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/graph/log/ProcessInstanceCreateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/graph/log/ProcessInstanceEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/ProcessStateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/SignalLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TokenEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/graph/log/TransitionLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableDeleteLog.hbm.xml"/>
+ <mapping resource="org/jbpm/context/log/VariableUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/ByteArrayUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/DateUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/DoubleUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/HibernateLongUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/HibernateStringUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/LongUpdateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/context/log/variableinstance/StringUpdateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskCreateLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskAssignLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/TaskEndLog.hbm.xml"/>
+ <mapping resource="org/jbpm/taskmgmt/log/SwimlaneLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/taskmgmt/log/SwimlaneCreateLog.hbm.xml"/>
+ <mapping
resource="org/jbpm/taskmgmt/log/SwimlaneAssignLog.hbm.xml"/>
+
+ </session-factory>
+</hibernate-configuration>