[portal-commits] JBoss Portal SVN: r11804 - modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Thu Sep 4 08:30:57 EDT 2008


Author: thomas.heute at jboss.com
Date: 2008-09-04 08:30:57 -0400 (Thu, 04 Sep 2008)
New Revision: 11804

Modified:
   modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublish.java
   modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublishImpl.java
Log:
Merging old cms with CMS module

Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublish.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublish.java	2008-09-04 12:28:53 UTC (rev 11803)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublish.java	2008-09-04 12:30:57 UTC (rev 11804)
@@ -38,27 +38,28 @@
     * 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
+    * @param content the content to be approved
+    * @return the process id of the workflow process set in motion
+    * @throws WorkflowException if an error occured during the approval process
     */
    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 processId the id of the approval process we are interested in
     * @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;
-   
-   /**
-    * Called when a manager either approves the publishing of a specific content to go live, but at the same time
-    * adds his/her own modifications to the original content
+
+    /**
+    * Called when a manager either approves the publishing of a specific content to go live, but at the same time adds
+    * his/her own modifications to the original content
     *
-    * @param processId
-    * @param manager   userId of the manager
-    * @param approved  true if approved, false if rejected
+    * @param processId       the process id of the workflow we're interesting in
+    * @param manager         userId of the manager
+    * @param modifiedContent modified content
     */
    public void processManagerResponse(long processId, String manager, String modifiedContent) throws WorkflowException;
 
@@ -69,7 +70,7 @@
     * @return
     * @throws WorkflowException
     */
-   public Collection getPendingQueue(String filePath) throws WorkflowException;
+   public Collection<Content> getPendingQueue(String filePath) throws WorkflowException;
 
    /**
     * Retrieves a queue of unapproved content for everything in the CMS.
@@ -77,7 +78,7 @@
     * @return
     * @throws WorkflowException
     */
-   public Collection getAllPendingInQueue() throws WorkflowException;
+   public Collection<Content> getAllPendingInQueue() throws WorkflowException;
 
    /**
     * Returns role names of Roles that are designated to be Managers in this workflow. Managers approve/deny all content
@@ -85,5 +86,5 @@
     *
     * @return a Set of role names
     */
-   public Set getManagers();
+   public Set<String> getManagers();
 }

Modified: modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublishImpl.java
===================================================================
--- modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublishImpl.java	2008-09-04 12:28:53 UTC (rev 11803)
+++ modules/cms/trunk/cms-jackrabbit/src/main/java/org/jboss/portal/cms/workflow/ApprovePublishImpl.java	2008-09-04 12:30:57 UTC (rev 11804)
@@ -75,7 +75,7 @@
    private String processName = null;
    private String managerRoles = null;
    private String[] managers = null;
-   private Set managerSet = null;
+   private Set<String> managerSet = null;
    private boolean overwrite = false;
    private String from = null;
    private String subject = null;
@@ -156,7 +156,7 @@
       //process managers that can serve as approvers/rejecters
       StringTokenizer st = new StringTokenizer(this.managerRoles, ",");
       this.managers = new String[st.countTokens()];
-      this.managerSet = new HashSet();
+      this.managerSet = new HashSet<String>();
       for (int i = 0; i < managers.length; i++)
       {
          this.managers[i] = st.nextToken();
@@ -164,10 +164,10 @@
       }
 
       this.membershipModule = (MembershipModule)identityServiceController.getIdentityContext().
-         getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
+              getObject(IdentityContext.TYPE_MEMBERSHIP_MODULE);
 
       this.userModule = (UserModule)identityServiceController.getIdentityContext().
-         getObject(IdentityContext.TYPE_USER_MODULE);
+              getObject(IdentityContext.TYPE_USER_MODULE);
    }
 
    /**
@@ -256,7 +256,7 @@
 
    /** @param identityServiceController  */
    public void setIdentityServiceController(
-      IdentityServiceController identityServiceController)
+           IdentityServiceController identityServiceController)
    {
       this.identityServiceController = identityServiceController;
    }
@@ -357,13 +357,6 @@
       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;
@@ -436,15 +429,7 @@
          IOTools.safeClose(jbpmContext);
       }
    }
-   
-   /**
-    * Called when a manager either approves the publishing of a specific content to go live, but at the same time
-    * adds his/her own modifications to the original content
-    *
-    * @param processId
-    * @param manager   userId of the manager
-    * @param approved  true if approved, false if rejected
-    */
+
    public void processManagerResponse(long processId, String manager, String modifiedContent) throws WorkflowException
    {
       JbpmContext jbpmContext = null;
@@ -463,28 +448,28 @@
             return;
          }
 
-         processInstance.getContextInstance().setVariable("approved", new Boolean(true));
+         processInstance.getContextInstance().setVariable("approved", true);
          processInstance.getContextInstance().setVariable("modifiedContent", modifiedContent);
 
-         Collection allTasks = processInstance.getTaskMgmtInstance().getTaskInstances();
+         @SuppressWarnings("unchecked")
+         Collection<TaskInstance> allTasks = processInstance.getTaskMgmtInstance().getTaskInstances();
          if (allTasks != null)
          {
-            for (Iterator itr = allTasks.iterator(); itr.hasNext();)
+            for (TaskInstance currentTask : allTasks)
             {
-               TaskInstance cour = (TaskInstance)itr.next();
-               if (this.isManager(manager, cour.getActorId()))
+               if (this.isManager(manager, currentTask.getActorId()))
                {
                   isManager = true;
-                  log.debug("Manager=" + cour.getActorId() + "(" + processId + ")");
+                  log.debug("Manager=" + currentTask.getActorId() + "(" + processId + ")");
 
                   //check and make sure this task instance is not marked for deletion
-                  if (cour.getVariable(processInstance.getId() + ":" + cour.getId()) != null)
+                  if (currentTask.getVariable(processInstance.getId() + ":" + currentTask.getId()) != null)
                   {
                      continue;
                   }
-                  
-                  cour.start();
-                  cour.end("approval");
+
+                  currentTask.start();
+                  currentTask.end("approval");
                   break;
                }
             }
@@ -503,8 +488,7 @@
 
          if (!isManager)
          {
-            WorkflowException we = new WorkflowException("You are not authorized to Approve/Deny content publish requests");
-            throw we;
+            throw new WorkflowException("You are not authorized to Approve/Deny content publish requests");
          }
          IOTools.safeClose(jbpmContext);
       }
@@ -517,9 +501,9 @@
     * @return
     * @throws WorkflowException
     */
-   public Collection getPendingQueue(String filePath) throws WorkflowException
+   public Collection<Content> getPendingQueue(String filePath) throws WorkflowException
    {
-      Collection pendingQueue = new ArrayList();
+      Collection<Content> pendingQueue = new ArrayList<Content>();
       JbpmContext jbpmContext = null;
       try
       {
@@ -527,17 +511,18 @@
 
          GraphSession graphSession = jbpmContext.getGraphSession();
          ProcessDefinition processDef = graphSession.findLatestProcessDefinition(this.processName);
-         List processInstances = graphSession.findProcessInstances(processDef.getId());
 
+         @SuppressWarnings("unchecked")
+         List<ProcessInstance> processInstances = graphSession.findProcessInstances(processDef.getId());
+
          if (processInstances != null)
          {
-            for (int i = 0; i < processInstances.size(); i++)
+            for (ProcessInstance processInstance : processInstances)
             {
-               ProcessInstance cour = (ProcessInstance)processInstances.get(i);
                //iterate through a list of currently pending approval tasks
-               if (!cour.hasEnded())
+               if (!processInstance.hasEnded())
                {
-                  Content content = (Content)cour.getContextInstance().getVariable("content");
+                  Content content = (Content)processInstance.getContextInstance().getVariable("content");
 
                   //apply proper criteria to extract pending content only for the specified file
                   if (content != null)
@@ -547,7 +532,7 @@
 
                      if (criteriaPath.trim().equals(filePath.trim()))
                      {
-                        content.setProcessId(String.valueOf(cour.getId()));
+                        content.setProcessId(String.valueOf(processInstance.getId()));
                         pendingQueue.add(content);
                      }
                   }
@@ -568,9 +553,9 @@
     * @return
     * @throws WorkflowException
     */
-   public Collection getAllPendingInQueue() throws WorkflowException
+   public Collection<Content> getAllPendingInQueue() throws WorkflowException
    {
-      Collection pendingQueue = new ArrayList();
+      Collection<Content> pendingQueue = new ArrayList<Content>();
       JbpmContext jbpmContext = null;
       try
       {
@@ -578,22 +563,23 @@
 
          GraphSession graphSession = jbpmContext.getGraphSession();
          ProcessDefinition processDef = graphSession.findLatestProcessDefinition(this.processName);
-         List processInstances = graphSession.findProcessInstances(processDef.getId());
 
+         @SuppressWarnings("unchecked")
+         List<ProcessInstance> processInstances = graphSession.findProcessInstances(processDef.getId());
+
          if (processInstances != null)
          {
-            for (int i = 0; i < processInstances.size(); i++)
+            for (ProcessInstance processInstance : processInstances)
             {
-               ProcessInstance cour = (ProcessInstance)processInstances.get(i);
                //iterate through a list of currently pending approval tasks
-               if (!cour.hasEnded())
+               if (!processInstance.hasEnded())
                {
-                  Content content = (Content)cour.getContextInstance().getVariable("content");
+                  Content content = (Content)processInstance.getContextInstance().getVariable("content");
 
                   //apply proper criteria to extract pending content only for the specified file
                   if (content != null)
                   {
-                     content.setProcessId(String.valueOf(cour.getId()));
+                     content.setProcessId(String.valueOf(processInstance.getId()));
                      pendingQueue.add(content);
                   }
                }
@@ -608,7 +594,7 @@
    }
 
    /** @return  */
-   public Set getManagers()
+   public Set<String> getManagers()
    {
       return this.managerSet;
    }
@@ -626,7 +612,7 @@
       boolean isManager = false;
 
       Set userRoles = this.membershipModule.getRoles(
-         this.userModule.findUserByUserName(user));
+              this.userModule.findUserByUserName(user));
       if (userRoles != null)
       {
          for (Iterator itr = userRoles.iterator(); itr.hasNext();)




More information about the portal-commits mailing list