Hi, This is a replacement for the maybeupload request wrapper which i needed for our project. Instead of directly writing files to the upload dir the files are kept in the request object and can be manually stored by an action.
Improvements: - More control over file attachments - Multiple upload dirs (configurable in sitemap) - One less optional package (i'd like the code to be put in the standard distro under the apache license). The following files are added / changed: org.apache.cocoon.environment.http - removed MaybeUpload wrapper - modified RequestWrapper2? to use new code org.apache.cocoon.environment.http.multipart - the parser and helper classes org.apache.cocoon.acting - added UploadAction src/webapp: - modified sitemap.xmap to use upload action for upload example src/webapp/docs/xsp/upload.xsp - modified to use upload action and removed code to list uploaded files (because the uploadDir constant no longer exists) build.xml: - removed MaybeUpload stuff I've tested the code using the upload example with: - Internet Explorer 6.0 (win 98) - Konqueror 2.2 (linux) - Mozilla 0.9.5 (linux) I've also tested opera 5 (linux) but, although the code works, opera does not post the submit field and thus the action is not executed. (I've verified this using the database examples which also didn't work). The patch is made against the 2.0.1 release and is divided into two parts: the source patch (multipart-src-patch) and the build.xml patch (multipart-build.xml-patch) which can both be applied using patch -p1 < multipart-*-patch in the cocoon 2.0.1 directory. Jeroen ter Voorde
diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/acting/UploadAction.java cocoon-2.0.1/src/java/org/apache/cocoon/acting/UploadAction.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/acting/UploadAction.java Thu Jan 1 01:00:00 1970 +++ cocoon-2.0.1/src/java/org/apache/cocoon/acting/UploadAction.java Fri Feb 22 17:21:30 2002 @@ -0,0 +1,80 @@ +/***************************************************************************** + * Copyright (C) The Apache Software Foundation. All rights reserved. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * + *****************************************************************************/ + +package org.apache.cocoon.acting; + +import org.apache.avalon.framework.configuration.Configurable; +import org.apache.avalon.framework.configuration.Configuration; +import org.apache.avalon.framework.configuration.ConfigurationException; +import org.apache.avalon.framework.parameters.Parameters; +import org.apache.avalon.framework.thread.ThreadSafe; +import org.apache.cocoon.Constants; +import org.apache.cocoon.environment.Redirector; +import org.apache.cocoon.environment.Request; +import org.apache.cocoon.environment.Context; +import org.apache.cocoon.environment.SourceResolver; +import org.apache.cocoon.acting.AbstractConfigurableAction; + +import org.apache.cocoon.environment.http.multipart.*; + +import java.util.*; +import java.io.*; + +public class UploadAction extends AbstractConfigurableAction implements ThreadSafe { + + Properties default_properties = null; + + + public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters parameters) throws Exception { + HashMap results = new HashMap(); + Request request = (Request)objectModel.get(Constants.REQUEST_OBJECT); + Context context = (Context)objectModel.get(Constants.CONTEXT_OBJECT); + Properties properties = new Properties(default_properties); + byte[] buf=new byte[4096]; + + Enumeration enum=request.getParameterNames(); + while(enum.hasMoreElements()) { + String name=(String)enum.nextElement(); + + Object obj=request.get(name); + getLogger().debug(request.getClass().getName()); + + if (obj instanceof FilePart) { + getLogger().debug("Uploading file: "+((FilePart)obj).getFileName()); + + String fileName=((FilePart)obj).getFileName(); + String uploadDir=(String)parameters.getParameter("upload-dir"); + String realPath=context.getRealPath("/"); + + if (realPath!=null) + uploadDir=realPath+uploadDir; + + File dir=new File(uploadDir); + if (!dir.exists()) + dir.mkdir(); + + FileOutputStream out=new FileOutputStream(uploadDir+File.separator+fileName); + InputStream in=((FilePart)obj).getInputStream(); + int read=in.read(buf); + while(read>0) { + out.write(buf,0,read); + read=in.read(buf); + } + + out.close(); + + } else if (obj instanceof String) { + getLogger().debug("Skipping parameter: "+(String)obj); + } + + } + + return Collections.unmodifiableMap(results); + + } +} diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/RequestWrapper22.java cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/RequestWrapper22.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/RequestWrapper22.java Thu Jan 31 12:40:02 2002 +++ cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/RequestWrapper22.java Fri Feb 22 17:25:05 2002 @@ -1,60 +1,85 @@ -/***************************************************************************** - * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * - *****************************************************************************/ -package org.apache.cocoon.environment.http; - -import javax.servlet.http.HttpServletRequest; -import java.io.File; -import java.util.Vector; - -/** - * - * Implements the {@link javax.servlet.http.HttpServletRequest} interface - * to provide request information for HTTP servlets. - * - * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:16 $ - */ - -public final class RequestWrapper { - - /** - * Return a wrapped request object - */ - public static HttpServletRequest getServletRequest(HttpServletRequest request, - boolean saveUploadedFilesToDisk, - File uploadDirectory, - boolean allowOverwrite, - boolean silentlyRename, - int maxUploadSize) { - return request; - } - - /** - * Implementation of the get method - */ - public static Object get(HttpServletRequest request, String name) { - String[] values = request.getParameterValues(name); - - if (values == null) return null; - - if (values.length == 1) { - return values[0]; - } - - if (values.length > 1) { - Vector vect = new Vector(values.length); - - for (int i = 0; i < values.length; i++) { - vect.add(values[i]); - } - - return vect; - } - return null; - } -} +/***************************************************************************** + * Copyright (C) The Apache Software Foundation. All rights reserved. * + * ------------------------------------------------------------------------- * + * This software is published under the terms of the Apache Software License * + * version 1.1, a copy of which has been included with this distribution in * + * the LICENSE file. * + *****************************************************************************/ +package org.apache.cocoon.environment.http; + +import org.apache.cocoon.environment.http.multipart.MultipartRequestWrapper; + +import javax.servlet.http.HttpServletRequest; +import java.io.File; +import java.util.Vector; + +/** + * + * Implements the {@link javax.servlet.http.HttpServletRequest} interface + * to provide request information for HTTP servlets. + * + * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> + * @version CVS $Revision: 1.1.2.4 $ $Date: 2001/10/11 08:56:11 $ + */ + +public final class RequestWrapper extends MultipartRequestWrapper { + + /** + * Return a wrapped request object + */ + public static HttpServletRequest getServletRequest(HttpServletRequest request,int maxUpload) { + HttpServletRequest req = request; + String contentType = req.getContentType(); + + if (contentType == null) { + contentType = "application/x-www-form-urlencoded"; + } + + if (contentType.startsWith("multipart/form-data")) { + try { + req = new RequestWrapper(request,maxUpload); + } catch (Exception e) { + req = request; + } + } + + return req; + } + + public RequestWrapper(HttpServletRequest httpservletrequest,int maxUpload) + throws Exception { + super(httpservletrequest,maxUpload); + } + + /** + * Implementation of the get method + */ + public static Object get(HttpServletRequest request, String name) { + // FIXME We should get rid of this instanceof test + if (request instanceof RequestWrapper) { + return ((RequestWrapper) request).get(name); + } else { + String[] values = request.getParameterValues(name); + + if (values == null) return null; + + if (values.length == 1) { + return values[0]; + } + + if (values.length > 1) { + Vector vect = new Vector(values.length); + + for (int i = 0; i < values.length; i++) { + vect.add(values[i]); + } + + return vect; + } + } + return null; + } + +} + + diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/RequestWrapper23.java cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/RequestWrapper23.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/RequestWrapper23.java Thu Jan 31 12:40:01 2002 +++ cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/RequestWrapper23.java Fri Feb 22 17:26:07 2002 @@ -7,8 +7,11 @@ *****************************************************************************/ package org.apache.cocoon.environment.http; +import org.apache.cocoon.environment.http.multipart.MultipartRequestWrapper; + import javax.servlet.http.HttpServletRequest; import java.io.File; +import java.util.Map; import java.util.Vector; /** @@ -20,42 +23,78 @@ * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:16 $ */ -public final class RequestWrapper { +public final class RequestWrapper extends MultipartRequestWrapper implements HttpServletRequest { /** * Return a wrapped request object */ - public static HttpServletRequest getServletRequest(HttpServletRequest request, - boolean saveUploadedFilesToDisk, - File uploadDirectory, - boolean allowOverwrite, - boolean silentlyRename, - int maxUploadSize) { - return request; + public static HttpServletRequest getServletRequest(HttpServletRequest request,int maxUpload) { + HttpServletRequest req = request; + String contentType = req.getContentType(); + + if (contentType == null) { + contentType = "application/x-www-form-urlencoded"; + } + + if (contentType.startsWith("multipart/form-data")) { + try { + req = new RequestWrapper(request,maxUpload); + + } catch (Exception e) { + req = request; + } + } + + return req; } /** * Implementation of the get method */ public static Object get(HttpServletRequest request, String name) { - String[] values = request.getParameterValues(name); + // FIXME We should get rid of this instanceof test + if (request instanceof RequestWrapper) { + return ((RequestWrapper) request).get(name); + } else { + String[] values = request.getParameterValues(name); + + if (values == null) return null; + + if (values.length == 1) { + return values[0]; + } + + if (values.length > 1) { + Vector vect = new Vector(values.length); + + for (int i = 0; i < values.length; i++) { + vect.add(values[i]); + } - if (values == null) return null; + return vect; + } + } + return null; + } + + public RequestWrapper(HttpServletRequest httpservletrequest, int maxUpload) + throws Exception { + super(httpservletrequest, maxUpload); + } - if (values.length == 1) { - return values[0]; + public Map getParameterMap() { + // FIXME: + return null; } - if (values.length > 1) { - Vector vect = new Vector(values.length); - for (int i = 0; i < values.length; i++) { - vect.add(values[i]); + public void setCharacterEncoding(String s) { + // FIXME: } - return vect; - } + + public StringBuffer getRequestURL() { + // FIXME: return null; } - } diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload22.java cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload22.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload22.java Thu Jan 31 12:40:01 2002 +++ cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload22.java Thu Jan 1 01:00:00 1970 @@ -1,93 +0,0 @@ -/***************************************************************************** - * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * - *****************************************************************************/ -package org.apache.cocoon.environment.http; - -import uk.co.weft.maybeupload.MaybeUploadRequestWrapper; - -import javax.servlet.http.HttpServletRequest; -import java.io.File; -import java.util.Vector; - -/** - * - * Implements the {@link javax.servlet.http.HttpServletRequest} interface - * to provide request information for HTTP servlets. - * - * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:16 $ - */ - -public final class RequestWrapper extends MaybeUploadRequestWrapper { - - /** - * Return a wrapped request object - */ - public static HttpServletRequest getServletRequest(HttpServletRequest request, - boolean saveUploadedFilesToDisk, - File uploadDirectory, - boolean allowOverwrite, - boolean silentlyRename, - int maxUploadSize) { - HttpServletRequest req = request; - String contentType = req.getContentType(); - - if (contentType == null) { - contentType = "application/x-www-form-urlencoded"; - } - - if (contentType.startsWith("multipart/form-data")) { - try { - req = new RequestWrapper(request, - saveUploadedFilesToDisk, - uploadDirectory, - allowOverwrite, - silentlyRename, - maxUploadSize); - } catch (Exception e) { - req = request; - } - } - - return req; - } - - public RequestWrapper(HttpServletRequest httpservletrequest, boolean flag1, File file, boolean flag2, boolean flag3, int size) - throws Exception { - super(httpservletrequest, flag1, file, flag2, flag3, size); - } - - /** - * Implementation of the get method - */ - public static Object get(HttpServletRequest request, String name) { - // FIXME We should get rid of this instanceof test - if (request instanceof RequestWrapper) { - return ((RequestWrapper) request).get(name); - } else { - String[] values = request.getParameterValues(name); - - if (values == null) return null; - - if (values.length == 1) { - return values[0]; - } - - if (values.length > 1) { - Vector vect = new Vector(values.length); - - for (int i = 0; i < values.length; i++) { - vect.add(values[i]); - } - - return vect; - } - } - return null; - } - -} diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload23.java cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload23.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload23.java Thu Jan 31 12:40:00 2002 +++ cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload23.java Thu Jan 1 01:00:00 1970 @@ -1,109 +0,0 @@ -/***************************************************************************** - * Copyright (C) The Apache Software Foundation. All rights reserved. * - * ------------------------------------------------------------------------- * - * This software is published under the terms of the Apache Software License * - * version 1.1, a copy of which has been included with this distribution in * - * the LICENSE file. * - *****************************************************************************/ -package org.apache.cocoon.environment.http; - -import uk.co.weft.maybeupload.MaybeUploadRequestWrapper; - -import javax.servlet.http.HttpServletRequest; -import java.io.File; -import java.util.Map; -import java.util.Vector; - -/** - * - * Implements the {@link javax.servlet.http.HttpServletRequest} interface - * to provide request information for HTTP servlets. - * - * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:16 $ - */ - -public final class RequestWrapper extends MaybeUploadRequestWrapper implements HttpServletRequest { - - /** - * Return a wrapped request object - */ - public static HttpServletRequest getServletRequest(HttpServletRequest request, - boolean saveUploadedFilesToDisk, - File uploadDirectory, - boolean allowOverwrite, - boolean silentlyRename, - int maxUploadSize) { - HttpServletRequest req = request; - String contentType = req.getContentType(); - - if (contentType == null) { - contentType = "application/x-www-form-urlencoded"; - } - - if (contentType.startsWith("multipart/form-data")) { - try { - req = new RequestWrapper(request, - saveUploadedFilesToDisk, - uploadDirectory, - allowOverwrite, - silentlyRename, - maxUploadSize); - } catch (Exception e) { - req = request; - } - } - - return req; - } - - /** - * Implementation of the get method - */ - public static Object get(HttpServletRequest request, String name) { - // FIXME We should get rid of this instanceof test - if (request instanceof RequestWrapper) { - return ((RequestWrapper) request).get(name); - } else { - String[] values = request.getParameterValues(name); - - if (values == null) return null; - - if (values.length == 1) { - return values[0]; - } - - if (values.length > 1) { - Vector vect = new Vector(values.length); - - for (int i = 0; i < values.length; i++) { - vect.add(values[i]); - } - - return vect; - } - } - return null; - } - - public RequestWrapper(HttpServletRequest httpservletrequest, boolean flag1, File file, boolean flag2, boolean flag3, int size) - throws Exception { - super(httpservletrequest, flag1, file, flag2, flag3, size); - } - - public Map getParameterMap() { - // FIXME: - return null; - } - - - public void setCharacterEncoding(String s) { - // FIXME: - } - - - public StringBuffer getRequestURL() { - // FIXME: - return null; - } -} diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/multipart/FilePart.java cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/multipart/FilePart.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/multipart/FilePart.java Thu Jan 1 01:00:00 1970 +++ cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/multipart/FilePart.java Fri Feb 22 18:47:55 2002 @@ -0,0 +1,60 @@ +package org.apache.cocoon.environment.http.multipart; +import java.io.File; +import java.io.InputStream; +import java.util.Map; + +/** + * This class represents a file part parsed from a http post stream. + * + * @author Jeroen ter Voorde + */ + +public class FilePart { + + private InputStream in=null; + private Map headers; + + protected FilePart(Map headers, InputStream in) { + this.headers=headers; + this.in=in; + } + + /** + * Returns the part headers + */ + public Map getHeaders() { + return headers; + } + + /** + * Returns the filename + */ + public String getFileName() { + File f=new File((String)headers.get("filename")); + return f.getName(); + } + + /** + * Returns the filepath + */ + public String getFilePath() { + return (String)headers.get("filename"); + + } + + /** + * Returns the mime type (or null if unknown) + */ + public String getMimeType() { + return (String)headers.get("content-type"); + } + + /** + * Returns a (ByteArray)InputStream containing the file data + */ + public InputStream getInputStream() { + return in; + } + +} + diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/multipart/MultipartException.java cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/multipart/MultipartException.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/multipart/MultipartException.java Thu Jan 1 01:00:00 1970 +++ cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/multipart/MultipartException.java Fri Feb 22 18:48:15 2002 @@ -0,0 +1,20 @@ +package org.apache.cocoon.environment.http.multipart; + +/** + * Exception thrown when on a parse error such as + * a malformed stream. + * + * @author Jeroen ter Voorde + */ +public class MultipartException extends Exception { + + public MultipartException() { + super(); + } + + public MultipartException(String text) { + super(text); + } + +} + diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/multipart/MultipartParser.java cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/multipart/MultipartParser.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/multipart/MultipartParser.java Thu Jan 1 01:00:00 1970 +++ cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/multipart/MultipartParser.java Fri Feb 22 18:49:13 2002 @@ -0,0 +1,457 @@ +package org.apache.cocoon.environment.http.multipart; + +import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.PushbackInputStream; +import java.util.Hashtable; +import java.util.Map; +import java.util.StringTokenizer; +import java.util.Vector; + +/** + Utility class for MultipartParser. Divides the inputstream into parts + separated by a given boundary. + + A newline is espected after each boundary and is parsed away. +*/ +class TokenStream extends PushbackInputStream { + + private static final int MAX_BOUNDARY_SIZE = 128; + + /** + * Initial state, no boundary has been set. + */ + public static final int STATE_NOBOUNDARY = -1; + + /** + * Fully read a part, now at the beginning of a new part + */ + public static final int STATE_NEXTPART = -2; + + /** + * Read last boundary, end of multipart block + */ + public static final int STATE_ENDMULTIPART = -3; + + /** + * End of stream, this should not happen + */ + public static final int STATE_ENDOFSTREAM = -4; + + /** + * Currently reading a part + */ + public static final int STATE_READING = -5; + + private PushbackInputStream in = null; + private byte[] boundary = null; + private int state = STATE_NOBOUNDARY; + + /** + * Creates a new pushback token stream from in. + * + * @param in The input stream + * @param pushbackSize Size (in bytes) of the pushback buffer + */ + public TokenStream(InputStream in, int pushbackSize) { + super(in, pushbackSize); + if (BufferedInputStream.class.isAssignableFrom(in.getClass())) { + this.in = new PushbackInputStream((BufferedInputStream) in, MAX_BOUNDARY_SIZE); + } + else { + this.in = new PushbackInputStream(new BufferedInputStream(in), MAX_BOUNDARY_SIZE); + } + } + + /** + * Creates a new pushback token stream from in with pushback buffer size 1. + * + * @param in The input stream + */ + public TokenStream(InputStream in) { + this(in, 1); + } + + /** + * Sets the boundary to scan for + * + * @param boundary A byte array containg the boundary + */ + public void setBoundary(byte[] boundary) throws MultipartException { + if (boundary.length > MAX_BOUNDARY_SIZE) + throw new MultipartException("Too many bytes in boundary"); + this.boundary = boundary; + state = STATE_READING; + } + + /** + * Start reading the next part in the stream. This method may only be called + * if state is STATE_NEXTPART. It will throw a MultipartException if not. + */ + public void nextPart() throws MultipartException { + if (state != STATE_NEXTPART) + throw new MultipartException("Illegal state"); + + state = STATE_READING; + } + + /** + * Return the stream state + */ + public int getState() { + return state; + } + + /** + * Fill the ouput buffer until either it's full, the boundary has been reached or + * the end of the inputstream has been reached. + * When a boundary is reached it is entirely read away including trailing \r's and \n's. + * It will not be written to the output buffer. + * The stream state is updated after each call. + * + * @param out The output buffer + */ + private int readToBoundary(byte[] out) throws IOException { + + if (state != STATE_READING) { + return 0; + } + + int boundaryIndex = 0; + int read = 0; + int written = 0; + int b = in.read(); + + while (true) { + boundaryIndex = 0; + while ((boundaryIndex < boundary.length) && ((byte) b == boundary[boundaryIndex])) { + b = in.read(); + boundaryIndex++; + } + + if (boundaryIndex == boundary.length) { // reached boundary + if (b != -1) { + if (b == '\r' || b == '\n') { // newline, another part follows + state = STATE_NEXTPART; + if (b == '\r') { + b = in.read(); + if (b != '\n') + in.unread(b); + } + } + else if (b == '-') { // hyphen, end of multipart + state = STATE_ENDMULTIPART; + b = in.read(); // read next hyphen + b = in.read(); // read \r or \n + if (b == '\r') { + b = in.read(); // read \n or next input + if (b != '\n') + in.unread(b); + } + } + else // something else, error + throw new IOException("Unexpected character after boundary"); + + } + else { //nothing after boundary, this shouldn't happen either + state = STATE_ENDOFSTREAM; + } + return written; + } + else { // no boundary reached + if (boundaryIndex == 0) { // no bytes skipped due to boundary + if (b != -1) { + out[written++] = (byte) b; + } + } + else { // bytes skipped, write first skipped byte, push back the rest + out[written++] = boundary[0]; + + if (b != -1) { + in.unread(b); // the non-matching byte + } + in.unread(boundary, 1, boundaryIndex - 1); // and unread skipped boundary data + + } + if (b == -1) { + state = STATE_ENDOFSTREAM; + return written; + } + else { + if (written == out.length) + return written; + } + } + b = in.read(); + } + } + + /** + * @see java.io.InputStream#read(byte[]) + */ + public int read(byte[] out) throws IOException { + if (state != STATE_READING) + return 0; + return readToBoundary(out); + + } + + /** + * @see java.io.InputStream#read(byte[],int,int) + */ + public int read(byte[] out, int off, int len) throws IOException { + + if (off < 0 ||off >= out.length) + throw new IOException("Buffer offset outside buffer"); + if (off + len >= out.length) + throw new IOException("Buffer end outside buffer"); + if (len<0) + throw new IOException("Length must be a positive integer"); + + byte[] buf = new byte[len]; + int read = read(buf); + if (read > 0) { + System.arraycopy(buf, 0, out, off, read); + } + return read; + } + + /** + * @see java.io.InputStream#read() + */ + public int read() throws IOException { + byte[] buf = new byte[1]; + int read = read(buf); + if (read == 0) { + return -1; + } + else { + return (int) buf[0]; + } + } + +} + +/** + * This class is used to implement a multipart request wrapper. + * It will parse the http post stream and return a hashtable containing the values. + * + * The map may contain: + * Vector: inline part values + * FilePart: file part + * + * @author Jeroen ter Voorde + */ + +public class MultipartParser { + + private final static int FILE_BUFFER_SIZE=4096; + private final static int INLINE_BUFFER_SIZE=256; + + /** + * Return map containing values from stream + * + * @param inStream Http post stream + * @param contentHeader Header line containing part boundary + * @return A map containing Vectors and FileParts + */ + public static Hashtable parse(InputStream inStream, String contentHeader) throws IOException, MultipartException { + + Hashtable values = new Hashtable(); + + parseMultiPart(new TokenStream(inStream), values, getBoundary(contentHeader)); + + return values; + } + + /** + * Parse a multipart block + */ + private static void parseMultiPart(TokenStream ts, Hashtable values, String boundary) throws IOException, MultipartException { + + ts.setBoundary(boundary.getBytes()); + ts.read(); // read first boundary away + + while (ts.getState() == TokenStream.STATE_NEXTPART) { + ts.nextPart(); + parsePart(ts, values); + } + + if (ts.getState() != TokenStream.STATE_ENDMULTIPART) + throw new MultipartException("Malformed stream"); + + } + + /** + * Parse a single part + */ + private static void parsePart(TokenStream ts, Hashtable values) throws IOException, MultipartException { + Hashtable headers = new Hashtable(); + + headers = readHeaders(ts); + try { + if (headers.containsKey("filename")) { + parseFilePart(ts, values, headers); + } + else if (((String) headers.get("content-disposition")).toLowerCase().equals("form-data")) { + parseInlinePart(ts, values, headers); + } + else if (((String) headers.get("content-disposition")).toLowerCase().indexOf("multipart")>-1) { + parseMultiPart(ts, values, "--" + (String) headers.get("boundary")); + } + else { + throw new MultipartException("Unknown part type"); + } + } + catch (IOException e) { + throw new MultipartException("Malformed stream: "+e.getMessage()); + } + catch (NullPointerException e) { + throw new MultipartException("Malformed header"); + } + + } + + /** + * Parse a file part + */ + private static void parseFilePart(TokenStream in, Hashtable values, Hashtable headers) throws IOException { + byte[] buf = new byte[FILE_BUFFER_SIZE]; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + while (in.getState() == TokenStream.STATE_READING) { // read data + int read = in.read(buf); + out.write(buf, 0, read); + } + + // trim trailing newline + byte[] bytes = out.toByteArray(); + if (bytes[bytes.length - 2] == '\r') + values.put(headers.get("name"), new FilePart(headers, new ByteArrayInputStream(bytes, 0, bytes.length - 2))); + else + values.put(headers.get("name"), new FilePart(headers, new ByteArrayInputStream(bytes, 0, bytes.length - 1))); + } + + /** + * Parse an inline part + */ + private static void parseInlinePart(TokenStream in, Hashtable values, Hashtable headers) throws IOException { + byte[] buf = new byte[INLINE_BUFFER_SIZE]; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + while (in.getState() == TokenStream.STATE_READING) { + int read = in.read(buf); + out.write(buf, 0, read); + } + + String field = (String) headers.get("name"); + + Vector v = (Vector) values.get(field); + if (v == null) { + v = new Vector(); + values.put(field, v); + } + + // trim trailing newline and add value + byte[] bytes = out.toByteArray(); + if (bytes[bytes.length - 2] == '\r') + v.add(new String(bytes, 0, bytes.length - 2)); + else + v.add(new String(bytes, 0, bytes.length - 1)); + + } + + /** + * Read part headers + */ + private static Hashtable readHeaders(TokenStream in) throws IOException { + Hashtable headers = new Hashtable(); + String hdrline = readln(in); + while (!"".equals(hdrline)) { + StringTokenizer tokenizer = new StringTokenizer(hdrline); + + headers.put(tokenizer.nextToken(" :").toLowerCase(), tokenizer.nextToken(" :;")); + while (tokenizer.hasMoreTokens()) { + headers.put(tokenizer.nextToken(" ;=\""), tokenizer.nextToken("=\"")); + } + + hdrline = readln(in); + } + return headers; + + } + + /** + * Get boundary from contentheader + */ + private static String getBoundary(String hdr) { + int start = hdr.toLowerCase().indexOf("boundary="); + if (start > -1) + return "--" + hdr.substring(start + 9); + else + return null; + } + + /** + * Read string until newline or end of stream + */ + private static String readln(TokenStream in) throws IOException { + StringBuffer out = new StringBuffer(); + + int b = in.read(); + while (b != -1) { + if (b == '\r' || b == '\n') { + + if (b == '\r') { + b = in.read(); + if (b != '\n') + in.unread(b); + } + return out.toString(); + } + else { + out.append((char) b); + + } + b = in.read(); + } + return out.toString(); + } + + + public static void main(String args[]) { + try { + + java.io.FileInputStream in = new java.io.FileInputStream("C:\\eclipse\\workspace\\multipartparser\\out.txt"); + +// Map results = MultipartParser.parse(in, "boundary=---------------------------7d03521f748"); + Hashtable results = MultipartParser.parse(in, "boundary=---------------------------7d22e4b6a4"); + + InputStream in2 = ((FilePart)results.get("MYFILE")).getInputStream(); + java.io.FileOutputStream out=new java.io.FileOutputStream("C:\\"+((FilePart)results.get("MYFILE")).getFileName()); + byte[] buf=new byte[4096]; + int read=4096; + read=in2.read(buf); + while(read>0) { + out.write(buf,0,read); + read=in2.read(buf); + } + + in2.close(); + out.close(); + + in.close(); + + System.out.println(results.size()); + + } + catch (Exception e) { + System.out.println(e); + } + + } + + +} diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/multipart/MultipartRequestWrapper.java cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/multipart/MultipartRequestWrapper.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/environment/http/multipart/MultipartRequestWrapper.java Thu Jan 1 01:00:00 1970 +++ cocoon-2.0.1/src/java/org/apache/cocoon/environment/http/multipart/MultipartRequestWrapper.java Fri Feb 22 17:26:52 2002 @@ -0,0 +1,290 @@ +package org.apache.cocoon.environment.http.multipart; + +import java.io.BufferedReader; +import java.io.IOException; +import java.security.Principal; +import java.util.Enumeration; +import java.util.Hashtable; +import java.util.Locale; +import java.util.Vector; + +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletRequest; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; + +import org.apache.cocoon.environment.http.multipart.*; + +public class MultipartRequestWrapper implements ServletRequest, HttpServletRequest { + + private final String CONTENTHEADER = "multipart/form-data"; + + private HttpServletRequest request=null; + private boolean isMultipart = false; + private Hashtable values = null; + + public MultipartRequestWrapper(HttpServletRequest request,int maxUpload) throws IllegalArgumentException, IOException, MultipartException { + + this.request = request; + String contentType = request.getContentType(); + + if (request.getContentLength()>maxUpload) + throw new IOException("Uploaded file is too big"); + + if (contentType != null && contentType.toLowerCase().indexOf(CONTENTHEADER) > -1) { + values = MultipartParser.parse(request.getInputStream(), request.getContentType()); + } + } + + public Object get(String name) { + Object result = null; + + if (values!=null) { + result = values.get(name); + if (result instanceof Vector) { + if (((Vector)result).size()==1) { + return ((Vector)result).elementAt(0); + } else { + return result; + } + } + } + else { + + String[] array = request.getParameterValues(name); + Vector vec = new Vector(); + + if (array != null) { + for (int i = 0; i < array.length; i++) + vec.addElement(array[i]); + + if (vec.size() == 1) + result = vec.elementAt(0); + else + result = vec; + } + } + return result; + } + + public Enumeration getParameterNames() { + if (values!=null) + return values.keys(); + else + return request.getParameterNames(); + } + + public String getParameter(String name) { + Object value = get(name); + String result = null; + + if (value != null) { + if (value instanceof Vector) + value = ((Vector) value).elementAt(0); + + result = value.toString(); + } + + return result; + } + + public String[] getParameterValues(String name) { + if (values!=null) { + Object value = get(name); + + if (value != null) { + if (value instanceof Vector) + return (String[])((Vector)value).toArray(); + else + return new String[] { value.toString() }; + } + return null; + } + else { + return request.getParameterValues(name); + } + } + + public HttpServletRequest getRequest() { + return request; + } + + public Object getAttribute(String name) { + return request.getAttribute(name); + } + + public Enumeration getAttributeNames() { + return request.getAttributeNames(); + } + + public String getCharacterEncoding() { + return request.getCharacterEncoding(); + } + + public int getContentLength() { + return request.getContentLength(); + } + + public String getContentType() { + return request.getContentType(); + } + + public ServletInputStream getInputStream() throws IOException { + return request.getInputStream(); + } + + public String getProtocol() { + return request.getProtocol(); + } + + public String getScheme() { + return request.getScheme(); + } + + public String getServerName() { + return request.getServerName(); + } + + public int getServerPort() { + return request.getServerPort(); + } + + public BufferedReader getReader() throws IOException { + return request.getReader(); + } + + public String getRemoteAddr() { + return request.getRemoteAddr(); + } + + public String getRemoteHost() { + return request.getRemoteHost(); + } + + public void setAttribute(String name, Object o) { + request.setAttribute(name, o); + } + + public void removeAttribute(String name) { + request.removeAttribute(name); + } + + public Locale getLocale() { + return request.getLocale(); + } + + public Enumeration getLocales() { + return request.getLocales(); + } + + public boolean isSecure() { + return request.isSecure(); + } + + public RequestDispatcher getRequestDispatcher(String path) { + return request.getRequestDispatcher(path); + } + + public String getRealPath(String path) { + return request.getRealPath(path); + } + + public String getAuthType() { + return request.getAuthType(); + } + + public Cookie[] getCookies() { + return request.getCookies(); + } + + public long getDateHeader(String name) { + return request.getDateHeader(name); + } + + public String getHeader(String name) { + return request.getHeader(name); + } + + public Enumeration getHeaders(String name) { + return request.getHeaders(name); + } + + public Enumeration getHeaderNames() { + return request.getHeaderNames(); + } + + public int getIntHeader(String name) { + return request.getIntHeader(name); + } + + public String getMethod() { + return request.getMethod(); + } + + public String getPathInfo() { + return request.getPathInfo(); + } + + public String getPathTranslated() { + return request.getPathTranslated(); + } + + public String getContextPath() { + return request.getContextPath(); + } + + public String getQueryString() { + return request.getQueryString(); + } + + public String getRemoteUser() { + return request.getRemoteUser(); + } + + public boolean isUserInRole(String role) { + return request.isUserInRole(role); + } + + public Principal getUserPrincipal() { + return request.getUserPrincipal(); + } + + public String getRequestedSessionId() { + return request.getRequestedSessionId(); + } + + public String getRequestURI() { + return request.getRequestURI(); + } + + public String getServletPath() { + return request.getServletPath(); + } + + public HttpSession getSession(boolean create) { + return request.getSession(create); + } + + public HttpSession getSession() { + return request.getSession(); + } + + public boolean isRequestedSessionIdValid() { + return request.isRequestedSessionIdValid(); + } + + public boolean isRequestedSessionIdFromCookie() { + return request.isRequestedSessionIdFromCookie(); + } + + public boolean isRequestedSessionIdFromURL() { + return request.isRequestedSessionIdFromURL(); + } + + public boolean isRequestedSessionIdFromUrl() { + return request.isRequestedSessionIdFromURL(); + } + +} diff -Naur cocoon-2.0.1-orig/src/java/org/apache/cocoon/servlet/CocoonServlet.java cocoon-2.0.1/src/java/org/apache/cocoon/servlet/CocoonServlet.java --- cocoon-2.0.1-orig/src/java/org/apache/cocoon/servlet/CocoonServlet.java Thu Jan 31 12:40:03 2002 +++ cocoon-2.0.1/src/java/org/apache/cocoon/servlet/CocoonServlet.java Fri Feb 22 17:23:52 2002 @@ -94,12 +94,8 @@ protected boolean showTime; protected boolean hiddenShowTime; - private static final boolean ALLOW_OVERWRITE = false; - private static final boolean SILENTLY_RENAME = true; - private static final boolean SAVE_UPLOADED_FILES_TO_DISK = true; private static final int MAX_UPLOAD_SIZE = 10000000; // 10Mb private int maxUploadSize = MAX_UPLOAD_SIZE; // 10Mb - private File uploadDir; private File workDir; private File cacheDir; @@ -225,27 +221,6 @@ } this.appContext.put(Constants.CONTEXT_WORK_DIR, workDir); - final String uploadDirParam = conf.getInitParameter("upload-directory"); - if ((uploadDirParam != null) && (!uploadDirParam.trim().equals(""))) { - if (this.servletContextPath == null) { - this.uploadDir = new File(uploadDirParam); - } else { - this.uploadDir = IOUtils.createFile( new File(servletContextPath) , uploadDirParam); - } - this.uploadDir.mkdirs(); - if (log.isDebugEnabled()) { - log.debug("using upload-directory " + this.uploadDir); - } - } else { - this.uploadDir = IOUtils.createFile(workDir, "upload-dir" + File.separator); - if (log.isDebugEnabled()) { - log.debug("upload-directory was not set - defaulting to " + this.uploadDir); - } - } - - this.appContext.put(Constants.CONTEXT_UPLOAD_DIR, this.uploadDir); - this.uploadDir.mkdirs(); - String maxSizeParam = conf.getInitParameter("upload-max-size"); if ((maxSizeParam != null) && (!maxSizeParam.trim().equals(""))) { this.maxUploadSize = Integer.parseInt(maxSizeParam); @@ -254,7 +229,7 @@ String cacheDirParam = conf.getInitParameter("cache-directory"); if ((cacheDirParam != null) && (!cacheDirParam.trim().equals(""))) { if (this.servletContextPath == null) { - this.cacheDir = new File(uploadDirParam); + this.cacheDir = new File(cacheDirParam); } else { this.cacheDir = IOUtils.createFile( new File(servletContextPath) , cacheDirParam); } @@ -720,12 +695,7 @@ // This is more scalable long start = System.currentTimeMillis(); - HttpServletRequest request = RequestWrapper.getServletRequest(req, - CocoonServlet.SAVE_UPLOADED_FILES_TO_DISK, - this.uploadDir, - CocoonServlet.ALLOW_OVERWRITE, - CocoonServlet.SILENTLY_RENAME, - this.maxUploadSize); + HttpServletRequest request = RequestWrapper.getServletRequest(req,this.maxUploadSize); this.cocoon = getCocoon(request.getPathInfo(), request.getParameter(Constants.RELOAD_PARAM)); diff -Naur cocoon-2.0.1-orig/src/webapp/docs/samples/xsp/upload.xsp cocoon-2.0.1/src/webapp/docs/samples/xsp/upload.xsp --- cocoon-2.0.1-orig/src/webapp/docs/samples/xsp/upload.xsp Thu Jan 31 12:40:10 2002 +++ cocoon-2.0.1/src/webapp/docs/samples/xsp/upload.xsp Fri Feb 22 18:33:48 2002 @@ -13,10 +13,8 @@ </xsp:structure> <xsp:logic> - File uploadDir = null; /** Contextualize this class */ public void contextualize(Context context) throws ContextException { - uploadDir = (File) context.get(Constants.CONTEXT_UPLOAD_DIR); } </xsp:logic> @@ -26,27 +24,8 @@ <para> <form method="post" enctype="multipart/form-data" action="upload"> File: <input type="file" name="uploaded_file" size="50" /> - <p><input type="submit" value="Upload File" /></p> + <p><input type="submit" name="cocoon-action" value="Upload" /></p> </form> - </para> - <para> - <ul> - <xsp:logic> - getLogger().debug("Dir=" + uploadDir); - String[] filelist = uploadDir.list(); - <![CDATA[ - getLogger().debug("List=" + filelist.length); - for (int i = 0; i < filelist.length; i++) { - getLogger().debug("File [" + i + "]=" + filelist[i]); - ]]> - <li> - <xsp:expr>filelist[i]</xsp:expr> - </li> - <![CDATA[ - } - ]]> - </xsp:logic> - </ul> </para> <para>Brought to you by Cocoon at <xsp:expr>new Date()</xsp:expr>.</para> diff -Naur cocoon-2.0.1-orig/src/webapp/sitemap.xmap cocoon-2.0.1/src/webapp/sitemap.xmap --- cocoon-2.0.1-orig/src/webapp/sitemap.xmap Thu Jan 31 12:40:12 2002 +++ cocoon-2.0.1/src/webapp/sitemap.xmap Fri Feb 22 18:59:18 2002 @@ -76,7 +76,18 @@ <map:generator name="extractor" logger="sitemap.generator.extractor" label="data" src="org.apache.cocoon.generation.FragmentExtractorGenerator"/> - </map:generators> + <map:generator name="velocity" src="org.apache.cocoon.generation.VelocityGenerator" logger="sitemap.generator.velocity" label="content,data"/> +<map:generator name="jsp" src="org.apache.cocoon.generation.JspGenerator" logger="sitemap.generator.jsp" label="content,data"/> +<map:generator name="stream" src="org.apache.cocoon.generation.StreamGenerator" logger="sitemap.generator.stream" label="content,data"/> +<map:generator name="html" src="org.apache.cocoon.generation.HTMLGenerator" logger="sitemap.generator.html" label="content"/> +<map:generator name="xmldb" src="org.apache.cocoon.generation.XMLDBGenerator" logger="sitemap.generator.xmldb"> +<driver>org.dbxml.client.xmldb.DatabaseImpl</driver><base>xmldb:dbxml:///db/</base> +</map:generator> +<map:generator name="xmldbcollection" src="org.apache.cocoon.generation.XMLDBCollectionGenerator" logger="sitemap.generator.xmldbcollection"> +<driver>org.dbxml.client.xmldb.DatabaseImpl</driver><base>xmldb:dbxml:///db/</base> +</map:generator> +<map:generator name="script" src="org.apache.cocoon.generation.ScriptGenerator" logger="sitemap.generator.script" label="content,data"/> +</map:generators> <!-- @@ -128,7 +139,8 @@ <map:transformer name="readDOMsession" logger="sitemap.transformer.readDOMsession" src="org.apache.cocoon.transformation.ReadDOMSessionTransformer"/> - </map:transformers> + <map:transformer name="xt" src="org.apache.cocoon.transformation.XTTransformer" logger="sitemap.transformer.xt"/> +</map:transformers> <!-- Readers are an exception to the above rule that a pipline need to @@ -182,7 +194,12 @@ <map:serializer name="text" mime-type="text/text" logger="sitemap.serializer.text" src="org.apache.cocoon.serialization.TextSerializer"/> - </map:serializers> + <map:serializer name="fo2pdf" src="org.apache.cocoon.serialization.FOPSerializer" logger="sitemap.serializer.fo2pdf" mime-type="application/pdf"/> +<map:serializer name="fo2ps" src="org.apache.cocoon.serialization.FOPSerializer" logger="sitemap.serializer.fo2ps" mime-type="application/postscript"/> +<map:serializer name="fo2pcl" src="org.apache.cocoon.serialization.FOPSerializer" logger="sitemap.serializer.fo2pcl" mime-type="application/vnd.hp-PCL"/> +<map:serializer name="svg2jpeg" src="org.apache.cocoon.serialization.SVGSerializer" logger="sitemap.serializer.svg2jpeg" mime-type="image/jpeg"/> +<map:serializer name="svg2png" src="org.apache.cocoon.serialization.SVGSerializer" logger="sitemap.serializer.svg2png" mime-type="image/png"/> +</map:serializers> <!-- @@ -334,6 +351,9 @@ <map:action name="resource-exists" logger="sitemap.action.resource-exists" src="org.apache.cocoon.acting.ResourceExistsAction"/> + <map:action name="file-upload" logger="sitemap.action.file-upload" + src="org.apache.cocoon.acting.UploadAction"/> + </map:actions> </map:components> @@ -928,7 +948,11 @@ </map:match> <!-- =========================== Dynamic ================================ --> + <map:match pattern="xsp/*"> + <map:act type="file-upload"> + <map:parameter name="upload-dir" value="incoming" /> + </map:act> <map:generate type="serverpages" src="docs/samples/xsp/{1}.xsp"/> <map:transform src="stylesheets/dynamic-page2html.xsl"> <map:parameter name="view-source" value="docs/samples/xsp/{1}.xsp"/> @@ -948,6 +972,7 @@ <map:generate type="serverpages" src="docs/samples/xsp/{1}.xsp"/> <map:serialize/> </map:match> + <map:match pattern="sql/*"> <map:generate src="docs/samples/sql/{1}.xml"/>
--- cocoon-2.0.1-orig/build.xml Thu Jan 31 12:40:22 2002 +++ cocoon-2.0.1/build.xml Fri Feb 22 15:42:20 2002 @@ -375,10 +375,6 @@ classname="org.w3c.tidy.Tidy"/> <class-available classpathref="classpath" - property="maybeupload.present" - classname="uk.co.weft.maybeupload.MaybeUploadRequestWrapper"/> - - <class-available classpathref="classpath" property="lucene.present" classname="org.apache.lucene.search.Searcher"/> @@ -510,16 +506,6 @@ value="JTidy is required for the html generator."/> </antcall> </target> - <target name="maybeupload-warn" unless="maybeupload.present" depends="optional-tests" - description="Outputs a warning if uk.co.weft.maybeupload.* classes are missing during compilation"> - <antcall target="op-warning"> - <param name="thing" value="MaybeUpload"/> - <param name="recovery" - value="Get MaybeUpload from http://www.weft.co.uk/library/maybeupload/ and place the jar in the lib/optional dir"/> - <param name="message" - value="MaybeUpload simplifies the handling of uploaded files."/> - </antcall> - </target> <target name="lucene-warn" unless="lucene.present" depends="optional-tests" description="Outputs a warning if org.apache.lucene.* classes are missing during compilation"> <antcall target="op-warning"> @@ -575,7 +561,7 @@ <!-- Print out warnings for optional components --> <!-- =================================================================== --> <target name="optional-warnings" - depends="bsf-warn, jfor-warn, xmldb-warn, xt-warn, php-warn, naming-warn, svg-warn, fop-warn, tidy-warn, maybeupload-warn, lucene-warn, deli-warn, velocity-warn, hsqldb-warn, resolver-warn" + depends="bsf-warn, jfor-warn, xmldb-warn, xt-warn, php-warn, naming-warn, svg-warn, fop-warn, tidy-warn, lucene-warn, deli-warn, velocity-warn, hsqldb-warn, resolver-warn" description="Outputs warnings if some optional jars are missing from the environment"> </target> @@ -684,16 +670,6 @@ </target> <!-- =================================================================== --> - <!-- Prepares the servlet 2.3 source code if maybeupload is present --> - <!-- =================================================================== --> - <target name="prepare-src-23-maybeupload" if="servlet23.present, maybeupload.present"> - <copy file="${java.dir}/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload23.java" - tofile="${build.src}/org/apache/cocoon/environment/http/RequestWrapper.java" - filtering="on" - overwrite="true"/> - </target> - - <!-- =================================================================== --> <!-- Prepares the servlet 2.3 source code --> <!-- =================================================================== --> <target name="prepare-src-23" if="servlet23.present" unless="maybeupload.present"> @@ -704,16 +680,6 @@ </target> <!-- =================================================================== --> - <!-- Prepares the servlet 2.2 source code if maybeupload is present --> - <!-- =================================================================== --> - <target name="prepare-src-22-maybeupload" unless="servlet23.present" if="maybeupload.present"> - <copy file="${java.dir}/org/apache/cocoon/environment/http/RequestWrapperMaybeUpload22.java" - tofile="${build.src}/org/apache/cocoon/environment/http/RequestWrapper.java" - filtering="on" - overwrite="true"/> - </target> - - <!-- =================================================================== --> <!-- Prepares the servlet 2.2 source code --> <!-- =================================================================== --> <target name="prepare-src-22" unless="servlet23.present, maybeupload.present"> @@ -727,9 +693,7 @@ <!-- =================================================================== --> <target name="prepare-src-servlet" depends="prepare-src-main" if="servlet.present"> <antcall target="prepare-src-22"/> - <antcall target="prepare-src-22-maybeupload"/> <antcall target="prepare-src-23"/> - <antcall target="prepare-src-23-maybeupload"/> </target> <!-- =================================================================== -->
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]