Author: unico Date: Tue Oct 26 04:42:28 2004 New Revision: 55600 Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/environment/portlet/ActionRequest.java cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/environment/portlet/RenderRequest.java cocoon/trunk/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java Log: add getInputStream method to the Request interface as discussed in http://marc.theaimsgroup.com/?t=109857486600002&r=1&w=2
Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/environment/portlet/ActionRequest.java ============================================================================== --- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/environment/portlet/ActionRequest.java (original) +++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/environment/portlet/ActionRequest.java Tue Oct 26 04:42:28 2004 @@ -23,7 +23,7 @@ * Implements the [EMAIL PROTECTED] org.apache.cocoon.environment.Request} interface for the * JSR-168 (Portlet) environment. * - * @version CVS $Id: ActionRequest.java,v 1.2 2004/03/05 13:02:08 bdelacretaz Exp $ + * @version CVS $Id$ * @author <a href="mailto:[EMAIL PROTECTED]">Alex Rudnev</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> */ @@ -68,6 +68,13 @@ return (javax.portlet.ActionRequest) getPortletRequest(); } + public InputStream getInputStream() throws IOException { + return getActionRequest().getPortletInputStream(); + } + + /** + * @deprecated use [EMAIL PROTECTED] #getInputStream()} + */ public InputStream getPortletInputStream() throws IOException { return getActionRequest().getPortletInputStream(); } Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/environment/portlet/RenderRequest.java ============================================================================== --- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/environment/portlet/RenderRequest.java (original) +++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/environment/portlet/RenderRequest.java Tue Oct 26 04:42:28 2004 @@ -15,13 +15,15 @@ */ package org.apache.cocoon.environment.portlet; +import java.io.InputStream; + /** * Implements the [EMAIL PROTECTED] org.apache.cocoon.environment.Request} interface for * the JSR-168 (Portlet) environment. * * @author <a href="mailto:[EMAIL PROTECTED]">Alex Rudnev</a> * @author <a href="mailto:[EMAIL PROTECTED]">Vadim Gritsenko</a> - * @version CVS $Id: RenderRequest.java,v 1.2 2004/03/05 13:02:08 bdelacretaz Exp $ + * @version CVS $Id$ */ public final class RenderRequest extends PortletRequest { @@ -50,4 +52,11 @@ public String getMethod() { return "GET"; } + + /* (non-Javadoc) + * @see org.apache.cocoon.environment.Request#getInputStream() + */ + public InputStream getInputStream() throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } } Modified: cocoon/trunk/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/components/flow/javascript/fom/FOM_Cocoon.java Tue Oct 26 04:42:28 2004 @@ -15,6 +15,7 @@ */ package org.apache.cocoon.components.flow.javascript.fom; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.net.MalformedURLException; @@ -604,6 +605,10 @@ public boolean jsFunction_isUserInRole(String role) { return request.isUserInRole(role); } + + public InputStream jsFunction_getInputStream() throws IOException, UnsupportedOperationException { + return request.getInputStream(); + } // Request interface @@ -792,33 +797,25 @@ return request.isRequestedSessionIdFromURL(); } - /* (non-Javadoc) - * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int) - */ public Object getAttribute(String name, int scope) { return this.request.getAttribute(name, scope); } - /* (non-Javadoc) - * @see org.apache.cocoon.environment.Request#getAttributeNames(int) - */ public Enumeration getAttributeNames(int scope) { return this.request.getAttributeNames(scope); } - /* (non-Javadoc) - * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int) - */ public void removeAttribute(String name, int scope) { this.request.removeAttribute(name, scope); } - /* (non-Javadoc) - * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int) - */ public void setAttribute(String name, Object o, int scope) { this.request.setAttribute( name, o, scope ); } + + public InputStream getInputStream() throws IOException, UnsupportedOperationException { + return this.request.getInputStream(); + } } public static class FOM_Cookie Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/environment/Request.java Tue Oct 26 04:42:28 2004 @@ -15,6 +15,8 @@ */ package org.apache.cocoon.environment; +import java.io.IOException; +import java.io.InputStream; import java.security.Principal; import java.util.Enumeration; import java.util.Locale; @@ -37,7 +39,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Davanum Srinivas</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a> - * @version CVS $Id: Request.java,v 1.11 2004/07/12 13:27:57 cziegeler Exp $ + * @version CVS $Id$ * */ @@ -580,6 +582,18 @@ */ Enumeration getHeaderNames(); + + /** + * Retrieves the body of the request as binary data using + * an <code>InputStream</code>. + * + * @return an <code>InputStream</code> + * containing the body of the request. + * + * @throws IOException if an input or output exception occurred + * @throws UnsupportedOperationException + */ + InputStream getInputStream() throws IOException, UnsupportedOperationException; /** * Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/environment/commandline/CommandLineRequest.java Tue Oct 26 04:42:28 2004 @@ -15,6 +15,7 @@ */ package org.apache.cocoon.environment.commandline; +import java.io.InputStream; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; @@ -35,7 +36,7 @@ * * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: CommandLineRequest.java,v 1.13 2004/07/12 13:27:57 cziegeler Exp $ + * @version CVS $Id$ */ /* @@ -418,4 +419,12 @@ public void setCharacterEncoding(java.lang.String env) throws java.io.UnsupportedEncodingException { characterEncoding = env; } public StringBuffer getRequestURL() { return null; } + + /* + * @see org.apache.cocoon.environment.Request#getInputStream() + */ + public InputStream getInputStream() throws UnsupportedOperationException { + throw new UnsupportedOperationException(); + } + } Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/environment/http/HttpRequest.java Tue Oct 26 04:42:28 2004 @@ -17,6 +17,7 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; import java.util.Collections; import java.util.Enumeration; import java.util.HashMap; @@ -25,7 +26,6 @@ import java.util.Vector; import javax.servlet.RequestDispatcher; -import javax.servlet.ServletInputStream; import javax.servlet.http.HttpServletRequest; import org.apache.avalon.framework.CascadingRuntimeException; @@ -40,7 +40,7 @@ * to provide request information in the HTTP servlets environment. * * @author <a href="mailto:[EMAIL PROTECTED]">Giacomo Pati</a> - * @version CVS $Id: HttpRequest.java,v 1.11 2004/07/12 13:27:57 cziegeler Exp $ + * @version CVS $Id$ */ public final class HttpRequest implements Request { @@ -376,7 +376,7 @@ return this.req.getContentType(); } - public ServletInputStream getInputStream() throws IOException { + public InputStream getInputStream() throws IOException { return this.req.getInputStream(); } Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java Tue Oct 26 04:42:28 2004 @@ -15,6 +15,8 @@ */ package org.apache.cocoon.environment.wrapper; +import java.io.IOException; +import java.io.InputStream; import java.security.Principal; import java.util.Enumeration; import java.util.Locale; @@ -31,7 +33,7 @@ * implementations. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: AbstractRequestWrapper.java,v 1.2 2004/07/11 13:59:12 cziegeler Exp $ + * @version CVS $Id$ * @since 2.2 */ public abstract class AbstractRequestWrapper implements Request { @@ -235,6 +237,13 @@ public Enumeration getHeaderNames() { return this.req.getHeaderNames(); } + + /* (non-Javadoc) + * @see org.apache.cocoon.environment.Request#getInputStream() + */ + public InputStream getInputStream() throws IOException, UnsupportedOperationException { + return this.req.getInputStream(); + } /* (non-Javadoc) * @see org.apache.cocoon.environment.Request#getMethod() Modified: cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java Tue Oct 26 04:42:28 2004 @@ -33,7 +33,7 @@ * are different. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Id: RequestWrapper.java,v 1.9 2004/07/11 13:59:12 cziegeler Exp $ + * @version CVS $Id$ */ public final class RequestWrapper extends AbstractRequestWrapper { @@ -228,4 +228,5 @@ this.requestAttributes.put( name, o ); } } + } Modified: cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java ============================================================================== --- cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java (original) +++ cocoon/trunk/src/test/org/apache/cocoon/environment/mock/MockRequest.java Tue Oct 26 04:42:28 2004 @@ -15,6 +15,8 @@ */ package org.apache.cocoon.environment.mock; +import java.io.IOException; +import java.io.InputStream; import java.security.Principal; import java.util.Collections; import java.util.Enumeration; @@ -57,6 +59,7 @@ private String charEncoding; private String serverName; private int port = 80; + private InputStream inputStream; private Hashtable parameters = new Hashtable(); private Hashtable headers = new Hashtable(); @@ -428,5 +431,14 @@ } } - + /* (non-Javadoc) + * @see org.apache.cocoon.environment.Request#getInputStream() + */ + public InputStream getInputStream() throws IOException, UnsupportedOperationException { + return this.inputStream; + } + + public void setInputStream(InputStream is) { + this.inputStream = is; + } }