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/08/27 23:00:53 UTC
cvs commit: cocoon-lenya/lib commons-io-1.0.jar
roku 2004/08/27 14:00:53
Modified: src/webapp/lenya/usecases/kupu usecase-kupu.js
usecase-kupu.xmap
src/java/org/apache/lenya/cms/cocoon/flow FlowHelper.java
Added: lib commons-io-1.0.jar
Log:
Fixed bug #27905 for Kupu (Save and Exit takes forever)
This also can fix the bug for bxe, but will need some usecase sitemap refactoring.
I would very appreciate to fix that for bxe too in 1.2.1
CHANGES in detail:
- Added method savePipelineToDocument to FlowHelper
- Refactored kupu usecase sitemap to save doc via js flow.
- Added coomons-io for faster output streams.
BTW: excalibur-io is deprecated !
Revision Changes Path
1.5 +20 -1 cocoon-lenya/src/webapp/lenya/usecases/kupu/usecase-kupu.js
Index: usecase-kupu.js
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/usecases/kupu/usecase-kupu.js,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- usecase-kupu.js 26 Aug 2004 23:09:11 -0000 1.4
+++ usecase-kupu.js 27 Aug 2004 21:00:53 -0000 1.5
@@ -8,10 +8,16 @@
importClass(Packages.org.apache.lenya.cms.publication.PublicationHelper);
importClass(Packages.org.apache.lenya.cms.publication.ResourcesManager);
+importClass(Packages.java.io.BufferedOutputStream);
+importClass(Packages.java.io.FileOutputStream);
+
+/**
+ * @version $Id$
+ */
+
/**
* Collects all link/url information from a publication's siteree.
* This information is used to generate xml for the Kupu (link) library drawer.
- * @version $Id$
*/
function sitetree_link_library() {
@@ -65,4 +71,17 @@
cocoon.sendPage(cocoon.parameters["template"], {"imageInfos" : imageInfos});
}
+/**
+ * Saves the edited document submitted by Kupu.
+ */
+function save() {
+ cocoon.log.debug("Starting to save Kupu doc.");
+ try {
+ new FlowHelper().savePipelineToDocument(cocoon, cocoon.parameters["template"]);
+ cocoon.response.setStatus(204); // Expected by Kupu upon successful save
+ } catch(e) {
+ cocoon.log.error("Error saving Kupu doc.", e);
+ cocoon.response.setStatus(500);// Send real error page? Kupu wo't display it anyway, but would be cleaner
+ }
+}
\ No newline at end of file
1.5 +17 -19 cocoon-lenya/src/webapp/lenya/usecases/kupu/usecase-kupu.xmap
Index: usecase-kupu.xmap
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/webapp/lenya/usecases/kupu/usecase-kupu.xmap,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- usecase-kupu.xmap 26 Aug 2004 22:12:32 -0000 1.4
+++ usecase-kupu.xmap 27 Aug 2004 21:00:53 -0000 1.5
@@ -60,6 +60,7 @@
</map:flow>
<!-- =========================== Pipelines ================================ -->
<map:pipelines>
+
<map:component-configurations>
<global-variables>
<!-- To access core resources -->
@@ -68,12 +69,14 @@
</global-variables>
</map:component-configurations>
+
<map:pipeline internal-only="true">
<map:match pattern="kupu-stream">
<map:generate type="stream"/>
<map:serialize type="xml"/>
</map:match>
+ <!-- Flow callbacks -->
<map:match pattern="sitetree_link_library_template">
<map:generate src="{fallback:resources/kupu/apache-lenya/kupu/imagedrawer/sitetree_link_library.xml.jx}" type="jx">
<map:parameter name="resource-icon-url" value="{page-envelope:context-prefix}/kupu/apache-lenya/kupu/images/right_arrow.png"/>
@@ -86,10 +89,19 @@
</map:generate>
<map:serialize type="xml"/>
</map:match>
- </map:pipeline>
+ <map:match pattern="request2document">
+ <map:aggregate element="edit-envelope">
+ <map:part element="edited" src="cocoon:/kupu-stream"/>
+ <map:part element="original"
+ src="{global:basedir}/pubs/{page-envelope:publication-id}/content/authoring/{page-envelope:document-path}"/>
+ </map:aggregate>
+ <map:transform src="{fallback:resources/kupu/apache-lenya/lenya/kupusave.xsl}"/>
+ <map:serialize type="xml"/>
+ </map:match>
+ </map:pipeline>
<!-- Usecase pipeline -->
- <map:pipeline>
+ <map:pipeline>
<map:match pattern="kupu" type="usecase">
<map:match pattern="open" type="step">
<map:match pattern="*/authoring/**.html">
@@ -249,23 +261,9 @@
<map:call resource="style-cms-page"/>
</map:act>
- <!-- Merge changed dcoument sent by Kupu with orginial.
- I.e. the dc meta data needs to be preserved.
- -->
- <map:aggregate element="edit-envelope">
- <map:part element="edited" src="cocoon:/kupu-stream"/>
- <map:part element="original"
- src="{global:basedir}/pubs/{page-envelope:publication-id}/content/authoring/{page-envelope:document-path}"/>
- </map:aggregate>
- <map:transform src="{fallback:resources/kupu/apache-lenya/lenya/kupusave.xsl}"/>
- <!-- Save the document -->
- <map:transform src="{global:basedir}/xslt/authoring/edit/addSourceTags.xsl">
- <map:parameter name="source"
- value="{global:basedir}/pubs/{page-envelope:publication-id}/content/authoring/{page-envelope:document-path}"/>
- </map:transform>
- <map:transform type="write-source"/>
-
- <map:serialize type="xml" status-code="204"/>
+ <map:call function="save">
+ <map:parameter name="template" value="request2document"/>
+ </map:call>
</map:when>
</map:select>
</map:match>
1.10 +22 -1 cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java
Index: FlowHelper.java
===================================================================
RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/cms/cocoon/flow/FlowHelper.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- FlowHelper.java 22 Aug 2004 21:51:14 -0000 1.9
+++ FlowHelper.java 27 Aug 2004 21:00:53 -0000 1.10
@@ -19,6 +19,7 @@
package org.apache.lenya.cms.cocoon.flow;
+import java.io.FileOutputStream;
import java.util.Enumeration;
import java.util.Map;
@@ -26,6 +27,8 @@
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.environment.Session;
+import org.apache.cocoon.util.BufferedOutputStream;
+import org.apache.commons.io.output.ByteArrayOutputStream;
import org.apache.lenya.ac.AccessControlException;
import org.apache.lenya.ac.Identity;
import org.apache.lenya.ac.Machine;
@@ -173,4 +176,22 @@
return value;
}
+ public void savePipelineToDocument(FOM_Cocoon cocoon, String pipeline)
+ throws Exception {
+ final ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ BufferedOutputStream docOutputStream = null;
+ try {
+ cocoon.jsFunction_processPipelineTo(pipeline, null, bos);
+ docOutputStream = new BufferedOutputStream(new FileOutputStream(getPageEnvelope(cocoon).getDocument().getFile()));
+ docOutputStream.write(bos.toByteArray());
+ } finally {
+ if(docOutputStream != null) {
+ docOutputStream.flush();
+ docOutputStream.close();
+ }
+ if(bos != null) {
+ bos.close(); // Not needed for ByteArrayOutpuStream, but it cleaner this way.
+ }
+ }
+ }
}
1.1 cocoon-lenya/lib/commons-io-1.0.jar
<<Binary file>>
---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org