You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2006/12/12 16:03:44 UTC

svn commit: r486178 - in /lenya/trunk/src/pubs/default: lenya/usecases/workflow/ modules/defaultusecases/ modules/defaultusecases/config/cocoon-xconf/ modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/

Author: andreas
Date: Tue Dec 12 07:03:43 2006
New Revision: 486178

URL: http://svn.apache.org/viewvc?view=rev&rev=486178
Log:
Removed 'subtree' functionality from Publish and Deactivate usecases, see bug 40670

Modified:
    lenya/trunk/src/pubs/default/lenya/usecases/workflow/deactivate.jx
    lenya/trunk/src/pubs/default/lenya/usecases/workflow/publish.jx
    lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-deactivate.xconf
    lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-publish.xconf
    lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
    lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
    lenya/trunk/src/pubs/default/modules/defaultusecases/module.xml

Modified: lenya/trunk/src/pubs/default/lenya/usecases/workflow/deactivate.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/lenya/usecases/workflow/deactivate.jx?view=diff&rev=486178&r1=486177&r2=486178
==============================================================================
--- lenya/trunk/src/pubs/default/lenya/usecases/workflow/deactivate.jx (original)
+++ lenya/trunk/src/pubs/default/lenya/usecases/workflow/deactivate.jx Tue Dec 12 07:03:43 2006
@@ -72,25 +72,6 @@
               </tr>
             </jx:if>
             <tr>
-              <td class="lenya-entry-caption">
-                <i18n:text>deactivate complete subtree</i18n:text>:
-              </td>
-              <td>
-                <jx:choose>
-                  <jx:when test="${usecase.getParameter('allowSingleDocument').equals('false')}">
-                    <input type="checkbox" checked="checked" disabled="disabled"/>
-                    <input name="subtree" type="hidden" value="on"/>
-                  </jx:when>
-                  <jx:when test="${usecase.getParameter('subtree') == null}">
-                    <input name="subtree" type="checkbox"/>
-                  </jx:when>
-                  <jx:otherwise>
-                    <input name="subtree" type="checkbox" checked="checked"/>
-                  </jx:otherwise>
-                </jx:choose>
-              </td>
-            </tr>
-            <tr>
               <td/>
               <td>
                 <input i18n:attr="value" type="submit" name="submit" value="Deactivate"/>

Modified: lenya/trunk/src/pubs/default/lenya/usecases/workflow/publish.jx
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/lenya/usecases/workflow/publish.jx?view=diff&rev=486178&r1=486177&r2=486178
==============================================================================
--- lenya/trunk/src/pubs/default/lenya/usecases/workflow/publish.jx (original)
+++ lenya/trunk/src/pubs/default/lenya/usecases/workflow/publish.jx Tue Dec 12 07:03:43 2006
@@ -98,26 +98,6 @@
             </jx:if>
             <tr>
               <td class="lenya-entry-caption">
-                <i18n:text>publish complete subtree</i18n:text>:
-              </td>
-              <td>
-                <jx:choose>
-                  <jx:when test="${usecase.getParameter('allowSingleDocument').equals('false')}">
-                    <input type="checkbox" checked="checked" disabled="disabled"/>
-                    <input name="subtree" type="hidden" value="on"/>
-                  </jx:when>
-                  <jx:when test="${usecase.getParameter('subtree') == null}">
-                    <input name="subtree" type="checkbox"/>
-                  </jx:when>
-                  <jx:otherwise>
-                    <input name="subtree" type="checkbox" checked="checked"/>
-                  </jx:otherwise>
-                </jx:choose>
-                
-              </td>
-            </tr>
-            <tr>
-              <td class="lenya-entry-caption">
                 <i18n:text>notify-submitter</i18n:text>:
               </td>
               <td>

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-deactivate.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-deactivate.xconf?view=diff&rev=486178&r1=486177&r2=486178
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-deactivate.xconf (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-deactivate.xconf Tue Dec 12 07:03:43 2006
@@ -27,6 +27,7 @@
                         logger="lenya.usecases.workflow"
                         class="org.apache.lenya.defaultpub.cms.usecases.Deactivate">
       <view template="usecases/workflow/deactivate.jx"/>
+      <event id="deactivate"/>
     </component-instance>
 
   </xconf>

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-publish.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-publish.xconf?view=diff&rev=486178&r1=486177&r2=486178
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-publish.xconf (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/config/cocoon-xconf/usecases-workflow-publish.xconf Tue Dec 12 07:03:43 2006
@@ -26,7 +26,8 @@
     <component-instance name="default/workflow.publish"
                         logger="lenya.usecases.workflow"
                         class="org.apache.lenya.defaultpub.cms.usecases.Publish">
-      <view template="usecases/workflow/publish.jx"/>
+      <view template="usecases/workflow/publish.jx"/>
+      <event id="publish"/>
     </component-instance>
 
   </xconf>

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java?view=diff&rev=486178&r1=486177&r2=486178
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Deactivate.java Tue Dec 12 07:03:43 2006
@@ -28,22 +28,18 @@
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentManager;
 import org.apache.lenya.cms.publication.Publication;
-import org.apache.lenya.cms.publication.PublicationException;
-import org.apache.lenya.cms.site.NodeIterator;
 import org.apache.lenya.cms.site.NodeSet;
 import org.apache.lenya.cms.site.SiteNode;
 import org.apache.lenya.cms.site.SiteUtil;
-import org.apache.lenya.cms.usecase.DocumentUsecase;
 import org.apache.lenya.cms.usecase.UsecaseException;
-import org.apache.lenya.cms.workflow.WorkflowUtil;
-import org.apache.lenya.workflow.WorkflowException;
+import org.apache.lenya.cms.workflow.usecases.InvokeWorkflow;
 
 /**
  * Deactivate usecase handler.
  * 
  * @version $Id$
  */
-public class Deactivate extends DocumentUsecase {
+public class Deactivate extends InvokeWorkflow {
 
     protected static final String LINKS_TO_DOCUMENT = "linksToDocument";
 
@@ -63,31 +59,17 @@
                 return;
             }
 
-            String event = getEvent();
-            boolean allowSingle = true;
-
             if (!getSourceDocument().existsAreaVersion(Publication.LIVE_AREA)) {
                 addErrorMessage("This usecase can only be invoked when the live version exists.");
             } else {
-                if (!WorkflowUtil.canInvoke(this.manager,
-                        getSession(),
-                        getLogger(),
-                        getSourceDocument(),
-                        event)) {
-                    allowSingle = false;
-                    addInfoMessage("The single document cannot be deactivated because the workflow event cannot be invoked.");
-                }
-
                 Document liveDoc = getSourceDocument().getAreaVersion(Publication.LIVE_AREA);
                 NodeSet subSite = SiteUtil.getSubSite(this.manager, liveDoc.getLink().getNode());
                 SiteNode node = liveDoc.getLink().getNode();
                 subSite.remove(node);
 
                 if (!subSite.isEmpty()) {
-                    allowSingle = false;
-                    addInfoMessage("You have to deactivate the whole subtree because descendants are live.");
+                    addErrorMessage("You can't deactivate this document because it has children.");
                 }
-                setParameter(Publish.ALLOW_SINGLE_DOCUMENT, Boolean.toString(allowSingle));
             }
 
             setParameter(LINKS_TO_DOCUMENT, getLinksToDocument());
@@ -124,19 +106,10 @@
     protected org.apache.lenya.cms.repository.Node[] getNodesToLock() throws UsecaseException {
         try {
             List nodes = new ArrayList();
-            NodeSet siteNodes = new NodeSet(this.manager);
 
             Document doc = getSourceDocument();
-            siteNodes.addAll(SiteUtil.getSubSite(this.manager, doc.getLink().getNode()));
-
             Document liveDoc = doc.getAreaVersion(Publication.LIVE_AREA);
-            siteNodes.addAll(SiteUtil.getSubSite(this.manager, liveDoc.getLink().getNode()));
-
-            Document[] documents = siteNodes.getDocuments();
-            for (int i = 0; i < documents.length; i++) {
-                nodes.add(documents[i].getRepositoryNode());
-            }
-
+            nodes.add(liveDoc.getRepositoryNode());
             nodes.add(liveDoc.area().getSite().getRepositoryNode());
             return (org.apache.lenya.cms.repository.Node[]) nodes.toArray(new org.apache.lenya.cms.repository.Node[nodes.size()]);
 
@@ -150,11 +123,7 @@
      */
     protected void doExecute() throws Exception {
         super.doExecute();
-        if (isSubtreeEnabled()) {
-            deactivateAll(getSourceDocument());
-        } else {
-            deactivate(getSourceDocument());
-        }
+        deactivate(getSourceDocument());
     }
 
     /**
@@ -175,12 +144,6 @@
             documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
             documentManager.delete(liveDocument);
 
-            WorkflowUtil.invoke(this.manager,
-                    getSession(),
-                    getLogger(),
-                    authoringDocument,
-                    getEvent());
-
             success = true;
         } catch (Exception e) {
             throw new RuntimeException(e);
@@ -202,64 +165,8 @@
 
     }
 
-    /**
-     * @return The event to invoke.
-     */
-    private String getEvent() {
+    protected String getEvent() {
         return "deactivate";
     }
 
-    /**
-     * Deactivates a document or the subtree below a document, based on the parameter SUBTREE.
-     * 
-     * @param document The document.
-     */
-    protected void deactivateAll(Document document) {
-
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Deactivating document [" + document + "]");
-            getLogger().debug("Subtree deactivation: [" + isSubtreeEnabled() + "]");
-        }
-
-        try {
-            NodeSet set = SiteUtil.getSubSite(this.manager, document.getLink().getNode());
-            for (NodeIterator i = set.descending(); i.hasNext();) {
-                deactivateAllLanguageVersions(i.next());
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Publishing completed.");
-        }
-    }
-
-    /**
-     * Returns whether subtree publishing is enabled.
-     * 
-     * @return A boolean value.
-     */
-    protected boolean isSubtreeEnabled() {
-        String value = getParameterAsString(Publish.SUBTREE);
-        return value != null;
-    }
-
-    /**
-     * Publishes all existing language versions of a document.
-     * 
-     * @param node The document.
-     * @throws PublicationException if an error occurs.
-     * @throws WorkflowException
-     */
-    protected void deactivateAllLanguageVersions(SiteNode node) throws PublicationException,
-            WorkflowException {
-        String[] languages = node.getLanguages();
-        for (int i = 0; i < languages.length; i++) {
-            Document version = node.getLink(languages[i]).getDocument();
-            if (WorkflowUtil.canInvoke(this.manager, getSession(), getLogger(), version, getEvent())) {
-                deactivate(version);
-            }
-        }
-    }
 }

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java?view=diff&rev=486178&r1=486177&r2=486178
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/java/src/org/apache/lenya/defaultpub/cms/usecases/Publish.java Tue Dec 12 07:03:43 2006
@@ -48,22 +48,18 @@
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.publication.PublicationException;
 import org.apache.lenya.cms.site.Link;
-import org.apache.lenya.cms.site.NodeIterator;
-import org.apache.lenya.cms.site.NodeSet;
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.SiteManager;
 import org.apache.lenya.cms.site.SiteNode;
 import org.apache.lenya.cms.site.SiteStructure;
-import org.apache.lenya.cms.site.SiteUtil;
-import org.apache.lenya.cms.usecase.DocumentUsecase;
 import org.apache.lenya.cms.usecase.UsecaseException;
 import org.apache.lenya.cms.usecase.scheduling.UsecaseScheduler;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
+import org.apache.lenya.cms.workflow.usecases.InvokeWorkflow;
 import org.apache.lenya.notification.Message;
 import org.apache.lenya.notification.NotificationEventDescriptor;
 import org.apache.lenya.notification.NotificationException;
 import org.apache.lenya.workflow.Version;
-import org.apache.lenya.workflow.WorkflowException;
 import org.apache.lenya.workflow.Workflowable;
 
 /**
@@ -71,13 +67,11 @@
  * 
  * @version $Id$
  */
-public class Publish extends DocumentUsecase {
+public class Publish extends InvokeWorkflow {
 
     protected static final String MESSAGE_SUBJECT = "notification-message";
     protected static final String MESSAGE_DOCUMENT_PUBLISHED = "document-published";
     protected static final String MISSING_DOCUMENTS = "missingDocuments";
-    protected static final String SUBTREE = "subtree";
-    protected static final String ALLOW_SINGLE_DOCUMENT = "allowSingleDocument";
     protected static final String SCHEDULE = "schedule";
     protected static final String SCHEDULE_TIME = "schedule.time";
     protected static final String SEND_NOTIFICATION = "sendNotification";
@@ -136,17 +130,11 @@
     protected org.apache.lenya.cms.repository.Node[] getNodesToLock() throws UsecaseException {
         try {
             List nodes = new ArrayList();
-            NodeSet set = new NodeSet(this.manager);
 
             Document doc = getSourceDocument();
-            set.addAll(SiteUtil.getSubSite(this.manager, doc.getLink().getNode()));
-
-            Document[] docs = set.getDocuments();
-            for (int i = 0; i < docs.length; i++) {
-                nodes.add(docs[i].getRepositoryNode());
-            }
-
+            nodes.add(doc.getRepositoryNode());
             nodes.add(doc.area().getSite().getRepositoryNode());
+            
             return (org.apache.lenya.cms.repository.Node[]) nodes
                     .toArray(new org.apache.lenya.cms.repository.Node[nodes.size()]);
 
@@ -165,7 +153,6 @@
         super.doCheckPreconditions();
         if (!hasErrors()) {
 
-            String event = getEvent();
             Document document = getSourceDocument();
 
             if (!document.getArea().equals(Publication.AUTHORING_AREA)) {
@@ -173,14 +160,6 @@
                 return;
             }
 
-            if (!WorkflowUtil.canInvoke(this.manager, getSession(), getLogger(),
-                    getSourceDocument(), event)) {
-                setParameter(ALLOW_SINGLE_DOCUMENT, Boolean.toString(false));
-                addInfoMessage("The single document cannot be published because the workflow event cannot be invoked.");
-            } else {
-                setParameter(ALLOW_SINGLE_DOCUMENT, Boolean.toString(true));
-            }
-
             Publication publication = document.getPublication();
             DocumentFactory map = document.getFactory();
             SiteStructure liveSite = publication.getArea(Publication.LIVE_AREA).getSite();
@@ -276,11 +255,7 @@
             }
         } else {
             super.doExecute();
-            if (isSubtreeEnabled()) {
-                publishAll(getSourceDocument());
-            } else {
-                publish(getSourceDocument());
-            }
+            publish(getSourceDocument());
         }
     }
 
@@ -294,8 +269,6 @@
         try {
             documentManager = (DocumentManager) this.manager.lookup(DocumentManager.ROLE);
             documentManager.copyToArea(authoringDocument, Publication.LIVE_AREA);
-            WorkflowUtil.invoke(this.manager, getSession(), getLogger(), authoringDocument,
-                    getEvent());
 
             boolean notify = Boolean.valueOf(getBooleanCheckboxParameter(SEND_NOTIFICATION))
                     .booleanValue();
@@ -354,40 +327,6 @@
         }
     }
 
-    /**
-     * @return The event to invoke.
-     */
-    private String getEvent() {
-        return "publish";
-    }
-
-    /**
-     * Publishes a document or the subtree below a document, based on the
-     * parameter SUBTREE.
-     * 
-     * @param document The document.
-     */
-    protected void publishAll(Document document) {
-
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Publishing document [" + document + "]");
-            getLogger().debug("Subtree publishing: [" + isSubtreeEnabled() + "]");
-        }
-
-        try {
-            NodeSet set = SiteUtil.getSubSite(this.manager, document.getLink().getNode());
-            for (NodeIterator i = set.ascending(); i.hasNext();) {
-                publishAllLanguageVersions(i.next());
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("Publishing completed.");
-        }
-    }
-
     protected void createAncestorNodes(Document document) throws PublicationException,
             DocumentException, SiteException {
         SiteStructure liveSite = document.getPublication().getArea(Publication.LIVE_AREA).getSite();
@@ -401,41 +340,6 @@
             path += "/" + steps[s];
             s++;
         }
-    }
-
-    /**
-     * Returns whether subtree publishing is enabled.
-     * 
-     * @return A boolean value.
-     */
-    protected boolean isSubtreeEnabled() {
-        String value = getParameterAsString(SUBTREE);
-        return value != null;
-    }
-
-    /**
-     * Publishes all existing language versions of a document.
-     * 
-     * @param node The document.
-     * @throws PublicationException if an error occurs.
-     * @throws WorkflowException
-     */
-    protected void publishAllLanguageVersions(SiteNode node) throws PublicationException,
-            WorkflowException {
-        String[] languages = node.getLanguages();
-
-        try {
-            for (int i = 0; i < languages.length; i++) {
-                Document version = node.getLink(languages[i]).getDocument();
-                if (WorkflowUtil.canInvoke(this.manager, getSession(), getLogger(), version,
-                        getEvent())) {
-                    publish(version);
-                }
-            }
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-
     }
 
 }

Modified: lenya/trunk/src/pubs/default/modules/defaultusecases/module.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/modules/defaultusecases/module.xml?view=diff&rev=486178&r1=486177&r2=486178
==============================================================================
--- lenya/trunk/src/pubs/default/modules/defaultusecases/module.xml (original)
+++ lenya/trunk/src/pubs/default/modules/defaultusecases/module.xml Tue Dec 12 07:03:43 2006
@@ -24,6 +24,7 @@
   <depends module="org.apache.lenya.modules.sitemanagement"/>
   <depends module="org.apache.lenya.modules.notification"/>
   <depends module="org.apache.lenya.modules.linking"/>
+  <depends module="org.apache.lenya.modules.workflow-impl"/>
   <package>org.apache.lenya.modules</package>
   <version>0.1-dev</version>
   <name>Default publication usecases</name>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org