Author: vgritsenko
Date: Tue Oct 19 08:39:30 2004
New Revision: 55071
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
cocoon/trunk/src/test/anteater/redirect.xml
cocoon/trunk/status.xml
Log:
Forbid flowscripts with no response
http://marc.theaimsgroup.com/?t=106849566300008&r=1
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallFunctionNode.java
Tue Oct 19 08:39:30 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.
@@ -28,6 +28,7 @@
import
org.apache.cocoon.components.treeprocessor.ParameterizableProcessingNode;
import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.Redirector;
/**
* Node handler for calling functions and resuming continuations in
@@ -35,7 +36,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Ovidiu Predescu</a>
* @since March 13, 2002
- * @version CVS $Id: CallFunctionNode.java,v 1.12 2004/07/15 12:49:50 sylvain
Exp $
+ * @version CVS $Id$
*/
public class CallFunctionNode extends AbstractProcessingNode implements
ParameterizableProcessingNode {
@@ -64,12 +65,12 @@
}
public boolean invoke(Environment env, InvokeContext context) throws
Exception {
-
+
Map objectModel = env.getObjectModel();
-
+
// Resolve parameters
Parameters params = VariableResolver.buildParameters(this.parameters,
context, objectModel);
-
+
// Build the list of positional arguments
//TODO (SW): Deprecate this in the future.
// It has be found to be bad practice to pass sitemap parameters
@@ -87,25 +88,33 @@
args = Collections.EMPTY_LIST;
}
- String continuation = continuationId.resolve(context, objectModel);
+ // Need redirector in any case
+ Redirector redirector = context.getRedirector();
// If the continuation id is not null, it takes precedence over
// the function call, so we invoke it here.
+ String continuation = continuationId.resolve(context,
env.getObjectModel());
if (continuation != null && continuation.length() > 0) {
- interpreter.handleContinuation(continuation, args,
context.getRedirector());
+ interpreter.handleContinuation(continuation, args, redirector);
+ if (!redirector.hasRedirected()) {
+ throw new ProcessingException("<map:call continuation> did not
send a response, at " +
+ getLocation());
+ }
return true;
}
// We don't have a continuation id passed in <map:call>, so invoke
// the specified function
-
String name = functionName.resolve(context, objectModel);
-
if (name != null && name.length() > 0) {
- interpreter.callFunction(name, args, context.getRedirector());
+ interpreter.callFunction(name, args, redirector);
+ if (!redirector.hasRedirected()) {
+ throw new ProcessingException("<map:call function> did not
send a response, at " +
+ getLocation());
+ }
return true;
}
-
+
// Found neither continuation nor function to call
throw new ProcessingException("No function nor continuation given in
<map:call function> at " + getLocation());
}
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
==============================================================================
---
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
(original)
+++
cocoon/trunk/src/java/org/apache/cocoon/components/treeprocessor/sitemap/CallNodeBuilder.java
Tue Oct 19 08:39:30 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.
@@ -30,15 +30,13 @@
import
org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
/**
- *
+ *
* @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez </a>
* @author <a href="mailto:[EMAIL PROTECTED]">Ovidiu Predescu </a>
- * @version CVS $Id: CallNodeBuilder.java,v 1.3 2004/03/05 13:02:51 bdelacretaz
- * Exp $
+ * @version CVS $Id$
*/
-
-public class CallNodeBuilder extends AbstractProcessingNodeBuilder implements
- LinkedProcessingNodeBuilder {
+public class CallNodeBuilder extends AbstractProcessingNodeBuilder
+ implements LinkedProcessingNodeBuilder {
protected ProcessingNode node;
@@ -48,7 +46,8 @@
protected String continuationId;
- public ProcessingNode buildNode(Configuration config) throws Exception {
+ public ProcessingNode buildNode(Configuration config)
+ throws Exception {
resourceName = config.getAttribute("resource", null);
functionName = config.getAttribute("function", null);
continuationId = config.getAttribute("continuation", null);
@@ -119,7 +118,7 @@
+ node.getLocation()
+ ". Define a control flow using <map:flow>, with embedded
<map:script> elements.");
}
-
+
// Get the Interpreter instance and set it up in the
// CallFunctionNode function
Interpreter interpreter = flow.getInterpreter();
Modified: cocoon/trunk/src/test/anteater/redirect.xml
==============================================================================
--- cocoon/trunk/src/test/anteater/redirect.xml (original)
+++ cocoon/trunk/src/test/anteater/redirect.xml Tue Oct 19 08:39:30 2004
@@ -62,7 +62,7 @@
<httpRequest href="${redirect-test}/donothing-from-flow">
<match>
- <responseCode value="404"/>
+ <responseCode value="500"/>
</match>
</httpRequest>
Modified: cocoon/trunk/status.xml
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Tue Oct 19 08:39:30 2004
@@ -311,6 +311,10 @@
</action>
</release>
<release version="2.1.6" date="TBD">
+ <action dev="VG" type="update">
+ Flow invocations (function calls or continuation invocations) should
always
+ result in a response. Flowscripts with no response are prohibited.
+ </action>
<action dev="CZ" type="add" due-to="Sascha-Matthias Kulawik"
due-to-email="[EMAIL PROTECTED]">
Authentication block: Add authenticator for JAAS.
</action>
@@ -330,11 +334,11 @@
Portal block: Apply patch for handling GET method when no enctype is set
in CopletTransformer.
</action>
<action dev="TC" type="fix" fixes-bug="31545">
- Throw a more meaningful exception if charset classes are missing
+ Throw a more meaningful exception if charset classes are missing
</action>
- <action dev="TC" type="fix" fixes-bug="30874">
+ <action dev="TC" type="fix" fixes-bug="30874">
Fixes the SQLTransformer not to close the statement twice
- </action>
+ </action>
<action dev="TC" type="fix" fixes-bug="30994">
Change constructor to be public in order to fix bug 30270
</action>