Return-Path: Delivered-To: apmail-cocoon-cvs-archive@cocoon.apache.org Received: (qmail 12642 invoked by uid 500); 9 Aug 2003 18:21:41 -0000 Mailing-List: contact cvs-help@cocoon.apache.org; run by ezmlm Precedence: bulk Reply-To: dev@cocoon.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list cvs@cocoon.apache.org Received: (qmail 12625 invoked by uid 500); 9 Aug 2003 18:21:41 -0000 Delivered-To: apmail-cocoon-2.1-cvs@apache.org Received: (qmail 12617 invoked from network); 9 Aug 2003 18:21:41 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 9 Aug 2003 18:21:41 -0000 Received: (qmail 85781 invoked by uid 1260); 9 Aug 2003 18:21:49 -0000 Date: 9 Aug 2003 18:21:49 -0000 Message-ID: <20030809182149.85780.qmail@minotaur.apache.org> From: cziegeler@apache.org To: cocoon-2.1-cvs@apache.org Subject: cvs commit: cocoon-2.1/src/blocks/html/java/org/apache/cocoon/generation HTMLGenerator.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N 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: Patch for allowing to specify a cocoon-view for internal requests in the query string. 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 @@ + + Patch for allowing to specify a cocoon-view for internal requests in the query string. + 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 @@ XMLDBTransformer: retrieving auto-generated resource id. - + midi block added 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