upayavira 2004/05/06 12:27:55
Modified: src/java/org/apache/cocoon/bean CocoonBean.java Target.java
src/java/org/apache/cocoon/components/pipeline/impl
CachingProcessingPipeline.java
src/java/org/apache/cocoon/components/treeprocessor/variables
PreparedVariableResolver.java
src/test/org/apache/cocoon/components/treeprocessor/variables
PreparedVariableResolverTestCase.java
PreparedVariableResolverTestCase.xtest
Log:
Fix for {baselink:} as found by Carsten.
Revision Changes Path
1.42 +18 -1
cocoon-2.1/src/java/org/apache/cocoon/bean/CocoonBean.java
Index: CocoonBean.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/bean/CocoonBean.java,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- CocoonBean.java 30 Apr 2004 12:55:55 -0000 1.41
+++ CocoonBean.java 6 May 2004 19:27:54 -0000 1.42
@@ -159,6 +159,7 @@
/**
* Adds a target for processing
*
+ * @deprecated in favour of addTarget(Target target)
* @param type Type of target - append, replace, insert.
* @param root
* @param sourceURI URI of the starting page
@@ -179,6 +180,9 @@
crawler.addTarget(target);
}
+ /**
+ * @deprecated in favour of addTarget(Target target)
+ */
public void addTarget(String type, String sourceURI, String destURI)
throws IllegalArgumentException {
Target target = new Target(type, sourceURI, destURI);
@@ -189,6 +193,9 @@
crawler.addTarget(target);
}
+ /**
+ * @deprecated in favour of addTarget(Target target)
+ */
public void addTarget(String sourceURI, String destURI)
throws IllegalArgumentException {
Target target = new Target(sourceURI, destURI);
@@ -199,6 +206,9 @@
crawler.addTarget(target);
}
+ /**
+ * @deprecated in favour of addTarget(Target target)
+ */
public void addTargets(List uris, String destURI)
throws IllegalArgumentException {
Iterator i = uris.iterator();
@@ -212,6 +222,9 @@
}
}
+ /**
+ * @deprecated in favour of addTarget(Target target)
+ */
public void addTarget(
String type,
String root,
@@ -237,6 +250,10 @@
crawler.addTarget(target);
}
+ public void addTarget(Target target) {
+ crawler.addTarget(target);
+ }
+
public int getTargetCount() {
return crawler.getRemainingCount();
}
1.13 +2 -2 cocoon-2.1/src/java/org/apache/cocoon/bean/Target.java
Index: Target.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/bean/Target.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Target.java 5 Mar 2004 13:02:45 -0000 1.12
+++ Target.java 6 May 2004 19:27:54 -0000 1.13
@@ -426,4 +426,4 @@
public void setLogger(String string) {
logger = string;
}
-}
\ No newline at end of file
+}
1.5 +17 -1
cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java
Index: CachingProcessingPipeline.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/pipeline/impl/CachingProcessingPipeline.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CachingProcessingPipeline.java 5 Mar 2004 13:02:50 -0000 1.4
+++ CachingProcessingPipeline.java 6 May 2004 19:27:54 -0000 1.5
@@ -16,7 +16,9 @@
package org.apache.cocoon.components.pipeline.impl;
import org.apache.avalon.framework.component.ComponentException;
+import org.apache.cocoon.Constants;
import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.caching.CacheValidityToSourceValidity;
import org.apache.cocoon.caching.CachedResponse;
import org.apache.cocoon.caching.CachingOutputStream;
import org.apache.cocoon.caching.ComponentCacheKey;
@@ -27,10 +29,14 @@
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.xml.XMLConsumer;
import org.apache.cocoon.xml.XMLProducer;
+import org.apache.excalibur.source.SourceValidity;
import java.io.OutputStream;
import java.io.Serializable;
+import java.lang.reflect.Array;
+import java.util.Arrays;
import java.util.Iterator;
+import java.util.List;
/**
* The CachingProcessingPipeline
@@ -55,6 +61,16 @@
expiresObj);
this.cache.store(this.toCacheKey,
response);
+/* List links = (List)
environment.getObjectModel().get(Constants.LINK_COLLECTION_OBJECT);
+ if (links!=null) {
+ SourceValidity[] linkValidities = new
SourceValidity[this.toCacheSourceValidities.length+1];
+ System.arraycopy(this.toCacheSourceValidities, 0,
linkValidities, 0, this.toCacheSourceValidities.length);
+ for (int i=0; i<this.toCacheSourceValidities.length;i++)
{
+ linkValidities[i]=this.toCacheSourceValidities[i];
+ }
+
linkValidities[this.toCacheSourceValidities.length]=CacheValidityToSourceValidity.createValidity(null);
+ this.cache.store(linkValidities, new
CachedResponse(links.serialize()));
+ }*/
} else {
CachedResponse response = new
CachedResponse(this.toCacheSourceValidities,
(byte[])this.xmlSerializer.getSAXFragment(),
1.10 +12 -4
cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java
Index: PreparedVariableResolver.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolver.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- PreparedVariableResolver.java 14 Apr 2004 18:05:46 -0000 1.9
+++ PreparedVariableResolver.java 6 May 2004 19:27:55 -0000 1.10
@@ -60,7 +60,8 @@
private static Token COLON_TOKEN = new Token(COLON);
private static Token OPEN_TOKEN = new Token(OPEN);
private static Token CLOSE_TOKEN = new Token(CLOSE);
-
+ private static Token EMPTY_TOKEN = new Token(EXPR);
+
public PreparedVariableResolver(String expr, ComponentManager manager)
throws PatternException {
super(expr);
@@ -249,7 +250,10 @@
Token expr = (Token)stack.pop();
Token lastButOne = (Token)stack.pop();
Token result;
- if (lastButOne.hasType(COLON)) {
+ if (expr.hasType(COLON)) { // i.e. nothing was specified
after the colon
+ stack.pop(); // Pop the OPEN
+ result = processModule(lastButOne, EMPTY_TOKEN,
objectModel, context, mapStack, stackSize);
+ } else if (lastButOne.hasType(COLON)) {
Token module = (Token)stack.pop();
stack.pop(); // Pop the OPEN
result = processModule(module, expr, objectModel,
context, mapStack, stackSize);
@@ -392,7 +396,11 @@
private int type;
public Token(int type) {
- this.value = null;
+ if (type==EXPR) {
+ this.value="";
+ } else {
+ this.value = null;
+ }
this.type = type;
}
1.5 +11 -1
cocoon-2.1/src/test/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java
Index: PreparedVariableResolverTestCase.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/test/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PreparedVariableResolverTestCase.java 14 Apr 2004 09:39:45 -0000
1.4
+++ PreparedVariableResolverTestCase.java 6 May 2004 19:27:55 -0000
1.5
@@ -216,4 +216,14 @@
assertEquals("This is a {brace}", resolver.resolve(context,
getObjectModel()));
}
+ public void testModuleWithoutOption() throws PatternException {
+ String expr = "{baselink:}";
+ InvokeContext context = new InvokeContext(true);
+ context.enableLogging(new LogKitLogger(getLogger()));
+
+ Map sitemapElements = new HashMap();
+ context.pushMap("sitemap", sitemapElements);
+ PreparedVariableResolver resolver = new
PreparedVariableResolver(expr, manager);
+ assertEquals("", resolver.resolve(context, getObjectModel()));
+ }
}
1.2 +1 -0
cocoon-2.1/src/test/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.xtest
Index: PreparedVariableResolverTestCase.xtest
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/test/org/apache/cocoon/components/treeprocessor/variables/PreparedVariableResolverTestCase.xtest,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PreparedVariableResolverTestCase.xtest 2 Apr 2004 20:22:07 -0000
1.1
+++ PreparedVariableResolverTestCase.xtest 6 May 2004 19:27:55 -0000
1.2
@@ -49,6 +49,7 @@
<components>
<input-modules>
<component-instance
class="org.apache.cocoon.components.modules.input.RequestParameterModule"
logger="core.modules.input" name="request-param"/>
+ <component-instance
class="org.apache.cocoon.components.modules.input.BaseLinkModule"
logger="core.modules.input" name="baselink"/>
</input-modules>
</components>