You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ro...@apache.org on 2004/09/11 21:07:40 UTC

svn commit: rev 45911 - in incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya: pubs/default usecases usecases/kupu

Author: roku
Date: Sat Sep 11 12:07:39 2004
New Revision: 45911

Added:
   incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecases/edit-document.js
Modified:
   incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/usecase-bxeng.xmap
   incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecases/kupu/usecase-kupu.js
   incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecases/kupu/usecase-kupu.xmap
Log:
Fix for bug "save+exit in bxe and kupu takes forever..."

Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/usecase-bxeng.xmap
==============================================================================
--- incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/usecase-bxeng.xmap	(original)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/pubs/default/usecase-bxeng.xmap	Sat Sep 11 12:07:39 2004
@@ -15,7 +15,7 @@
   limitations under the License.
 -->
 
-<!-- $Id: usecase-bxeng.xmap,v 1.18 2004/07/01 13:02:31 gregor Exp $ -->
+<!-- $Id$ -->
 
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
   
@@ -79,13 +79,24 @@
     
     
   </map:resources>
-
+  <!-- =========================== Flow ===================================== -->
+  <map:flow language="javascript">
+    <map:script src="../../usecases/edit-document.js"/>
+  </map:flow>
 	<!-- =========================== Pipelines ================================ -->
 	
 	<map:pipelines>
 	  
     <map:pipeline type="noncaching">
       
+      <map:match pattern="request2document">
+        <map:generate type="stream"/>
+        <map:transform src="../../xslt/bxeng/change-object-path-back.xsl">
+          <map:parameter name="documentid" value="{page-envelope:document-id}"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+      
       <map:match type="usecase" pattern="bxeng">
         
       <map:match type="step" pattern="open">
@@ -238,23 +249,12 @@
         	  <map:transform src="../../xslt/rc/rco-exception.xsl"/>
 	          <map:call resource="style-cms-page"/>
         	</map:act>
-            <map:generate type="stream"/>
-            <map:transform src="../../xslt/authoring/edit/addSourceTags.xsl">
-              <map:parameter name="source" value="content/{page-envelope:area}/{page-envelope:document-path}"/>
-            </map:transform>
-            <map:transform src="../../xslt/bxeng/change-object-path-back.xsl">
-              <map:parameter name="documentid" value="{page-envelope:document-id}"/>
-            </map:transform>
-            <map:transform type="write-source"/>
-            <map:act type="workflow">
-              <map:parameter name="area" value="{page-envelope:area}"/>
-              <map:parameter name="document-id" value="{page-envelope:document-id}"/>
-              <map:parameter name="language" value="{page-envelope:document-language}"/>
-              <map:parameter name="event" value="edit"/>
-            </map:act>
-            <map:serialize type="xml" status-code="204"/>
-          </map:when>
           
+          <map:call function="editDocument">
+            <map:parameter name="sourceUri" value="cocoon:/request2document"/>
+          </map:call>
+          </map:when>
+
           <map:otherwise> <!-- GET -->
             <map:generate src="content/authoring/{page-envelope:document-path}"/>
             <map:transform src="../../xslt/bxeng/change-object-path.xsl">

Added: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecases/edit-document.js
==============================================================================
--- (empty file)
+++ incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecases/edit-document.js	Sat Sep 11 12:07:39 2004
@@ -0,0 +1,64 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed 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.
+ *
+ */
+
+importClass(Packages.org.apache.lenya.cms.cocoon.flow.FlowHelper);
+importClass(Packages.org.apache.excalibur.source.SourceResolver);
+importClass(Packages.org.apache.lenya.cms.cocoon.source.SourceUtil);
+
+/**
+ * Provides general flow functions for document editing.
+ * @version $Id$
+ */
+
+/**
+ * Saves a Source to the document in the current PageEnvelope.
+ * TODO: Use nobby's new usecase fw in 1.4 branch
+ * @param sourceUri An URI of a Source providing the edited document data
+ * @param useBuffer If "true", the source Source is read into a buffer before it is written to its final destination.
+ * @param workflowEvent Name of the workflow event to trigger. Default is "edit".
+ * @param noWorkflow If true, no workflow event will be triggered.
+ * @param status Default int value is 204. Used to set the response status.
+ * @param noStatus If true, then no response status will be set.     
+ */
+function editDocument() {
+    try {
+        var flowHelper = new FlowHelper();
+        var resolver = cocoon.getComponent(SourceResolver.ROLE);
+        var dstUri = flowHelper.getDocumentHelper(cocoon).getSourceUri(flowHelper.getPageEnvelope(cocoon).getDocument());
+        
+        SourceUtil.copy(resolver, cocoon.parameters["sourceUri"], dstUri, _getParameter("useBuffer", "false") == "true");
+
+        if(_getParameter("noWorkflow", "false") == "false")
+            flowHelper.triggerWorkflow(cocoon, _getParameter("workflowEvent", "edit"));
+
+        if(_getParameter("noStatus", "false") == "false")
+            cocoon.sendStatus(_getParameter("status", 204));
+        
+    } catch (exception) {
+        cocoon.log.error("Can not edit doucment.", exception);
+    } finally {
+        if(resolver != null)
+            cocoon.releaseComponent(resolver);
+    }
+}
+
+function _getParameter(name, defaultValue) {
+    if(cocoon.parameters[name])
+        return cocoon.parameters[name];
+    else
+        return defaultValue;
+}

Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecases/kupu/usecase-kupu.js
==============================================================================
Binary files. No diff available.

Modified: incubator/lenya/branches/BRANCH_1_2_X/src/webapp/lenya/usecases/kupu/usecase-kupu.xmap
==============================================================================
Binary files. No diff available.

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