You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2003/08/09 20:21:49 UTC
cvs commit: cocoon-2.1/src/blocks/html/java/org/apache/cocoon/generation HTMLGenerator.java
cziegeler 2003/08/09 11:21:49
Modified: . status.xml
src/java/org/apache/cocoon/environment/wrapper
EnvironmentWrapper.java
src/java/org/apache/cocoon/components/source/impl
SitemapSource.java
src/blocks/html/java/org/apache/cocoon/generation
HTMLGenerator.java
Log:
<action dev="CZ" type="add" fixes-bug="22270" due-to="Unico Hommes" due-to-email="unico@hippo.nl">
Patch for allowing to specify a cocoon-view for internal requests in the query string.
</action>
Revision Changes Path
1.112 +5 -2 cocoon-2.1/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/status.xml,v
retrieving revision 1.111
retrieving revision 1.112
diff -u -r1.111 -r1.112
--- status.xml 7 Aug 2003 16:54:16 -0000 1.111
+++ status.xml 9 Aug 2003 18:21:49 -0000 1.112
@@ -167,6 +167,9 @@
<changes>
<release version="@version@" date="@date@">
+ <action dev="CZ" type="add" fixes-bug="22270" due-to="Unico Hommes" due-to-email="unico@hippo.nl">
+ Patch for allowing to specify a cocoon-view for internal requests in the query string.
+ </action>
<action dev="JH" type="fix" fixes-bug="19839">
Instrumentation support: Updated client libraries to make instrumentation work again.
Added a target "start-instrumentation-client" to Cocoon's ant files and removed "runclient" shell scripts.
@@ -174,7 +177,7 @@
<action dev="JH" type="fix" fixes-bug="22064" due-to="Nicolas Maisonneuve" due-to-email="nicoo_@hotmail.com">
XMLDBTransformer: retrieving auto-generated resource id.
</action>
- <action dev="BD" type="add" due-to="Mark Leicester" due-to.email="mark.leicester@energyintellect.com">
+ <action dev="BD" type="add" due-to="Mark Leicester" due-to-email="mark.leicester@energyintellect.com">
midi block added
</action>
<action dev="BD" type="add">
1.10 +17 -2 cocoon-2.1/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java
Index: EnvironmentWrapper.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- EnvironmentWrapper.java 4 Aug 2003 03:21:51 -0000 1.9
+++ EnvironmentWrapper.java 9 Aug 2003 18:21:49 -0000 1.10
@@ -139,7 +139,22 @@
ComponentManager manager,
boolean rawMode)
throws MalformedURLException {
- super(env.getURI(), env.getView(), env.getContext(), env.getAction());
+ this(env, requestURI, queryString, logger, null, rawMode,env.getView());
+ }
+
+ /**
+ * Constructs an EnvironmentWrapper object from a Request
+ * and Response objects
+ */
+ public EnvironmentWrapper(Environment env,
+ String requestURI,
+ String queryString,
+ Logger logger,
+ ComponentManager manager,
+ boolean rawMode,
+ String view)
+ throws MalformedURLException {
+ super(env.getURI(), view, env.getContext(), env.getAction());
this.rootContext = env.getRootContext();
this.enableLogging(logger);
1.9 +26 -2 cocoon-2.1/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java
Index: SitemapSource.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/source/impl/SitemapSource.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SitemapSource.java 6 Jul 2003 11:44:30 -0000 1.8
+++ SitemapSource.java 9 Aug 2003 18:21:49 -0000 1.9
@@ -54,6 +54,7 @@
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.Logger;
+import org.apache.cocoon.Constants;
import org.apache.cocoon.Processor;
import org.apache.cocoon.ResourceNotFoundException;
import org.apache.cocoon.components.CocoonComponentManager;
@@ -201,6 +202,29 @@
uri = uri.substring(position);
}
this.uri = uri;
+
+ // determine if the queryString specifies a cocoon-view
+ String view = null;
+ if (queryString != null) {
+ int index = queryString.indexOf(Constants.VIEW_PARAM);
+ if (index != -1
+ && (index == 0 || queryString.charAt(index-1) == '&')
+ && queryString.length() > index + Constants.VIEW_PARAM.length()
+ && queryString.charAt(index+Constants.VIEW_PARAM.length()) == '=') {
+
+ String tmp = queryString.substring(index+Constants.VIEW_PARAM.length()+1);
+ index = tmp.indexOf('&');
+ if (index != -1) {
+ view = tmp.substring(0,index);
+ } else {
+ view = tmp;
+ }
+ } else {
+ view = env.getView();
+ }
+ } else {
+ view = env.getView();
+ }
// build the request uri which is relative to the context
String requestURI = (this.prefix == null ? env.getURIPrefix() + uri : uri);
@@ -212,7 +236,7 @@
// create environment...
this.environment = new EnvironmentWrapper(env, requestURI,
- queryString, logger, manager, rawMode);
+ queryString, logger, manager, rawMode, view);
// ...and put information passed from the parent request to the internal request
if ( null != parameters ) {
this.environment.getObjectModel().put(ObjectModelHelper.PARENT_CONTEXT, parameters);
1.6 +7 -10 cocoon-2.1/src/blocks/html/java/org/apache/cocoon/generation/HTMLGenerator.java
Index: HTMLGenerator.java
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/html/java/org/apache/cocoon/generation/HTMLGenerator.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- HTMLGenerator.java 2 Apr 2003 21:39:09 -0000 1.5
+++ HTMLGenerator.java 9 Aug 2003 18:21:49 -0000 1.6
@@ -190,7 +190,7 @@
throw new ProcessingException(
"HtmlGenerator with no \"src\" parameter expects a sitemap parameter called '" +
FORM_NAME + "' for handling form data"
- );
+ );
}
String sXml = request.getParameter(requested);
@@ -205,7 +205,7 @@
if (len > 0) {
requestStream = new PostInputStream(request.getInputStream(), len);
} else {
- throw new IOException("getContentLen() == 0");
+ throw new IOException("getContentLen() == 0");
}
} else {
throw new IOException("Unexpected getContentType(): " + request.getContentType());
@@ -275,8 +275,7 @@
*/
public void generate()
throws IOException, SAXException, ProcessingException {
- try
- {
+ try {
// Setup an instance of Tidy.
Tidy tidy = new Tidy();
tidy.setXmlOut(true);
@@ -309,20 +308,18 @@
errorWriter.flush();
errorWriter.close();
- if(getLogger().isWarnEnabled()){
+ if(getLogger().isWarnEnabled()) {
getLogger().warn(stringWriter.toString());
}
- if(xpath != null)
- {
+ if(xpath != null) {
DOMStreamer domStreamer = new DOMStreamer(this.contentHandler,this.lexicalHandler);
contentHandler.startDocument();
NodeList nl = processor.selectNodeList(doc, xpath);
int length = nl.getLength();
- for(int i=0;i<length;i++)
- {
+ for(int i=0;i<length;i++) {
domStreamer.stream(nl.item(i));
}
contentHandler.endDocument();