Return-Path: Delivered-To: apmail-cocoon-cvs-archive@www.apache.org Received: (qmail 27147 invoked from network); 27 Sep 2004 20:28:49 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 27 Sep 2004 20:28:49 -0000 Received: (qmail 88300 invoked by uid 500); 27 Sep 2004 20:28:48 -0000 Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 88249 invoked by uid 500); 27 Sep 2004 20:28:48 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 88237 invoked by uid 99); 27 Sep 2004 20:28:48 -0000 X-ASF-Spam-Status: No, hits=-10.0 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.28) with SMTP; Mon, 27 Sep 2004 13:28:47 -0700 Received: (qmail 27103 invoked by uid 65534); 27 Sep 2004 20:28:46 -0000 Date: 27 Sep 2004 20:28:46 -0000 Message-ID: <20040927202846.27099.qmail@minotaur.apache.org> From: vgritsenko@apache.org To: cvs@cocoon.apache.org Subject: svn commit: rev 47329 - cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/pipeline/impl X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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;