cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ilgro...@apache.org
Subject svn commit: r1197931 - in /cocoon/cocoon3/trunk: cocoon-controller/src/main/java/org/apache/cocoon/controller/node/ cocoon-sample/src/main/resources/COB-INF/ cocoon-sample/src/main/resources/COB-INF/string-template/ cocoon-servlet/src/main/java/org/apa...
Date Sat, 05 Nov 2011 11:18:56 GMT
Author: ilgrosso
Date: Sat Nov  5 11:18:55 2011
New Revision: 1197931

URL: http://svn.apache.org/viewvc?rev=1197931&view=rev
Log:
Fixes issue COCOON3-79

Modified:
    cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/string-template/template.xml
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/ResponseHeaderCollector.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/Invocation.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/JexlLanguageInterpreter.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/LanguageInterpreter.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SettingsInterpreter.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SitemapLanguageInterpreter.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java

Modified: cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java
Sat Nov  5 11:18:55 2011
@@ -47,8 +47,8 @@ public class CallNode extends AbstractSi
     public InvocationResult invoke(Invocation invocation) {
         Map<String, Object> parameters = new HashMap<String, Object>();
         for (Entry<String, String> entry : this.getParameters().entrySet()) {
-            String resolvedValue = invocation.resolveParameter(entry.getValue());
-            parameters.put(entry.getKey(), resolvedValue);
+            parameters.put(entry.getKey(),
+                           invocation.resolveParameter(entry.getValue()));
         }
 
         parameters.put("baseUrl", invocation.resolve(""));

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/sitemap.xmap Sat Nov  5
11:18:55 2011
@@ -552,6 +552,7 @@
       <map:match wildcard="string-template/generator">
         <map:generate type="string-template" src="string-template/template.xml">
 	  <map:parameter name="parameter" value="A value"/>
+	  <map:parameter name="booleanParameter" value="{jexl:true}"/>
         </map:generate>
         <map:serialize/>
       </map:match>
@@ -559,6 +560,7 @@
         <map:generate src="string-template/template.xml"/>
         <map:transform type="string-template">
 	  <map:parameter name="parameter" value="Another value"/>
+	  <map:parameter name="booleanParameter" value="{jexl:false}"/>
         </map:transform>
         <map:serialize/>
       </map:match>

Modified: cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/string-template/template.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/string-template/template.xml?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/string-template/template.xml
(original)
+++ cocoon/cocoon3/trunk/cocoon-sample/src/main/resources/COB-INF/string-template/template.xml
Sat Nov  5 11:18:55 2011
@@ -24,5 +24,10 @@
   <body>
     <h3>StringTemplate demo</h3>
     <p>parameter=$parameter$</p>
+$if(booleanParameter)$
+<p>booleanParameter was TRUE</p>
+$else$
+<p>booleanParameter was FALSE</p>
+$endif$
   </body>
 </html>

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/ResponseHeaderCollector.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/ResponseHeaderCollector.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/ResponseHeaderCollector.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/collector/ResponseHeaderCollector.java
Sat Nov  5 11:18:55 2011
@@ -106,12 +106,14 @@ public class ResponseHeaderCollector {
     @Around("execution(* org.apache.cocoon.sitemap.node.SerializeNode.invoke(..)) &&
args(invocation)")
     public Object interceptInvoke(ProceedingJoinPoint proceedingJoinPoint, Invocation invocation)
throws Throwable {
         SerializeNode target = (SerializeNode) proceedingJoinPoint.getTarget();
-        String statusCode = invocation.resolveParameter(target.getParameters().get("status-code"));
+        Object statusCode = invocation.resolveParameter(target.getParameters().get("status-code"));
+        if (statusCode != null && !(statusCode instanceof String))
+                throw new IllegalArgumentException("Status code must resolve to String");
 
         InvocationResult invocationResult = (InvocationResult) proceedingJoinPoint.proceed();
         if (invocationResult.isContinued() && statusCode != null) {
             try {
-                setStatusCode(Integer.valueOf(statusCode));
+                setStatusCode(Integer.valueOf((String) statusCode));
             } catch (NumberFormatException nfe) {
                 throw new InvalidStatusCodeException("The status-code '" + statusCode + "
is not valid number.", nfe);
             }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/Invocation.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/Invocation.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/Invocation.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/Invocation.java
Sat Nov  5 11:18:55 2011
@@ -60,5 +60,5 @@ public interface Invocation {
 
     void popSitemapParameters();
 
-    String resolveParameter(final String parameter);
+    Object resolveParameter(final String parameter);
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/InvocationImpl.java
Sat Nov  5 11:18:55 2011
@@ -47,7 +47,7 @@ public class InvocationImpl implements I
      * Logger.
      */
     private static final Logger ERROR_LOG =
-            LoggerFactory.getLogger(InvocationImpl.class.getName() 
+            LoggerFactory.getLogger(InvocationImpl.class.getName()
             + "/handle-errors");
 
     private static final Pattern PARAMETER_PATTERN = Pattern.compile("\\{([a-zA-Z\\-]+):([^\\{]*)\\}");
@@ -69,7 +69,7 @@ public class InvocationImpl implements I
     private ObjectModel objectModel;
 
     private boolean hasFinisher;
-    
+
     @Autowired
     private Settings settings;
 
@@ -340,7 +340,7 @@ public class InvocationImpl implements I
                 }
             }
         }
-        
+
         this.objectModel.getCocoonObject().put("exception", cause);
         ParameterHelper.setThrowable(this.parameters, cause);
 
@@ -357,51 +357,58 @@ public class InvocationImpl implements I
      *
      * @see org.apache.cocoon.sitemap.Invocation#resolveParameter(java.lang.String)
      */
-    public String resolveParameter(final String parameter) {
+    public Object resolveParameter(final String parameter) {
         if (parameter == null) {
             return null;
         }
 
-        final StringBuilder result = new StringBuilder(parameter);
-        final Matcher matcher = PARAMETER_PATTERN.matcher(result);
+        Object resolved = parameter;
+        final StringBuilder sbResult = new StringBuilder(parameter);
+
+        final Matcher matcher = PARAMETER_PATTERN.matcher(sbResult);
+        final boolean wholeMatch = matcher.matches();
+        matcher.reset();
 
         while (matcher.find()) {
             final String language = matcher.group(1);
-            final LanguageInterpreter languageInterpreter = this.getLanguageInterpreter(language);
-            if (languageInterpreter == null) {
-                throw new UnsupportedExpressionLanguageException("Could not resolve parameter
'" + parameter
-                        + "'. The language '" + language + "' is not supported.");
+            final LanguageInterpreter interpreter =
+                    this.getLanguageInterpreter(language);
+            if (interpreter == null) {
+                throw new UnsupportedExpressionLanguageException(
+                        "Could not resolve parameter '" + parameter + "'. "
+                        + "The language '" + language + "' is not supported.");
             }
-
+            
             final String variable = matcher.group(2);
-            final String replacement = languageInterpreter.resolve(variable, this.objectModel);
+            resolved = interpreter.resolve(variable, this.objectModel);
+            if (resolved == null) {
+                throw new VariableNotFoundException("Variable {" + language
+                        + ":" + variable + "} not found or is null.");
+            }
 
-            if (replacement != null) {
-                result.replace(matcher.start(), matcher.end(), replacement);
-            } else {
-                throw new VariableNotFoundException("Variable {" + language + ":" + variable
-                        + "} not found or is null.");
+            if (!wholeMatch) {
+                sbResult.replace(matcher.start(), matcher.end(),
+                        resolved.toString());
+                matcher.reset();
             }
-            matcher.reset();
         }
 
-        return result.toString();
+        return wholeMatch ? resolved : sbResult.toString();
     }
 
     private Map<String, ? extends Object> resolveParameters(final Map<String, ?
extends Object> componentParameters) {
         final Map<String, Object> resolvedParameters = new HashMap<String, Object>();
 
-        for (Map.Entry <String, ? extends Object> entry : 
+        for (Map.Entry <String, ? extends Object> entry :
                 componentParameters.entrySet()) {
-            if (!(entry.getValue() instanceof String)) {
+
+            if (entry.getValue() instanceof String) {
+                resolvedParameters.put(entry.getKey(),
+                        this.resolveParameter((String) entry.getValue()));
+            } else {
                 // can only resolve strings
                 resolvedParameters.put(entry.getKey(), entry.getValue());
-                continue;
             }
-
-            final String resolvedParameter = 
-                    this.resolveParameter((String) entry.getValue());
-            resolvedParameters.put(entry.getKey(), resolvedParameter);
         }
 
         return resolvedParameters;

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/SitemapParametersStack.java
Sat Nov  5 11:18:55 2011
@@ -32,7 +32,7 @@ public class SitemapParametersStack {
 
     private Stack<Entry> entries = new Stack<Entry>();
 
-    public String getParameter(String parameterName) {
+    public Object getParameter(String parameterName) {
 
         Matcher absoluteParameterMatcher = ABSOLUTE_PARAMETER_PATTERN.matcher(parameterName);
         if (absoluteParameterMatcher.matches()) {
@@ -56,18 +56,13 @@ public class SitemapParametersStack {
         this.entries.push(new Entry(name, parameters));
     }
 
-    private String resolveAbsoluteParameter(String parameterName, Matcher absoluteParameterMatcher)
{
+    private Object resolveAbsoluteParameter(String parameterName, Matcher absoluteParameterMatcher)
{
         final String entryName = absoluteParameterMatcher.group(1);
         final String name = absoluteParameterMatcher.group(2);
 
         for (Entry entry : this.entries) {
             if (entryName.equals(entry.getName())) {
-                Object result = entry.getParameter(name);
-                if (result == null) {
-                    return null;
-                }
-
-                return result.toString();
+                return entry.getParameter(name);
             }
         }
 
@@ -75,15 +70,10 @@ public class SitemapParametersStack {
                 + "' could not be resolved. There was no entry for the name '" + entryName
+ "'");
     }
 
-    private String resolveRelativeParameter(Matcher relativeParameterMatcher) {
+    private Object resolveRelativeParameter(Matcher relativeParameterMatcher) {
         final String levelPrefix = relativeParameterMatcher.group(2);
-        final String name = relativeParameterMatcher.group(3);
-        final int level;
-        if (levelPrefix == null) {
-            level = 0;
-        } else {
-            level = levelPrefix.length() / RELATIVE_LOCATION_PREFIX.length();
-        }
+        final int level = levelPrefix == null
+                ? 0 : levelPrefix.length() / RELATIVE_LOCATION_PREFIX.length();
 
         final int index = this.entries.size() - level - 1;
         if (index < 0) {
@@ -92,13 +82,9 @@ public class SitemapParametersStack {
                     + level + " entries were requested.");
         }
 
-        Entry entry = this.entries.get(index);
-        Object result = entry.getParameter(name);
-        if (result == null) {
-            return null;
-        }
-
-        return result.toString();
+        final Entry entry = this.entries.get(index);
+        final String name = relativeParameterMatcher.group(3);
+        return entry.getParameter(name);
     }
 
     private class Entry {

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/JexlLanguageInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/JexlLanguageInterpreter.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/JexlLanguageInterpreter.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/JexlLanguageInterpreter.java
Sat Nov  5 11:18:55 2011
@@ -35,7 +35,7 @@ public class JexlLanguageInterpreter imp
             LoggerFactory.getLogger(JexlLanguageInterpreter.class);
 
     @Override
-    public String resolve(final String expression,
+    public Object resolve(final String expression,
             final ObjectModel objectModel) {
 
         final JexlEngine jexlEngine = new JexlEngine();
@@ -51,6 +51,6 @@ public class JexlLanguageInterpreter imp
             LOG.error("While evaluating '" + expression + "'", e);
         }
 
-        return result == null ? "" : result.toString();
+        return result == null ? "" : result;
     }
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/LanguageInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/LanguageInterpreter.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/LanguageInterpreter.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/LanguageInterpreter.java
Sat Nov  5 11:18:55 2011
@@ -20,5 +20,5 @@ import org.apache.cocoon.sitemap.objectm
 
 public interface LanguageInterpreter {
 
-    String resolve(String expression, ObjectModel objectModel);
+    Object resolve(String expression, ObjectModel objectModel);
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SettingsInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SettingsInterpreter.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SettingsInterpreter.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SettingsInterpreter.java
Sat Nov  5 11:18:55 2011
@@ -31,8 +31,8 @@ public class SettingsInterpreter impleme
     @Autowired
     private Settings settings;
 
-    public String resolve(String expression, ObjectModel objectModel) {
-        Object result = null;
+    public Object resolve(String expression, ObjectModel objectModel) {
+        String result = null;
 
         try {
             result = this.settings.getProperty(expression);
@@ -40,7 +40,6 @@ public class SettingsInterpreter impleme
             e.printStackTrace();
         }
 
-        return result != null ? result.toString() : "";
+        return result != null ? result : "";
     }
-
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SitemapLanguageInterpreter.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SitemapLanguageInterpreter.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SitemapLanguageInterpreter.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/expression/SitemapLanguageInterpreter.java
Sat Nov  5 11:18:55 2011
@@ -22,7 +22,7 @@ import org.apache.cocoon.sitemap.objectm
 
 public class SitemapLanguageInterpreter implements LanguageInterpreter {
 
-    public String resolve(String variable, ObjectModel objectModel) {
+    public Object resolve(String variable,ObjectModel objectModel) {
         return objectModel.getSitemapParameters().getParameter(variable);
     }
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java
Sat Nov  5 11:18:55 2011
@@ -212,4 +212,30 @@ public abstract class AbstractSitemapNod
 
         return result.toString();
     }
+    
+    protected InvocationResult invoke(final String src, final String type, 
+            final Invocation invocation) {
+        
+        final Map<String, Object> invocationParams = 
+                new HashMap<String, Object>(this.getParameters());
+        if (src != null) {
+            final Object resolvedSource = invocation.resolveParameter(src);
+            if (!(resolvedSource instanceof String)) {
+                throw new IllegalArgumentException(
+                        "Only strings can be resolved as URLs");
+            }
+
+            invocationParams.put("source",
+                    invocation.resolve((String) resolvedSource));
+        }
+
+        // set the baseUrl
+        invocationParams.put("baseUrl", invocation.resolve(""));
+
+        // install the component
+        invocation.installComponent(type, invocationParams);
+
+        // signal that we did some processing
+        return InvocationResult.CONTINUE;
+    }
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java
Sat Nov  5 11:18:55 2011
@@ -18,9 +18,6 @@
  */
 package org.apache.cocoon.sitemap.node;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.cocoon.sitemap.Invocation;
 import org.apache.cocoon.sitemap.node.annotations.Parameter;
 
@@ -42,20 +39,7 @@ public class GenerateNode extends Abstra
      */
     @Override
     public InvocationResult invoke(Invocation invocation) {
-        Map<String, Object> parameters = new HashMap<String, Object>(this.getParameters());
-        if (this.src != null) {
-            String resolvedSource = invocation.resolveParameter(this.src);
-            parameters.put("source", invocation.resolve(resolvedSource));
-        }
-
-        // set the baseUrl
-        parameters.put("baseUrl", invocation.resolve(""));
-
-        // install the component
-        invocation.installComponent(GENERATOR_CATEGORY + this.type, parameters);
-
-        // signal that we did some processing
-        return InvocationResult.CONTINUE;
+        return invoke(this.src, GENERATOR_CATEGORY + this.type, invocation);
     }
 
     /**

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java
Sat Nov  5 11:18:55 2011
@@ -40,7 +40,7 @@ public class MatchNode extends AbstractS
      */
     private static final Logger LOG =
             LoggerFactory.getLogger(MatchNode.class);
-    
+
     @Parameter
     private String name;
 
@@ -79,11 +79,14 @@ public class MatchNode extends AbstractS
      */
     @Override
     public InvocationResult invoke(Invocation invocation) {
+        final Object resolvedValue = invocation.resolveParameter(this.value);
+
         // try to resolve the test value in the case that it is an expression
-        String testValue = invocation.resolveParameter(this.value);
+        String testValue = resolvedValue == null
+                ? null : resolvedValue.toString();
         if (testValue == null) {
             testValue = invocation.getRequestURI();
-            if (testValue.startsWith("/")) {
+            if (testValue.charAt(0) == '/') {
                 testValue = testValue.substring(1);
             }
         }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java
Sat Nov  5 11:18:55 2011
@@ -51,20 +51,7 @@ public class ReadNode extends AbstractSi
      */
     @Override
     public InvocationResult invoke(Invocation invocation) {
-        Map<String, Object> parameters = new HashMap<String, Object>(this.getParameters());
-        if (this.src != null) {
-            String resolvedSource = invocation.resolveParameter(this.src);
-            parameters.put("source", invocation.resolve(resolvedSource));
-        }
-
-        // set the baseUrl
-        parameters.put("baseUrl", invocation.resolve(""));
-
-        // install the component
-        invocation.installComponent(READER_CATEGORY + this.type, parameters);
-
-        // signal that we did some processing
-        return InvocationResult.CONTINUE;
+        return invoke(this.src, READER_CATEGORY + this.type, invocation);
     }
 
     /**

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java?rev=1197931&r1=1197930&r2=1197931&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java
Sat Nov  5 11:18:55 2011
@@ -18,9 +18,6 @@
  */
 package org.apache.cocoon.sitemap.node;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.cocoon.sitemap.Invocation;
 import org.apache.cocoon.sitemap.node.annotations.Parameter;
 
@@ -51,20 +48,7 @@ public class TransformNode extends Abstr
      */
     @Override
     public InvocationResult invoke(final Invocation invocation) {
-        final Map<String, Object> parameters = new HashMap<String, Object>(this.getParameters());
-        if (this.src != null) {
-            String resolvedSource = invocation.resolveParameter(this.src);
-            parameters.put("source", invocation.resolve(resolvedSource));
-        }
-
-        // set the baseUrl
-        parameters.put("baseUrl", invocation.resolve(""));
-
-        // install the component
-        invocation.installComponent(TRANSFORMER_CATEGORY + this.type, parameters);
-
-        // signal that we did some processing
-        return InvocationResult.CONTINUE;
+        return invoke(this.src, TRANSFORMER_CATEGORY + this.type, invocation);
     }
 
     /**



Mime
View raw message