Update of 
/var/cvs/contributions/CMSContainer/cmsc/edit-webapp/src/java/com/finalist/cmsc/editwizard
In directory 
james.mmbase.org:/tmp/cvs-serv12554/cmsc/edit-webapp/src/java/com/finalist/cmsc/editwizard

Modified Files:
        WizardController.java WizardWorkflowController.java 
Log Message:
CMSC-1087 (changes the status box of a page to a dynamic tree in the Workflow 
section of the CMSC)


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/edit-webapp/src/java/com/finalist/cmsc/editwizard
See also: http://www.mmbase.org/jira/browse/CMSC-1087


Index: WizardController.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/edit-webapp/src/java/com/finalist/cmsc/editwizard/WizardController.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- WizardController.java       29 Jul 2008 21:28:02 -0000      1.11
+++ WizardController.java       4 Nov 2008 12:02:06 -0000       1.12
@@ -14,12 +14,14 @@
 import org.mmbase.applications.editwizard.Config.WizardConfig;
 import org.mmbase.bridge.Cloud;
 import org.mmbase.bridge.Node;
+import org.mmbase.bridge.implementation.BasicNode;
 import org.mmbase.security.Rank;
 import org.mmbase.util.logging.Logger;
 import org.mmbase.util.logging.Logging;
 
 import com.finalist.cmsc.navigation.NavigationUtil;
 import com.finalist.cmsc.navigation.PagesUtil;
+import com.finalist.cmsc.repository.AssetElementUtil;
 import com.finalist.cmsc.repository.ContentElementUtil;
 import com.finalist.cmsc.repository.RepositoryUtil;
 import com.finalist.cmsc.security.Role;
@@ -43,6 +45,7 @@
    protected static final String NEW_OBJECT = "new";
 
    protected static final String SESSION_CONTENTTYPE = "contenttype";
+   protected static final String SESSION_ASSETTYPE = "assettype";
    protected static final String SESSION_CREATION = "creation";
    protected static final String SESSION_READONLY = "readonly";
 
@@ -68,15 +71,21 @@
 
       HttpSession session = request.getSession();
       String objectnr = config.objectNumber;
-      String contenttype = null;
+      String elementtype = null;
       if (objectnr != null && NEW_OBJECT.equals(objectnr)) {
-         contenttype = (String) session.getAttribute(SESSION_CONTENTTYPE);
+         String contenttype = (String) 
session.getAttribute(SESSION_CONTENTTYPE);
+         String assettype = (String) session.getAttribute(SESSION_ASSETTYPE);
+         if(StringUtils.isBlank(contenttype)){
+            elementtype = contenttype;
+         }else if (StringUtils.isBlank(assettype)){
+            elementtype = (String) session.getAttribute(SESSION_ASSETTYPE);
+         }
       }
       else {
          Node node = cloud.getNode(objectnr);
-         contenttype = node.getNodeManager().getName();
+         elementtype = node.getNodeManager().getName();
       }
-      log.debug("contenttype " + contenttype);
+      log.debug("elementtype " + elementtype);
 
       String readonly = (String) session.getAttribute(SESSION_READONLY);
       if (StringUtils.isBlank(readonly)) {
@@ -89,7 +98,7 @@
       log.debug("readonly " + readonly);
 
       Node creationNode = null;
-      if (StringUtils.isNotEmpty(contenttype)) {
+      if (StringUtils.isNotEmpty(elementtype)) {
          String creation = (String) session.getAttribute(SESSION_CREATION);
          if (StringUtils.isNotEmpty(creation)) {
             creationNode = cloud.getNode(creation);
@@ -101,7 +110,7 @@
                creationNode = node;
                session.setAttribute(SESSION_CREATION, "" + 
creationNode.getNumber());
             }
-            if (ContentElementUtil.isContentType(contenttype)) {
+            if (ContentElementUtil.isContentType(elementtype) || 
AssetElementUtil.isAssetType(elementtype)) {
                if (RepositoryUtil.hasCreationChannel(node)) {
                   creationNode = RepositoryUtil.getCreationChannel(node);
                   session.setAttribute(SESSION_CREATION, "" + 
creationNode.getNumber());
@@ -146,7 +155,7 @@
          }
       }
 
-      openWizard(request, ewconfig, config, cloud, params, userrole, 
contenttype);
+      openWizard(request, ewconfig, config, cloud, params, userrole, 
elementtype);
 
       log.debug("params = " + params);
       return params;
@@ -154,7 +163,7 @@
 
 
    public void openWizard(HttpServletRequest request, Config ewconfig, 
Config.WizardConfig config, Cloud cloud,
-         Map<String, String> params, UserRole userrole, String contenttype) {
+         Map<String, String> params, UserRole userrole, String elementtype) {
       // nothing to do
    }
 
@@ -186,7 +195,7 @@
          }
 
          Node editNode = null;
-         String contenttype = null;
+         String elementtype = null;
 
          String objectnr = wizardConfig.objectNumber;
          log.debug("objectnr " + objectnr);
@@ -209,6 +218,20 @@
 
          if (editNode != null) {
             if (ContentElementUtil.isContentElement(editNode)) {
+               closeContentElement(session, editNode, objectnr, ewconfig, 
wizardConfig);
+            }else if (AssetElementUtil.isAssetElement(editNode)) {
+               closeAssetElement(session, editNode, objectnr, ewconfig, 
wizardConfig);
+            }
+            elementtype = editNode.getNodeManager().getName();
+         }
+         log.debug("contenttype " + elementtype);
+
+         closeWizard(request, ewconfig, wizardConfig, cloud, editNode, 
elementtype);
+      }
+   }
+
+
+   private void closeContentElement(HttpSession session, Node editNode, String 
objectnr, Config ewconfig, Config.WizardConfig wizardConfig) {
                if (NEW_OBJECT.equals(objectnr)) {
                   String channelnr = (String) 
session.getAttribute(SESSION_CREATION);
                   log.debug("Creation " + channelnr);
@@ -253,11 +276,51 @@
                   log.error("Problem while adding version for node : " + 
objectnr, e);
                }
             }
-            contenttype = editNode.getNodeManager().getName();
+
+
+   private void closeAssetElement(HttpSession session, Node editNode, String 
objectnr, Config ewconfig, Config.WizardConfig wizardConfig) {
+      if (NEW_OBJECT.equals(objectnr)) {
+            String channelnr = (String) session.getAttribute(SESSION_CREATION);
+            log.debug("Creation " + channelnr);
+
+            // this has creation channel check is needed, because with it
+            // will create double creationchannels when first "save" and
+            // then "save and close"
+            if (!RepositoryUtil.hasCreationChannel(editNode)) {
+               if (StringUtils.isNotEmpty(channelnr)) {
+                  RepositoryUtil.addCreationChannel(editNode, channelnr);
+                  AssetElementUtil.addOwner(editNode);
+                  if (isMainWizard(ewconfig, wizardConfig)) {
+                     RepositoryUtil.addAssetToChannel(editNode, channelnr);
+                  }
+               }
+               else {
+                  log.warn("AssetElement: Creationchannel was not found in 
session");
+               }
+            }
+         }
+         else {
+            if (!AssetElementUtil.hasOwner(editNode)) {
+               AssetElementUtil.addOwner(editNode);
+            }
+
+            if (!RepositoryUtil.hasCreationChannel(editNode)) {
+               String channelnr = (String) 
session.getAttribute(SESSION_CREATION);
+               log.debug("Creation " + channelnr);
+
+               if (StringUtils.isNotEmpty(channelnr)) {
+                  RepositoryUtil.addCreationChannel(editNode, channelnr);
+               }
+            }
          }
-         log.debug("contenttype " + contenttype);
 
-         closeWizard(request, ewconfig, wizardConfig, cloud, editNode, 
contenttype);
+         try {
+            if (wizardConfig.wiz.committed()) {
+               Versioning.addVersion(editNode);
+            }
+         }
+         catch (VersioningException e) {
+            log.error("Problem while adding version for node : " + objectnr, 
e);
       }
    }
 


Index: WizardWorkflowController.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/edit-webapp/src/java/com/finalist/cmsc/editwizard/WizardWorkflowController.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- WizardWorkflowController.java       8 Aug 2008 13:43:53 -0000       1.8
+++ WizardWorkflowController.java       4 Nov 2008 12:02:06 -0000       1.9
@@ -61,12 +61,12 @@
     */
    @Override
    public void openWizard(HttpServletRequest request, Config ewconfig, 
Config.WizardConfig config, Cloud cloud,
-         Map<String, String> params, UserRole userrole, String contenttype) {
+         Map<String, String> params, UserRole userrole, String elementtype) {
 
       String objectnr = config.objectNumber;
 
-      if (isMainWizard(ewconfig, config) && contenttype != null && 
!"".equals(contenttype)
-            && Workflow.isWorkflowType(contenttype)) {
+      if (isMainWizard(ewconfig, config) && elementtype != null && 
!"".equals(elementtype)
+            && Workflow.isWorkflowType(elementtype)) {
 
          params.put("WORKFLOW", TRUE);
          params.put("WORKFLOW-ACCEPTED-ENABLED", 
Boolean.toString(Workflow.isAcceptedStepEnabled()));
@@ -104,7 +104,7 @@
             }
          }
          else {
-            if (PagesUtil.isPageType(cloud.getNodeManager(contenttype))) {
+            if (PagesUtil.isPageType(cloud.getNodeManager(elementtype))) {
                // disable workflow for a new page
                params.put("WORKFLOW", OFF);
             }
@@ -113,7 +113,7 @@
          params.put("ACTIVITY", activity);
       }
       else {
-         if (contenttype != null && !"".equals(contenttype) && 
Workflow.isWorkflowType(contenttype)) {
+         if (elementtype != null && !"".equals(elementtype) && 
Workflow.isWorkflowType(elementtype)) {
             params.put("WORKFLOW", FALSE);
          }
          else {
@@ -125,9 +125,9 @@
 
    @Override
    public void closeWizard(HttpServletRequest request, Config ewconfig, 
Config.WizardConfig wizardConfig, Cloud cloud,
-         Node editNode, String contenttype) {
+         Node editNode, String elementtype) {
 
-      if (isMainWizard(ewconfig, wizardConfig) && editNode != null && 
Workflow.isWorkflowType(contenttype)) {
+      if (isMainWizard(ewconfig, wizardConfig) && editNode != null && 
Workflow.isWorkflowType(elementtype)) {
 
          String objectnr = wizardConfig.objectNumber;
 
@@ -200,7 +200,7 @@
          }
       }
       else {
-         if (editNode != null && !Workflow.isWorkflowType(contenttype)) {
+         if (editNode != null && !Workflow.isWorkflowType(elementtype)) {
 
             String workflowCommand = request.getParameter(WORKFLOWCOMMAND);
             if (PUBLISH.equals(workflowCommand)) {
_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to