cziegeler 02/02/13 00:23:40 Modified: . changes.xml todo.xml src/java/org/apache/cocoon/components/source SitemapSource.java SourceHandlerImpl.java src/java/org/apache/cocoon/environment/wrapper EnvironmentWrapper.java RequestWrapper.java Log: Added cocoon:raw subprotocol Revision Changes Path 1.105 +7 -1 xml-cocoon2/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/changes.xml,v retrieving revision 1.104 retrieving revision 1.105 diff -u -r1.104 -r1.105 --- changes.xml 9 Feb 2002 15:43:30 -0000 1.104 +++ changes.xml 13 Feb 2002 08:23:40 -0000 1.105 @@ -4,7 +4,7 @@ <!-- History of Cocoon changes - $Id: changes.xml,v 1.104 2002/02/09 15:43:30 vgritsenko Exp $ + $Id: changes.xml,v 1.105 2002/02/13 08:23:40 cziegeler Exp $ --> <changes title="History of Changes"> @@ -31,6 +31,12 @@ </devs> <release version="@version@" date="@date@"> + <action dev="CZ" type="update"> + Added subprotocol "raw" to the cocoon: protocol. When the subprotocol is + appended, the request parameters of the original request are not + forwarded to the internal pipelines. Suggested by + Michael Hartle [[EMAIL PROTECTED]]. + </action> <action dev="VG" type="add"> Added Pizza Java compiler as another alternative to Sun javac and Jikes. </action> 1.24 +2 -8 xml-cocoon2/todo.xml Index: todo.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/todo.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- todo.xml 4 Feb 2002 02:37:16 -0000 1.23 +++ todo.xml 13 Feb 2002 08:23:40 -0000 1.24 @@ -4,11 +4,11 @@ <!-- History of Cocoon changes - $Id: todo.xml,v 1.23 2002/02/04 02:37:16 vgritsenko Exp $ + $Id: todo.xml,v 1.24 2002/02/13 08:23:40 cziegeler Exp $ --> -<todo title="Things To Do for Apache Cocoon 2"> +<todo title="Things To Do"> <devs> <!-- in strict alphabetical order --> @@ -62,12 +62,6 @@ </actions> <actions priority="medium"> - <action context="code"> - Add a possibility to control wether the parameters of a request should be - passed to internal pipelines or not. Suggestions from - Michael Hartle [[EMAIL PROTECTED]] is cocoon:raw:/URI. - </action> - <action context="code"> Make all the examples which are currently commented out work again. </action> 1.8 +8 -2 xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java Index: SitemapSource.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SitemapSource.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- SitemapSource.java 11 Feb 2002 12:15:11 -0000 1.7 +++ SitemapSource.java 13 Feb 2002 08:23:40 -0000 1.8 @@ -93,7 +93,7 @@ * Description of a source which is defined by a pipeline. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: SitemapSource.java,v 1.7 2002/02/11 12:15:11 cziegeler Exp $ + * @version CVS $Id: SitemapSource.java,v 1.8 2002/02/13 08:23:40 cziegeler Exp $ */ public final class SitemapSource @@ -148,11 +148,17 @@ this.manager = manager; this.setLogger(logger); + boolean rawMode = false; // remove the protocol int protocolEnd = uri.indexOf(':'); if (protocolEnd != -1) { uri = uri.substring(protocolEnd + 1); + // check for subprotocol + if (uri.startsWith("raw:")) { + uri = uri.substring(4); + rawMode = true; + } } // does the uri point to this sitemap or to the root sitemap? @@ -190,7 +196,7 @@ "cocoon://" + requestURI : "cocoon://" + requestURI + "?" + queryString; - this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger); + this.environment = new EnvironmentWrapper(env, requestURI, queryString, logger, rawMode); this.uri = uri; this.refresh(); } 1.5 +7 -7 xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceHandlerImpl.java Index: SourceHandlerImpl.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/source/SourceHandlerImpl.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- SourceHandlerImpl.java 4 Feb 2002 09:40:16 -0000 1.4 +++ SourceHandlerImpl.java 13 Feb 2002 08:23:40 -0000 1.5 @@ -83,7 +83,7 @@ /** * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version $Id: SourceHandlerImpl.java,v 1.4 2002/02/04 09:40:16 cziegeler Exp $ + * @version $Id: SourceHandlerImpl.java,v 1.5 2002/02/13 08:23:40 cziegeler Exp $ */ public final class SourceHandlerImpl extends AbstractLoggable @@ -158,7 +158,7 @@ public void dispose() { this.manager.release(this.urlFactory); - Iterator iter = this.sourceFactories.values().iterator(); + final Iterator iter = this.sourceFactories.values().iterator(); SourceFactory current; while (iter.hasNext()) { current = (SourceFactory) iter.next(); @@ -172,10 +172,10 @@ */ public Source getSource(Environment environment, String location) throws ProcessingException, MalformedURLException, IOException { - int protocolEnd = location.indexOf(':'); + final int protocolEnd = location.indexOf(':'); if (protocolEnd != -1) { - String protocol = location.substring(0, protocolEnd); - SourceFactory sourceFactory = (SourceFactory)this.sourceFactories.get(protocol); + final String protocol = location.substring(0, protocolEnd); + final SourceFactory sourceFactory = (SourceFactory)this.sourceFactories.get(protocol); if (sourceFactory != null) { return sourceFactory.getSource(environment, location); } @@ -190,8 +190,8 @@ */ public Source getSource(Environment environment, URL base, String location) throws ProcessingException, MalformedURLException, IOException { - String protocol = base.getProtocol(); - SourceFactory sourceFactory = (SourceFactory)this.sourceFactories.get(protocol); + final String protocol = base.getProtocol(); + final SourceFactory sourceFactory = (SourceFactory)this.sourceFactories.get(protocol); if (sourceFactory != null) { return sourceFactory.getSource(environment, base, location); } 1.8 +18 -2 xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java Index: EnvironmentWrapper.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/EnvironmentWrapper.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- EnvironmentWrapper.java 11 Feb 2002 13:29:23 -0000 1.7 +++ EnvironmentWrapper.java 13 Feb 2002 08:23:40 -0000 1.8 @@ -77,7 +77,7 @@ * contains a <code>RequestWrapper</code> object. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version $Id: EnvironmentWrapper.java,v 1.7 2002/02/11 13:29:23 cziegeler Exp $ + * @version $Id: EnvironmentWrapper.java,v 1.8 2002/02/13 08:23:40 cziegeler Exp $ */ public final class EnvironmentWrapper extends AbstractEnvironment @@ -116,6 +116,19 @@ String queryString, Logger logger) throws MalformedURLException { + this(env, requestURI, queryString, logger, false); + } + + /** + * Constructs an EnvironmentWrapper object from a Request + * and Response objects + */ + public EnvironmentWrapper(Environment env, + String requestURI, + String queryString, + Logger logger, + boolean rawMode) + throws MalformedURLException { super(env.getURI(), env.getView(), env.getRootContext(), env.getAction()); this.setLogger(logger); this.environment = env; @@ -134,7 +147,10 @@ this.objectModel.put(key, oldObjectModel.get(key)); } this.request = new RequestWrapper(ObjectModelHelper.getRequest(oldObjectModel), - requestURI, queryString, this); + requestURI, + queryString, + this, + rawMode); this.objectModel.put(ObjectModelHelper.REQUEST_OBJECT, this.request); this.objectModel.put("Internal-Request", "true"); 1.5 +44 -21 xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java Index: RequestWrapper.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- RequestWrapper.java 4 Feb 2002 09:45:07 -0000 1.4 +++ RequestWrapper.java 13 Feb 2002 08:23:40 -0000 1.5 @@ -70,7 +70,7 @@ * are different. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version $Id: RequestWrapper.java,v 1.4 2002/02/04 09:45:07 cziegeler Exp $ + * @version $Id: RequestWrapper.java,v 1.5 2002/02/13 08:23:40 cziegeler Exp $ */ public final class RequestWrapper implements Request { @@ -86,6 +86,9 @@ /** The environment */ private Environment environment; + /** raw mode? **/ + private boolean rawMode; + /** * Constructor */ @@ -93,11 +96,23 @@ String requestURI, String queryString, Environment env) { + this(request, requestURI, queryString, env, false); + } + + /** + * Constructor + */ + public RequestWrapper(Request request, + String requestURI, + String queryString, + Environment env, + boolean rawMode) { this.environment = env; this.req = request; this.queryString = queryString; this.parameters = new RequestParameters(queryString); - if (this.req.getQueryString() != null) { + this.rawMode = rawMode; + if (this.req.getQueryString() != null && this.rawMode == false) { if (this.queryString == null) this.queryString = this.req.getQueryString(); else @@ -131,24 +146,28 @@ public String getParameter(String name) { String value = this.parameters.getParameter(name); - if (value == null) + if (value == null && this.rawMode == false) return this.req.getParameter(name); else return value; } public Enumeration getParameterNames() { - // put all parameter names into a set - Set parameterNames = new HashSet(); - Enumeration names = this.parameters.getParameterNames(); - while (names.hasMoreElements()) { - parameterNames.add(names.nextElement()); + if ( this.rawMode == false ) { + // put all parameter names into a set + Set parameterNames = new HashSet(); + Enumeration names = this.parameters.getParameterNames(); + while (names.hasMoreElements()) { + parameterNames.add(names.nextElement()); + } + names = this.req.getParameterNames(); + while (names.hasMoreElements()) { + parameterNames.add(names.nextElement()); + } + return new EnumerationFromIterator(parameterNames.iterator()); + } else { + return this.parameters.getParameterNames(); } - names = this.req.getParameterNames(); - while (names.hasMoreElements()) { - parameterNames.add(names.nextElement()); - } - return new EnumerationFromIterator(parameterNames.iterator()); } final class EnumerationFromIterator implements Enumeration { @@ -164,14 +183,18 @@ } public String[] getParameterValues(String name) { - String[] values = this.parameters.getParameterValues(name); - String[] inherited = this.req.getParameterValues(name); - if (inherited == null) return values; - if (values == null) return inherited; - String[] allValues = new String[values.length + inherited.length]; - System.arraycopy(values, 0, allValues, 0, values.length); - System.arraycopy(inherited, 0, allValues, values.length, inherited.length); - return allValues; + if ( this.rawMode == false) { + String[] values = this.parameters.getParameterValues(name); + String[] inherited = this.req.getParameterValues(name); + if (inherited == null) return values; + if (values == null) return inherited; + String[] allValues = new String[values.length + inherited.length]; + System.arraycopy(values, 0, allValues, 0, values.length); + System.arraycopy(inherited, 0, allValues, values.length, inherited.length); + return allValues; + } else { + return this.parameters.getParameterValues(name); + } } public String getProtocol() {
---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]