You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2014/02/07 15:50:53 UTC

[1/3] WICKET-5503 Remove local copies of Commons FileUpload files and use Maven dependency

Updated Branches:
  refs/heads/master 7cd01f71c -> 99fcd91fe


http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/MultipartFormInputStream.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/MultipartFormInputStream.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/MultipartFormInputStream.java
deleted file mode 100644
index 1602715..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/MultipartFormInputStream.java
+++ /dev/null
@@ -1,1192 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.wicket.util.io.Streams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * <p>
- * Low level API for processing file uploads.
- * 
- * <p>
- * This class can be used to process data streams conforming to MIME 'multipart' format as defined
- * in <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Arbitrarily large amounts of data
- * in the stream can be processed under constant memory usage.
- * 
- * <p>
- * The format of the stream is defined in the following way:<br>
- * 
- * <code>
- *   multipart-body := preamble 1*encapsulation close-delimiter epilogue<br>
- *   encapsulation := delimiter body CRLF<br>
- *   delimiter := "--" boundary CRLF<br>
- *   close-delimiter := "--" boudary "--"<br>
- *   preamble := &lt;ignore&gt;<br>
- *   epilogue := &lt;ignore&gt;<br>
- *   body := header-part CRLF body-part<br>
- *   header-part := 1*header CRLF<br>
- *   header := header-name ":" header-value<br>
- *   header-name := &lt;printable ascii characters except ":"&gt;<br>
- *   header-value := &lt;any ascii characters except CR & LF&gt;<br>
- *   body-data := &lt;arbitrary data&gt;<br>
- * </code>
- * 
- * <p>
- * Note that body-data can contain another mulipart entity. There is limited support for single pass
- * processing of such nested streams. The nested stream is <strong>required</strong> to have a
- * boundary token of the same length as the parent stream (see {@link #setBoundary(byte[])}).
- * 
- * <p>
- * Here is an example of usage of this class.<br>
- * 
- * <pre>
- *      try {
- *          MultipartStream multipartStream = new MultipartStream(input,
- *                                                                boundary);
- *        boolean nextPart = multipartStream.skipPreamble();
- *          OutputStream output;
- *          while(nextPart) {
- *              header = chunks.readHeader();
- *              // process headers
- *              // create some output stream
- *              multipartStream.readBodyPart(output);
- *              nextPart = multipartStream.readBoundary();
- *          }
- *      } catch(MultipartStream.MalformedStreamException e) {
- *            // the stream failed to follow required syntax
- *      } catch(IOException) {
- *            // a read or write error occurred
- *      }
- * 
- * </pre>
- * 
- * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- * @author Sean C. Sullivan
- * 
- */
-public class MultipartFormInputStream
-{
-	/** Log. */
-	private static final Logger log = LoggerFactory.getLogger(MultipartFormInputStream.class);
-
-	/**
-	 * Internal class, which is used to invoke the {@link ProgressListener}.
-	 */
-	static class ProgressNotifier
-	{
-		/**
-		 * The listener to invoke.
-		 */
-		private final ProgressListener listener;
-		/**
-		 * Number of expected bytes, if known, or -1.
-		 */
-		private final long contentLength;
-		/**
-		 * Number of bytes, which have been read so far.
-		 */
-		private long bytesRead;
-		/**
-		 * Number of items, which have been read so far.
-		 */
-		private int items;
-
-		/**
-		 * Creates a new instance with the given listener and content length.
-		 * 
-		 * @param pListener
-		 *            The listener to invoke.
-		 * @param pContentLength
-		 *            The expected content length.
-		 */
-		ProgressNotifier(final ProgressListener pListener, final long pContentLength)
-		{
-			listener = pListener;
-			contentLength = pContentLength;
-		}
-
-		/**
-		 * Called to indicate that bytes have been read.
-		 * 
-		 * @param pBytes
-		 *            Number of bytes, which have been read.
-		 */
-		void noteBytesRead(final int pBytes)
-		{
-			/*
-			 * Indicates, that the given number of bytes have been read from the input stream.
-			 */
-			bytesRead += pBytes;
-			notifyListener();
-		}
-
-		/**
-		 * Called to indicate, that a new file item has been detected.
-		 */
-		void noteItem()
-		{
-			++items;
-		}
-
-		/**
-		 * Called for notifying the listener.
-		 */
-		private void notifyListener()
-		{
-			if (listener != null)
-			{
-				listener.update(bytesRead, contentLength, items);
-			}
-		}
-	}
-
-	// ----------------------------------------------------- Manifest constants
-
-
-	/**
-	 * The Carriage Return ASCII character value.
-	 */
-	public static final byte CR = 0x0D;
-
-
-	/**
-	 * The Line Feed ASCII character value.
-	 */
-	public static final byte LF = 0x0A;
-
-
-	/**
-	 * The dash (-) ASCII character value.
-	 */
-	public static final byte DASH = 0x2D;
-
-
-	/**
-	 * The maximum length of <code>header-part</code> that will be processed (10 kilobytes = 10240
-	 * bytes.).
-	 */
-	public static final int HEADER_PART_SIZE_MAX = 10240;
-
-
-	/**
-	 * The default length of the buffer used for processing a request.
-	 */
-	protected static final int DEFAULT_BUFSIZE = 4096;
-
-
-	/**
-	 * A byte sequence that marks the end of <code>header-part</code> (<code>CRLFCRLF</code>).
-	 */
-	protected static final byte[] HEADER_SEPARATOR = { CR, LF, CR, LF };
-
-
-	/**
-	 * A byte sequence that that follows a delimiter that will be followed by an encapsulation (
-	 * <code>CRLF</code>).
-	 */
-	protected static final byte[] FIELD_SEPARATOR = { CR, LF };
-
-
-	/**
-	 * A byte sequence that that follows a delimiter of the last encapsulation in the stream (
-	 * <code>--</code>).
-	 */
-	protected static final byte[] STREAM_TERMINATOR = { DASH, DASH };
-
-
-	/**
-	 * A byte sequence that precedes a boundary (<code>CRLF--</code>).
-	 */
-	protected static final byte[] BOUNDARY_PREFIX = { CR, LF, DASH, DASH };
-
-
-	// ----------------------------------------------------------- Data members
-
-
-	/**
-	 * The input stream from which data is read.
-	 */
-	private final InputStream input;
-
-
-	/**
-	 * The length of the boundary token plus the leading <code>CRLF--</code>.
-	 */
-	private int boundaryLength;
-
-
-	/**
-	 * The amount of data, in bytes, that must be kept in the buffer in order to detect delimiters
-	 * reliably.
-	 */
-	private final int keepRegion;
-
-
-	/**
-	 * The byte sequence that partitions the stream.
-	 */
-	private final byte[] boundary;
-
-
-	/**
-	 * The length of the buffer used for processing the request.
-	 */
-	private final int bufSize;
-
-
-	/**
-	 * The buffer used for processing the request.
-	 */
-	private final byte[] buffer;
-
-
-	/**
-	 * The index of first valid character in the buffer. <br>
-	 * 0 <= head < bufSize
-	 */
-	private int head;
-
-
-	/**
-	 * The index of last valid characer in the buffer + 1. <br>
-	 * 0 <= tail <= bufSize
-	 */
-	private int tail;
-
-
-	/**
-	 * The content encoding to use when reading headers.
-	 */
-	private String headerEncoding;
-
-
-	/**
-	 * The progress notifier, if any, or null.
-	 */
-	private final ProgressNotifier notifier;
-
-	// ----------------------------------------------------------- Constructors
-
-	/**
-	 * <p>
-	 * Constructs a <code>MultipartStream</code> with a custom size buffer.
-	 * 
-	 * <p>
-	 * Note that the buffer must be at least big enough to contain the boundary string, plus 4
-	 * characters for CR/LF and double dash, plus at least one byte of data. Too small a buffer size
-	 * setting will degrade performance.
-	 * 
-	 * @param input
-	 *            The <code>InputStream</code> to serve as a data source.
-	 * @param boundary
-	 *            The token used for dividing the stream into <code>encapsulations</code>.
-	 * @param bufSize
-	 *            The size of the buffer to be used, in bytes.
-	 * @param pNotifier
-	 *            The notifier, which is used for calling the progress listener, if any.
-	 * 
-	 * @see #MultipartFormInputStream(InputStream, byte[],
-	 *      MultipartFormInputStream.ProgressNotifier)
-	 */
-	MultipartFormInputStream(final InputStream input, final byte[] boundary, final int bufSize,
-		final ProgressNotifier pNotifier)
-	{
-		this.input = input;
-		this.bufSize = bufSize;
-		buffer = new byte[bufSize];
-		notifier = pNotifier;
-
-		// We prepend CR/LF to the boundary to chop trailng CR/LF from
-		// body-data tokens.
-		boundaryLength = boundary.length + BOUNDARY_PREFIX.length;
-		if (bufSize < this.boundaryLength + 1)
-		{
-			throw new IllegalArgumentException(
-				"The buffer size specified for the MultipartFormInputStream is too small");
-		}
-		this.boundary = new byte[this.boundaryLength];
-		keepRegion = this.boundary.length;
-
-		System.arraycopy(BOUNDARY_PREFIX, 0, this.boundary, 0, BOUNDARY_PREFIX.length);
-		System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length, boundary.length);
-
-		head = 0;
-		tail = 0;
-	}
-
-
-	/**
-	 * <p>
-	 * Constructs a <code>MultipartStream</code> with a default size buffer.
-	 * 
-	 * @param input
-	 *            The <code>InputStream</code> to serve as a data source.
-	 * @param boundary
-	 *            The token used for dividing the stream into <code>encapsulations</code>.
-	 * @param pNotifier
-	 *            An object for calling the progress listener, if any.
-	 * 
-	 * 
-	 * @see #MultipartFormInputStream(InputStream, byte[], int,
-	 *      MultipartFormInputStream.ProgressNotifier)
-	 * @throws IllegalArgumentException If the buffer size is too small
-	 */
-	MultipartFormInputStream(final InputStream input, final byte[] boundary,
-		final ProgressNotifier pNotifier)
-	{
-		this(input, boundary, DEFAULT_BUFSIZE, pNotifier);
-	}
-
-	// --------------------------------------------------------- Public methods
-
-
-	/**
-	 * Retrieves the character encoding used when reading the headers of an individual part. When
-	 * not specified, or <code>null</code>, the platform default encoding is used.
-	 * 
-	 * 
-	 * @return The encoding used to read part headers.
-	 */
-	public String getHeaderEncoding()
-	{
-		return headerEncoding;
-	}
-
-
-	/**
-	 * Specifies the character encoding to be used when reading the headers of individual parts.
-	 * When not specified, or <code>null</code>, the platform default encoding is used.
-	 * 
-	 * @param encoding
-	 *            The encoding used to read part headers.
-	 */
-	public void setHeaderEncoding(final String encoding)
-	{
-		headerEncoding = encoding;
-	}
-
-
-	/**
-	 * Reads a byte from the <code>buffer</code>, and refills it as necessary.
-	 * 
-	 * @return The next byte from the input stream.
-	 * 
-	 * @throws IOException
-	 *             if there is no more data available.
-	 */
-	public byte readByte() throws IOException
-	{
-		// Buffer depleted ?
-		if (head == tail)
-		{
-			head = 0;
-			// Refill.
-			tail = input.read(buffer, head, bufSize);
-			if (tail == -1)
-			{
-				// No more data available.
-				throw new IOException("No more data is available");
-			}
-			if (notifier != null)
-			{
-				notifier.noteBytesRead(tail);
-			}
-		}
-		return buffer[head++];
-	}
-
-
-	/**
-	 * Skips a <code>boundary</code> token, and checks whether more <code>encapsulations</code> are
-	 * contained in the stream.
-	 * 
-	 * @return <code>true</code> if there are more encapsulations in this stream; <code>false</code>
-	 *         otherwise.
-	 * 
-	 * @throws MalformedStreamException
-	 *             if the stream ends unexpecetedly or fails to follow required syntax.
-	 */
-	public boolean readBoundary() throws MalformedStreamException
-	{
-		byte[] marker = new byte[2];
-		boolean nextChunk = false;
-
-		head += boundaryLength;
-		try
-		{
-			marker[0] = readByte();
-			if (marker[0] == LF)
-			{
-				// Work around IE5 Mac bug with input type=image.
-				// Because the boundary delimiter, not including the trailing
-				// CRLF, must not appear within any file (RFC 2046, section
-				// 5.1.1), we know the missing CR is due to a buggy browser
-				// rather than a file containing something similar to a
-				// boundary.
-				return true;
-			}
-
-			marker[1] = readByte();
-			if (arrayequals(marker, STREAM_TERMINATOR, 2))
-			{
-				nextChunk = false;
-			}
-			else if (arrayequals(marker, FIELD_SEPARATOR, 2))
-			{
-				nextChunk = true;
-			}
-			else
-			{
-				throw new MalformedStreamException("Unexpected characters follow a boundary");
-			}
-		}
-		catch (IOException e)
-		{
-			throw new MalformedStreamException("Stream ended unexpectedly");
-		}
-		return nextChunk;
-	}
-
-
-	/**
-	 * <p>
-	 * Changes the boundary token used for partitioning the stream.
-	 * 
-	 * <p>
-	 * This method allows single pass processing of nested multipart streams.
-	 * 
-	 * <p>
-	 * The boundary token of the nested stream is <code>required</code> to be of the same length as
-	 * the boundary token in parent stream.
-	 * 
-	 * <p>
-	 * Restoring the parent stream boundary token after processing of a nested stream is left to the
-	 * application.
-	 * 
-	 * @param boundary
-	 *            The boundary to be used for parsing of the nested stream.
-	 * 
-	 * @throws IllegalBoundaryException
-	 *             if the <code>boundary</code> has a different length than the one being currently
-	 *             parsed.
-	 */
-	public void setBoundary(final byte[] boundary) throws IllegalBoundaryException
-	{
-		if (boundary.length != boundaryLength - BOUNDARY_PREFIX.length)
-		{
-			throw new IllegalBoundaryException("The length of a boundary token can not be changed");
-		}
-		System.arraycopy(boundary, 0, this.boundary, BOUNDARY_PREFIX.length, boundary.length);
-	}
-
-
-	/**
-	 * <p>
-	 * Reads the <code>header-part</code> of the current <code>encapsulation</code>.
-	 * 
-	 * <p>
-	 * Headers are returned verbatim to the input stream, including the trailing <code>CRLF</code>
-	 * marker. Parsing is left to the application.
-	 * 
-	 * <p>
-	 * <strong>TODO</strong> allow limiting maximum header size to protect against abuse.
-	 * 
-	 * @return The <code>header-part</code> of the current encapsulation.
-	 * 
-	 * @throws MalformedStreamException
-	 *             if the stream ends unexpecetedly.
-	 */
-	public String readHeaders() throws MalformedStreamException
-	{
-		int i = 0;
-		byte b;
-		// to support multi-byte characters
-		ByteArrayOutputStream baos = new ByteArrayOutputStream();
-		int size = 0;
-		while (i < HEADER_SEPARATOR.length)
-		{
-			try
-			{
-				b = readByte();
-			}
-			catch (IOException e)
-			{
-				throw new MalformedStreamException("Stream ended unexpectedly");
-			}
-			if (++size > HEADER_PART_SIZE_MAX)
-			{
-				throw new MalformedStreamException("Header section has more than " +
-					HEADER_PART_SIZE_MAX + " bytes (maybe it is not properly terminated)");
-			}
-			if (b == HEADER_SEPARATOR[i])
-			{
-				i++;
-			}
-			else
-			{
-				i = 0;
-			}
-			baos.write(b);
-		}
-
-		String headers = null;
-		if (headerEncoding != null)
-		{
-			try
-			{
-				headers = baos.toString(headerEncoding);
-			}
-			catch (UnsupportedEncodingException e)
-			{
-				// Fall back to platform default if specified encoding is not
-				// supported.
-				headers = baos.toString();
-			}
-		}
-		else
-		{
-			headers = baos.toString();
-		}
-
-		return headers;
-	}
-
-
-	/**
-	 * <p>
-	 * Reads <code>body-data</code> from the current <code>encapsulation</code> and writes its
-	 * contents into the output <code>Stream</code>.
-	 * 
-	 * <p>
-	 * Arbitrary large amounts of data can be processed by this method using a constant size buffer.
-	 * (see
-	 * {@link #MultipartFormInputStream(InputStream,byte[],int, MultipartFormInputStream.ProgressNotifier)
-	 * constructor}).
-	 * 
-	 * @param output
-	 *            The <code>Stream</code> to write data into. May be null, in which case this method
-	 *            is equivalent to {@link #discardBodyData()}.
-	 * 
-	 * @return the amount of data written.
-	 * 
-	 * @throws MalformedStreamException
-	 *             if the stream ends unexpectedly.
-	 * @throws IOException
-	 *             if an i/o error occurs.
-	 */
-	public int readBodyData(final OutputStream output) throws MalformedStreamException, IOException
-	{
-		final InputStream istream = newInputStream();
-		return Streams.copy(istream, output == null ? new NoopOutputStream() : output);
-	}
-
-	/**
-	 * Creates a new {@link ItemInputStream}.
-	 * 
-	 * @return A new instance of {@link ItemInputStream}.
-	 */
-	ItemInputStream newInputStream()
-	{
-		return new ItemInputStream();
-	}
-
-	/**
-	 * <p>
-	 * Reads <code>body-data</code> from the current <code>encapsulation</code> and discards it.
-	 * 
-	 * <p>
-	 * Use this method to skip encapsulations you don't need or don't understand.
-	 * 
-	 * @return The amount of data discarded.
-	 * 
-	 * @throws MalformedStreamException
-	 *             if the stream ends unexpectedly.
-	 * @throws IOException
-	 *             if an i/o error occurs.
-	 */
-	public int discardBodyData() throws MalformedStreamException, IOException
-	{
-		return readBodyData(null);
-	}
-
-
-	/**
-	 * Finds the beginning of the first <code>encapsulation</code>.
-	 * 
-	 * @return <code>true</code> if an <code>encapsulation</code> was found in the stream.
-	 * 
-	 * @throws IOException
-	 *             if an i/o error occurs.
-	 */
-	public boolean skipPreamble() throws IOException
-	{
-		// First delimiter may be not preceeded with a CRLF.
-		System.arraycopy(boundary, 2, boundary, 0, boundary.length - 2);
-		boundaryLength = boundary.length - 2;
-		try
-		{
-			// Discard all data up to the delimiter.
-			discardBodyData();
-
-			// Read boundary - if succeded, the stream contains an
-			// encapsulation.
-			return readBoundary();
-		}
-		catch (MalformedStreamException e)
-		{
-			log.error("Error while reading servlet request multi-part data: " + e.getMessage() +
-				". " + toString());
-			return false;
-		}
-		finally
-		{
-			// Restore delimiter.
-			System.arraycopy(boundary, 0, boundary, 2, boundary.length - 2);
-			boundaryLength = boundary.length;
-			boundary[0] = CR;
-			boundary[1] = LF;
-		}
-	}
-
-
-	/**
-	 * Compares <code>count</code> first bytes in the arrays <code>a</code> and <code>b</code>.
-	 * 
-	 * @param a
-	 *            The first array to compare.
-	 * @param b
-	 *            The second array to compare.
-	 * @param count
-	 *            How many bytes should be compared.
-	 * 
-	 * @return <code>true</code> if <code>count</code> first bytes in arrays <code>a</code> and
-	 *         <code>b</code> are equal.
-	 */
-	public static boolean arrayequals(final byte[] a, final byte[] b, final int count)
-	{
-		for (int i = 0; i < count; i++)
-		{
-			if (a[i] != b[i])
-			{
-				return false;
-			}
-		}
-		return true;
-	}
-
-
-	/**
-	 * Searches for a byte of specified value in the <code>buffer</code>, starting at the specified
-	 * <code>position</code>.
-	 * 
-	 * @param value
-	 *            The value to find.
-	 * @param pos
-	 *            The starting position for searching.
-	 * 
-	 * @return The position of byte found, counting from beginning of the <code>buffer</code>, or
-	 *         <code>-1</code> if not found.
-	 */
-	protected int findByte(final byte value, final int pos)
-	{
-		for (int i = pos; i < tail; i++)
-		{
-			if (buffer[i] == value)
-			{
-				return i;
-			}
-		}
-
-		return -1;
-	}
-
-
-	/**
-	 * Searches for the <code>boundary</code> in the <code>buffer</code> region delimited by
-	 * <code>head</code> and <code>tail</code>.
-	 * 
-	 * @return The position of the boundary found, counting from the beginning of the
-	 *         <code>buffer</code>, or <code>-1</code> if not found.
-	 */
-	protected int findSeparator()
-	{
-		int first;
-		int match = 0;
-		int maxpos = tail - boundaryLength;
-		for (first = head; (first <= maxpos) && (match != boundaryLength); first++)
-		{
-			first = findByte(boundary[0], first);
-			if ((first == -1) || (first > maxpos))
-			{
-				return -1;
-			}
-			for (match = 1; match < boundaryLength; match++)
-			{
-				if (buffer[first + match] != boundary[match])
-				{
-					break;
-				}
-			}
-		}
-		if (match == boundaryLength)
-		{
-			return first - 1;
-		}
-		return -1;
-	}
-
-	/**
-	 * Returns a string representation of this object.
-	 * 
-	 * @return The string representation of this object.
-	 */
-	@Override
-	public String toString()
-	{
-		StringBuilder sbTemp = new StringBuilder();
-		sbTemp.append("boundary='");
-		for (byte b : boundary)
-		{
-			if (Character.isDefined(b))
-			{
-				sbTemp.append((char)b);
-			}
-			else
-			{
-				sbTemp.append("#");
-				sbTemp.append(b);
-				sbTemp.append(";");
-			}
-		}
-		sbTemp.append("'; bufSize=");
-		sbTemp.append(bufSize);
-		return sbTemp.toString();
-	}
-
-
-	/**
-	 * Thrown to indicate that the input stream fails to follow the required syntax.
-	 */
-	public static class MalformedStreamException extends IOException
-	{
-		private static final long serialVersionUID = 1L;
-
-		/**
-		 * Constructs a <code>MalformedStreamException</code> with no detail message.
-		 */
-		public MalformedStreamException()
-		{
-			super();
-		}
-
-		/**
-		 * Constructs an <code>MalformedStreamException</code> with the specified detail message.
-		 * 
-		 * @param message
-		 *            The detail message.
-		 */
-		public MalformedStreamException(final String message)
-		{
-			super(message);
-		}
-	}
-
-
-	/**
-	 * Thrown upon attempt of setting an invalid boundary token.
-	 */
-	public static class IllegalBoundaryException extends IOException
-	{
-		private static final long serialVersionUID = 1L;
-
-		/**
-		 * Constructs an <code>IllegalBoundaryException</code> with no detail message.
-		 */
-		public IllegalBoundaryException()
-		{
-			super();
-		}
-
-		/**
-		 * Constructs an <code>IllegalBoundaryException</code> with the specified detail message.
-		 * 
-		 * @param message
-		 *            The detail message.
-		 */
-		public IllegalBoundaryException(final String message)
-		{
-			super(message);
-		}
-	}
-
-	/**
-	 * An {@link InputStream} for reading an items contents.
-	 */
-	public class ItemInputStream extends InputStream implements Closeable
-	{
-		/**
-		 * The number of bytes, which have been read so far.
-		 */
-		private long total;
-		/**
-		 * The number of bytes, which must be hold, because they might be a part of the boundary.
-		 */
-		private int pad;
-		/**
-		 * The current offset in the buffer.
-		 */
-		private int pos;
-		/**
-		 * Whether the stream is already closed.
-		 */
-		private boolean closed;
-
-		/**
-		 * Creates a new instance.
-		 */
-		ItemInputStream()
-		{
-			findSeparator();
-		}
-
-		/**
-		 * Called for finding the separator.
-		 */
-		private void findSeparator()
-		{
-			pos = MultipartFormInputStream.this.findSeparator();
-			if (pos == -1)
-			{
-				if (tail - head > keepRegion)
-				{
-					pad = keepRegion;
-				}
-				else
-				{
-					pad = tail - head;
-				}
-			}
-		}
-
-		/**
-		 * Returns the number of bytes, which have been read by the stream.
-		 * 
-		 * @return Number of bytes, which have been read so far.
-		 */
-		public long getBytesRead()
-		{
-			return total;
-		}
-
-		/**
-		 * Returns the number of bytes, which are currently available, without blocking.
-		 * 
-		 * @throws IOException
-		 *             An I/O error occurs.
-		 * @return Number of bytes in the buffer.
-		 */
-		@Override
-		public int available() throws IOException
-		{
-			if (pos == -1)
-			{
-				return tail - head - pad;
-			}
-			return pos - head;
-		}
-
-		/**
-		 * Offset when converting negative bytes to integers.
-		 */
-		private static final int BYTE_POSITIVE_OFFSET = 256;
-
-		/**
-		 * Returns the next byte in the stream.
-		 * 
-		 * @return The next byte in the stream, as a non-negative integer, or -1 for EOF.
-		 * @throws IOException
-		 *             An I/O error occurred.
-		 */
-		@Override
-		public int read() throws IOException
-		{
-			if (closed)
-			{
-				throw new FileItemStream.ItemSkippedException();
-			}
-			if (available() == 0)
-			{
-				if (makeAvailable() == 0)
-				{
-					return -1;
-				}
-			}
-			++total;
-			int b = buffer[head++];
-			if (b >= 0)
-			{
-				return b;
-			}
-			return b + BYTE_POSITIVE_OFFSET;
-		}
-
-		/**
-		 * Reads bytes into the given buffer.
-		 * 
-		 * @param b
-		 *            The destination buffer, where to write to.
-		 * @param off
-		 *            Offset of the first byte in the buffer.
-		 * @param len
-		 *            Maximum number of bytes to read.
-		 * @return Number of bytes, which have been actually read, or -1 for EOF.
-		 * @throws IOException
-		 *             An I/O error occurred.
-		 */
-		@Override
-		public int read(final byte[] b, final int off, final int len) throws IOException
-		{
-			if (closed)
-			{
-				throw new FileItemStream.ItemSkippedException();
-			}
-			if (len == 0)
-			{
-				return 0;
-			}
-			int res = available();
-			if (res == 0)
-			{
-				res = makeAvailable();
-				if (res == 0)
-				{
-					return -1;
-				}
-			}
-			res = Math.min(res, len);
-			System.arraycopy(buffer, head, b, off, res);
-			head += res;
-			total += res;
-			return res;
-		}
-
-		/**
-		 * Closes the input stream.
-		 * 
-		 * @throws IOException
-		 *             An I/O error occurred.
-		 */
-		@Override
-		public void close() throws IOException
-		{
-			close(false);
-		}
-
-		/**
-		 * Closes the input stream.
-		 * 
-		 * @param pCloseUnderlying
-		 *            Whether to close the underlying stream (hard close)
-		 * @throws IOException
-		 *             An I/O error occurred.
-		 */
-		public void close(final boolean pCloseUnderlying) throws IOException
-		{
-			if (closed)
-			{
-				return;
-			}
-			if (pCloseUnderlying)
-			{
-				closed = true;
-				input.close();
-			}
-			else
-			{
-				for (;;)
-				{
-					int av = available();
-					if (av == 0)
-					{
-						av = makeAvailable();
-						if (av == 0)
-						{
-							break;
-						}
-					}
-					skip(av);
-				}
-			}
-			closed = true;
-		}
-
-		/**
-		 * Skips the given number of bytes.
-		 * 
-		 * @param bytes
-		 *            Number of bytes to skip.
-		 * @return The number of bytes, which have actually been skipped.
-		 * @throws IOException
-		 *             An I/O error occurred.
-		 */
-		@Override
-		public long skip(final long bytes) throws IOException
-		{
-			if (closed)
-			{
-				throw new FileItemStream.ItemSkippedException();
-			}
-			int av = available();
-			if (av == 0)
-			{
-				av = makeAvailable();
-				if (av == 0)
-				{
-					return 0;
-				}
-			}
-			long res = Math.min(av, bytes);
-			head += res;
-			return res;
-		}
-
-		/**
-		 * Attempts to read more data.
-		 * 
-		 * @return Number of available bytes
-		 * @throws IOException
-		 *             An I/O error occurred.
-		 */
-		private int makeAvailable() throws IOException
-		{
-			if (pos != -1)
-			{
-				return 0;
-			}
-
-			// Move the data to the beginning of the buffer.
-			total += tail - head - pad;
-			System.arraycopy(buffer, tail - pad, buffer, 0, pad);
-
-			// Refill buffer with new data.
-			head = 0;
-			tail = pad;
-
-			for (;;)
-			{
-				int bytesRead = input.read(buffer, tail, bufSize - tail);
-				if (bytesRead == -1)
-				{
-					// The last pad amount is left in the buffer.
-					// Boundary can't be in there so signal an error
-					// condition.
-					final String msg = "Stream ended unexpectedly";
-					throw new MalformedStreamException(msg);
-				}
-				if (notifier != null)
-				{
-					notifier.noteBytesRead(bytesRead);
-				}
-				tail += bytesRead;
-
-				findSeparator();
-				int av = available();
-
-				if ((av > 0) || (pos != -1))
-				{
-					return av;
-				}
-			}
-		}
-
-		/**
-		 * Returns, whether the stream is closed.
-		 * 
-		 * @return True, if the stream is closed, otherwise false.
-		 */
-		@Override
-		public boolean isClosed()
-		{
-			return closed;
-		}
-	}
-
-	private final static class NoopOutputStream extends OutputStream
-	{
-		@Override
-		public void close()
-		{
-		}
-
-		@Override
-		public void flush()
-		{
-		}
-
-		@Override
-		public void write(final byte[] b)
-		{
-		}
-
-		@Override
-		public void write(final byte[] b, final int i, final int l)
-		{
-		}
-
-		@Override
-		public void write(final int b)
-		{
-		}
-	}
-
-	// ------------------------------------------------------ Debugging methods
-
-
-	// These are the methods that were used to debug this stuff.
-	/*
-	 * 
-	 * // Dump data. protected void dump() { System.out.println("01234567890"); byte[] temp = new
-	 * byte[buffer.length]; for(int i=0; i<buffer.length; i++) { if (buffer[i] == 0x0D || buffer[i]
-	 * == 0x0A) { temp[i] = 0x21; } else { temp[i] = buffer[i]; } } System.out.println(new
-	 * String(temp)); int i; for (i=0; i<head; i++) System.out.print(" "); System.out.println("h");
-	 * for (i=0; i<tail; i++) System.out.print(" "); System.out.println("t"); System.out.flush(); }
-	 * 
-	 * // Main routine, for testing purposes only. // // @param args A String[] with the command
-	 * line arguments. // @throws Exception, a generic exception. public static void main( String[]
-	 * args ) throws Exception { File boundaryFile = new File("boundary.dat"); int boundarySize =
-	 * (int)boundaryFile.length(); byte[] boundary = new byte[boundarySize]; FileInputStream input =
-	 * new FileInputStream(boundaryFile); input.read(boundary,0,boundarySize);
-	 * 
-	 * input = new FileInputStream("multipart.dat"); MultipartStream chunks = new
-	 * MultipartStream(input, boundary);
-	 * 
-	 * int i = 0; String header; OutputStream output; boolean nextChunk = chunks.skipPreamble();
-	 * while (nextChunk) { header = chunks.readHeaders(); System.out.println("!"+header+"!");
-	 * System.out.println("wrote part"+i+".dat"); output = new
-	 * FileOutputStream("part"+(i++)+".dat"); chunks.readBodyData(output); nextChunk =
-	 * chunks.readBoundary(); } }
-	 */
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/ParameterParser.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/ParameterParser.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/ParameterParser.java
deleted file mode 100644
index c3b2163..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/ParameterParser.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A simple parser intended to parse sequences of name/value pairs. Parameter values are exptected
- * to be enclosed in quotes if they contain unsafe characters, such as '=' characters or separators.
- * Parameter values are optional and can be omitted.
- * 
- * <p>
- * <code>param1 = value; param2 = "anything goes; really"; param3</code>
- * </p>
- * 
- * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a>
- */
-
-public class ParameterParser
-{
-	/**
-	 * String to be parsed.
-	 */
-	private char[] chars = null;
-
-	/**
-	 * Current position in the string.
-	 */
-	private int pos = 0;
-
-	/**
-	 * Maximum position in the string.
-	 */
-	private int len = 0;
-
-	/**
-	 * Start of a token.
-	 */
-	private int i1 = 0;
-
-	/**
-	 * End of a token.
-	 */
-	private int i2 = 0;
-
-	/**
-	 * Whether names stored in the map should be converted to lower case.
-	 */
-	private boolean lowerCaseNames = false;
-
-	/**
-	 * Default ParameterParser constructor.
-	 */
-	public ParameterParser()
-	{
-		super();
-	}
-
-	/**
-	 * Are there any characters left to parse?
-	 * 
-	 * @return <tt>true</tt> if there are unparsed characters, <tt>false</tt> otherwise.
-	 */
-	private boolean hasChar()
-	{
-		return pos < len;
-	}
-
-	/**
-	 * A helper method to process the parsed token. This method removes leading and trailing blanks
-	 * as well as enclosing quotation marks, when necessary.
-	 * 
-	 * @param quoted
-	 *            <tt>true</tt> if quotation marks are expected, <tt>false</tt> otherwise.
-	 * @return the token
-	 */
-	private String getToken(final boolean quoted)
-	{
-		// Trim leading white spaces
-		while ((i1 < i2) && (Character.isWhitespace(chars[i1])))
-		{
-			i1++;
-		}
-		// Trim trailing white spaces
-		while ((i2 > i1) && (Character.isWhitespace(chars[i2 - 1])))
-		{
-			i2--;
-		}
-		// Strip away quotation marks if necessary
-		if (quoted)
-		{
-			if (((i2 - i1) >= 2) && (chars[i1] == '"') && (chars[i2 - 1] == '"'))
-			{
-				i1++;
-				i2--;
-			}
-		}
-		String result = null;
-		if (i2 > i1)
-		{
-			result = new String(chars, i1, i2 - i1);
-		}
-		return result;
-	}
-
-	/**
-	 * Tests if the given character is present in the array of characters.
-	 * 
-	 * @param ch
-	 *            the character to test for presense in the array of characters
-	 * @param charray
-	 *            the array of characters to test against
-	 * 
-	 * @return <tt>true</tt> if the character is present in the array of characters, <tt>false</tt>
-	 *         otherwise.
-	 */
-	private boolean isOneOf(final char ch, final char[] charray)
-	{
-		for (char c : charray)
-		{
-			if (ch == c)
-			{
-				return true;
-			}
-		}
-		return false;
-	}
-
-	/**
-	 * Parses out a token until any of the given terminators is encountered.
-	 * 
-	 * @param terminators
-	 *            the array of terminating characters. Any of these characters when encountered
-	 *            signify the end of the token
-	 * 
-	 * @return the token
-	 */
-	private String parseToken(final char[] terminators)
-	{
-		char ch;
-		i1 = pos;
-		i2 = pos;
-		while (hasChar())
-		{
-			ch = chars[pos];
-			if (isOneOf(ch, terminators))
-			{
-				break;
-			}
-			i2++;
-			pos++;
-		}
-		return getToken(false);
-	}
-
-	/**
-	 * Parses out a token until any of the given terminators is encountered outside the quotation
-	 * marks.
-	 * 
-	 * @param terminators
-	 *            the array of terminating characters. Any of these characters when encountered
-	 *            outside the quotation marks signify the end of the token
-	 * 
-	 * @return the token
-	 */
-	private String parseQuotedToken(final char[] terminators)
-	{
-		char ch;
-		i1 = pos;
-		i2 = pos;
-		boolean quoted = false;
-		boolean charEscaped = false;
-		while (hasChar())
-		{
-			ch = chars[pos];
-			if (!quoted && isOneOf(ch, terminators))
-			{
-				break;
-			}
-			if (!charEscaped && (ch == '"'))
-			{
-				quoted = !quoted;
-			}
-			charEscaped = (!charEscaped && (ch == '\\'));
-			i2++;
-			pos++;
-
-		}
-		return getToken(true);
-	}
-
-	/**
-	 * Returns <tt>true</tt> if parameter names are to be converted to lower case when name/value
-	 * pairs are parsed.
-	 * 
-	 * @return <tt>true</tt> if parameter names are to be converted to lower case when name/value
-	 *         pairs are parsed. Otherwise returns <tt>false</tt>
-	 */
-	public boolean isLowerCaseNames()
-	{
-		return lowerCaseNames;
-	}
-
-	/**
-	 * Sets the flag if parameter names are to be converted to lower case when name/value pairs are
-	 * parsed.
-	 * 
-	 * @param b
-	 *            <tt>true</tt> if parameter names are to be converted to lower case when name/value
-	 *            pairs are parsed. <tt>false</tt> otherwise.
-	 */
-	public void setLowerCaseNames(final boolean b)
-	{
-		lowerCaseNames = b;
-	}
-
-	/**
-	 * Extracts a map of name/value pairs from the given string. Names are expected to be unique.
-	 * Multiple separators may be specified and the earliest found in the input string is used.
-	 * 
-	 * @param str
-	 *            the string that contains a sequence of name/value pairs
-	 * @param separators
-	 *            the name/value pairs separators
-	 * 
-	 * @return a map of name/value pairs
-	 */
-	public Map<String, String> parse(final String str, final char[] separators)
-	{
-		if ((separators == null) || (separators.length == 0))
-		{
-			return new HashMap<>();
-		}
-		char separator = separators[0];
-		if (str != null)
-		{
-			int idx = str.length();
-			for (char sep : separators)
-			{
-				int tmp = str.indexOf(sep);
-				if (tmp != -1)
-				{
-					if (tmp < idx)
-					{
-						idx = tmp;
-						separator = sep;
-					}
-				}
-			}
-		}
-		return parse(str, separator);
-	}
-
-	/**
-	 * Extracts a map of name/value pairs from the given string. Names are expected to be unique.
-	 * 
-	 * @param str
-	 *            the string that contains a sequence of name/value pairs
-	 * @param separator
-	 *            the name/value pairs separator
-	 * 
-	 * @return a map of name/value pairs
-	 */
-	public Map<String, String> parse(final String str, final char separator)
-	{
-		if (str == null)
-		{
-			return new HashMap<>();
-		}
-		return parse(str.toCharArray(), separator);
-	}
-
-	/**
-	 * Extracts a map of name/value pairs from the given array of characters. Names are expected to
-	 * be unique.
-	 * 
-	 * @param chars
-	 *            the array of characters that contains a sequence of name/value pairs
-	 * @param separator
-	 *            the name/value pairs separator
-	 * 
-	 * @return a map of name/value pairs
-	 */
-	public Map<String, String> parse(final char[] chars, final char separator)
-	{
-		if (chars == null)
-		{
-			return new HashMap<>();
-		}
-		return parse(chars, 0, chars.length, separator);
-	}
-
-	/**
-	 * Extracts a map of name/value pairs from the given array of characters. Names are expected to
-	 * be unique.
-	 * 
-	 * @param chars
-	 *            the array of characters that contains a sequence of name/value pairs
-	 * @param offset
-	 *            - the initial offset.
-	 * @param length
-	 *            - the length.
-	 * @param separator
-	 *            the name/value pairs separator
-	 * 
-	 * @return a map of name/value pairs
-	 */
-	public Map<String, String> parse(final char[] chars, final int offset, final int length,
-		final char separator)
-	{
-
-		if (chars == null)
-		{
-			return new HashMap<>();
-		}
-		Map<String, String> params = new HashMap<>();
-		this.chars = chars;
-		pos = offset;
-		len = length;
-
-		String paramName = null;
-		String paramValue = null;
-		while (hasChar())
-		{
-			paramName = parseToken(new char[] { '=', separator });
-			paramValue = null;
-			if (hasChar() && (chars[pos] == '='))
-			{
-				pos++; // skip '='
-				paramValue = parseQuotedToken(new char[] { separator });
-			}
-			if (hasChar() && (chars[pos] == separator))
-			{
-				pos++; // skip separator
-			}
-			if ((paramName != null) && (paramName.length() > 0))
-			{
-				if (lowerCaseNames)
-				{
-					paramName = paramName.toLowerCase();
-				}
-				params.put(paramName, paramValue);
-			}
-		}
-		return params;
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/ProgressListener.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/ProgressListener.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/ProgressListener.java
deleted file mode 100644
index eed1ff6..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/ProgressListener.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-
-/**
- * The {@link ProgressListener} may be used to display a progress bar or do stuff like that.
- */
-public interface ProgressListener
-{
-	/**
-	 * Updates the listeners status information.
-	 * 
-	 * @param pBytesRead
-	 *            The total number of bytes, which have been read so far.
-	 * @param pContentLength
-	 *            The total number of bytes, which are being read. May be -1, if this number is
-	 *            unknown.
-	 * @param pItems
-	 *            The number of the field, which is currently being read. (0 = no item so far, 1 =
-	 *            first item is being read, ...)
-	 */
-	void update(long pBytesRead, long pContentLength, int pItems);
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/RequestContext.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/RequestContext.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/RequestContext.java
deleted file mode 100644
index f0a8597..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/RequestContext.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * <p>
- * Abstracts access to the request information needed for file uploads. This interface should be
- * implemented for each type of request that may be handled by FileUpload, such as servlets and
- * portlets.
- * </p>
- * 
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- */
-public interface RequestContext
-{
-
-	/**
-	 * Retrieve the character encoding for the request.
-	 * 
-	 * @return The character encoding for the request.
-	 */
-	String getCharacterEncoding();
-
-	/**
-	 * Retrieve the content type of the request.
-	 * 
-	 * @return The content type of the request.
-	 */
-	String getContentType();
-
-	/**
-	 * Retrieve the content length of the request.
-	 * 
-	 * @return The content length of the request.
-	 */
-	int getContentLength();
-
-	/**
-	 * Retrieve the input stream for the request.
-	 * 
-	 * @return The input stream for the request.
-	 * 
-	 * @throws IOException
-	 *             if a problem occurs.
-	 */
-	InputStream getInputStream() throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletFileUpload.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletFileUpload.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletFileUpload.java
deleted file mode 100644
index 7e1062c..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletFileUpload.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.IOException;
-import java.util.List;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * <p>
- * High level API for processing file uploads.
- * </p>
- * 
- * <p>
- * This class handles multiple files per single HTML widget, sent using <code>multipart/mixed</code>
- * encoding type, as specified by <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use
- * {@link #parseRequest(HttpServletRequest)} to acquire a list of
- * {@link org.apache.wicket.util.upload.FileItem}s associated with a given HTML widget.
- * </p>
- * 
- * <p>
- * How the data for individual parts is stored is determined by the factory used to create them; a
- * given part may be in memory, on disk, or somewhere else.
- * </p>
- * 
- * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
- * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- * @author Sean C. Sullivan
- */
-public class ServletFileUpload extends FileUpload
-{
-
-	// ---------------------------------------------------------- Class methods
-
-
-	/**
-	 * Utility method that determines whether the request contains multipart content.
-	 * 
-	 * @param request
-	 *            The servlet request to be evaluated. Must be non-null.
-	 * 
-	 * @return <code>true</code> if the request is multipart; <code>false</code> otherwise.
-	 */
-	public static final boolean isMultipartContent(final HttpServletRequest request)
-	{
-		if (!"post".equals(request.getMethod().toLowerCase()))
-		{
-			return false;
-		}
-		String contentType = request.getContentType();
-		if (contentType == null)
-		{
-			return false;
-		}
-		if (contentType.toLowerCase().startsWith(MULTIPART))
-		{
-			return true;
-		}
-		return false;
-	}
-
-
-	// ----------------------------------------------------------- Constructors
-
-
-	/**
-	 * Constructs an uninitialised instance of this class. A factory must be configured, using
-	 * <code>setFileItemFactory()</code>, before attempting to parse requests.
-	 * 
-	 * @see FileUpload#FileUpload(FileItemFactory)
-	 */
-	public ServletFileUpload()
-	{
-		super();
-	}
-
-
-	/**
-	 * Constructs an instance of this class which uses the supplied factory to create
-	 * <code>FileItem</code> instances.
-	 * 
-	 * @see FileUpload#FileUpload()
-	 * @param fileItemFactory
-	 *            The factory to use for creating file items.
-	 */
-	public ServletFileUpload(final FileItemFactory fileItemFactory)
-	{
-		super(fileItemFactory);
-	}
-
-
-	// --------------------------------------------------------- Public methods
-
-
-	/**
-	 * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> compliant
-	 * <code>multipart/form-data</code> stream.
-	 * 
-	 * @param request
-	 *            The servlet request to be parsed.
-	 * 
-	 * @return A list of <code>FileItem</code> instances parsed from the request, in the order that
-	 *         they were transmitted.
-	 * 
-	 * @throws FileUploadException
-	 *             if there are problems reading/parsing the request or storing files.
-	 */
-	public List<FileItem> parseRequest(final HttpServletRequest request) throws FileUploadException
-	{
-		return parseRequest(new ServletRequestContext(request));
-	}
-
-
-	/**
-	 * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> compliant
-	 * <code>multipart/form-data</code> stream.
-	 * 
-	 * @param request
-	 *            The servlet request to be parsed.
-	 * 
-	 * @return An iterator to instances of <code>FileItemStream</code> parsed from the request, in
-	 *         the order that they were transmitted.
-	 * 
-	 * @throws FileUploadException
-	 *             if there are problems reading/parsing the request or storing files.
-	 * @throws IOException
-	 *             An I/O error occurred. This may be a network error while communicating with the
-	 *             client or a problem while storing the uploaded content.
-	 */
-	public FileItemIterator getItemIterator(final HttpServletRequest request)
-		throws FileUploadException, IOException
-	{
-		return super.getItemIterator(new ServletRequestContext(request));
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletRequestContext.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletRequestContext.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletRequestContext.java
deleted file mode 100644
index 10fb6c9..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/ServletRequestContext.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import javax.servlet.http.HttpServletRequest;
-
-/**
- * <p>
- * Provides access to the request information needed for a request made to an HTTP servlet.
- * </p>
- * 
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- */
-public class ServletRequestContext implements RequestContext
-{
-
-	// ----------------------------------------------------- Instance Variables
-
-	/**
-	 * The request for which the context is being provided.
-	 */
-	private final HttpServletRequest request;
-
-
-	// ----------------------------------------------------------- Constructors
-
-	/**
-	 * Construct a context for this request.
-	 * 
-	 * @param request
-	 *            The request to which this context applies.
-	 */
-	public ServletRequestContext(final HttpServletRequest request)
-	{
-		this.request = request;
-	}
-
-
-	// --------------------------------------------------------- Public Methods
-
-	/**
-	 * Retrieve the character encoding for the request.
-	 * 
-	 * @return The character encoding for the request.
-	 */
-	@Override
-	public String getCharacterEncoding()
-	{
-		return request.getCharacterEncoding();
-	}
-
-	/**
-	 * Retrieve the content type of the request.
-	 * 
-	 * @return The content type of the request.
-	 */
-	@Override
-	public String getContentType()
-	{
-		return request.getContentType();
-	}
-
-	/**
-	 * Retrieve the content length of the request.
-	 * 
-	 * @return The content length of the request.
-	 */
-	@Override
-	public int getContentLength()
-	{
-		return request.getContentLength();
-	}
-
-	/**
-	 * Retrieve the input stream for the request.
-	 * 
-	 * @return The input stream for the request.
-	 * 
-	 * @throws IOException
-	 *             if a problem occurs.
-	 */
-	@Override
-	public InputStream getInputStream() throws IOException
-	{
-		return request.getInputStream();
-	}
-
-	/**
-	 * @see java.lang.Object#toString()
-	 */
-	@Override
-	public String toString()
-	{
-		return "ContentLength=" + getContentLength() + ", ContentType=" + getContentType();
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/package.html
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/package.html b/wicket-util/src/main/java/org/apache/wicket/util/upload/package.html
deleted file mode 100644
index 59b6480..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/package.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<!DOCTYPE HTML PUBLIC "-//W3C/DTD HTML 3.2 Final//NL">
-<html>
-	<head>
-		<title>
-			org.apache.wicket.util.upload package
-		</title>
-	</head>
-	<body>
-		<p>
-			Protocol independent upload utilities. Copied from the
-			Apache Jakarta Commons FileUpload project (1.1-dev, HEAD at 21st of august 2005).
-		</p>
-	</body>
-</html>
\ No newline at end of file


[3/3] git commit: WICKET-5503 Remove local copies of Commons FileUpload files and use Maven dependency

Posted by mg...@apache.org.
WICKET-5503 Remove local copies of Commons FileUpload files and use Maven dependency


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/99fcd91f
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/99fcd91f
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/99fcd91f

Branch: refs/heads/master
Commit: 99fcd91fe8c3568750f65e7ed830c62b5d46cdaf
Parents: 7cd01f7
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Fri Feb 7 15:49:51 2014 +0100
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Fri Feb 7 15:49:51 2014 +0100

----------------------------------------------------------------------
 .../apache/wicket/markup/html/form/Form.java    |    6 +-
 .../markup/html/form/upload/FileUpload.java     |    6 +-
 .../html/form/upload/FileUploadField.java       |    2 +-
 .../html/form/upload/MultiFileUploadField.java  |    2 +-
 .../protocol/http/IMultipartWebRequest.java     |    2 +-
 .../http/mock/MockHttpServletRequest.java       |    2 +-
 .../servlet/MultipartServletWebRequest.java     |    2 +-
 .../servlet/MultipartServletWebRequestImpl.java |   31 +-
 .../http/servlet/ServletWebRequest.java         |    4 +-
 .../markup/html/form/upload/FileUploadTest.java |   20 +-
 .../wicket/atmosphere/AtmosphereWebRequest.java |    4 +-
 wicket-util/pom.xml                             |   19 +-
 .../apache/wicket/util/file/FileCleaner.java    |    3 +
 .../util/file/FileCleanerTrackerAdapter.java    |   59 +
 .../wicket/util/file/FileCleaningTracker.java   |  331 -----
 .../wicket/util/file/FileDeleteStrategy.java    |  140 --
 .../wicket/util/file/FolderDeleteStrategy.java  |    4 +-
 .../apache/wicket/util/file/IFileCleaner.java   |    2 +
 .../apache/wicket/util/upload/Closeable.java    |   43 -
 .../apache/wicket/util/upload/DiskFileItem.java |  783 -----------
 .../wicket/util/upload/DiskFileItemFactory.java |  205 ---
 .../org/apache/wicket/util/upload/FileItem.java |  215 ---
 .../wicket/util/upload/FileItemFactory.java     |   47 -
 .../wicket/util/upload/FileItemHeaders.java     |   74 -
 .../wicket/util/upload/FileItemHeadersImpl.java |   98 --
 .../util/upload/FileItemHeadersSupport.java     |   46 -
 .../wicket/util/upload/FileItemIterator.java    |   50 -
 .../wicket/util/upload/FileItemStream.java      |   99 --
 .../apache/wicket/util/upload/FileUpload.java   |  114 --
 .../wicket/util/upload/FileUploadBase.java      | 1285 ------------------
 .../wicket/util/upload/FileUploadException.java |  112 --
 .../wicket/util/upload/LimitedInputStream.java  |  173 ---
 .../util/upload/MultipartFormInputStream.java   | 1192 ----------------
 .../wicket/util/upload/ParameterParser.java     |  362 -----
 .../wicket/util/upload/ProgressListener.java    |   38 -
 .../wicket/util/upload/RequestContext.java      |   64 -
 .../wicket/util/upload/ServletFileUpload.java   |  153 ---
 .../util/upload/ServletRequestContext.java      |  113 --
 .../org/apache/wicket/util/upload/package.html  |   30 -
 39 files changed, 129 insertions(+), 5806 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
index 7eeb1e1..8386d2a 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/Form.java
@@ -26,6 +26,8 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.fileupload.FileUploadBase;
+import org.apache.commons.fileupload.FileUploadException;
 import org.apache.wicket.Component;
 import org.apache.wicket.IGenericComponent;
 import org.apache.wicket.Page;
@@ -60,8 +62,6 @@ import org.apache.wicket.util.string.AppendingStringBuffer;
 import org.apache.wicket.util.string.PrependingStringBuffer;
 import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.util.string.interpolator.MapVariableInterpolator;
-import org.apache.wicket.util.upload.FileUploadBase.SizeLimitExceededException;
-import org.apache.wicket.util.upload.FileUploadException;
 import org.apache.wicket.util.value.LongValue;
 import org.apache.wicket.util.visit.ClassVisitFilter;
 import org.apache.wicket.util.visit.IVisit;
@@ -1405,7 +1405,7 @@ public class Form<T> extends WebMarkupContainer implements IFormSubmitListener,
 	protected void onFileUploadException(final FileUploadException e,
 		final Map<String, Object> model)
 	{
-		if (e instanceof SizeLimitExceededException)
+		if (e instanceof FileUploadBase.SizeLimitExceededException)
 		{
 			String msg = getString(UPLOAD_TOO_LARGE_RESOURCE_KEY, Model.ofMap(model));
 			error(msg);

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
index ad54846..ab5e4a0 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUpload.java
@@ -24,6 +24,7 @@ import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.fileupload.FileItem;
 import org.apache.wicket.util.io.IClusterable;
 import org.apache.wicket.Session;
 import org.apache.wicket.WicketRuntimeException;
@@ -32,7 +33,6 @@ import org.apache.wicket.util.file.Files;
 import org.apache.wicket.util.io.IOUtils;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.string.Strings;
-import org.apache.wicket.util.upload.FileItem;
 
 
 /**
@@ -229,7 +229,7 @@ public class FileUpload implements IClusterable
 	 *            The file
 	 * @throws IOException
 	 */
-	public void writeTo(final File file) throws IOException
+	public void writeTo(final File file) throws Exception
 	{
 		item.write(file);
 	}
@@ -246,7 +246,7 @@ public class FileUpload implements IClusterable
 	 * @return temporary file containing the contents of the uploaded file
 	 * @throws IOException
 	 */
-	public final File writeToTempFile() throws IOException
+	public final File writeToTempFile() throws Exception
 	{
 		String sessionId = Session.exists() ? Session.get().getId() : "";
 		String tempFileName = sessionId + "_" + RequestCycle.get().getStartTime();

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUploadField.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUploadField.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUploadField.java
index bfd6059..9ebe306 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUploadField.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/FileUploadField.java
@@ -20,13 +20,13 @@ package org.apache.wicket.markup.html.form.upload;
 import java.util.ArrayList;
 import java.util.List;
 
+import org.apache.commons.fileupload.FileItem;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.html.form.FormComponent;
 import org.apache.wicket.model.IModel;
 import org.apache.wicket.protocol.http.IMultipartWebRequest;
 import org.apache.wicket.request.Request;
 import org.apache.wicket.util.convert.ConversionException;
-import org.apache.wicket.util.upload.FileItem;
 
 /**
  * Form component that corresponds to a &lt;input type=&quot;file&quot;&gt;. When a FileInput

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java
index 4e803a3..8e907fd 100644
--- a/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java
+++ b/wicket-core/src/main/java/org/apache/wicket/markup/html/form/upload/MultiFileUploadField.java
@@ -23,6 +23,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.apache.commons.fileupload.FileItem;
 import org.apache.wicket.markup.ComponentTag;
 import org.apache.wicket.markup.head.IHeaderResponse;
 import org.apache.wicket.markup.head.JavaScriptHeaderItem;
@@ -42,7 +43,6 @@ import org.apache.wicket.request.resource.JavaScriptResourceReference;
 import org.apache.wicket.request.resource.ResourceReference;
 import org.apache.wicket.util.convert.ConversionException;
 import org.apache.wicket.util.string.Strings;
-import org.apache.wicket.util.upload.FileItem;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/protocol/http/IMultipartWebRequest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/IMultipartWebRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/IMultipartWebRequest.java
index c278d47..529ffc4 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/IMultipartWebRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/IMultipartWebRequest.java
@@ -19,7 +19,7 @@ package org.apache.wicket.protocol.http;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.wicket.util.upload.FileItem;
+import org.apache.commons.fileupload.FileItem;
 
 
 /**

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
index 5cfac7d..53b18f7 100755
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/mock/MockHttpServletRequest.java
@@ -55,6 +55,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
 import javax.servlet.http.Part;
 
+import org.apache.commons.fileupload.FileUploadBase;
 import org.apache.wicket.Application;
 import org.apache.wicket.WicketRuntimeException;
 import org.apache.wicket.mock.MockRequestParameters;
@@ -67,7 +68,6 @@ import org.apache.wicket.util.io.IOUtils;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.string.StringValue;
 import org.apache.wicket.util.string.Strings;
-import org.apache.wicket.util.upload.FileUploadBase;
 import org.apache.wicket.util.value.ValueMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java
index c3ac56c..77d0dec 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequest.java
@@ -21,10 +21,10 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.fileupload.FileItem;
 import org.apache.wicket.protocol.http.IMultipartWebRequest;
 import org.apache.wicket.request.IRequestParameters;
 import org.apache.wicket.request.Url;
-import org.apache.wicket.util.upload.FileItem;
 
 /**
  * Servlet specific WebRequest subclass for multipart content uploads.

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequestImpl.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequestImpl.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequestImpl.java
index 8a036ba..75712bc 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequestImpl.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/MultipartServletWebRequestImpl.java
@@ -26,18 +26,21 @@ import java.util.Map;
 
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.FileUploadBase;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.commons.fileupload.servlet.ServletRequestContext;
+import org.apache.commons.io.FileCleaningTracker;
 import org.apache.wicket.Application;
 import org.apache.wicket.WicketRuntimeException;
+import org.apache.wicket.util.file.FileCleanerTrackerAdapter;
+import org.apache.wicket.util.file.IFileCleaner;
 import org.apache.wicket.util.lang.Args;
 import org.apache.wicket.util.lang.Bytes;
 import org.apache.wicket.util.string.StringValue;
-import org.apache.wicket.util.upload.DiskFileItemFactory;
-import org.apache.wicket.util.upload.FileItem;
-import org.apache.wicket.util.upload.FileItemFactory;
-import org.apache.wicket.util.upload.FileUploadBase;
-import org.apache.wicket.util.upload.FileUploadException;
-import org.apache.wicket.util.upload.ServletFileUpload;
-import org.apache.wicket.util.upload.ServletRequestContext;
 import org.apache.wicket.util.value.ValueMap;
 
 
@@ -87,9 +90,17 @@ public class MultipartServletWebRequestImpl extends MultipartServletWebRequest
 	public MultipartServletWebRequestImpl(HttpServletRequest request, String filterPrefix,
 		Bytes maxSize, String upload) throws FileUploadException
 	{
-		this(request, filterPrefix, maxSize, upload, new DiskFileItemFactory(Application.get()
-			.getResourceSettings()
-			.getFileCleaner()));
+		this(request, filterPrefix, maxSize, upload, new DiskFileItemFactory()
+		{
+			@Override
+			public FileCleaningTracker getFileCleaningTracker()
+			{
+				IFileCleaner fileCleaner = Application.get()
+						.getResourceSettings()
+						.getFileCleaner();
+				return new FileCleanerTrackerAdapter(fileCleaner);
+			}
+		});
 	}
 
 	/**

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
index 0581076..a4ecc20 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
@@ -31,6 +31,8 @@ import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.FileUploadException;
 import org.apache.wicket.protocol.http.RequestUtils;
 import org.apache.wicket.request.IRequestParameters;
 import org.apache.wicket.request.IWritableRequestParameters;
@@ -44,8 +46,6 @@ import org.apache.wicket.util.string.PrependingStringBuffer;
 import org.apache.wicket.util.string.StringValue;
 import org.apache.wicket.util.string.Strings;
 import org.apache.wicket.util.time.Time;
-import org.apache.wicket.util.upload.FileItemFactory;
-import org.apache.wicket.util.upload.FileUploadException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadTest.java b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadTest.java
index 39325c1..9a25b3b 100644
--- a/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/markup/html/form/upload/FileUploadTest.java
@@ -21,13 +21,15 @@ import java.io.InputStream;
 import java.lang.reflect.Field;
 import java.util.List;
 
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.io.FileCleaningTracker;
 import org.apache.wicket.WicketTestCase;
 import org.apache.wicket.util.file.File;
 import org.apache.wicket.util.file.FileCleaner;
+import org.apache.wicket.util.file.FileCleanerTrackerAdapter;
 import org.apache.wicket.util.file.IFileCleaner;
 import org.apache.wicket.util.tester.FormTester;
-import org.apache.wicket.util.upload.DiskFileItemFactory;
-import org.apache.wicket.util.upload.FileItem;
 import org.junit.Test;
 
 
@@ -49,10 +51,18 @@ public class FileUploadTest extends WicketTestCase
 	@Test
 	public void getInputStream() throws Exception
 	{
-		IFileCleaner fileUploadCleaner = new FileCleaner();
+		final IFileCleaner fileUploadCleaner = new FileCleaner();
 
-		FileItem fileItem = new DiskFileItemFactory(fileUploadCleaner).createItem("dummyFieldName",
-			"text/java", false, "FileUploadTest.java");
+		DiskFileItemFactory itemFactory = new DiskFileItemFactory()
+		{
+			@Override
+			public FileCleaningTracker getFileCleaningTracker()
+			{
+				return new FileCleanerTrackerAdapter(fileUploadCleaner);
+			}
+		};
+		FileItem fileItem = itemFactory.createItem("dummyFieldName",
+				"text/java", false, "FileUploadTest.java");
 		// Initialize the upload
 		fileItem.getOutputStream();
 

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereWebRequest.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereWebRequest.java b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereWebRequest.java
index 18556de..7dd0137 100644
--- a/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereWebRequest.java
+++ b/wicket-experimental/wicket-atmosphere/src/main/java/org/apache/wicket/atmosphere/AtmosphereWebRequest.java
@@ -24,6 +24,8 @@ import java.util.Locale;
 import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.FileUploadException;
 import org.apache.wicket.protocol.http.RequestUtils;
 import org.apache.wicket.protocol.http.servlet.MultipartServletWebRequest;
 import org.apache.wicket.protocol.http.servlet.ServletWebRequest;
@@ -31,8 +33,6 @@ import org.apache.wicket.request.IRequestParameters;
 import org.apache.wicket.request.Url;
 import org.apache.wicket.util.lang.Bytes;
 import org.apache.wicket.util.time.Time;
-import org.apache.wicket.util.upload.FileItemFactory;
-import org.apache.wicket.util.upload.FileUploadException;
 
 /**
  * Internal request to signal the processing of an event. This request will be mapped by

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/pom.xml
----------------------------------------------------------------------
diff --git a/wicket-util/pom.xml b/wicket-util/pom.xml
index aa1592a..3c4a4045 100755
--- a/wicket-util/pom.xml
+++ b/wicket-util/pom.xml
@@ -25,13 +25,18 @@
 	</parent>
 	<artifactId>wicket-util</artifactId>
 	<name>Wicket Util</name>
-  <dependencies>
-	<dependency>
-		<groupId>junit</groupId>
-		<artifactId>junit</artifactId>
-		<scope>provided</scope>
-	</dependency>
-  </dependencies>
+	<dependencies>
+		<dependency>
+			<groupId>commons-fileupload</groupId>
+			<artifactId>commons-fileupload</artifactId>
+			<version>1.3.1</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<scope>provided</scope>
+		</dependency>
+	</dependencies>
   <build>
   	<pluginManagement>
   		<plugins>

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaner.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaner.java b/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaner.java
index 3835192..3b7b5a9 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaner.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaner.java
@@ -18,6 +18,9 @@ package org.apache.wicket.util.file;
 
 import java.io.File;
 
+import org.apache.commons.io.FileCleaningTracker;
+import org.apache.commons.io.FileDeleteStrategy;
+
 /**
  * Default implementation of {@link IFileCleaner} that uses Apache commons-io
  * {@link FileCleaningTracker} to track and clean the temporary created files.

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleanerTrackerAdapter.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleanerTrackerAdapter.java b/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleanerTrackerAdapter.java
new file mode 100644
index 0000000..d58e23f
--- /dev/null
+++ b/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleanerTrackerAdapter.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.util.file;
+
+
+import org.apache.commons.io.FileCleaningTracker;
+import org.apache.commons.io.FileDeleteStrategy;
+import org.apache.wicket.util.lang.Args;
+
+/**
+ * Adapts IFileCleaner to FileCleaningTracker
+ */
+public class FileCleanerTrackerAdapter extends FileCleaningTracker
+{
+	private final IFileCleaner fileCleaner;
+
+	public FileCleanerTrackerAdapter(IFileCleaner fileCleaner)
+	{
+		this.fileCleaner = Args.notNull(fileCleaner, "fileCleaner");
+	}
+
+	@Override
+	public void track(java.io.File file, Object marker)
+	{
+		fileCleaner.track(file, marker);
+	}
+
+	@Override
+	public void track(java.io.File file, Object marker, FileDeleteStrategy deleteStrategy)
+	{
+		fileCleaner.track(file, marker, deleteStrategy);
+	}
+
+	@Override
+	public void track(String path, Object marker)
+	{
+		fileCleaner.track(new File(path), marker);
+	}
+
+	@Override
+	public void track(String path, Object marker, FileDeleteStrategy deleteStrategy)
+	{
+		fileCleaner.track(new File(path), marker, deleteStrategy);
+	}
+}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaningTracker.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaningTracker.java b/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaningTracker.java
deleted file mode 100644
index 04d469f..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/file/FileCleaningTracker.java
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.file;
-
-import java.io.File;
-import java.lang.ref.PhantomReference;
-import java.lang.ref.ReferenceQueue;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-
-/**
- * Keeps track of files awaiting deletion, and deletes them when an associated marker object is
- * reclaimed by the garbage collector.
- * <p>
- * This utility creates a background thread to handle file deletion. Each file to be deleted is
- * registered with a handler object. When the handler object is garbage collected, the file is
- * deleted.
- * <p>
- * In an environment with multiple class loaders (a servlet container, for example), you should
- * consider stopping the background thread if it is no longer needed. This is done by invoking the
- * method {@link #exitWhenFinished}, typically in
- * {@link javax.servlet.ServletContextListener#contextDestroyed} or similar.
- * 
- * @author Noel Bergman
- * @author Martin Cooper
- * @version $Id$
- */
-public class FileCleaningTracker
-{
-	/**
-	 * Queue of <code>Tracker</code> instances being watched.
-	 */
-	ReferenceQueue<Object> q = new ReferenceQueue<Object>();
-	/**
-	 * Collection of <code>Tracker</code> instances in existence.
-	 */
-	final Collection<Tracker> trackers = Collections.synchronizedSet(new HashSet<Tracker>()); // synchronized
-	/**
-	 * Collection of File paths that failed to delete.
-	 */
-	final List<String> deleteFailures = Collections.synchronizedList(new ArrayList<String>());
-	/**
-	 * Whether to terminate the thread when the tracking is complete.
-	 */
-	volatile boolean exitWhenFinished = false;
-	/**
-	 * The thread that will clean up registered files.
-	 */
-	Thread reaper;
-
-	// -----------------------------------------------------------------------
-	/**
-	 * Track the specified file, using the provided marker, deleting the file when the marker
-	 * instance is garbage collected. The {@link FileDeleteStrategy#NORMAL normal} deletion strategy
-	 * will be used.
-	 * 
-	 * @param file
-	 *            the file to be tracked, not null
-	 * @param marker
-	 *            the marker object used to track the file, not null
-	 * @throws NullPointerException
-	 *             if the file is null
-	 */
-	public void track(final File file, final Object marker)
-	{
-		track(file, marker, (FileDeleteStrategy)null);
-	}
-
-	/**
-	 * Track the specified file, using the provided marker, deleting the file when the marker
-	 * instance is garbage collected. The speified deletion strategy is used.
-	 * 
-	 * @param file
-	 *            the file to be tracked, not null
-	 * @param marker
-	 *            the marker object used to track the file, not null
-	 * @param deleteStrategy
-	 *            the strategy to delete the file, null means normal
-	 * @throws NullPointerException
-	 *             if the file is null
-	 */
-	public void track(final File file, final Object marker, final FileDeleteStrategy deleteStrategy)
-	{
-		if (file == null)
-		{
-			throw new NullPointerException("The file must not be null");
-		}
-		addTracker(file.getPath(), marker, deleteStrategy);
-	}
-
-	/**
-	 * Track the specified file, using the provided marker, deleting the file when the marker
-	 * instance is garbage collected. The {@link FileDeleteStrategy#NORMAL normal} deletion strategy
-	 * will be used.
-	 * 
-	 * @param path
-	 *            the full path to the file to be tracked, not null
-	 * @param marker
-	 *            the marker object used to track the file, not null
-	 * @throws NullPointerException
-	 *             if the path is null
-	 */
-	public void track(final String path, final Object marker)
-	{
-		track(path, marker, null);
-	}
-
-	/**
-	 * Track the specified file, using the provided marker, deleting the file when the marker
-	 * instance is garbage collected. The speified deletion strategy is used.
-	 * 
-	 * @param path
-	 *            the full path to the file to be tracked, not null
-	 * @param marker
-	 *            the marker object used to track the file, not null
-	 * @param deleteStrategy
-	 *            the strategy to delete the file, null means normal
-	 * @throws NullPointerException
-	 *             if the path is null
-	 */
-	public void track(final String path, final Object marker,
-		final FileDeleteStrategy deleteStrategy)
-	{
-		if (path == null)
-		{
-			throw new NullPointerException("The path must not be null");
-		}
-		addTracker(path, marker, deleteStrategy);
-	}
-
-	/**
-	 * Adds a tracker to the list of trackers.
-	 * 
-	 * @param path
-	 *            the full path to the file to be tracked, not null
-	 * @param marker
-	 *            the marker object used to track the file, not null
-	 * @param deleteStrategy
-	 *            the strategy to delete the file, null means normal
-	 */
-	private synchronized void addTracker(final String path, final Object marker,
-		final FileDeleteStrategy deleteStrategy)
-	{
-		// synchronized block protects reaper
-		if (exitWhenFinished)
-		{
-			throw new IllegalStateException(
-				"No new trackers can be added once exitWhenFinished() is called");
-		}
-		if (reaper == null)
-		{
-			reaper = new Reaper();
-			reaper.start();
-		}
-		trackers.add(new Tracker(path, deleteStrategy, marker, q));
-	}
-
-	// -----------------------------------------------------------------------
-	/**
-	 * Retrieve the number of files currently being tracked, and therefore awaiting deletion.
-	 * 
-	 * @return the number of files being tracked
-	 */
-	public int getTrackCount()
-	{
-		return trackers.size();
-	}
-
-	/**
-	 * Return the file paths that failed to delete.
-	 * 
-	 * @return the file paths that failed to delete
-	 * @since Commons IO 2.0
-	 */
-	public List<String> getDeleteFailures()
-	{
-		return deleteFailures;
-	}
-
-	/**
-	 * Call this method to cause the file cleaner thread to terminate when there are no more objects
-	 * being tracked for deletion.
-	 * <p>
-	 * In a simple environment, you don't need this method as the file cleaner thread will simply
-	 * exit when the JVM exits. In a more complex environment, with multiple class loaders (such as
-	 * an application server), you should be aware that the file cleaner thread will continue
-	 * running even if the class loader it was started from terminates. This can consitute a memory
-	 * leak.
-	 * <p>
-	 * For example, suppose that you have developed a web application, which contains the commons-io
-	 * jar file in your WEB-INF/lib directory. In other words, the FileCleaner class is loaded
-	 * through the class loader of your web application. If the web application is terminated, but
-	 * the servlet container is still running, then the file cleaner thread will still exist, posing
-	 * a memory leak.
-	 * <p>
-	 * This method allows the thread to be terminated. Simply call this method in the resource
-	 * cleanup code, such as {@link javax.servlet.ServletContextListener#contextDestroyed}. Once
-	 * called, no new objects can be tracked by the file cleaner.
-	 */
-	public synchronized void exitWhenFinished()
-	{
-		// synchronized block protects reaper
-		exitWhenFinished = true;
-		if (reaper != null)
-		{
-			synchronized (reaper)
-			{
-				reaper.interrupt();
-			}
-		}
-	}
-
-	// -----------------------------------------------------------------------
-	/**
-	 * The reaper thread.
-	 */
-	private final class Reaper extends Thread
-	{
-		/** Construct a new Reaper */
-		Reaper()
-		{
-			super("File Reaper");
-			setPriority(Thread.MAX_PRIORITY);
-			setDaemon(true);
-		}
-
-		/**
-		 * Run the reaper thread that will delete files as their associated marker objects are
-		 * reclaimed by the garbage collector.
-		 */
-		@Override
-		public void run()
-		{
-			// thread exits when exitWhenFinished is true and there are no more tracked objects
-			while ((exitWhenFinished == false) || (trackers.size() > 0))
-			{
-				try
-				{
-					// Wait for a tracker to remove.
-					Tracker tracker = (Tracker)q.remove(); // cannot return null
-					trackers.remove(tracker);
-					if (!tracker.delete())
-					{
-						deleteFailures.add(tracker.getPath());
-					}
-					tracker.clear();
-				}
-				catch (InterruptedException e)
-				{
-					continue;
-				}
-			}
-		}
-	}
-
-	// -----------------------------------------------------------------------
-
-	/**
-	 * Inner class which acts as the reference for a file pending deletion.
-	 */
-	private static final class Tracker extends PhantomReference<Object>
-	{
-		/**
-		 * The full path to the file being tracked.
-		 */
-		private final String path;
-		/**
-		 * The strategy for deleting files.
-		 */
-		private final FileDeleteStrategy deleteStrategy;
-
-		/**
-		 * Constructs an instance of this class from the supplied parameters.
-		 * 
-		 * @param path
-		 *            the full path to the file to be tracked, not null
-		 * @param deleteStrategy
-		 *            the strategy to delete the file, null means normal
-		 * @param marker
-		 *            the marker object used to track the file, not null
-		 * @param queue
-		 *            the queue on to which the tracker will be pushed, not null
-		 */
-		Tracker(final String path, final FileDeleteStrategy deleteStrategy, final Object marker,
-			final ReferenceQueue<? super Object> queue)
-		{
-			super(marker, queue);
-			this.path = path;
-			this.deleteStrategy = (deleteStrategy == null ? FileDeleteStrategy.NORMAL
-				: deleteStrategy);
-		}
-
-		/**
-		 * Return the path.
-		 * 
-		 * @return the path
-		 */
-		public String getPath()
-		{
-			return path;
-		}
-
-		/**
-		 * Deletes the file associated with this tracker instance.
-		 * 
-		 * @return <code>true</code> if the file was deleted successfully; <code>false</code>
-		 *         otherwise.
-		 */
-		public boolean delete()
-		{
-			return deleteStrategy.deleteQuietly(new File(path));
-		}
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/file/FileDeleteStrategy.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/FileDeleteStrategy.java b/wicket-util/src/main/java/org/apache/wicket/util/file/FileDeleteStrategy.java
deleted file mode 100644
index ae769dd..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/file/FileDeleteStrategy.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.file;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Strategy for deleting files.
- * <p>
- * There is more than one way to delete a file. You may want to limit access to certain directories,
- * to only delete directories if they are empty, or maybe to force deletion.
- * <p>
- * This class captures the strategy to use and is designed for user subclassing.
- * 
- * @author Stephen Colebourne
- * @version $Id$
- * @since Commons IO 1.3
- */
-public class FileDeleteStrategy
-{
-	/**
-	 * The singleton instance for normal file deletion, which does not permit the deletion of
-	 * directories that are not empty.
-	 */
-	public static final FileDeleteStrategy NORMAL = new FileDeleteStrategy("Normal");
-
-	/** The name of the strategy. */
-	private final String name;
-
-	// -----------------------------------------------------------------------
-	/**
-	 * Restricted constructor.
-	 * 
-	 * @param name
-	 *            the name by which the strategy is known
-	 */
-	protected FileDeleteStrategy(final String name)
-	{
-		this.name = name;
-	}
-
-	// -----------------------------------------------------------------------
-	/**
-	 * Deletes the file object, which may be a file or a directory. All <code>IOException</code>s
-	 * are caught and false returned instead. If the file does not exist or is null, true is
-	 * returned.
-	 * <p>
-	 * Subclass writers should override {@link #doDelete(File)}, not this method.
-	 * 
-	 * @param fileToDelete
-	 *            the file to delete, null returns true
-	 * @return true if the file was deleted, or there was no such file
-	 */
-	public boolean deleteQuietly(final File fileToDelete)
-	{
-		if ((fileToDelete == null) || (fileToDelete.exists() == false))
-		{
-			return true;
-		}
-		try
-		{
-			return doDelete(fileToDelete);
-		}
-		catch (IOException ex)
-		{
-			return false;
-		}
-	}
-
-	/**
-	 * Deletes the file object, which may be a file or a directory. If the file does not exist, the
-	 * method just returns.
-	 * <p>
-	 * Subclass writers should override {@link #doDelete(File)}, not this method.
-	 * 
-	 * @param fileToDelete
-	 *            the file to delete, not null
-	 * @throws NullPointerException
-	 *             if the file is null
-	 * @throws IOException
-	 *             if an error occurs during file deletion
-	 */
-	public void delete(final File fileToDelete) throws IOException
-	{
-		if (fileToDelete.exists() && (doDelete(fileToDelete) == false))
-		{
-			throw new IOException("Deletion failed: " + fileToDelete);
-		}
-	}
-
-	/**
-	 * Actually deletes the file object, which may be a file or a directory.
-	 * <p>
-	 * This method is designed for subclasses to override. The implementation may return either
-	 * false or an <code>IOException</code> when deletion fails. The {@link #delete(File)} and
-	 * {@link #deleteQuietly(File)} methods will handle either response appropriately. A check has
-	 * been made to ensure that the file will exist.
-	 * <p>
-	 * This implementation uses {@link File#delete()}.
-	 * 
-	 * @param fileToDelete
-	 *            the file to delete, exists, not null
-	 * @return true if the file was deleteds
-	 * @throws NullPointerException
-	 *             if the file is null
-	 * @throws IOException
-	 *             if an error occurs during file deletion
-	 */
-	protected boolean doDelete(final File fileToDelete) throws IOException
-	{
-		return fileToDelete.delete();
-	}
-
-	// -----------------------------------------------------------------------
-	/**
-	 * Gets a string describing the delete strategy.
-	 * 
-	 * @return a string describing the delete strategy
-	 */
-	@Override
-	public String toString()
-	{
-		return "FileDeleteStrategy[" + name + "]";
-	}
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/file/FolderDeleteStrategy.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/FolderDeleteStrategy.java b/wicket-util/src/main/java/org/apache/wicket/util/file/FolderDeleteStrategy.java
index 88f067f..2e9395f 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/file/FolderDeleteStrategy.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/file/FolderDeleteStrategy.java
@@ -19,6 +19,8 @@ package org.apache.wicket.util.file;
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.commons.io.FileDeleteStrategy;
+
 /**
  * A {@link FileDeleteStrategy} that can delete folders.
  */
@@ -26,8 +28,6 @@ public class FolderDeleteStrategy extends FileDeleteStrategy
 {
 	/**
 	 * Construct.
-	 * 
-	 * @param name
 	 */
 	protected FolderDeleteStrategy()
 	{

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/file/IFileCleaner.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/file/IFileCleaner.java b/wicket-util/src/main/java/org/apache/wicket/util/file/IFileCleaner.java
index 4da6633..3f9fe16 100644
--- a/wicket-util/src/main/java/org/apache/wicket/util/file/IFileCleaner.java
+++ b/wicket-util/src/main/java/org/apache/wicket/util/file/IFileCleaner.java
@@ -18,6 +18,8 @@ package org.apache.wicket.util.file;
 
 import java.io.File;
 
+import org.apache.commons.io.FileDeleteStrategy;
+
 /**
  * Keeps track of files awaiting deletion, and deletes them when an associated marker object is
  * reclaimed by the garbage collector.

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/Closeable.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/Closeable.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/Closeable.java
deleted file mode 100644
index 1c7b459..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/Closeable.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.IOException;
-
-
-/**
- * Interface of an object, which may be closed.
- */
-public interface Closeable
-{
-	/**
-	 * Closes the object.
-	 * 
-	 * @throws IOException
-	 *             An I/O error occurred.
-	 */
-	void close() throws IOException;
-
-	/**
-	 * Returns, whether the object is already closed.
-	 * 
-	 * @return True, if the object is closed, otherwise false.
-	 * @throws IOException
-	 *             An I/O error occurred.
-	 */
-	boolean isClosed() throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/DiskFileItem.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/DiskFileItem.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/DiskFileItem.java
deleted file mode 100644
index f4ec711..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/DiskFileItem.java
+++ /dev/null
@@ -1,783 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Map;
-import java.util.Random;
-import java.util.UUID;
-
-import org.apache.wicket.util.file.Files;
-import org.apache.wicket.util.file.IFileCleaner;
-import org.apache.wicket.util.io.DeferredFileOutputStream;
-import org.apache.wicket.util.io.IOUtils;
-import org.apache.wicket.util.io.Streams;
-import org.apache.wicket.util.lang.Checks;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * <p>
- * The default implementation of the {@link org.apache.wicket.util.upload.FileItem FileItem}
- * interface.
- * 
- * <p>
- * After retrieving an instance of this class from a
- * {@link org.apache.wicket.util.upload.FileUpload#FileUpload(FileItemFactory)} instance (see
- * {@link org.apache.wicket.util.upload.FileUploadBase#parseRequest(RequestContext)}
- * ), you may either request all contents of file at once using {@link #get()} or request an
- * {@link java.io.InputStream InputStream} with {@link #getInputStream()} and process the file
- * without attempting to load it into memory, which may come handy with large files.
- * 
- * <p>
- * When using the <code>DiskFileItemFactory</code>, then you should consider the following:
- * Temporary files are automatically deleted as soon as they are no longer needed. (More precisely,
- * when the corresponding instance of {@link java.io.File} is garbage collected.) This is done by
- * the so-called reaper thread, which is started automatically when the class
- * {@link org.apache.wicket.util.file.FileCleaner} is loaded. It might make sense to terminate that
- * thread, for example, if your web application ends. See the section on "Resource cleanup" in the
- * users guide of commons-fileupload.
- * </p>
- * 
- * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @author <a href="mailto:sean@informage.net">Sean Legassick</a>
- * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- * @author Sean C. Sullivan
- */
-public class DiskFileItem implements FileItem, FileItemHeadersSupport
-{
-	private static final Logger log = LoggerFactory.getLogger(DiskFileItem.class);
-
-	/**
-	 * The UID to use when serializing this instance.
-	 */
-	private static final long serialVersionUID = 2237570099615271025L;
-
-	/**
-	 * Default content charset to be used when no explicit charset parameter is provided by the
-	 * sender. Media subtypes of the "text" type are defined to have a default charset value of
-	 * "ISO-8859-1" when received via HTTP.
-	 */
-	public static final String DEFAULT_CHARSET = "ISO-8859-1";
-
-	// ----------------------------------------------------------- Data members
-
-	/**
-	 * UID used in unique file name generation.
-	 */
-	private static final String UID = UUID.randomUUID()
-		.toString()
-		.replace(':', '_')
-		.replace('-', '_');
-
-	/**
-	 * Random counter used in unique identifier generation.
-	 */
-	private static final Random counter = new Random();
-
-	/**
-	 * The name of the form field as provided by the browser.
-	 */
-	private String fieldName;
-
-	/**
-	 * The content type passed by the browser, or <code>null</code> if not defined.
-	 */
-	private final String contentType;
-
-	/**
-	 * Whether or not this item is a simple form field.
-	 */
-	private boolean isFormField;
-
-	/**
-	 * The original filename in the user's filesystem.
-	 */
-	private final String fileName;
-
-	/**
-	 * The size of the item, in bytes. This is used to cache the size when a file item is moved from
-	 * its original location.
-	 */
-	private long size = -1;
-
-	/**
-	 * The threshold above which uploads will be stored on disk.
-	 */
-	private final int sizeThreshold;
-
-	/**
-	 * The directory in which uploaded files will be stored, if stored on disk.
-	 */
-	private final File repository;
-
-	/**
-	 * Cached contents of the file.
-	 */
-	private byte[] cachedContent;
-
-	/**
-	 * Output stream for this item.
-	 */
-	private transient DeferredFileOutputStream dfos;
-
-	/**
-	 * The temporary file to use.
-	 */
-	private transient File tempFile;
-
-	/**
-	 * File to allow for serialization of the content of this item.
-	 */
-	private File dfosFile;
-
-	/**
-	 * The file items headers.
-	 */
-	private FileItemHeaders headers;
-
-	/**
-	 * This is transient because it is needed only for the upload request lifetime to add this file
-	 * item in the tracker. After that the cleaner is not needed anymore.
-	 */
-	private transient final IFileCleaner fileUploadCleaner;
-
-	/**
-	 * Constructs a new <code>DiskFileItem</code> instance.
-	 * 
-	 * @param fieldName
-	 *            The name of the form field.
-	 * @param contentType
-	 *            The content type passed by the browser or <code>null</code> if not specified.
-	 * @param isFormField
-	 *            Whether or not this item is a plain form field, as opposed to a file upload.
-	 * @param fileName
-	 *            The original filename in the user's filesystem, or <code>null</code> if not
-	 *            specified.
-	 * @param sizeThreshold
-	 *            The threshold, in bytes, below which items will be retained in memory and above
-	 *            which they will be stored as a file.
-	 * @param repository
-	 *            The data repository, which is the directory in which files will be created, should
-	 *            the item size exceed the threshold.
-	 * @param fileUploadCleaner
-	 */
-	public DiskFileItem(final String fieldName, final String contentType,
-		final boolean isFormField, final String fileName, final int sizeThreshold,
-		final File repository, final IFileCleaner fileUploadCleaner)
-	{
-		this.fieldName = fieldName;
-		this.contentType = contentType;
-		this.isFormField = isFormField;
-		this.fileName = fileName;
-		this.sizeThreshold = sizeThreshold;
-		this.repository = repository;
-		this.fileUploadCleaner = fileUploadCleaner;
-	}
-
-	/**
-	 * Returns an {@link java.io.InputStream InputStream} that can be used to retrieve the contents
-	 * of the file.
-	 * 
-	 * @return An {@link java.io.InputStream InputStream} that can be used to retrieve the contents
-	 *         of the file.
-	 * 
-	 * @throws IOException
-	 *             if an error occurs.
-	 */
-	@Override
-	public InputStream getInputStream() throws IOException
-	{
-		if (!isInMemory())
-		{
-			return new FileInputStream(dfos.getFile());
-		}
-
-		if (cachedContent == null)
-		{
-			cachedContent = dfos.getData();
-		}
-		return new ByteArrayInputStream(cachedContent);
-	}
-
-	/**
-	 * Returns the content type passed by the agent or <code>null</code> if not defined.
-	 * 
-	 * @return The content type passed by the agent or <code>null</code> if not defined.
-	 */
-	@Override
-	public String getContentType()
-	{
-		return contentType;
-	}
-
-	/**
-	 * Returns the content charset passed by the agent or <code>null</code> if not defined.
-	 * 
-	 * @return The content charset passed by the agent or <code>null</code> if not defined.
-	 */
-	public String getCharSet()
-	{
-		ParameterParser parser = new ParameterParser();
-		parser.setLowerCaseNames(true);
-		// Parameter parser can handle null input
-		Map<?, ?> params = parser.parse(getContentType(), ';');
-		return (String)params.get("charset");
-	}
-
-	/**
-	 * Returns the original filename in the client's filesystem.
-	 * 
-	 * @return The original filename in the client's filesystem.
-	 */
-	@Override
-	public String getName()
-	{
-		return fileName;
-	}
-
-	/**
-	 * Provides a hint as to whether or not the file contents will be read from memory.
-	 * 
-	 * @return <code>true</code> if the file contents will be read from memory; <code>false</code>
-	 *         otherwise.
-	 */
-	@Override
-	public boolean isInMemory()
-	{
-		if (cachedContent != null)
-		{
-			return true;
-		}
-		return dfos.isInMemory();
-	}
-
-	/**
-	 * Returns the size of the file.
-	 * 
-	 * @return The size of the file, in bytes.
-	 */
-	@Override
-	public long getSize()
-	{
-		if (size >= 0)
-		{
-			return size;
-		}
-		else if (cachedContent != null)
-		{
-			return cachedContent.length;
-		}
-		else if (dfos.isInMemory())
-		{
-			return dfos.getData().length;
-		}
-		else
-		{
-			return dfos.getFile().length();
-		}
-	}
-
-	/**
-	 * Returns the contents of the file as an array of bytes. If the contents of the file were not
-	 * yet cached in memory, they will be loaded from the disk storage and cached.
-	 * 
-	 * @return The contents of the file as an array of bytes.
-	 */
-	@Override
-	public byte[] get()
-	{
-		if (isInMemory())
-		{
-			if (cachedContent == null)
-			{
-				cachedContent = dfos.getData();
-			}
-			return cachedContent;
-		}
-
-		File file = dfos.getFile();
-
-		try
-		{
-			return Files.readBytes(file);
-		}
-		catch (IOException e)
-		{
-			log.debug("failed to read content of file: " + file.getAbsolutePath(), e);
-			return null;
-		}
-	}
-
-
-	/**
-	 * Returns the contents of the file as a String, using the specified encoding. This method uses
-	 * {@link #get()} to retrieve the contents of the file.
-	 * 
-	 * @param charset
-	 *            The charset to use.
-	 * 
-	 * @return The contents of the file, as a string.
-	 * 
-	 * @throws UnsupportedEncodingException
-	 *             if the requested character encoding is not available.
-	 */
-	@Override
-	public String getString(final String charset) throws UnsupportedEncodingException
-	{
-		return new String(get(), charset);
-	}
-
-	/**
-	 * Returns the contents of the file as a String, using the default character encoding. This
-	 * method uses {@link #get()} to retrieve the contents of the file.
-	 * 
-	 * @return The contents of the file, as a string.
-	 * 
-	 * @todo Consider making this method throw UnsupportedEncodingException.
-	 */
-	@Override
-	public String getString()
-	{
-		byte[] rawdata = get();
-		String charset = getCharSet();
-		if (charset == null)
-		{
-			charset = DEFAULT_CHARSET;
-		}
-		try
-		{
-			return new String(rawdata, charset);
-		}
-		catch (UnsupportedEncodingException e)
-		{
-			return new String(rawdata);
-		}
-	}
-
-
-	/**
-	 * A convenience method to write an uploaded item to disk. The client code is not concerned with
-	 * whether or not the item is stored in memory, or on disk in a temporary location. They just
-	 * want to write the uploaded item to a file.
-	 * <p>
-	 * This implementation first attempts to rename the uploaded item to the specified destination
-	 * file, if the item was originally written to disk. Otherwise, the data will be copied to the
-	 * specified file.
-	 * <p>
-	 * This method is only guaranteed to work <em>once</em>, the first time it is invoked for a
-	 * particular item. This is because, in the event that the method renames a temporary file, that
-	 * file will no longer be available to copy or rename again at a later time.
-	 * 
-	 * @param file
-	 *            The <code>File</code> into which the uploaded item should be stored.
-	 * 
-	 * @throws Exception
-	 *             if an error occurs.
-	 */
-	@Override
-	public void write(final File file) throws IOException
-	{
-		if (isInMemory())
-		{
-			FileOutputStream fout = new FileOutputStream(file);
-
-			try
-			{
-				fout.write(get());
-			}
-			finally
-			{
-				fout.close();
-			}
-		}
-		else
-		{
-			File outputFile = getStoreLocation();
-			Checks.notNull(outputFile,
-				"for a non-memory upload the file location must not be empty");
-
-			// Save the length of the file
-			size = outputFile.length();
-			/*
-			 * The uploaded file is being stored on disk in a temporary location so move it to the
-			 * desired file.
-			 */
-			if (!outputFile.renameTo(file))
-			{
-				BufferedInputStream in = null;
-				BufferedOutputStream out = null;
-				try
-				{
-					in = new BufferedInputStream(new FileInputStream(outputFile));
-					out = new BufferedOutputStream(new FileOutputStream(file));
-					Streams.copy(in, out);
-				}
-				finally
-				{
-					IOUtils.closeQuietly(in);
-					IOUtils.closeQuietly(out);
-				}
-			}
-		}
-	}
-
-	/**
-	 * Deletes the underlying storage for a file item, including deleting any associated temporary
-	 * disk file. Although this storage will be deleted automatically when the <code>FileItem</code>
-	 * instance is garbage collected, this method can be used to ensure that this is done at an
-	 * earlier time, thus preserving system resources.
-	 */
-	@Override
-	public void delete()
-	{
-		cachedContent = null;
-		File outputFile = getStoreLocation();
-		if ((outputFile != null) && outputFile.exists())
-		{
-			if (Files.remove(outputFile) == false)
-			{
-				log.error("failed to delete file: " + outputFile.getAbsolutePath());
-			}
-		}
-	}
-
-
-	/**
-	 * Returns the name of the field in the multipart form corresponding to this file item.
-	 * 
-	 * @return The name of the form field.
-	 * 
-	 * @see #setFieldName(java.lang.String)
-	 * 
-	 */
-	@Override
-	public String getFieldName()
-	{
-		return fieldName;
-	}
-
-	/**
-	 * Sets the field name used to reference this file item.
-	 * 
-	 * @param fieldName
-	 *            The name of the form field.
-	 * 
-	 * @see #getFieldName()
-	 * 
-	 */
-	@Override
-	public void setFieldName(final String fieldName)
-	{
-		this.fieldName = fieldName;
-	}
-
-	/**
-	 * Determines whether or not a <code>FileItem</code> instance represents a simple form field.
-	 * 
-	 * @return <code>true</code> if the instance represents a simple form field; <code>false</code>
-	 *         if it represents an uploaded file.
-	 * 
-	 * @see #setFormField(boolean)
-	 * 
-	 */
-	@Override
-	public boolean isFormField()
-	{
-		return isFormField;
-	}
-
-
-	/**
-	 * Specifies whether or not a <code>FileItem</code> instance represents a simple form field.
-	 * 
-	 * @param state
-	 *            <code>true</code> if the instance represents a simple form field;
-	 *            <code>false</code> if it represents an uploaded file.
-	 * 
-	 * @see #isFormField()
-	 * 
-	 */
-	@Override
-	public void setFormField(final boolean state)
-	{
-		isFormField = state;
-	}
-
-
-	/**
-	 * Returns an {@link java.io.OutputStream OutputStream} that can be used for storing the
-	 * contents of the file.
-	 * 
-	 * @return An {@link java.io.OutputStream OutputStream} that can be used for storing the
-	 *         contensts of the file.
-	 * 
-	 * @throws IOException
-	 *             if an error occurs.
-	 */
-	@Override
-	public OutputStream getOutputStream() throws IOException
-	{
-		if (dfos == null)
-		{
-			dfos = new DeferredFileOutputStream(sizeThreshold,
-				new DeferredFileOutputStream.FileFactory()
-				{
-					@Override
-					public File createFile()
-					{
-						return getTempFile();
-					}
-				});
-		}
-		return dfos;
-	}
-
-
-	// --------------------------------------------------------- Public methods
-
-
-	/**
-	 * Returns the {@link java.io.File} object for the <code>FileItem</code>'s data's temporary
-	 * location on the disk. Note that for <code>FileItem</code>s that have their data stored in
-	 * memory, this method will return <code>null</code>. When handling large files, you can use
-	 * {@link java.io.File#renameTo(java.io.File)} to move the file to new location without copying
-	 * the data, if the source and destination locations reside within the same logical volume.
-	 * 
-	 * @return The data file, or <code>null</code> if the data is stored in memory.
-	 */
-	public File getStoreLocation()
-	{
-		return dfos == null ? null : dfos.getFile();
-	}
-
-
-	// ------------------------------------------------------ Protected methods
-
-
-	/**
-	 * Removes the file contents from the temporary storage.
-	 */
-	@Override
-	protected void finalize() throws Throwable
-	{
-		super.finalize(); // currently empty but there for safer refactoring
-
-		File outputFile = dfos.getFile();
-
-		if ((outputFile != null) && outputFile.exists())
-		{
-			if (Files.remove(outputFile) == false)
-			{
-				log.error("failed to delete file: " + outputFile.getAbsolutePath());
-			}
-		}
-	}
-
-
-	/**
-	 * Creates and returns a {@link java.io.File File} representing a uniquely named temporary file
-	 * in the configured repository path. The lifetime of the file is tied to the lifetime of the
-	 * <code>FileItem</code> instance; the file will be deleted when the instance is garbage
-	 * collected.
-	 * 
-	 * @return The {@link java.io.File File} to be used for temporary storage.
-	 */
-	protected File getTempFile()
-	{
-		if (tempFile == null)
-		{
-			File tempDir = repository;
-			if (tempDir == null)
-			{
-				String systemTmp = null;
-				try
-				{
-					systemTmp = System.getProperty("java.io.tmpdir");
-				}
-				catch (SecurityException e)
-				{
-					throw new RuntimeException(
-						"Reading property java.io.tmpdir is not allowed"
-							+ " for the current security settings. The repository location needs to be"
-							+ " set manually, or upgrade permissions to allow reading the tmpdir property.");
-				}
-				tempDir = new File(systemTmp);
-			}
-
-			try
-			{
-				do
-				{
-					String tempFileName = "upload_" + UID + "_" + getUniqueId() + ".tmp";
-					tempFile = new File(tempDir, tempFileName);
-				}
-				while (!tempFile.createNewFile());
-			}
-			catch (IOException e)
-			{
-				throw new RuntimeException("Could not create the temp file for upload: " +
-					tempFile.getAbsolutePath(), e);
-			}
-
-			if (fileUploadCleaner != null)
-			{
-				fileUploadCleaner.track(tempFile, this);
-			}
-		}
-		return tempFile;
-	}
-
-	// -------------------------------------------------------- Private methods
-
-
-	/**
-	 * Returns an identifier that is unique within the class loader used to load this class, but
-	 * does not have random-like appearance.
-	 * 
-	 * @return A String with the non-random looking instance identifier.
-	 */
-	private static String getUniqueId()
-	{
-		final int limit = 100000000;
-		int current;
-		synchronized (DiskFileItem.class)
-		{
-			current = counter.nextInt();
-		}
-		String id = Integer.toString(current);
-
-		// If you manage to get more than 100 million of ids, you'll
-		// start getting ids longer than 8 characters.
-		if (current < limit)
-		{
-			id = ("00000000" + id).substring(id.length());
-		}
-		return id;
-	}
-
-
-	/**
-	 * @see java.lang.Object#toString()
-	 */
-	@Override
-	public String toString()
-	{
-		return "name=" + getName() + ", StoreLocation=" + String.valueOf(getStoreLocation()) +
-			", size=" + getSize() + "bytes, " + "isFormField=" + isFormField() + ", FieldName=" +
-			getFieldName();
-	}
-
-
-	// -------------------------------------------------- Serialization methods
-
-
-	/**
-	 * Writes the state of this object during serialization.
-	 * 
-	 * @param out
-	 *            The stream to which the state should be written.
-	 * 
-	 * @throws IOException
-	 *             if an error occurs.
-	 */
-	private void writeObject(final ObjectOutputStream out) throws IOException
-	{
-		// Read the data
-		if (dfos.isInMemory())
-		{
-			cachedContent = get();
-		}
-		else
-		{
-			cachedContent = null;
-			dfosFile = dfos.getFile();
-		}
-
-		// write out values
-		out.defaultWriteObject();
-	}
-
-	/**
-	 * Reads the state of this object during deserialization.
-	 * 
-	 * @param in
-	 *            The stream from which the state should be read.
-	 * 
-	 * @throws IOException
-	 *             if an error occurs.
-	 * @throws ClassNotFoundException
-	 *             if class cannot be found.
-	 */
-	private void readObject(final ObjectInputStream in) throws IOException, ClassNotFoundException
-	{
-		// read values
-		in.defaultReadObject();
-
-		OutputStream output = getOutputStream();
-		if (cachedContent != null)
-		{
-			output.write(cachedContent);
-		}
-		else
-		{
-			FileInputStream input = new FileInputStream(dfosFile);
-			Streams.copy(input, output);
-			Files.remove(dfosFile);
-			dfosFile = null;
-		}
-		output.close();
-
-		cachedContent = null;
-	}
-
-	/**
-	 * Returns the file item headers.
-	 * 
-	 * @return The file items headers.
-	 */
-	@Override
-	public FileItemHeaders getHeaders()
-	{
-		return headers;
-	}
-
-	/**
-	 * Sets the file item headers.
-	 * 
-	 * @param pHeaders
-	 *            The file items headers.
-	 */
-	@Override
-	public void setHeaders(final FileItemHeaders pHeaders)
-	{
-		headers = pHeaders;
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/DiskFileItemFactory.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/DiskFileItemFactory.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/DiskFileItemFactory.java
deleted file mode 100644
index 0123e1f..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/DiskFileItemFactory.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.File;
-
-import org.apache.wicket.util.file.FileCleaningTracker;
-import org.apache.wicket.util.file.IFileCleaner;
-
-
-/**
- * <p>
- * The default {@link org.apache.wicket.util.upload.FileItemFactory} implementation. This
- * implementation creates {@link org.apache.wicket.util.upload.FileItem} instances which keep their
- * content either in memory, for smaller items, or in a temporary file on disk, for larger items.
- * The size threshold, above which content will be stored on disk, is configurable, as is the
- * directory in which temporary files will be created.
- * </p>
- * 
- * <p>
- * If not otherwise configured, the default configuration values are as follows:
- * <ul>
- * <li>Size threshold is 10KB.</li>
- * <li>Repository is the system default temp directory, as returned by
- * <code>System.getProperty("java.io.tmpdir")</code>.</li>
- * </ul>
- * </p>
- * 
- * <p>
- * When using the <code>DiskFileItemFactory</code>, then you should consider the following:
- * Temporary files are automatically deleted as soon as they are no longer needed. (More precisely,
- * when the corresponding instance of {@link java.io.File} is garbage collected.) Cleaning up those
- * files is done by an instance of {@link FileCleaningTracker}, and an associated thread. In a
- * complex environment, for example in a web application, you should consider terminating this
- * thread, for example, when your web application ends. See the section on "Resource cleanup" in the
- * users guide of commons-fileupload.
- * </p>
- * 
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- */
-public class DiskFileItemFactory implements FileItemFactory
-{
-
-	// ----------------------------------------------------- Manifest constants
-
-
-	/**
-	 * The default threshold above which uploads will be stored on disk.
-	 */
-	public static final int DEFAULT_SIZE_THRESHOLD = 10240;
-
-
-	// ----------------------------------------------------- Instance Variables
-
-
-	/**
-	 * The directory in which uploaded files will be stored, if stored on disk.
-	 */
-	private File repository;
-
-
-	/**
-	 * The threshold above which uploads will be stored on disk.
-	 */
-	private int sizeThreshold = DEFAULT_SIZE_THRESHOLD;
-
-	private final IFileCleaner fileUploadCleaner;
-
-	// ----------------------------------------------------------- Constructors
-
-
-	/**
-	 * Constructs an unconfigured instance of this class. The resulting factory may be configured by
-	 * calling the appropriate setter methods.
-	 * 
-	 * @param fileUploadCleaner
-	 */
-	public DiskFileItemFactory(final IFileCleaner fileUploadCleaner)
-	{
-		this(DEFAULT_SIZE_THRESHOLD, null, fileUploadCleaner);
-	}
-
-
-	/**
-	 * Constructs a preconfigured instance of this class.
-	 * 
-	 * @param sizeThreshold
-	 *            The threshold, in bytes, below which items will be retained in memory and above
-	 *            which they will be stored as a file.
-	 * @param repository
-	 *            The data repository, which is the directory in which files will be created, should
-	 *            the item size exceed the threshold.
-	 * @param fileUploadCleaner
-	 */
-	public DiskFileItemFactory(final int sizeThreshold, final File repository,
-		final IFileCleaner fileUploadCleaner)
-	{
-		this.sizeThreshold = sizeThreshold;
-		this.repository = repository;
-		this.fileUploadCleaner = fileUploadCleaner;
-	}
-
-	// ------------------------------------------------------------- Properties
-
-
-	/**
-	 * Returns the directory used to temporarily store files that are larger than the configured
-	 * size threshold.
-	 * 
-	 * @return The directory in which temporary files will be located.
-	 * 
-	 * @see #setRepository(java.io.File)
-	 * 
-	 */
-	public File getRepository()
-	{
-		return repository;
-	}
-
-
-	/**
-	 * Sets the directory used to temporarily store files that are larger than the configured size
-	 * threshold.
-	 * 
-	 * @param repository
-	 *            The directory in which temporary files will be located.
-	 * 
-	 * @see #getRepository()
-	 * 
-	 */
-	public void setRepository(final File repository)
-	{
-		this.repository = repository;
-	}
-
-
-	/**
-	 * Returns the size threshold beyond which files are written directly to disk. The default value
-	 * is 10240 bytes.
-	 * 
-	 * @return The size threshold, in bytes.
-	 * 
-	 * @see #setSizeThreshold(int)
-	 */
-	public int getSizeThreshold()
-	{
-		return sizeThreshold;
-	}
-
-
-	/**
-	 * Sets the size threshold beyond which files are written directly to disk.
-	 * 
-	 * @param sizeThreshold
-	 *            The size threshold, in bytes.
-	 * 
-	 * @see #getSizeThreshold()
-	 * 
-	 */
-	public void setSizeThreshold(final int sizeThreshold)
-	{
-		this.sizeThreshold = sizeThreshold;
-	}
-
-
-	// --------------------------------------------------------- Public Methods
-
-	/**
-	 * Create a new {@link org.apache.wicket.util.upload.DiskFileItem} instance from the supplied
-	 * parameters and the local factory configuration.
-	 * 
-	 * @param fieldName
-	 *            The name of the form field.
-	 * @param contentType
-	 *            The content type of the form field.
-	 * @param isFormField
-	 *            <code>true</code> if this is a plain form field; <code>false</code> otherwise.
-	 * @param fileName
-	 *            The name of the uploaded file, if any, as supplied by the browser or other client.
-	 * 
-	 * @return The newly created file item.
-	 */
-	@Override
-	public FileItem createItem(final String fieldName, final String contentType,
-		final boolean isFormField, final String fileName)
-	{
-		return new DiskFileItem(fieldName, contentType, isFormField, fileName, sizeThreshold,
-			repository, fileUploadCleaner);
-	}
-
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItem.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItem.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItem.java
deleted file mode 100644
index bfdf357..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItem.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.apache.wicket.util.io.IClusterable;
-
-/**
- * <p>
- * This class represents a file or form item that was received within a
- * <code>multipart/form-data</code> POST request.
- * 
- * <p>
- * After retrieving an instance of this class from a
- * {@link org.apache.wicket.util.upload.FileUpload FileUpload} instance (see
- * {@link org.apache.wicket.util.upload.FileUpload #parseRequest(javax.servlet.http.HttpServletRequest)}
- * ), you may either request all contents of the file at once using {@link #get()} or request an
- * {@link java.io.InputStream InputStream} with {@link #getInputStream()} and process the file
- * without attempting to load it into memory, which may come handy with large files.
- * 
- * <p>
- * While this interface does not extend <code>javax.activation.DataSource</code> per se (to avoid a
- * seldom used dependency), several of the defined methods are specifically defined with the same
- * signatures as methods in that interface. This allows an implementation of this interface to also
- * implement <code>javax.activation.DataSource</code> with minimal additional work.
- * 
- * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @author <a href="mailto:sean@informage.net">Sean Legassick</a>
- * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- */
-public interface FileItem extends IClusterable
-{
-
-
-	// ------------------------------- Methods from javax.activation.DataSource
-
-
-	/**
-	 * Returns an {@link java.io.InputStream InputStream} that can be used to retrieve the contents
-	 * of the file.
-	 * 
-	 * @return An {@link java.io.InputStream InputStream} that can be used to retrieve the contents
-	 *         of the file.
-	 * 
-	 * @throws IOException
-	 *             if an error occurs.
-	 */
-	InputStream getInputStream() throws IOException;
-
-
-	/**
-	 * Returns the content type passed by the browser or <code>null</code> if not defined.
-	 * 
-	 * @return The content type passed by the browser or <code>null</code> if not defined.
-	 */
-	String getContentType();
-
-
-	/**
-	 * Returns the original filename in the client's filesystem, as provided by the browser (or
-	 * other client software). In most cases, this will be the base file name, without path
-	 * information. However, some clients, such as the Opera browser, do include path information.
-	 * 
-	 * @return The original filename in the client's filesystem.
-	 */
-	String getName();
-
-
-	// ------------------------------------------------------- FileItem methods
-
-
-	/**
-	 * Provides a hint as to whether or not the file contents will be read from memory.
-	 * 
-	 * @return <code>true</code> if the file contents will be read from memory; <code>false</code>
-	 *         otherwise.
-	 */
-	boolean isInMemory();
-
-
-	/**
-	 * Returns the size of the file item.
-	 * 
-	 * @return The size of the file item, in bytes.
-	 */
-	long getSize();
-
-
-	/**
-	 * Returns the contents of the file item as an array of bytes.
-	 * 
-	 * @return The contents of the file item as an array of bytes.
-	 */
-	byte[] get();
-
-
-	/**
-	 * Returns the contents of the file item as a String, using the specified encoding. This method
-	 * uses {@link #get()} to retrieve the contents of the item.
-	 * 
-	 * @param encoding
-	 *            The character encoding to use.
-	 * 
-	 * @return The contents of the item, as a string.
-	 * 
-	 * @throws UnsupportedEncodingException
-	 *             if the requested character encoding is not available.
-	 */
-	String getString(String encoding) throws UnsupportedEncodingException;
-
-
-	/**
-	 * Returns the contents of the file item as a String, using the default character encoding. This
-	 * method uses {@link #get()} to retrieve the contents of the item.
-	 * 
-	 * @return The contents of the item, as a string.
-	 */
-	String getString();
-
-
-	/**
-	 * A convenience method to write an uploaded item to disk. The client code is not concerned with
-	 * whether or not the item is stored in memory, or on disk in a temporary location. They just
-	 * want to write the uploaded item to a file.
-	 * <p>
-	 * This method is not guaranteed to succeed if called more than once for the same item. This
-	 * allows a particular implementation to use, for example, file renaming, where possible, rather
-	 * than copying all of the underlying data, thus gaining a significant performance benefit.
-	 * 
-	 * @param file
-	 *            The <code>File</code> into which the uploaded item should be stored.
-	 * @throws IOException
-	 *             if an error occurs.
-	 */
-	void write(File file) throws IOException;
-
-
-	/**
-	 * Deletes the underlying storage for a file item, including deleting any associated temporary
-	 * disk file. Although this storage will be deleted automatically when the <code>FileItem</code>
-	 * instance is garbage collected, this method can be used to ensure that this is done at an
-	 * earlier time, thus preserving system resources.
-	 */
-	void delete();
-
-
-	/**
-	 * Returns the name of the field in the multipart form corresponding to this file item.
-	 * 
-	 * @return The name of the form field.
-	 */
-	String getFieldName();
-
-
-	/**
-	 * Sets the field name used to reference this file item.
-	 * 
-	 * @param name
-	 *            The name of the form field.
-	 */
-	void setFieldName(String name);
-
-
-	/**
-	 * Determines whether or not a <code>FileItem</code> instance represents a simple form field.
-	 * 
-	 * @return <code>true</code> if the instance represents a simple form field; <code>false</code>
-	 *         if it represents an uploaded file.
-	 */
-	boolean isFormField();
-
-
-	/**
-	 * Specifies whether or not a <code>FileItem</code> instance represents a simple form field.
-	 * 
-	 * @param state
-	 *            <code>true</code> if the instance represents a simple form field;
-	 *            <code>false</code> if it represents an uploaded file.
-	 */
-	void setFormField(boolean state);
-
-
-	/**
-	 * Returns an {@link java.io.OutputStream OutputStream} that can be used for storing the
-	 * contents of the file.
-	 * 
-	 * @return An {@link java.io.OutputStream OutputStream} that can be used for storing the
-	 *         contents of the file.
-	 * 
-	 * @throws IOException
-	 *             if an error occurs.
-	 */
-	OutputStream getOutputStream() throws IOException;
-
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemFactory.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemFactory.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemFactory.java
deleted file mode 100644
index 6c01c8f..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemFactory.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-
-/**
- * <p>
- * A factory interface for creating {@link FileItem} instances. Factories can provide their own
- * custom configuration, over and above that provided by the default file upload implementation.
- * </p>
- * 
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- */
-public interface FileItemFactory
-{
-
-	/**
-	 * Create a new {@link FileItem} instance from the supplied parameters and any local factory
-	 * configuration.
-	 * 
-	 * @param fieldName
-	 *            The name of the form field.
-	 * @param contentType
-	 *            The content type of the form field.
-	 * @param isFormField
-	 *            <code>true</code> if this is a plain form field; <code>false</code> otherwise.
-	 * @param fileName
-	 *            The name of the uploaded file, if any, as supplied by the browser or other client.
-	 * 
-	 * @return The newly created file item.
-	 */
-	FileItem createItem(String fieldName, String contentType, boolean isFormField, String fileName);
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeaders.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeaders.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeaders.java
deleted file mode 100644
index 8e1f128..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeaders.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.util.Iterator;
-
-/**
- * <p>
- * This class provides support for accessing the headers for a file or form item that was received
- * within a <code>multipart/form-data</code> POST request.
- * </p>
- * 
- * @author Michael C. Macaluso
- */
-public interface FileItemHeaders
-{
-	/**
-	 * Returns the value of the specified part header as a <code>String</code>. If the part did not
-	 * include a header of the specified name, this method return <code>null</code>. If there are
-	 * multiple headers with the same name, this method returns the first header in the item. The
-	 * header name is case insensitive.
-	 * 
-	 * @param name
-	 *            a <code>String</code> specifying the header name
-	 * @return a <code>String</code> containing the value of the requested header, or
-	 *         <code>null</code> if the item does not have a header of that name
-	 */
-	String getHeader(String name);
-
-	/**
-	 * <p>
-	 * Returns all the values of the specified item header as an <code>Enumeration</code> of
-	 * <code>String</code> objects.
-	 * </p>
-	 * <p>
-	 * If the item did not include any headers of the specified name, this method returns an empty
-	 * <code>Enumeration</code>. The header name is case insensitive.
-	 * </p>
-	 * 
-	 * @param name
-	 *            a <code>String</code> specifying the header name
-	 * @return an <code>Enumeration</code> containing the values of the requested header. If the
-	 *         item does not have any headers of that name, return an empty <code>Enumeration</code>
-	 */
-	Iterator<String> getHeaders(String name);
-
-	/**
-	 * <p>
-	 * Returns an <code>Enumeration</code> of all the header names.
-	 * </p>
-	 * <p>
-	 * If the item did not include any headers of the specified name, this method returns an empty
-	 * <code>Enumeration</code>. The header name is case insensitive.
-	 * </p>
-	 * 
-	 * @return an <code>Enumeration</code> containing the values of the requested header. If the
-	 *         item does not have any headers of that name return an empty <code>Enumeration</code>
-	 */
-	Iterator<String> getHeaderNames();
-}


[2/3] WICKET-5503 Remove local copies of Commons FileUpload files and use Maven dependency

Posted by mg...@apache.org.
http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeadersImpl.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeadersImpl.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeadersImpl.java
deleted file mode 100644
index 8400ed8..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeadersImpl.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.wicket.util.lang.Generics;
-
-/**
- * Default implementation of the {@link FileItemHeaders} interface.
- * 
- * @author Michael C. Macaluso
- * @since 1.3
- */
-public class FileItemHeadersImpl implements FileItemHeaders, Serializable
-{
-	private static final long serialVersionUID = -4455695752627032559L;
-
-	/**
-	 * Map of <code>String</code> keys to a <code>List</code> of <code>String</code> instances.
-	 */
-	private final Map<String, List<String>> headerNameToValueListMap = Generics.newHashMap();
-
-	/**
-	 * List to preserve order of headers as added. This would not be needed if a
-	 * <code>LinkedHashMap</code> could be used, but don't want to depend on 1.4.
-	 */
-	private final List<String> headerNameList = Generics.newArrayList();
-
-	@Override
-	public String getHeader(final String name)
-	{
-		String nameLower = name.toLowerCase();
-		List<String> headerValueList = headerNameToValueListMap.get(nameLower);
-		if (null == headerValueList)
-		{
-			return null;
-		}
-		return headerValueList.get(0);
-	}
-
-	@Override
-	public Iterator<String> getHeaderNames()
-	{
-		return headerNameList.iterator();
-	}
-
-	@Override
-	public Iterator<String> getHeaders(final String name)
-	{
-		String nameLower = name.toLowerCase();
-		List<String> headerValueList = headerNameToValueListMap.get(nameLower);
-		if (null == headerValueList)
-		{
-			headerValueList = Collections.emptyList();
-		}
-		return headerValueList.iterator();
-	}
-
-	/**
-	 * Method to add header values to this instance.
-	 * 
-	 * @param name
-	 *            name of this header
-	 * @param value
-	 *            value of this header
-	 */
-	public synchronized void addHeader(final String name, final String value)
-	{
-		String nameLower = name.toLowerCase();
-		List<String> headerValueList = headerNameToValueListMap.get(nameLower);
-		if (null == headerValueList)
-		{
-			headerValueList = Generics.newArrayList();
-			headerNameToValueListMap.put(nameLower, headerValueList);
-			headerNameList.add(nameLower);
-		}
-		headerValueList.add(value);
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeadersSupport.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeadersSupport.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeadersSupport.java
deleted file mode 100644
index cbd629e..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemHeadersSupport.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-/**
- * Interface that will indicate that {@link FileItem} or {@link FileItemStream} implementations will
- * accept the headers read for the item.
- * 
- * @author Michael C. Macaluso
- * 
- * @see FileItem
- * @see FileItemStream
- */
-public interface FileItemHeadersSupport
-{
-	/**
-	 * Returns the collection of headers defined locally within this item.
-	 * 
-	 * @return the {@link FileItemHeaders} present for this item.
-	 */
-	FileItemHeaders getHeaders();
-
-	/**
-	 * Sets the headers read from within an item. Implementations of {@link FileItem} or
-	 * {@link FileItemStream} should implement this interface to be able to get the raw headers
-	 * found within the item header block.
-	 * 
-	 * @param headers
-	 *            the instance that holds onto the headers for this instance.
-	 */
-	void setHeaders(FileItemHeaders headers);
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemIterator.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemIterator.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemIterator.java
deleted file mode 100644
index 9fce5c7..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemIterator.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.IOException;
-
-
-/**
- * An iterator, as returned by {@link FileUploadBase#getItemIterator(RequestContext)}.
- */
-public interface FileItemIterator
-{
-	/**
-	 * Returns, whether another instance of {@link FileItemStream} is available.
-	 * 
-	 * @throws FileUploadException
-	 *             Parsing or processing the file item failed.
-	 * @throws IOException
-	 *             Reading the file item failed.
-	 * @return True, if one or more additional file items are available, otherwise false.
-	 */
-	boolean hasNext() throws FileUploadException, IOException;
-
-	/**
-	 * Returns the next available {@link FileItemStream}.
-	 * 
-	 * @throws java.util.NoSuchElementException
-	 *             No more items are available. Use {@link #hasNext()} to prevent this exception.
-	 * @throws FileUploadException
-	 *             Parsing or processing the file item failed.
-	 * @throws IOException
-	 *             Reading the file item failed.
-	 * @return FileItemStream instance, which provides access to the next file item.
-	 */
-	FileItemStream next() throws FileUploadException, IOException;
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemStream.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemStream.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemStream.java
deleted file mode 100644
index 7d18c0e..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileItemStream.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-
-/**
- * <p>
- * This interface provides access to a file or form item that was received within a
- * <code>multipart/form-data</code> POST request. The items contents are retrieved by calling
- * {@link #openStream()}.
- * </p>
- * <p>
- * Instances of this class are created by accessing the iterator, returned by
- * {@link FileUploadBase#getItemIterator(RequestContext)}.
- * </p>
- * <p>
- * <em>Note</em>: There is an interaction between the iterator and its associated instances of
- * {@link FileItemStream}: By invoking {@link java.util.Iterator#hasNext()} on the iterator, you
- * discard all data, which hasn't been read so far from the previous data.
- * </p>
- */
-public interface FileItemStream extends FileItemHeadersSupport
-{
-	/**
-	 * This exception is thrown, if an attempt is made to read data from the {@link InputStream},
-	 * which has been returned by {@link FileItemStream#openStream()}, after
-	 * {@link java.util.Iterator#hasNext()} has been invoked on the iterator, which created the
-	 * {@link FileItemStream}.
-	 */
-	public static class ItemSkippedException extends IOException
-	{
-		/**
-		 * The exceptions serial version UID, which is being used when serializing an exception
-		 * instance.
-		 */
-		private static final long serialVersionUID = -7280778431581963740L;
-	}
-
-	/**
-	 * Creates an {@link InputStream}, which allows to read the items contents.
-	 * 
-	 * @return The input stream, from which the items data may be read.
-	 * @throws IllegalStateException
-	 *             The method was already invoked on this item. It is not possible to recreate the
-	 *             data stream.
-	 * @throws IOException
-	 *             An I/O error occurred.
-	 * @see ItemSkippedException
-	 */
-	InputStream openStream() throws IOException;
-
-	/**
-	 * Returns the content type passed by the browser or <code>null</code> if not defined.
-	 * 
-	 * @return The content type passed by the browser or <code>null</code> if not defined.
-	 */
-	String getContentType();
-
-	/**
-	 * Returns the original filename in the client's filesystem, as provided by the browser (or
-	 * other client software). In most cases, this will be the base file name, without path
-	 * information. However, some clients, such as the Opera browser, do include path information.
-	 * 
-	 * @return The original filename in the client's filesystem.
-	 */
-	String getName();
-
-	/**
-	 * Returns the name of the field in the multipart form corresponding to this file item.
-	 * 
-	 * @return The name of the form field.
-	 */
-	String getFieldName();
-
-	/**
-	 * Determines whether or not a <code>FileItem</code> instance represents a simple form field.
-	 * 
-	 * @return <code>true</code> if the instance represents a simple form field; <code>false</code>
-	 *         if it represents an uploaded file.
-	 */
-	boolean isFormField();
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUpload.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUpload.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUpload.java
deleted file mode 100644
index 0657436..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUpload.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-
-/**
- * <p>
- * High level API for processing file uploads.
- * </p>
- * 
- * <p>
- * This class handles multiple files per single HTML widget, sent using <code>multipart/mixed</code>
- * encoding type, as specified by <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use
- * {@link #parseRequest(javax.servlet.http.HttpServletRequest)} to acquire a list of
- * {@link org.apache.wicket.util.upload.FileItem FileItems} associated with a given HTML widget.
- * </p>
- * 
- * <p>
- * How the data for individual parts is stored is determined by the factory used to create them; a
- * given part may be in memory, on disk, or somewhere else.
- * </p>
- * 
- * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
- * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- * @author Sean C. Sullivan
- */
-public class FileUpload extends FileUploadBase
-{
-
-	// ----------------------------------------------------------- Data members
-
-
-	/**
-	 * The factory to use to create new form items.
-	 */
-	private FileItemFactory fileItemFactory;
-
-
-	// ----------------------------------------------------------- Constructors
-
-
-	/**
-	 * Constructs an uninitialised instance of this class. A factory must be configured, using
-	 * <code>setFileItemFactory()</code>, before attempting to parse requests.
-	 * 
-	 * @see #FileUpload(FileItemFactory)
-	 */
-	public FileUpload()
-	{
-		super();
-	}
-
-
-	/**
-	 * Constructs an instance of this class which uses the supplied factory to create
-	 * <code>FileItem</code> instances.
-	 * 
-	 * @see #FileUpload()
-	 * @param fileItemFactory
-	 *            The factory to use for creating file items.
-	 */
-	public FileUpload(final FileItemFactory fileItemFactory)
-	{
-		super();
-		this.fileItemFactory = fileItemFactory;
-	}
-
-
-	// ----------------------------------------------------- Property accessors
-
-
-	/**
-	 * Returns the factory class used when creating file items.
-	 * 
-	 * @return The factory class for new file items.
-	 */
-	@Override
-	public FileItemFactory getFileItemFactory()
-	{
-		return fileItemFactory;
-	}
-
-
-	/**
-	 * Sets the factory class to use when creating file items.
-	 * 
-	 * @param factory
-	 *            The factory class for new file items.
-	 */
-	@Override
-	public void setFileItemFactory(final FileItemFactory factory)
-	{
-		fileItemFactory = factory;
-	}
-
-
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUploadBase.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUploadBase.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUploadBase.java
deleted file mode 100644
index 1bd5a86..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUploadBase.java
+++ /dev/null
@@ -1,1285 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.wicket.util.io.Streams;
-import org.apache.wicket.util.lang.Args;
-import org.apache.wicket.util.lang.Generics;
-import org.apache.wicket.util.upload.MultipartFormInputStream.ItemInputStream;
-
-/**
- * <p>
- * High level API for processing file uploads.
- * </p>
- * 
- * <p>
- * This class handles multiple files per single HTML widget, sent using <code>multipart/mixed</code>
- * encoding type, as specified by <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a>. Use
- * {@link #parseRequest(HttpServletRequest)} to acquire a list of
- * {@link org.apache.wicket.util.upload.FileItem}s associated with a given HTML widget.
- * </p>
- * 
- * <p>
- * How the data for individual parts is stored is determined by the factory used to create them; a
- * given part may be in memory, on disk, or somewhere else.
- * </p>
- * 
- * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
- * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
- * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
- * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
- * @author Sean C. Sullivan
- */
-public abstract class FileUploadBase
-{
-	// ---------------------------------------------------------- Class methods
-
-	/**
-	 * <p>
-	 * Utility method that determines whether the request contains multipart content.
-	 * </p>
-	 * 
-	 * <p>
-	 * <strong>NOTE:</strong>This method will be moved to the <code>ServletFileUpload</code> class
-	 * after the FileUpload 1.1 release. Unfortunately, since this method is static, it is not
-	 * possible to provide its replacement until this method is removed.
-	 * </p>
-	 * 
-	 * @param ctx
-	 *            The request context to be evaluated. Must be non-null.
-	 * 
-	 * @return <code>true</code> if the request is multipart; <code>false</code> otherwise.
-	 */
-	public static final boolean isMultipartContent(final RequestContext ctx)
-	{
-		String contentType = ctx.getContentType();
-		if (contentType == null)
-		{
-			return false;
-		}
-		return contentType.toLowerCase().startsWith(MULTIPART);
-	}
-
-	// ----------------------------------------------------- Manifest constants
-
-	/**
-	 * HTTP content type header name.
-	 */
-	public static final String CONTENT_TYPE = "Content-type";
-
-	/**
-	 * HTTP content disposition header name.
-	 */
-	public static final String CONTENT_DISPOSITION = "Content-disposition";
-
-	/**
-	 * HTTP content length header name.
-	 */
-	public static final String CONTENT_LENGTH = "Content-length";
-
-	/**
-	 * Content-disposition value for form data.
-	 */
-	public static final String FORM_DATA = "form-data";
-
-	/**
-	 * Content-disposition value for file attachment.
-	 */
-	public static final String ATTACHMENT = "attachment";
-
-	/**
-	 * Part of HTTP content type header.
-	 */
-	public static final String MULTIPART = "multipart/";
-
-	/**
-	 * HTTP content type header for multipart forms.
-	 */
-	public static final String MULTIPART_FORM_DATA = "multipart/form-data";
-
-	/**
-	 * HTTP content type header for multiple uploads.
-	 */
-	public static final String MULTIPART_MIXED = "multipart/mixed";
-
-	// ----------------------------------------------------------- Data members
-
-	/**
-	 * The maximum size permitted for the complete request, as opposed to {@link #fileSizeMax}. A
-	 * value of -1 indicates no maximum.
-	 */
-	private long sizeMax = -1;
-
-	/**
-	 * The maximum size permitted for a single uploaded file, as opposed to {@link #sizeMax}. A
-	 * value of -1 indicates no maximum.
-	 */
-	private long fileSizeMax = -1;
-
-	/**
-	 * The content encoding to use when reading part headers.
-	 */
-	private String headerEncoding;
-
-	/**
-	 * The progress listener.
-	 */
-	private ProgressListener listener;
-
-	// ----------------------------------------------------- Property accessors
-
-	/**
-	 * Returns the factory class used when creating file items.
-	 * 
-	 * @return The factory class for new file items.
-	 */
-	public abstract FileItemFactory getFileItemFactory();
-
-	/**
-	 * Sets the factory class to use when creating file items.
-	 * 
-	 * @param factory
-	 *            The factory class for new file items.
-	 */
-	public abstract void setFileItemFactory(FileItemFactory factory);
-
-	/**
-	 * Returns the maximum allowed size of a complete request, as opposed to
-	 * {@link #getFileSizeMax()}.
-	 * 
-	 * @return The maximum allowed size, in bytes. The default value of -1 indicates, that there is
-	 *         no limit.
-	 * 
-	 * @see #setSizeMax(long)
-	 * 
-	 */
-	public long getSizeMax()
-	{
-		return sizeMax;
-	}
-
-	/**
-	 * Sets the maximum allowed size of a complete request, as opposed to
-	 * {@link #setFileSizeMax(long)}.
-	 * 
-	 * @param sizeMax
-	 *            The maximum allowed size, in bytes. The default value of -1 indicates, that there
-	 *            is no limit.
-	 * 
-	 * @see #getSizeMax()
-	 * 
-	 */
-	public void setSizeMax(final long sizeMax)
-	{
-		this.sizeMax = sizeMax;
-	}
-
-	/**
-	 * Returns the maximum allowed size of a single uploaded file, as opposed to
-	 * {@link #getSizeMax()}.
-	 * 
-	 * @see #setFileSizeMax(long)
-	 * @return Maximum size of a single uploaded file.
-	 */
-	public long getFileSizeMax()
-	{
-		return fileSizeMax;
-	}
-
-	/**
-	 * Sets the maximum allowed size of a single uploaded file, as opposed to {@link #getSizeMax()}.
-	 * 
-	 * @see #getFileSizeMax()
-	 * @param fileSizeMax
-	 *            Maximum size of a single uploaded file.
-	 */
-	public void setFileSizeMax(final long fileSizeMax)
-	{
-		this.fileSizeMax = fileSizeMax;
-	}
-
-	/**
-	 * Retrieves the character encoding used when reading the headers of an individual part. When
-	 * not specified, or <code>null</code>, the request encoding is used. If that is also not
-	 * specified, or <code>null</code>, the platform default encoding is used.
-	 * 
-	 * @return The encoding used to read part headers.
-	 */
-	public String getHeaderEncoding()
-	{
-		return headerEncoding;
-	}
-
-	/**
-	 * Specifies the character encoding to be used when reading the headers of individual part. When
-	 * not specified, or <code>null</code>, the request encoding is used. If that is also not
-	 * specified, or <code>null</code>, the platform default encoding is used.
-	 * 
-	 * @param encoding
-	 *            The encoding used to read part headers.
-	 */
-	public void setHeaderEncoding(final String encoding)
-	{
-		headerEncoding = encoding;
-	}
-
-	// --------------------------------------------------------- Public methods
-
-	/**
-	 * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> compliant
-	 * <code>multipart/form-data</code> stream.
-	 * 
-	 * @param ctx
-	 *            The context for the request to be parsed.
-	 * 
-	 * @return An iterator to instances of <code>FileItemStream</code> parsed from the request, in
-	 *         the order that they were transmitted.
-	 * 
-	 * @throws FileUploadException
-	 *             if there are problems reading/parsing the request or storing files.
-	 * @throws IOException
-	 *             An I/O error occurred. This may be a network error while communicating with the
-	 *             client or a problem while storing the uploaded content.
-	 */
-	public FileItemIterator getItemIterator(final RequestContext ctx) throws FileUploadException,
-		IOException
-	{
-		return new FileItemIteratorImpl(ctx);
-	}
-
-	/**
-	 * Processes an <a href="http://www.ietf.org/rfc/rfc1867.txt">RFC 1867</a> compliant
-	 * <code>multipart/form-data</code> stream.
-	 * 
-	 * @param ctx
-	 *            The context for the request to be parsed.
-	 * 
-	 * @return A list of <code>FileItem</code> instances parsed from the request, in the order that
-	 *         they were transmitted.
-	 * 
-	 * @throws FileUploadException
-	 *             if there are problems reading/parsing the request or storing files.
-	 */
-	public List<FileItem> parseRequest(final RequestContext ctx) throws FileUploadException
-	{
-		try
-		{
-			FileItemIterator iter = getItemIterator(ctx);
-			List<FileItem> items = Generics.newArrayList();
-			FileItemFactory fac = getFileItemFactory();
-			if (fac == null)
-			{
-				throw new NullPointerException("No FileItemFactory has been set.");
-			}
-			while (iter.hasNext())
-			{
-				FileItemStream item = iter.next();
-				FileItem fileItem = fac.createItem(item.getFieldName(), item.getContentType(),
-					item.isFormField(), item.getName());
-				try
-				{
-					Streams.copyAndClose(item.openStream(), fileItem.getOutputStream());
-				}
-				catch (FileUploadIOException e)
-				{
-					throw (FileUploadException)e.getCause();
-				}
-				catch (IOException e)
-				{
-					throw new IOFileUploadException("Processing of " + MULTIPART_FORM_DATA +
-						" request failed. " + e.getMessage(), e);
-				}
-				if (fileItem instanceof FileItemHeadersSupport)
-				{
-					final FileItemHeaders fih = item.getHeaders();
-					((FileItemHeadersSupport)fileItem).setHeaders(fih);
-				}
-				items.add(fileItem);
-			}
-			return items;
-		}
-		catch (FileUploadIOException e)
-		{
-			throw (FileUploadException)e.getCause();
-		}
-		catch (IOException e)
-		{
-			throw new FileUploadException(e.getMessage(), e);
-		}
-	}
-
-
-	// ------------------------------------------------------ Protected methods
-
-
-	/**
-	 * Retrieves the boundary from the <code>Content-type</code> header.
-	 * 
-	 * @param contentType
-	 *            The value of the content type header from which to extract the boundary value.
-	 * 
-	 * @return The boundary, as a byte array.
-	 */
-	protected byte[] getBoundary(final String contentType)
-	{
-		ParameterParser parser = new ParameterParser();
-		parser.setLowerCaseNames(true);
-		// Parameter parser can handle null input
-		Map<String, String> params = parser.parse(contentType, new char[] { ';', ',' });
-		String boundaryStr = params.get("boundary");
-
-		if (boundaryStr == null)
-		{
-			return null;
-		}
-		byte[] boundary;
-		try
-		{
-			boundary = boundaryStr.getBytes("ISO-8859-1");
-		}
-		catch (UnsupportedEncodingException e)
-		{
-			boundary = boundaryStr.getBytes();
-		}
-		return boundary;
-	}
-
-	/**
-	 * Retrieves the file name from the <code>Content-disposition</code> header.
-	 * 
-	 * @param headers
-	 *            The HTTP headers object.
-	 * 
-	 * @return The file name for the current <code>encapsulation</code>.
-	 */
-	protected String getFileName(final FileItemHeaders headers)
-	{
-		return getFileName(headers.getHeader(CONTENT_DISPOSITION));
-	}
-
-	/**
-	 * Returns the given content-disposition headers file name.
-	 * 
-	 * @param pContentDisposition
-	 *            The content-disposition headers value.
-	 * @return The file name
-	 */
-	private String getFileName(final String pContentDisposition)
-	{
-		String fileName = null;
-		if (pContentDisposition != null)
-		{
-			String cdl = pContentDisposition.toLowerCase();
-			if (cdl.startsWith(FORM_DATA) || cdl.startsWith(ATTACHMENT))
-			{
-				ParameterParser parser = new ParameterParser();
-				parser.setLowerCaseNames(true);
-				// Parameter parser can handle null input
-				Map<String, String> params = parser.parse(pContentDisposition, ';');
-				if (params.containsKey("filename"))
-				{
-					fileName = params.get("filename");
-					if (fileName != null)
-					{
-						fileName = fileName.trim();
-					}
-					else
-					{
-						// Even if there is no value, the parameter is present,
-						// so we return an empty file name rather than no file
-						// name.
-						fileName = "";
-					}
-				}
-			}
-		}
-		return fileName;
-	}
-
-
-	/**
-	 * Retrieves the field name from the <code>Content-disposition</code> header.
-	 * 
-	 * @param headers
-	 *            A <code>Map</code> containing the HTTP request headers.
-	 * 
-	 * @return The field name for the current <code>encapsulation</code>.
-	 */
-	protected String getFieldName(final FileItemHeaders headers)
-	{
-		return getFieldName(headers.getHeader(CONTENT_DISPOSITION));
-	}
-
-	/**
-	 * Returns the field name, which is given by the content-disposition header.
-	 * 
-	 * @param pContentDisposition
-	 *            The content-dispositions header value.
-	 * @return The field jake
-	 */
-	private String getFieldName(final String pContentDisposition)
-	{
-		String fieldName = null;
-		if ((pContentDisposition != null) &&
-			pContentDisposition.toLowerCase().startsWith(FORM_DATA))
-		{
-			ParameterParser parser = new ParameterParser();
-			parser.setLowerCaseNames(true);
-			// Parameter parser can handle null input
-			Map<String, String> params = parser.parse(pContentDisposition, ';');
-			fieldName = params.get("name");
-			if (fieldName != null)
-			{
-				fieldName = fieldName.trim();
-			}
-		}
-		return fieldName;
-	}
-
-	/**
-	 * <p>
-	 * Parses the <code>header-part</code> and returns as key/value pairs.
-	 * 
-	 * <p>
-	 * If there are multiple headers of the same names, the name will map to a comma-separated list
-	 * containing the values.
-	 * 
-	 * @param headerPart
-	 *            The <code>header-part</code> of the current <code>encapsulation</code>.
-	 * 
-	 * @return A <code>Map</code> containing the parsed HTTP request headers.
-	 */
-	protected FileItemHeaders getParsedHeaders(final String headerPart)
-	{
-		final int len = headerPart.length();
-		FileItemHeadersImpl headers = newFileItemHeaders();
-		int start = 0;
-		for (;;)
-		{
-			int end = parseEndOfLine(headerPart, start);
-			if (start == end)
-			{
-				break;
-			}
-			StringBuilder header = new StringBuilder(headerPart.substring(start, end));
-			start = end + 2;
-			while (start < len)
-			{
-				int nonWs = start;
-				while (nonWs < len)
-				{
-					char c = headerPart.charAt(nonWs);
-					if ((c != ' ') && (c != '\t'))
-					{
-						break;
-					}
-					++nonWs;
-				}
-				if (nonWs == start)
-				{
-					break;
-				}
-				// Continuation line found
-				end = parseEndOfLine(headerPart, nonWs);
-				header.append(' ').append(headerPart.substring(nonWs, end));
-				start = end + 2;
-			}
-			parseHeaderLine(headers, header.toString());
-		}
-		return headers;
-	}
-
-	/**
-	 * Creates a new instance of {@link FileItemHeaders}.
-	 * 
-	 * @return The new instance.
-	 */
-	protected FileItemHeadersImpl newFileItemHeaders()
-	{
-		return new FileItemHeadersImpl();
-	}
-
-	/**
-	 * Skips bytes until the end of the current line.
-	 * 
-	 * @param headerPart
-	 *            The headers, which are being parsed.
-	 * @param end
-	 *            Index of the last byte, which has yet been processed.
-	 * @return Index of the \r\n sequence, which indicates end of line.
-	 */
-	private int parseEndOfLine(final String headerPart, final int end)
-	{
-		int index = end;
-		for (;;)
-		{
-			int offset = headerPart.indexOf('\r', index);
-			if ((offset == -1) || (offset + 1 >= headerPart.length()))
-			{
-				throw new IllegalStateException(
-					"Expected headers to be terminated by an empty line.");
-			}
-			if (headerPart.charAt(offset + 1) == '\n')
-			{
-				return offset;
-			}
-			index = offset + 1;
-		}
-	}
-
-	/**
-	 * Reads the next header line.
-	 * 
-	 * @param headers
-	 *            String with all headers.
-	 * @param header
-	 *            Map where to store the current header.
-	 */
-	private void parseHeaderLine(final FileItemHeadersImpl headers, final String header)
-	{
-		final int colonOffset = header.indexOf(':');
-		if (colonOffset == -1)
-		{
-			// This header line is malformed, skip it.
-			return;
-		}
-		String headerName = header.substring(0, colonOffset).trim();
-		String headerValue = header.substring(header.indexOf(':') + 1).trim();
-		headers.addHeader(headerName, headerValue);
-	}
-
-	/**
-	 * The iterator, which is returned by {@link FileUploadBase#getItemIterator(RequestContext)}.
-	 */
-	private class FileItemIteratorImpl implements FileItemIterator
-	{
-		/**
-		 * Default implementation of {@link FileItemStream}.
-		 */
-		private class FileItemStreamImpl implements FileItemStream
-		{
-			/**
-			 * The file items content type.
-			 */
-			private final String contentType;
-			/**
-			 * The file items field name.
-			 */
-			private final String fieldName;
-			/**
-			 * The file items file name.
-			 */
-			private final String name;
-			/**
-			 * Whether the file item is a form field.
-			 */
-			private final boolean formField;
-			/**
-			 * The file items input stream.
-			 */
-			private final InputStream stream;
-			/**
-			 * Whether the file item was already opened.
-			 */
-			private boolean opened;
-			/**
-			 * The headers, if any.
-			 */
-			private FileItemHeaders headers;
-
-			/**
-			 * Creates a new instance.
-			 * 
-			 * @param pName
-			 *            The items file name, or null.
-			 * @param pFieldName
-			 *            The items field name.
-			 * @param pContentType
-			 *            The items content type, or null.
-			 * @param pFormField
-			 *            Whether the item is a form field.
-			 * @param pContentLength
-			 *            The items content length, if known, or -1
-			 * @throws IOException
-			 *             Creating the file item failed.
-			 */
-			FileItemStreamImpl(final String pName, final String pFieldName,
-				final String pContentType, final boolean pFormField, final long pContentLength)
-				throws IOException
-			{
-				name = pName;
-				fieldName = pFieldName;
-				contentType = pContentType;
-				formField = pFormField;
-				final ItemInputStream itemStream = multi.newInputStream();
-				InputStream istream = itemStream;
-				if (fileSizeMax != -1)
-				{
-					if ((pContentLength != -1) && (pContentLength > fileSizeMax))
-					{
-						FileUploadException e = new FileSizeLimitExceededException("The field " +
-							fieldName + " exceeds its maximum permitted " + " size of " +
-							fileSizeMax + " characters.", pContentLength, fileSizeMax);
-						throw new FileUploadIOException(e);
-					}
-					istream = new LimitedInputStream(istream, fileSizeMax)
-					{
-						@Override
-						protected void raiseError(final long pSizeMax, final long pCount)
-							throws IOException
-						{
-							itemStream.close(true);
-							FileUploadException e = new FileSizeLimitExceededException(
-								"The field " + fieldName + " exceeds its maximum permitted " +
-									" size of " + pSizeMax + " characters.", pCount, pSizeMax);
-							throw new FileUploadIOException(e);
-						}
-					};
-				}
-				stream = istream;
-			}
-
-			/**
-			 * Returns the items content type, or null.
-			 * 
-			 * @return Content type, if known, or null.
-			 */
-			@Override
-			public String getContentType()
-			{
-				return contentType;
-			}
-
-			/**
-			 * Returns the items field name.
-			 * 
-			 * @return Field name.
-			 */
-			@Override
-			public String getFieldName()
-			{
-				return fieldName;
-			}
-
-			/**
-			 * Returns the items file name.
-			 * 
-			 * @return File name, if known, or null.
-			 */
-			@Override
-			public String getName()
-			{
-				return name;
-			}
-
-			/**
-			 * Returns, whether this is a form field.
-			 * 
-			 * @return True, if the item is a form field, otherwise false.
-			 */
-			@Override
-			public boolean isFormField()
-			{
-				return formField;
-			}
-
-			/**
-			 * Returns an input stream, which may be used to read the items contents.
-			 * 
-			 * @return Opened input stream.
-			 * @throws IOException
-			 *             An I/O error occurred.
-			 */
-			@Override
-			public InputStream openStream() throws IOException
-			{
-				if (opened)
-				{
-					throw new IllegalStateException("The stream was already opened.");
-				}
-				if (((Closeable)stream).isClosed())
-				{
-					throw new FileItemStream.ItemSkippedException();
-				}
-				return stream;
-			}
-
-			/**
-			 * Closes the file item.
-			 * 
-			 * @throws IOException
-			 *             An I/O error occurred.
-			 */
-			void close() throws IOException
-			{
-				stream.close();
-			}
-
-			/**
-			 * Returns the file item headers.
-			 * 
-			 * @return The items header object
-			 */
-			@Override
-			public FileItemHeaders getHeaders()
-			{
-				return headers;
-			}
-
-			/**
-			 * Sets the file item headers.
-			 * 
-			 * @param pHeaders
-			 *            The items header object
-			 */
-			@Override
-			public void setHeaders(final FileItemHeaders pHeaders)
-			{
-				headers = pHeaders;
-			}
-		}
-
-		/**
-		 * The multi part stream to process.
-		 */
-		private final MultipartFormInputStream multi;
-		/**
-		 * The notifier, which used for triggering the {@link ProgressListener}.
-		 */
-		private final MultipartFormInputStream.ProgressNotifier notifier;
-		/**
-		 * The boundary, which separates the various parts.
-		 */
-		private final byte[] boundary;
-		/**
-		 * The item, which we currently process.
-		 */
-		private FileItemStreamImpl currentItem;
-		/**
-		 * The current items field name.
-		 */
-		private String currentFieldName;
-		/**
-		 * Whether we are currently skipping the preamble.
-		 */
-		private boolean skipPreamble;
-		/**
-		 * Whether the current item may still be read.
-		 */
-		private boolean itemValid;
-		/**
-		 * Whether we have seen the end of the file.
-		 */
-		private boolean eof;
-
-		/**
-		 * Creates a new instance.
-		 * 
-		 * @param ctx
-		 *            The request context.
-		 * @throws FileUploadException
-		 *             An error occurred while parsing the request.
-		 * @throws IOException
-		 *             An I/O error occurred.
-		 */
-		FileItemIteratorImpl(final RequestContext ctx) throws FileUploadException, IOException
-		{
-			Args.notNull(ctx, "ctx");
-
-			String contentType = ctx.getContentType();
-			if ((null == contentType) || (!contentType.toLowerCase().startsWith(MULTIPART)))
-			{
-				throw new InvalidContentTypeException("the request doesn't contain a " +
-					MULTIPART_FORM_DATA + " or " + MULTIPART_MIXED +
-					" stream, content type header is " + contentType);
-			}
-
-			InputStream input = ctx.getInputStream();
-
-			if (sizeMax >= 0)
-			{
-				int requestSize = ctx.getContentLength();
-				if (requestSize == -1)
-				{
-					input = new LimitedInputStream(input, sizeMax)
-					{
-						@Override
-						protected void raiseError(final long pSizeMax, final long pCount)
-							throws IOException
-						{
-							FileUploadException ex = new SizeLimitExceededException(
-								"the request was rejected because" + " its size (" + pCount +
-									") exceeds the configured maximum" + " (" + pSizeMax + ")",
-								pCount, pSizeMax);
-							throw new FileUploadIOException(ex);
-						}
-					};
-				}
-				else
-				{
-					if ((sizeMax >= 0) && (requestSize > sizeMax))
-					{
-						throw new SizeLimitExceededException(
-							"the request was rejected because its size (" + requestSize +
-								") exceeds the configured maximum (" + sizeMax + ")", requestSize,
-							sizeMax);
-					}
-				}
-			}
-
-			String charEncoding = headerEncoding;
-			if (charEncoding == null)
-			{
-				charEncoding = ctx.getCharacterEncoding();
-			}
-
-			boundary = getBoundary(contentType);
-			if (boundary == null)
-			{
-				throw new FileUploadException("the request was rejected because "
-					+ "no multipart boundary was found");
-			}
-
-			notifier = new MultipartFormInputStream.ProgressNotifier(listener,
-				ctx.getContentLength());
-			try
-			{
-				multi = new MultipartFormInputStream(input, boundary, notifier);
-			}
-			catch (IllegalArgumentException iae)
-			{
-				throw new InvalidContentTypeException(String.format(
-					"The boundary specified in the %s header is too long",
-					CONTENT_TYPE), iae);
-			}
-			multi.setHeaderEncoding(charEncoding);
-
-			skipPreamble = true;
-			findNextItem();
-		}
-
-		/**
-		 * Called for finding the nex item, if any.
-		 * 
-		 * @return True, if an next item was found, otherwise false.
-		 * @throws IOException
-		 *             An I/O error occurred.
-		 */
-		private boolean findNextItem() throws IOException
-		{
-			if (eof)
-			{
-				return false;
-			}
-			if (currentItem != null)
-			{
-				currentItem.close();
-				currentItem = null;
-			}
-			for (;;)
-			{
-				boolean nextPart;
-				if (skipPreamble)
-				{
-					nextPart = multi.skipPreamble();
-				}
-				else
-				{
-					nextPart = multi.readBoundary();
-				}
-				if (!nextPart)
-				{
-					if (currentFieldName == null)
-					{
-						// Outer multipart terminated -> No more data
-						eof = true;
-						return false;
-					}
-					// Inner multipart terminated -> Return to parsing the outer
-					multi.setBoundary(boundary);
-					currentFieldName = null;
-					continue;
-				}
-				FileItemHeaders headers = getParsedHeaders(multi.readHeaders());
-				if (currentFieldName == null)
-				{
-					// We're parsing the outer multipart
-					String fieldName = getFieldName(headers);
-					if (fieldName != null)
-					{
-						String subContentType = headers.getHeader(CONTENT_TYPE);
-						if ((subContentType != null) &&
-							subContentType.toLowerCase().startsWith(MULTIPART_MIXED))
-						{
-							currentFieldName = fieldName;
-							// Multiple files associated with this field name
-							byte[] subBoundary = getBoundary(subContentType);
-							multi.setBoundary(subBoundary);
-							skipPreamble = true;
-							continue;
-						}
-						String fileName = getFileName(headers);
-						currentItem = new FileItemStreamImpl(fileName, fieldName,
-							headers.getHeader(CONTENT_TYPE), fileName == null,
-							getContentLength(headers));
-						notifier.noteItem();
-						itemValid = true;
-						return true;
-					}
-				}
-				else
-				{
-					String fileName = getFileName(headers);
-					if (fileName != null)
-					{
-						currentItem = new FileItemStreamImpl(fileName, currentFieldName,
-							headers.getHeader(CONTENT_TYPE), false, getContentLength(headers));
-						notifier.noteItem();
-						itemValid = true;
-						return true;
-					}
-				}
-				multi.discardBodyData();
-			}
-		}
-
-		private long getContentLength(final FileItemHeaders pHeaders)
-		{
-			try
-			{
-				return Long.parseLong(pHeaders.getHeader(CONTENT_LENGTH));
-			}
-			catch (Exception e)
-			{
-				return -1;
-			}
-		}
-
-		/**
-		 * Returns, whether another instance of {@link FileItemStream} is available.
-		 * 
-		 * @throws FileUploadException
-		 *             Parsing or processing the file item failed.
-		 * @throws IOException
-		 *             Reading the file item failed.
-		 * @return True, if one or more additional file items are available, otherwise false.
-		 */
-		@Override
-		public boolean hasNext() throws FileUploadException, IOException
-		{
-			if (eof)
-			{
-				return false;
-			}
-			if (itemValid)
-			{
-				return true;
-			}
-			return findNextItem();
-		}
-
-		/**
-		 * Returns the next available {@link FileItemStream}.
-		 * 
-		 * @throws java.util.NoSuchElementException
-		 *             No more items are available. Use {@link #hasNext()} to prevent this
-		 *             exception.
-		 * @throws FileUploadException
-		 *             Parsing or processing the file item failed.
-		 * @throws IOException
-		 *             Reading the file item failed.
-		 * @return FileItemStream instance, which provides access to the next file item.
-		 */
-		@Override
-		public FileItemStream next() throws FileUploadException, IOException
-		{
-			if (eof || (!itemValid && !hasNext()))
-			{
-				throw new NoSuchElementException();
-			}
-			itemValid = false;
-			return currentItem;
-		}
-	}
-
-	/**
-	 * This exception is thrown for hiding an inner {@link FileUploadException} in an
-	 * {@link IOException}.
-	 */
-	public static class FileUploadIOException extends IOException
-	{
-		/**
-		 * The exceptions UID, for serializing an instance.
-		 */
-		private static final long serialVersionUID = -7047616958165584154L;
-		/**
-		 * The exceptions cause; we overwrite the parent classes field, which is available since
-		 * Java 1.4 only.
-		 */
-		private final FileUploadException cause;
-
-		/**
-		 * Creates a <code>FileUploadIOException</code> with the given cause.
-		 * 
-		 * @param pCause
-		 *            The exceptions cause, if any, or null.
-		 */
-		public FileUploadIOException(final FileUploadException pCause)
-		{
-			// We're not doing super(pCause) cause of 1.3 compatibility.
-			cause = pCause;
-		}
-
-		/**
-		 * Returns the exceptions cause.
-		 * 
-		 * @return The exceptions cause, if any, or null.
-		 */
-		@Override
-		public Throwable getCause()
-		{
-			return cause;
-		}
-	}
-
-	/**
-	 * Thrown to indicate that the request is not a multipart request.
-	 */
-	public static class InvalidContentTypeException extends FileUploadException
-	{
-		/**
-		 * The exceptions UID, for serializing an instance.
-		 */
-		private static final long serialVersionUID = -9073026332015646668L;
-
-		/**
-		 * Constructs a <code>InvalidContentTypeException</code> with no detail message.
-		 */
-		public InvalidContentTypeException()
-		{
-			// Nothing to do.
-		}
-
-		/**
-		 * Constructs an <code>InvalidContentTypeException</code> with the specified detail message.
-		 * 
-		 * @param message
-		 *            The detail message.
-		 */
-		public InvalidContentTypeException(final String message)
-		{
-			super(message);
-		}
-
-		/**
-		 * Constructs an <code>InvalidContentTypeException</code> with the specified detail message
-		 * and cause.
-		 *
-		 * @param message
-		 *            The detail message.
-		 * @param cause
-		 *            The real cause
-		 */
-		public InvalidContentTypeException(final String message, Throwable cause)
-		{
-			super(message, cause);
-		}
-	}
-
-	/**
-	 * Thrown to indicate an IOException.
-	 */
-	public static class IOFileUploadException extends FileUploadException
-	{
-		/**
-		 * The exceptions UID, for serializing an instance.
-		 */
-		private static final long serialVersionUID = 1749796615868477269L;
-		/**
-		 * The exceptions cause; we overwrite the parent classes field, which is available since
-		 * Java 1.4 only.
-		 */
-		private final IOException cause;
-
-		/**
-		 * Creates a new instance with the given cause.
-		 * 
-		 * @param pMsg
-		 *            The detail message.
-		 * @param pException
-		 *            The exceptions cause.
-		 */
-		public IOFileUploadException(final String pMsg, final IOException pException)
-		{
-			super(pMsg);
-			cause = pException;
-		}
-
-		/**
-		 * Returns the exceptions cause.
-		 * 
-		 * @return The exceptions cause, if any, or null.
-		 */
-		@Override
-		public Throwable getCause()
-		{
-			return cause;
-		}
-	}
-
-	/**
-	 * This exception is thrown, if a requests permitted size is exceeded.
-	 */
-	protected abstract static class SizeException extends FileUploadException
-	{
-		private static final long serialVersionUID = 1L;
-
-		/**
-		 * The actual size of the request.
-		 */
-		private final long actual;
-
-		/**
-		 * The maximum permitted size of the request.
-		 */
-		private final long permitted;
-
-		/**
-		 * Creates a new instance.
-		 * 
-		 * @param message
-		 *            The detail message.
-		 * @param actual
-		 *            The actual number of bytes in the request.
-		 * @param permitted
-		 *            The requests size limit, in bytes.
-		 */
-		protected SizeException(final String message, final long actual, final long permitted)
-		{
-			super(message);
-			this.actual = actual;
-			this.permitted = permitted;
-		}
-
-		/**
-		 * Retrieves the actual size of the request.
-		 * 
-		 * @return The actual size of the request.
-		 */
-		public long getActualSize()
-		{
-			return actual;
-		}
-
-		/**
-		 * Retrieves the permitted size of the request.
-		 * 
-		 * @return The permitted size of the request.
-		 */
-		public long getPermittedSize()
-		{
-			return permitted;
-		}
-	}
-
-	/**
-	 * Thrown to indicate that the request size exceeds the configured maximum.
-	 */
-	public static class SizeLimitExceededException extends SizeException
-	{
-		/**
-		 * The exceptions UID, for serializing an instance.
-		 */
-		private static final long serialVersionUID = -2474893167098052828L;
-
-		/**
-		 * Constructs a <code>SizeExceededException</code> with the specified detail message, and
-		 * actual and permitted sizes.
-		 * 
-		 * @param message
-		 *            The detail message.
-		 * @param actual
-		 *            The actual request size.
-		 * @param permitted
-		 *            The maximum permitted request size.
-		 */
-		public SizeLimitExceededException(final String message, final long actual,
-			final long permitted)
-		{
-			super(message, actual, permitted);
-		}
-	}
-
-	/**
-	 * Thrown to indicate that A files size exceeds the configured maximum.
-	 */
-	public static class FileSizeLimitExceededException extends SizeException
-	{
-		/**
-		 * The exceptions UID, for serializing an instance.
-		 */
-		private static final long serialVersionUID = 8150776562029630058L;
-
-		/**
-		 * Constructs a <code>SizeExceededException</code> with the specified detail message, and
-		 * actual and permitted sizes.
-		 * 
-		 * @param message
-		 *            The detail message.
-		 * @param actual
-		 *            The actual request size.
-		 * @param permitted
-		 *            The maximum permitted request size.
-		 */
-		public FileSizeLimitExceededException(final String message, final long actual,
-			final long permitted)
-		{
-			super(message, actual, permitted);
-		}
-	}
-
-	/**
-	 * Returns the progress listener.
-	 * 
-	 * @return The progress listener, if any, or null.
-	 */
-	public ProgressListener getProgressListener()
-	{
-		return listener;
-	}
-
-	/**
-	 * Sets the progress listener.
-	 * 
-	 * @param pListener
-	 *            The progress listener, if any. Defaults to null.
-	 */
-	public void setProgressListener(final ProgressListener pListener)
-	{
-		listener = pListener;
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUploadException.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUploadException.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUploadException.java
deleted file mode 100644
index 2ba9d67..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/FileUploadException.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
-
-/**
- * Exception for errors encountered while processing the request.
- * 
- * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
- */
-public class FileUploadException extends Exception
-{
-	/**
-	 * Serial version UID, being used, if the exception is serialized.
-	 */
-	private static final long serialVersionUID = 8881893724388807504L;
-	/**
-	 * The exceptions cause. We overwrite the cause of the super class, which isn't available in
-	 * Java 1.3.
-	 */
-	private final Throwable cause;
-
-	/**
-	 * Constructs a new <code>FileUploadException</code> without message.
-	 */
-	public FileUploadException()
-	{
-		this(null, null);
-	}
-
-	/**
-	 * Constructs a new <code>FileUploadException</code> with specified detail message.
-	 * 
-	 * @param msg
-	 *            the error message.
-	 */
-	public FileUploadException(final String msg)
-	{
-		this(msg, null);
-	}
-
-	/**
-	 * Creates a new <code>FileUploadException</code> with the given detail message and cause.
-	 * 
-	 * @param msg
-	 *            The exceptions detail message.
-	 * @param cause
-	 *            The exceptions cause.
-	 */
-	public FileUploadException(final String msg, final Throwable cause)
-	{
-		super(msg);
-		this.cause = cause;
-	}
-
-	/**
-	 * Prints this throwable and its backtrace to the specified print stream.
-	 * 
-	 * @param stream
-	 *            <code>PrintStream</code> to use for output
-	 */
-	@Override
-	public void printStackTrace(final PrintStream stream)
-	{
-		super.printStackTrace(stream);
-		if (cause != null)
-		{
-			stream.println("Caused by:");
-			cause.printStackTrace(stream);
-		}
-	}
-
-	/**
-	 * Prints this throwable and its backtrace to the specified print writer.
-	 * 
-	 * @param writer
-	 *            <code>PrintWriter</code> to use for output
-	 */
-	@Override
-	public void printStackTrace(final PrintWriter writer)
-	{
-		super.printStackTrace(writer);
-		if (cause != null)
-		{
-			writer.println("Caused by:");
-			cause.printStackTrace(writer);
-		}
-	}
-
-	@Override
-	public Throwable getCause()
-	{
-		return cause;
-	}
-}

http://git-wip-us.apache.org/repos/asf/wicket/blob/99fcd91f/wicket-util/src/main/java/org/apache/wicket/util/upload/LimitedInputStream.java
----------------------------------------------------------------------
diff --git a/wicket-util/src/main/java/org/apache/wicket/util/upload/LimitedInputStream.java b/wicket-util/src/main/java/org/apache/wicket/util/upload/LimitedInputStream.java
deleted file mode 100644
index 0aa4bb9..0000000
--- a/wicket-util/src/main/java/org/apache/wicket/util/upload/LimitedInputStream.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.util.upload;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-
-/**
- * An input stream, which limits its data size. This stream is used, if the content length is
- * unknown.
- */
-public abstract class LimitedInputStream extends FilterInputStream implements Closeable
-{
-	/**
-	 * The maximum size of an item, in bytes.
-	 */
-	private final long sizeMax;
-	/**
-	 * The current number of bytes.
-	 */
-	private long count;
-	/**
-	 * Whether this stream is already closed.
-	 */
-	private boolean closed;
-
-	/**
-	 * Creates a new instance.
-	 * 
-	 * @param pIn
-	 *            The input stream, which shall be limited.
-	 * @param pSizeMax
-	 *            The limit; no more than this number of bytes shall be returned by the source
-	 *            stream.
-	 */
-	public LimitedInputStream(final InputStream pIn, final long pSizeMax)
-	{
-		super(pIn);
-		sizeMax = pSizeMax;
-	}
-
-	/**
-	 * Called to indicate, that the input streams limit has been exceeded.
-	 * 
-	 * @param pSizeMax
-	 *            The input streams limit, in bytes.
-	 * @param pCount
-	 *            The actual number of bytes.
-	 * @throws IOException
-	 *             The called method is expected to raise an IOException.
-	 */
-	protected abstract void raiseError(long pSizeMax, long pCount) throws IOException;
-
-	/**
-	 * Called to check, whether the input streams limit is reached.
-	 * 
-	 * @throws IOException
-	 *             The given limit is exceeded.
-	 */
-	private void checkLimit() throws IOException
-	{
-		if (count > sizeMax)
-		{
-			raiseError(sizeMax, count);
-		}
-	}
-
-	/**
-	 * Reads the next byte of data from this input stream. The value byte is returned as an
-	 * <code>int</code> in the range <code>0</code> to <code>255</code>. If no byte is available
-	 * because the end of the stream has been reached, the value <code>-1</code> is returned. This
-	 * method blocks until input data is available, the end of the stream is detected, or an
-	 * exception is thrown.
-	 * <p>
-	 * This method simply performs <code>in.read()</code> and returns the result.
-	 * 
-	 * @return the next byte of data, or <code>-1</code> if the end of the stream is reached.
-	 * @exception IOException
-	 *                if an I/O error occurs.
-	 * @see java.io.FilterInputStream#in
-	 */
-	@Override
-	public int read() throws IOException
-	{
-		int res = super.read();
-		if (res != -1)
-		{
-			count++;
-			checkLimit();
-		}
-		return res;
-	}
-
-	/**
-	 * Reads up to <code>len</code> bytes of data from this input stream into an array of bytes. If
-	 * <code>len</code> is not zero, the method blocks until some input is available; otherwise, no
-	 * bytes are read and <code>0</code> is returned.
-	 * <p>
-	 * This method simply performs <code>in.read(b, off, len)</code> and returns the result.
-	 * 
-	 * @param b
-	 *            the buffer into which the data is read.
-	 * @param off
-	 *            The start offset in the destination array <code>b</code>.
-	 * @param len
-	 *            the maximum number of bytes read.
-	 * @return the total number of bytes read into the buffer, or <code>-1</code> if there is no
-	 *         more data because the end of the stream has been reached.
-	 * @exception NullPointerException
-	 *                If <code>b</code> is <code>null</code>.
-	 * @exception IndexOutOfBoundsException
-	 *                If <code>off</code> is negative, <code>len</code> is negative, or
-	 *                <code>len</code> is greater than <code>b.length - off</code>
-	 * @exception IOException
-	 *                if an I/O error occurs.
-	 * @see java.io.FilterInputStream#in
-	 */
-	@Override
-	public int read(final byte[] b, final int off, final int len) throws IOException
-	{
-		int res = super.read(b, off, len);
-		if (res > 0)
-		{
-			count += res;
-			checkLimit();
-		}
-		return res;
-	}
-
-	/**
-	 * Returns, whether this stream is already closed.
-	 * 
-	 * @return True, if the stream is closed, otherwise false.
-	 * @throws IOException
-	 *             An I/O error occurred.
-	 */
-	@Override
-	public boolean isClosed() throws IOException
-	{
-		return closed;
-	}
-
-	/**
-	 * Closes this input stream and releases any system resources associated with the stream. This
-	 * method simply performs <code>in.close()</code>.
-	 * 
-	 * @exception IOException
-	 *                if an I/O error occurs.
-	 * @see java.io.FilterInputStream#in
-	 */
-	@Override
-	public void close() throws IOException
-	{
-		closed = true;
-		super.close();
-	}
-}