cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: rev 47329 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl
Date Mon, 27 Sep 2004 20:28:46 GMT
Author: vgritsenko
Date: Mon Sep 27 13:28:45 2004
New Revision: 47329

Modified:
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
   cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
Log:
Fix SAXException: XMLSerializer expects byte[], not CachedResponse


Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
Mon Sep 27 13:28:45 2004
@@ -171,21 +171,23 @@
     throws ProcessingException {
         if (this.toCacheKey == null && this.cachedResponse == null) {
             return super.processXMLPipeline(environment);
+        }
 
-        } else if (this.cachedResponse != null
-                && this.completeResponseIsCached) {
+        if (this.cachedResponse != null && this.completeResponseIsCached) {
 
             // Allow for 304 (not modified) responses in dynamic content
-            if (super.checkIfModified(environment, this.cachedLastModified)) {
+            if (checkIfModified(environment, this.cachedLastModified)) {
                 return true;
             }
 
-            // set mime-type
-            if ( this.cachedResponse.getContentType() != null ) {
+            // Set mime-type
+            if (this.cachedResponse.getContentType() != null) {
                 environment.setContentType(this.cachedResponse.getContentType());
             } else {
-                this.setMimeTypeForSerializer(environment);
+                setMimeTypeForSerializer(environment);
             }
+
+            // Write response out
             try {
                 final OutputStream outputStream = environment.getOutputStream(0);
                 final byte[] content = this.cachedResponse.getResponse();
@@ -197,7 +199,7 @@
                 handleException(e);
             }
         } else {
-            this.setMimeTypeForSerializer(environment);
+            setMimeTypeForSerializer(environment);
             if (getLogger().isDebugEnabled() && this.toCacheKey != null) {
                 getLogger().debug("processXMLPipeline: caching content for further" +
                                   " requests of '" + environment.getURI() +
@@ -208,49 +210,51 @@
                 OutputStream os = null;
 
                 if (this.cacheCompleteResponse && this.toCacheKey != null) {
-                    os = new CachingOutputStream(environment.getOutputStream(
-                            this.outputBufferSize));
+                    os = new CachingOutputStream(environment.getOutputStream(this.outputBufferSize));
                 }
+
                 if (super.serializer != super.lastConsumer) {
                     if (os == null) {
                         os = environment.getOutputStream(this.outputBufferSize);
                     }
+
                     // internal processing
                     if (this.xmlDeserializer != null) {
-                        this.xmlDeserializer.deserialize(this.cachedResponse);
+                        this.xmlDeserializer.deserialize(this.cachedResponse.getResponse());
                     } else {
                         this.generator.generate();
                     }
+
                 } else {
                     if (this.serializer.shouldSetContentLength()) {
                         if (os == null) {
                             os = environment.getOutputStream(0);
                         }
-                        // set the output stream
-                        ByteArrayOutputStream baos =
-                            new ByteArrayOutputStream();
+
+                        // Set the output stream
+                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
                         this.serializer.setOutputStream(baos);
 
-                        // execute the pipeline:
-                        if ( this.xmlDeserializer != null ) {
-                            this.xmlDeserializer.deserialize(
-                                    this.cachedResponse);
+                        // Execute the pipeline
+                        if (this.xmlDeserializer != null) {
+                            this.xmlDeserializer.deserialize(this.cachedResponse.getResponse());
                         } else {
                             this.generator.generate();
                         }
+
                         environment.setContentLength(baos.size());
                         baos.writeTo(os);
                     } else {
                         if (os == null) {
-                            os = environment.getOutputStream(
-                                    this.outputBufferSize);
+                            os = environment.getOutputStream(this.outputBufferSize);
                         }
-                        // set the output stream
+
+                        // Set the output stream
                         this.serializer.setOutputStream(os);
-                        // execute the pipeline:
+
+                        // Execute the pipeline
                         if (this.xmlDeserializer != null) {
-                            this.xmlDeserializer.deserialize(
-                                    this.cachedResponse);
+                            this.xmlDeserializer.deserialize(this.cachedResponse.getResponse());
                         } else {
                             this.generator.generate();
                         }
@@ -646,8 +650,8 @@
      */
     protected void connectPipeline(Environment   environment)
     throws ProcessingException {
-        if ( this.toCacheKey == null && this.cachedResponse == null) {
-            super.connectPipeline( environment );
+        if (this.toCacheKey == null && this.cachedResponse == null) {
+            super.connectPipeline(environment);
             return;
         } else if (this.completeResponseIsCached) {
             // do nothing

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingPointProcessingPipeline.java
Mon Sep 27 13:28:45 2004
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -82,10 +82,10 @@
     /**
      * Set the generator.
      */
-    public void setGenerator (String role, String source, Parameters param, Parameters hintParam)

+    public void setGenerator (String role, String source, Parameters param, Parameters hintParam)
     throws ProcessingException {
         super.setGenerator(role, source, param, hintParam);
-        
+
         // check the hint param for a "caching-point" hint
         String pipelinehint = null;
         try {
@@ -128,7 +128,7 @@
                 getLogger().warn("caching-point hint Exception, pipeline-hint ignored: "
+ ex);
             }
         }
-	
+
         // add caching point flag
         // default value is false
         this.isCachePoint.add(new Boolean(this.nextIsCachePoint));
@@ -156,7 +156,7 @@
         }
         if (!this.autoCachingPoint) {
             return;
-        }   
+        }
 
         this.nextIsCachePoint = true;
         if (this.getLogger().isDebugEnabled()) {
@@ -265,8 +265,8 @@
                     this.xmlSerializer = (XMLSerializer)this.manager.lookup( XMLSerializer.ROLE
);
                     localXMLSerializer = this.xmlSerializer;
                 }
-                if ( this.cachedResponse == null ) {
 
+                if (this.cachedResponse == null) {
                     XMLProducer prev = super.generator;
                     XMLConsumer next;
 

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
Mon Sep 27 13:28:45 2004
@@ -1,12 +1,12 @@
 /*
  * 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.
@@ -47,7 +47,7 @@
     */
     protected void cacheResults(Environment environment, OutputStream os)  throws Exception
{
         if (this.toCacheKey != null) {
-            // See if there is an expires object for this resource.                
+            // See if there is an expires object for this resource.
             Long expiresObj = (Long) environment.getObjectModel().get(ObjectModelHelper.EXPIRES_OBJECT);
             if ( this.cacheCompleteResponse ) {
                 CachedResponse response = new CachedResponse(this.toCacheSourceValidities,
@@ -85,7 +85,8 @@
                     this.xmlSerializer = (XMLSerializer)this.manager.lookup( XMLSerializer.ROLE
);
                     localXMLSerializer = this.xmlSerializer;
                 }
-                if ( this.cachedResponse == null ) {
+
+                if (this.cachedResponse == null) {
                     XMLProducer prev = super.generator;
                     XMLConsumer next;
 

Mime
View raw message