Author: julien(a)jboss.com
Date: 2007-01-15 20:56:16 -0500 (Mon, 15 Jan 2007)
New Revision: 6012
Added:
trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/
trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/IdentityBindingInterceptor.java
trunk/core-cms/src/main/org/jboss/portal/core/cms/workflow/
trunk/core-cms/src/main/org/jboss/portal/core/cms/workflow/PublishAssignmentHandler.java
Removed:
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java
Modified:
trunk/build/ide/intellij/idea60/modules/core-cms/core-cms.iml
trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
trunk/server/src/main/org/jboss/portal/server/ServerInvocation.java
trunk/server/src/main/org/jboss/portal/server/ServerRequest.java
trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml
Log:
forgot to move PublishAssignmentHandler to core-cms integration
Modified: trunk/build/ide/intellij/idea60/modules/core-cms/core-cms.iml
===================================================================
--- trunk/build/ide/intellij/idea60/modules/core-cms/core-cms.iml 2007-01-16 01:34:04 UTC
(rev 6011)
+++ trunk/build/ide/intellij/idea60/modules/core-cms/core-cms.iml 2007-01-16 01:56:16 UTC
(rev 6012)
@@ -50,6 +50,7 @@
</library>
</orderEntry>
<orderEntry type="module" module-name="portlet" />
+ <orderEntry type="module" module-name="identity" />
<orderEntryProperties />
</component>
<component name="VcsManagerConfiguration">
Modified: trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2007-01-16
01:34:04 UTC (rev 6011)
+++
trunk/core/src/main/org/jboss/portal/core/aspects/server/UserInterceptor.java 2007-01-16
01:56:16 UTC (rev 6012)
@@ -184,11 +184,6 @@
// Attach the request user to the invocation
invocation.getRequest().setUser(user);
- // setup the portal user information to be used by the CMS Business Layer
- // for fine grained access control enforcement
- // JCRCMS.getUserInfo().set(user);
- System.out.println("No JCR CMS integration done");
-
// Continue the invocation
invocation.invokeNext();
}
Deleted:
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java 2007-01-16
01:34:04 UTC (rev 6011)
+++
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java 2007-01-16
01:56:16 UTC (rev 6012)
@@ -1,135 +0,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. *
- ******************************************************************************/
-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);
- }
- }
-}
Added:
trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/IdentityBindingInterceptor.java
===================================================================
---
trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/IdentityBindingInterceptor.java 2007-01-16
01:34:04 UTC (rev 6011)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/aspect/IdentityBindingInterceptor.java 2007-01-16
01:56:16 UTC (rev 6012)
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * 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.cms.aspect;
+
+import org.jboss.portal.identity.User;
+import org.jboss.portal.cms.impl.jcr.JCRCMS;
+import org.jboss.portal.cms.impl.jcr.JCRCommand;
+import org.jboss.portal.cms.CMSInterceptor;
+import org.jboss.portal.server.ServerInterceptor;
+import org.jboss.portal.server.ServerInvocation;
+import com.sun.jdi.InvocationException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class IdentityBindingInterceptor extends ServerInterceptor
+{
+
+ protected void invoke(ServerInvocation invocation) throws Exception,
InvocationException
+ {
+ try
+ {
+ // setup the portal user information to be used by the CMS Business Layer
+ // for fine grained access control enforcement
+ User user = (User)invocation.getRequest().getUser();
+ JCRCMS.getUserInfo().set(user);
+ invocation.invokeNext();
+ }
+ finally
+ {
+ JCRCMS.getUserInfo().set(null);
+ }
+ }
+}
Copied:
trunk/core-cms/src/main/org/jboss/portal/core/cms/workflow/PublishAssignmentHandler.java
(from rev 6009,
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java)
===================================================================
---
trunk/core/src/main/org/jboss/portal/core/workflow/cms/PublishAssignmentHandler.java 2007-01-15
23:29:20 UTC (rev 6009)
+++
trunk/core-cms/src/main/org/jboss/portal/core/cms/workflow/PublishAssignmentHandler.java 2007-01-16
01:56:16 UTC (rev 6012)
@@ -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.cms.workflow;
+
+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/server/src/main/org/jboss/portal/server/ServerInvocation.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/ServerInvocation.java 2007-01-16
01:34:04 UTC (rev 6011)
+++ trunk/server/src/main/org/jboss/portal/server/ServerInvocation.java 2007-01-16
01:56:16 UTC (rev 6012)
@@ -45,6 +45,9 @@
/** . */
public static final Scope NAVIGATIONAL_STATE_SCOPE = new
Scope("navigationalstate");
+ /** . */
+ public static final String IDENTITY_KEY = "identity";
+
/** The request. */
private ServerRequest req;
Modified: trunk/server/src/main/org/jboss/portal/server/ServerRequest.java
===================================================================
--- trunk/server/src/main/org/jboss/portal/server/ServerRequest.java 2007-01-16 01:34:04
UTC (rev 6011)
+++ trunk/server/src/main/org/jboss/portal/server/ServerRequest.java 2007-01-16 01:56:16
UTC (rev 6012)
@@ -40,8 +40,11 @@
/** The server used during the request. */
protected Server server;
- public ServerRequest()
+ protected ServerInvocation invocation;
+
+ public ServerRequest(ServerInvocation invocation)
{
+ this.invocation = invocation;
}
public Object getUser()
@@ -49,9 +52,19 @@
return user;
}
+ /**
+ * Associate a user object with the current request. If the user is null, it is
equivalent to remove it.
+ * The underlying server invocation will have the user object bound into the
<code>ServerInvocation.REQUEST_SCOPE</code>
+ * using the <code>ServerInvocation.USER_IDENTITY_KEY</code> name.
+ *
+ * @param user the request user
+ */
public void setUser(Object user)
{
this.user = user;
+
+ //
+ invocation.setAttribute(ServerInvocation.REQUEST_SCOPE,
ServerInvocation.IDENTITY_KEY, user);
}
public Server getServer()
Modified: trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml
===================================================================
--- trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml 2007-01-16
01:34:04 UTC (rev 6011)
+++ trunk/workflow/src/resources/portal-workflow-sar/META-INF/jboss-service.xml 2007-01-16
01:56:16 UTC (rev 6012)
@@ -81,7 +81,7 @@
</start-state>
<task-node name="request_approval" signal="first">
<task name="approve_publish">
- <assignment
class="org.jboss.portal.core.workflow.cms.PublishAssignmentHandler"/>
+ <assignment
class="org.jboss.portal.core.cms.workflow.PublishAssignmentHandler"/>
<event type="task-start">
<action
class="org.jboss.portal.cms.workflow.FinalizePublish"/>
</event>