You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by ch...@apache.org on 2005/11/18 16:11:34 UTC

svn commit: r345495 - in /lenya/trunk/src/webapp/lenya: pubs/default/usecase-bxe.xmap usecases/bxe/bxe.js

Author: chestnut
Date: Fri Nov 18 07:11:30 2005
New Revision: 345495

URL: http://svn.apache.org/viewcvs?rev=345495&view=rev
Log:
replaces the SourceWritingTransformer with a flow approach that uses
the processPipelineTo() method of the cocoon flow object. When exiting the flow
a plain status code is sent back to the browser.

Thanks to a patch by Felix Röthenbacher

Added:
    lenya/trunk/src/webapp/lenya/usecases/bxe/bxe.js   (with props)
Modified:
    lenya/trunk/src/webapp/lenya/pubs/default/usecase-bxe.xmap

Modified: lenya/trunk/src/webapp/lenya/pubs/default/usecase-bxe.xmap
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/pubs/default/usecase-bxe.xmap?rev=345495&r1=345494&r2=345495&view=diff
==============================================================================
--- lenya/trunk/src/webapp/lenya/pubs/default/usecase-bxe.xmap (original)
+++ lenya/trunk/src/webapp/lenya/pubs/default/usecase-bxe.xmap Fri Nov 18 07:11:30 2005
@@ -56,6 +56,7 @@
   <!-- =========================== Flow ===================================== -->
   <map:flow language="javascript">
     <map:script src="fallback://lenya/usecases/edit-document.js"/>
+    <map:script src="fallback://lenya/usecases/bxe/bxe.js"/>
   </map:flow>
 	<!-- =========================== Pipelines ================================ -->
 	
@@ -161,27 +162,33 @@
 	    +-->
 
         <map:match type="step" pattern="config">
-          <map:generate src="fallback://lenya/resources/misc/bxe/inc/config.xml"/>
-          <map:transform src="fallback://lenya/xslt/bxe/config-xml.xsl">
+          <map:select type="resource-exists">
+            <map:when test="fallback://lenya/modules/{page-envelope:document-type}/config/bxe.xml">
+              <map:generate src="fallback://lenya/modules/{page-envelope:document-type}/config/bxe.xml"/>
+            </map:when>
+            <map:otherwise>
+              <map:generate src="fallback://lenya/resources/misc/bxe/inc/config.xml"/>
+            </map:otherwise>
+          </map:select>
 
+          <map:transform src="fallback://lenya/xslt/bxe/config-xml.xsl">
             <!-- Parameter BX_xmlfile:
                  defines the Lenya URL with which BXE interacts, to
                  1. get the document contents (by issuing a GET to this URL),
                  2. save the changed contents (by issuing a PUT to this URL)
               -->
             <map:parameter name="BX_xmlfile" value="{request:requestURI}?lenya.usecase=bxe&amp;lenya.step=xml"/>
-
             <map:parameter name="defaultlanguage" value="{page-envelope:default-language}"/>
-            
-  <!--      Instead of an xsl we use the xhtml file to provide the basic layout
+          
+            <!-- Instead of an xsl we use the xhtml file to provide the basic layout
             <map:parameter name="BX_xslfile" value="{2}.xsl"/>
-  -->
+            -->
             <map:parameter name="BX_xhtmlfile" value="{../2}.bxe.html?rendertype=edit"/>
             <map:parameter name="BX_validationfile" value="{request:contextPath}/{page-envelope:publication-id}/{page-envelope:area}/schemas/{page-envelope:document-type}.rng"/>
             <map:parameter name="css" value="{request:contextPath}/{page-envelope:publication-id}/{page-envelope:area}/css/{page-envelope:document-type}-bxe.css"/>
-  <!--       The document is checked in when we exit from bx (in case of save&exit and in case of exit), so we use the usecase
-             for the checkin while we redirect to the document
-  -->
+            <!-- The document is checked in when we exit from bx (in case of save&exit and in case of exit), so we use the usecase
+                 for the checkin while we redirect to the document
+              -->
             <map:parameter name="BX_exitdestination" value="{request:requestURI}?lenya.usecase=edit.bxe&amp;lenya.continuation={request-param:lenya.continuation}&amp;submit=Submit"/>
             <map:parameter name="contextmenufile" value="fallback://lenya/resources/misc/bxe/contextmenu.xml"/>
           </map:transform>
@@ -209,16 +216,9 @@
              or in the change-object-path-back.xsl stylesheet.
            -->
           <map:when test="PUT">
-            <map:generate type="stream"/>
-            <map:transform src="fallback://lenya/xslt/bxe/change-object-path-back.xsl">
-              <map:parameter name="documentid" value="{page-envelope:document-id}"/>
-            </map:transform>
-            <map:transform src="fallback://lenya/usecases/edit/bxe/addSourceTags.xsl">
+            <map:call function="saveXML">
               <map:parameter name="source" value="context://lenya/pubs/{page-envelope:publication-id}/work/bxe/content/{page-envelope:area}/{page-envelope:document-path}.tmp"/>
-            </map:transform>
-            <map:transform type="write-source"/>
-            <map:transform src="fallback://lenya/usecases/edit/bxe/removeSourceTags.xsl"/>
-            <map:serialize type="xml" status-code="204"/>
+            </map:call>
           </map:when>
 
           <map:otherwise> <!-- GET -->
@@ -236,6 +236,14 @@
       </map:match> <!-- uri pattern -->
             
       </map:match> <!-- usecase -->
+
+      <map:match pattern="saveXML">
+        <map:generate type="stream"/>
+        <map:transform src="fallback://lenya/xslt/bxe/change-object-path-back.xsl">
+          <map:parameter name="documentid" value="{page-envelope:document-id}"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
     </map:pipeline>
     
 	</map:pipelines>

Added: lenya/trunk/src/webapp/lenya/usecases/bxe/bxe.js
URL: http://svn.apache.org/viewcvs/lenya/trunk/src/webapp/lenya/usecases/bxe/bxe.js?rev=345495&view=auto
==============================================================================
--- lenya/trunk/src/webapp/lenya/usecases/bxe/bxe.js (added)
+++ lenya/trunk/src/webapp/lenya/usecases/bxe/bxe.js Fri Nov 18 07:11:30 2005
@@ -0,0 +1,53 @@
+/*
+* 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.
+*/
+
+function saveXML() {
+  var resolver = null;
+  var source = null;
+  var outputStream = null;
+  try {
+    resolver = cocoon.getComponent(Packages.org.apache.excalibur.source.SourceResolver.ROLE);
+
+    var uri = cocoon.parameters.source;
+    source = resolver.resolveURI(uri);
+
+    outputStream = source.getOutputStream();
+
+    cocoon.processPipelineTo("saveXML", null, outputStream);
+
+  } catch (error) {
+    log.cocoon.error("Error saving document: " + error);
+    cocoon.sendStatus(500);
+  } finally {
+    if (source != null)
+      resolver.release(source);
+    if (outputStream != null) {
+      try {
+        outputStream.flush();
+        outputStream.close();
+      } catch (error) {
+        cocoon.log.error("Could not flush/close outputstream: " + error);
+        cocoon.sendStatus(500);
+      }
+    }
+    if (resolver != null)
+      cocoon.releaseComponent(resolver);
+
+    cocoon.sendStatus(204);
+    cocoon.exit();
+  }
+}
+

Propchange: lenya/trunk/src/webapp/lenya/usecases/bxe/bxe.js
------------------------------------------------------------------------------
    svn:eol-style = native



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