You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by vg...@apache.org on 2005/03/18 17:57:56 UTC
svn commit: r158099 - in cocoon/trunk/src/java/org/apache/cocoon/components:
pipeline/impl/AbstractCachingProcessingPipeline.java
source/impl/MultiSourceValidity.java
Author: vgritsenko
Date: Fri Mar 18 08:57:54 2005
New Revision: 158099
URL: http://svn.apache.org/viewcvs?view=rev&rev=158099
Log:
Use SourceValidity constants
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java?view=diff&r1=158098&r2=158099
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/pipeline/impl/AbstractCachingProcessingPipeline.java Fri Mar 18 08:57:54 2005
@@ -486,23 +486,23 @@
while (responseIsValid && i < fromCacheValidityObjects.length) {
boolean isValid = false;
- // BH check if validities[i] is null, may happen
- // if exception was thrown due to malformed content
+ // BH Check if validities[i] is null, may happen
+ // if exception was thrown due to malformed content
SourceValidity validity = fromCacheValidityObjects[i];
- int valid = validity != null ? validity.isValid() : -1;
- if (valid == 0) { // don't know if valid, make second test
-
- validity = this.getValidityForInternalPipeline(i);
+ int valid = validity == null ? SourceValidity.INVALID : validity.isValid();
+ if (valid == SourceValidity.UNKNOWN) {
+ // Don't know if valid, make second test
+ validity = getValidityForInternalPipeline(i);
if (validity != null) {
- valid = fromCacheValidityObjects[i].isValid( validity );
- if (valid == 0) {
+ valid = fromCacheValidityObjects[i].isValid(validity);
+ if (valid == SourceValidity.UNKNOWN) {
validity = null;
} else {
- isValid = (valid == 1);
+ isValid = (valid == SourceValidity.VALID);
}
}
} else {
- isValid = (valid == 1);
+ isValid = (valid == SourceValidity.VALID);
}
if (!isValid) {
@@ -559,7 +559,7 @@
this.cacheCompleteResponse = false;
} else {
// the entry is invalid, remove it
- this.cache.remove( this.fromCacheKey );
+ this.cache.remove(this.fromCacheKey);
}
// try a shorter key
@@ -676,7 +676,7 @@
SourceValidity[] validities = cachedObject.getValidityObjects();
if (validities == null || validities.length != 1) {
// to avoid getting here again and again, we delete it
- this.cache.remove( pcKey );
+ this.cache.remove(pcKey);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Cached response for '" + environment.getURI() +
"' using key: " + pcKey + " is invalid.");
@@ -684,24 +684,24 @@
this.cachedResponse = null;
} else {
SourceValidity cachedValidity = validities[0];
- int result = cachedValidity.isValid();
- boolean valid = false;
- if ( result == 0 ) {
+ boolean isValid = false;
+ int valid = cachedValidity.isValid();
+ if (valid == SourceValidity.UNKNOWN) {
// get reader validity and compare
- readerValidity = ((CacheableProcessingComponent)super.reader).getValidity();
+ readerValidity = ((CacheableProcessingComponent) super.reader).getValidity();
if (readerValidity != null) {
- result = cachedValidity.isValid(readerValidity);
- if ( result == 0 ) {
+ valid = cachedValidity.isValid(readerValidity);
+ if (valid == SourceValidity.UNKNOWN) {
readerValidity = null;
} else {
- valid = (result == 1);
+ isValid = (valid == SourceValidity.VALID);
}
}
} else {
- valid = (result > 0);
+ isValid = (valid == SourceValidity.VALID);
}
- if (valid) {
+ if (isValid) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("processReader: using valid cached content for '" +
environment.getURI() + "'.");
@@ -709,10 +709,10 @@
byte[] response = cachedObject.getResponse();
if (response.length > 0) {
usedCache = true;
- if ( cachedObject.getContentType() != null ) {
+ if (cachedObject.getContentType() != null) {
environment.setContentType(cachedObject.getContentType());
} else {
- this.setMimeTypeForReader(environment);
+ setMimeTypeForReader(environment);
}
outputStream = environment.getOutputStream(0);
environment.setContentLength(response.length);
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java?view=diff&r1=158098&r2=158099
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/source/impl/MultiSourceValidity.java Fri Mar 18 08:57:54 2005
@@ -1,5 +1,5 @@
/*
- * Copyright 1999-2004 The Apache Software Foundation.
+ * Copyright 1999-2005 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.
@@ -28,7 +28,7 @@
* <p>An aggregated {@link SourceValidity} for multiple sources.</p>
*
* @author <a href="http://www.apache.org/~sylvain">Sylvain Wallez</a>
- * @version CVS $Id$
+ * @version $Id$
*/
public class MultiSourceValidity extends AbstractAggregatedValidity
implements SourceValidity {
@@ -160,7 +160,7 @@
/* Check the validity status */
SourceValidity validity = (SourceValidity) validities.get(i);
- switch(validity.isValid()) {
+ switch (validity.isValid()) {
/* The current source is valid: just continue to next source */
case SourceValidity.VALID:
@@ -173,24 +173,30 @@
/* The source validity is not known: check with the new source */
case SourceValidity.UNKNOWN:
/* We have no resolver: definitely don't know */
- if (resolver == null) return 0;
+ if (resolver == null) {
+ return SourceValidity.UNKNOWN;
+ }
/* Check the new source by asking to the resolver */
Source newSrc = null;
int newValidity = SourceValidity.INVALID;
try {
- newSrc = resolver.resolveURI((String) uris.get(i));
+ newSrc = resolver.resolveURI((String) this.uris.get(i));
newValidity = validity.isValid(newSrc.getValidity());
} catch(IOException ioe) {
/* Swallow the IOException, but set the new validity */
newValidity = SourceValidity.INVALID;
} finally {
/* Make sure that the source is released */
- if (newSrc != null) resolver.release(newSrc);
+ if (newSrc != null) {
+ resolver.release(newSrc);
+ }
}
/* If the source is still valid, go to the next one */
- if (newValidity == SourceValidity.VALID) break;
+ if (newValidity == SourceValidity.VALID) {
+ break;
+ }
/* The source is not valid (or unknown), we invalidate the lot */
return SourceValidity.INVALID;
@@ -202,6 +208,6 @@
}
/* All items checked successfully */
- return 1;
+ return SourceValidity.VALID;
}
}