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 2007/01/12 16:25:12 UTC

svn commit: r495605 - in /lenya/trunk/src: modules/editors/ modules/editors/config/cocoon-xconf/ modules/editors/java/src/org/apache/lenya/cms/editors/ modules/neutron/ modules/neutron/config/ modules/neutron/config/cocoon-xconf/ modules/neutron/xslt/ ...

Author: andreas
Date: Fri Jan 12 07:25:11 2007
New Revision: 495605

URL: http://svn.apache.org/viewvc?view=rev&rev=495605
Log:
Fixed saving with neutron

Added:
    lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/SaveDocument.java
    lenya/trunk/src/modules/neutron/config/
    lenya/trunk/src/modules/neutron/config/cocoon-xconf/
    lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkin.xconf
    lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkout.xconf
Modified:
    lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-edit.xconf
    lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/EditDocument.java
    lenya/trunk/src/modules/editors/sitemap.xmap
    lenya/trunk/src/modules/neutron/sitemap.xmap
    lenya/trunk/src/modules/neutron/xslt/introspection.xsl
    lenya/trunk/src/modules/webdav/sitemap.xmap
    lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml

Modified: lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-edit.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-edit.xconf?view=diff&rev=495605&r1=495604&r2=495605
==============================================================================
--- lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-edit.xconf (original)
+++ lenya/trunk/src/modules/editors/config/cocoon-xconf/usecase-edit.xconf Fri Jan 12 07:25:11 2007
@@ -24,6 +24,6 @@
   <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'editors.publicationEdit']">
     <component-instance name="editors.publicationEdit" logger="lenya.publication"
       class="org.apache.lenya.cms.editors.EditDocument">
-      <parameter name="sourceUri" value="cocoon:/request2document"/>
+      <parameter name="sourceUri" value="cocoon://modules/editors/stream.xml"/>
     </component-instance>
   </xconf>

Modified: lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/EditDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/EditDocument.java?view=diff&rev=495605&r1=495604&r2=495605
==============================================================================
--- lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/EditDocument.java (original)
+++ lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/EditDocument.java Fri Jan 12 07:25:11 2007
@@ -21,10 +21,15 @@
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.cms.linking.LinkConverter;
+import org.apache.lenya.cms.publication.Document;
+import org.apache.lenya.cms.publication.ResourceType;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.usecase.DocumentUsecase;
 import org.apache.lenya.cms.usecase.UsecaseException;
+import org.apache.lenya.cms.usecase.xml.UsecaseErrorHandler;
 import org.apache.lenya.cms.workflow.WorkflowUtil;
+import org.apache.lenya.xml.Schema;
+import org.apache.lenya.xml.ValidationUtil;
 
 /**
  * Usecase to edit documents.
@@ -43,29 +48,24 @@
      */
     protected void doExecute() throws Exception {
         super.doExecute();
-        SourceResolver resolver = null;
-        Source source = null;
-        try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            SourceUtil.copy(resolver,
-                    getParameterAsString(SOURCE_URI),
-                    getSourceDocument().getSourceURI());
+
+        Document sourceDoc = getSourceDocument();
+
+        String sourceUri = getParameterAsString(SOURCE_URI);
+        org.w3c.dom.Document xmlDoc = SourceUtil.readDOM(sourceUri, this.manager);
+        
+        ResourceType resourceType = sourceDoc.getResourceType();
+        Schema schema = resourceType.getSchema();
+        ValidationUtil.validate(this.manager, xmlDoc, schema, new UsecaseErrorHandler(this));
+
+        if (!hasErrors()) {
+            SourceUtil.writeDOM(xmlDoc, sourceDoc.getSourceURI(), this.manager);
             
             LinkConverter converter = new LinkConverter(this.manager, getLogger());
             converter.convertUrlsToUuids(getSourceDocument());
 
-            WorkflowUtil.invoke(this.manager,
-                    getSession(),
-                    getLogger(),
-                    getSourceDocument(),
+            WorkflowUtil.invoke(this.manager, getSession(), getLogger(), getSourceDocument(),
                     "edit");
-        } finally {
-            if (resolver != null) {
-                if (source != null) {
-                    resolver.release(source);
-                }
-                this.manager.release(resolver);
-            }
         }
     }
 
@@ -73,11 +73,6 @@
      * @see org.apache.lenya.cms.usecase.AbstractUsecase#getNodesToLock()
      */
     protected Node[] getNodesToLock() throws UsecaseException {
-        if (getLogger().isDebugEnabled()) {
-            getLogger().debug("EditDocument::getObjectsToLock() called on source document ["
-                    + getSourceDocument().getId() + "]");
-        }
-
         Node[] objects = { getSourceDocument().getRepositoryNode() };
         return objects;
     }

Added: lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/SaveDocument.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/SaveDocument.java?view=auto&rev=495605
==============================================================================
--- lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/SaveDocument.java (added)
+++ lenya/trunk/src/modules/editors/java/src/org/apache/lenya/cms/editors/SaveDocument.java Fri Jan 12 07:25:11 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.editors;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.lenya.cms.usecase.DocumentUsecase;
+import org.apache.lenya.cms.usecase.UsecaseInvoker;
+import org.apache.lenya.cms.usecase.UsecaseMessage;
+import org.apache.lenya.util.Assert;
+
+/**
+ * <p>
+ * This usecase saves the document from the request stream
+ * <strong>before</strong> the view is displayed.
+ * That's kind of a hack, since it violates the standard usecase principle,
+ * but it is very convenient because you can save and re-load the document
+ * without a redirect.
+ * </p>
+ * 
+ * @version $Id: EditDocument.java 495324 2007-01-11 18:44:04Z andreas $
+ */
+public class SaveDocument extends DocumentUsecase {
+
+    protected void doCheckPreconditions() throws Exception {
+        super.doCheckPreconditions();
+
+        String usecase = getParameterAsString("usecaseName");
+        Assert.notNull("usecase", usecase);
+
+        UsecaseInvoker invoker = null;
+        try {
+            invoker = (UsecaseInvoker) this.manager.lookup(UsecaseInvoker.ROLE);
+            Map params = new HashMap();
+            params.put(EditDocument.SOURCE_URI, getParameter(EditDocument.SOURCE_URI));
+            invoker.invoke(getSourceURL(), usecase, params);
+
+            if (invoker.getResult() != UsecaseInvoker.SUCCESS) {
+                List messages = invoker.getErrorMessages();
+                for (Iterator i = messages.iterator(); i.hasNext();) {
+                    UsecaseMessage message = (UsecaseMessage) i.next();
+                    addErrorMessage(message.getMessage(), message.getParameters());
+                }
+            }
+        } finally {
+            if (invoker == null) {
+                this.manager.release(invoker);
+            }
+        }
+
+    }
+
+}

Modified: lenya/trunk/src/modules/editors/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/editors/sitemap.xmap?view=diff&rev=495605&r1=495604&r2=495605
==============================================================================
--- lenya/trunk/src/modules/editors/sitemap.xmap (original)
+++ lenya/trunk/src/modules/editors/sitemap.xmap Fri Jan 12 07:25:11 2007
@@ -71,6 +71,15 @@
         <map:serialize type="xml"/>
       </map:match>
       
+      <map:match pattern="stream.xml">
+        <map:generate type="stream"/>
+        <map:serialize type="xml"/>
+      </map:match>
+      
+      <map:match pattern="**">
+        <map:read src="lenya-document:/{page-envelope:document-uuid}"/>
+      </map:match>
+      
     </map:pipeline>
     
   </map:pipelines>

Added: lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkin.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkin.xconf?view=auto&rev=495605
==============================================================================
--- lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkin.xconf (added)
+++ lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkin.xconf Fri Jan 12 07:25:11 2007
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: usecases-workflow-deactivate.xconf 348547 2005-11-23 20:13:01Z chestnut $ -->
+<!--
+    This file defines the publication specific use-cases
+-->
+
+  <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'neutron.checkin']">
+    <component-instance name="neutron.checkin" logger="lenya.neutron"
+      class="org.apache.lenya.cms.editors.SaveDocument">
+      <parameter name="sourceUri" value="cocoon://modules/editors/stream.xml"/>
+      <parameter name="usecaseName" value="editors.publicationEdit"/>
+      <view uri="cocoon://modules/neutron/load.xml"/>
+    </component-instance>
+  </xconf>

Added: lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkout.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkout.xconf?view=auto&rev=495605
==============================================================================
--- lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkout.xconf (added)
+++ lenya/trunk/src/modules/neutron/config/cocoon-xconf/usecase-checkout.xconf Fri Jan 12 07:25:11 2007
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+
+<!-- $Id: usecases-workflow-deactivate.xconf 348547 2005-11-23 20:13:01Z chestnut $ -->
+<!--
+    This file defines the publication specific use-cases
+-->
+
+  <xconf xpath="/cocoon/usecases" unless="/cocoon/usecases/component-instance[@name = 'neutron.checkout']">
+    <component-instance name="neutron.checkout" logger="lenya.neutron"
+      class="org.apache.lenya.cms.usecase.DummyUsecase">
+      <view uri="cocoon://modules/neutron/load.xml"/>
+    </component-instance>
+  </xconf>

Modified: lenya/trunk/src/modules/neutron/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/sitemap.xmap?view=diff&rev=495605&r1=495604&r2=495605
==============================================================================
--- lenya/trunk/src/modules/neutron/sitemap.xmap (original)
+++ lenya/trunk/src/modules/neutron/sitemap.xmap Fri Jan 12 07:25:11 2007
@@ -38,95 +38,34 @@
   
     <map:pipeline>
         
-      <map:match pattern="open" type="step">
-        <map:select type="resource-exists">
-        <map:parameter name="prefix" value="lenyadoc:/"/>
-          <map:when test="{page-envelope:document-language}/{page-envelope:document-id}">
-            <map:read src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
+      <map:match pattern="load.xml">
+        <map:select type="parameter">
+          <map:parameter name="parameter-selector-test" value="{flow-attr:count(usecase/errorMessages)}"/>
+          <map:when test="0.0">
+            <map:read src="lenya-document:{page-envelope:document-uuid}"/>
           </map:when>
           <map:otherwise>
             <map:generate src="context://lenya/content/util/empty.xml"/>
-            <map:serialize type="xml" status-code="412"/>
+            <map:serialize type="xml" status-code="500"/>
           </map:otherwise>
         </map:select>
       </map:match>
       
-      <map:match pattern="checkout" type="step">
+      <map:match pattern="checkout.xml">
         <map:select type="resource-exists">
-        <map:parameter name="prefix" value="lenyadoc:/"/>
-          <map:when test="{page-envelope:document-language}/{page-envelope:document-id}">
+          <map:when test="lenya-document:{page-envelope:document-uuid}">
             <map:act type="reserved-checkout">
               <!-- TODO: add info from RCML ... -->
               <map:generate src="checkout-exception.xml"/>
               <map:serialize type="xml" status-code="500"/>
             </map:act>
-            <map:read src="lenyadoc:/{page-envelope:document-language}/{page-envelope:document-id}"/>
+            <map:read src="lenya-document:{page-envelope:document-uuid}"/>
           </map:when>
           <map:otherwise>
             <map:generate src="context://lenya/content/util/empty.xml"/>
             <map:serialize type="xml" status-code="412"/>
           </map:otherwise>
         </map:select>
-      </map:match>
-      
-      <map:match pattern="save" type="step">
-        <!-- test if the document is checked out -->
-        <map:act type="reserved-checkout-test">
-          <map:generate src="checkout-exception.xml"/>
-          <map:serialize type="xml" status-code="500"/>
-        </map:act>
-        <map:generate type="stream"/>
-        <map:transform src="fallback://lenya/modules/neutron/xslt/addSourceTags.xsl">
-          <map:parameter name="source" value="context://lenya/pubs/{page-envelope:publication-id}/content/{page-envelope:area}/{page-envelope:document-path}"/>
-        </map:transform>
-        <map:transform type="write-source">
-          <map:parameter name="serializer" value="xml"/>
-        </map:transform>
-        <map:serialize type="xml"/>
-      </map:match>
-        
-      <map:match pattern="checkin" type="step">
-        <!-- test if the document is checked out -->
-        <map:act type="reserved-checkout-test">
-          <map:generate src="checkout-exception.xml"/>
-          <map:serialize type="xml" status-code="500"/>
-        </map:act>
-        <map:generate type="stream"/>
-        <map:transform src="fallback://lenya/modules/neutron/xslt/addSourceTags.xsl">
-          <map:parameter name="source" value="context://lenya/pubs/{page-envelope:publication-id}/content/{page-envelope:area}/{page-envelope:document-path}"/>
-        </map:transform>
-        <map:transform type="write-source">
-          <map:parameter name="serializer" value="xml"/>
-        </map:transform>
-        <map:act type="reserved-checkin">
-          <map:generate src="checkin-exception.xml"/>
-          <map:serialize type="xml"  status-code="500"/>
-        </map:act>
-        <map:serialize type="xml"/>
-      </map:match>
-      
-      <map:match pattern="lock" type="step">
-        <map:select type="resource-exists">
-        <map:parameter name="prefix" value="lenyadoc:/"/>
-          <map:when test="{page-envelope:document-language}/{page-envelope:document-id}">
-            <map:act type="reserved-checkout">
-              <!-- TODO: add info from RCML ... -->
-              <map:generate src="checkout-exception.xml"/>
-              <map:serialize type="xml" status-code="500"/>
-            </map:act>
-          </map:when>
-          <map:otherwise>
-            <map:generate src="context://lenya/content/util/empty.xml"/>
-            <map:serialize type="xml" status-code="412"/>
-          </map:otherwise>
-        </map:select>
-      </map:match>
-      
-      <map:match pattern="unlock" type="step">
-        <map:act type="reserved-checkin">
-          <map:generate src="checkin-exception.xml"/>
-          <map:serialize type="xml"  status-code="500"/>
-        </map:act>
       </map:match>
       
     </map:pipeline>

Modified: lenya/trunk/src/modules/neutron/xslt/introspection.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/neutron/xslt/introspection.xsl?view=diff&rev=495605&r1=495604&r2=495605
==============================================================================
--- lenya/trunk/src/modules/neutron/xslt/introspection.xsl (original)
+++ lenya/trunk/src/modules/neutron/xslt/introspection.xsl Fri Jan 12 07:25:11 2007
@@ -34,21 +34,22 @@
 <!--
     <edit mime-type="application/xml" name="Body Content">
 -->
-<!-- TODO: In order to get the WYSIWYG view one needs to change the mime-type to xhtml+xml, but somehow this causes problems re saving ... See missing mime-type within cocoon_2_1_x/src/java/org/apache/cocoon/generation/StreamGenerator.java -->
-    <edit mime-type="application/xhtml+xml" name="Body Content">
 
-      <!--<open url="{$context}/{$publication}/authoring/{$page-id}.xml?lenya.module=neutron&amp;lenya.step=open" method="GET"/>-->
+    <!--
+    TODO: In order to get the WYSIWYG view one needs to change the mime-type
+    to xhtml+xml, but somehow this causes problems re saving ...
+    See missing mime-type within
+    cocoon_2_1_x/src/java/org/apache/cocoon/generation/StreamGenerator.java
+    -->
+    <edit mime-type="application/xhtml+xml" name="Body Content">
 
-      <checkout url="{$context}/{$publication}/authoring/{$page-id}.xml?lenya.module=neutron&amp;lenya.step=checkout" method="GET"/>
+      <checkout url="{$context}/{$publication}/authoring/{$page-id}.xml?lenya.usecase=neutron.checkout" method="GET"/>
 
 <!-- Save without releasing the lock, e.g. for "global" temporary saving -->
 <!--
       <save url="{$context}/{$publication}/authoring/{$page-id}.xml?lenya.module=neutron&amp;lenya.step=save" method="PUT"/>
 -->
-      
-      <checkin url="{$context}/{$publication}/authoring/{$page-id}.xml?lenya.module=neutron&amp;lenya.step=checkin" method="PUT"/>
-
-
+      <checkin url="{$context}/{$publication}/authoring/{$page-id}.xml?lenya.usecase=neutron.checkin" method="PUT"/>
 
 <!--
       <schemas>

Modified: lenya/trunk/src/modules/webdav/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/webdav/sitemap.xmap?view=diff&rev=495605&r1=495604&r2=495605
==============================================================================
--- lenya/trunk/src/modules/webdav/sitemap.xmap (original)
+++ lenya/trunk/src/modules/webdav/sitemap.xmap Fri Jan 12 07:25:11 2007
@@ -142,7 +142,13 @@
           <map:parameter name="requestURI" value="{request:requestURI}" />
         </map:call>
       </map:match>
-
+      <map:match pattern="*/authoring/**">
+        <map:call function="selectMethod">
+          <map:parameter name="page" value="{1}"/>
+          <map:parameter name="requestURI" value="{request:requestURI}" />
+        </map:call>
+      </map:match>
+      
 
       <map:match pattern="{page-envelope:publication-id}">
         <map:call function="selectMethod">

Modified: lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml?view=diff&rev=495605&r1=495604&r2=495605
==============================================================================
--- lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml (original)
+++ lenya/trunk/src/pubs/default/config/ac/usecase-policies.xml Fri Jan 12 07:25:11 2007
@@ -355,5 +355,11 @@
     <role id="edit" method="grant"/>
     <role id="review" method="grant"/>
   </usecase>
+  <usecase id="neutron.checkout">
+    <role id="edit" method="grant"/>
+  </usecase>
+  <usecase id="neutron.checkin">
+    <role id="edit" method="grant"/>
+  </usecase>
 </usecases>
     



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