From 6370846db5b4d578b22325c8bea39d744e1f74ae Mon Sep 17 00:00:00 2001 From: "Donald J. Brown" Date: Sat, 25 Mar 2006 03:08:15 +0000 Subject: [PATCH] Removing the Pell implementation of file upload. According to Jason Pell's page - http://www.geocities.com/jasonpell/programs.html#multipartrequest - the code is under the LGPL license. git-svn-id: https://svn.apache.org/repos/asf/incubator/webwork2@388693 13f79535-47bb-0310-9956-ffa450edef68 --- ivy.xml | 3 - .../multipart/PellMultiPartRequest.java | 129 ------------------ 2 files changed, 132 deletions(-) delete mode 100644 src/java/org/apache/struts/action2/dispatcher/multipart/PellMultiPartRequest.java diff --git a/ivy.xml b/ivy.xml index 26e22783f..c57eecaba 100644 --- a/ivy.xml +++ b/ivy.xml @@ -88,9 +88,6 @@ - - - diff --git a/src/java/org/apache/struts/action2/dispatcher/multipart/PellMultiPartRequest.java b/src/java/org/apache/struts/action2/dispatcher/multipart/PellMultiPartRequest.java deleted file mode 100644 index d2d1323fb..000000000 --- a/src/java/org/apache/struts/action2/dispatcher/multipart/PellMultiPartRequest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2002-2003 by OpenSymphony - * All rights reserved. - */ -package org.apache.struts.action2.dispatcher.multipart; - -import org.apache.struts.action2.config.Configuration; -import org.apache.struts.action2.WebWorkConstants; -import http.utils.multipartrequest.ServletMultipartRequest; - -import javax.servlet.http.HttpServletRequest; -import java.io.File; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Enumeration; -import java.util.List; - - -/** - * Multipart form data request adapter for Jason Pell's multipart utils package. - * - * @author Matt Baldree (modified for WW's use) - * @author Scott Farquhar (added i18n handling (WW-109)) - */ -public class PellMultiPartRequest extends MultiPartRequest { - - private ServletMultipartRequest multi; - - - /** - * Creates a new request wrapper to handle multi-part data using methods adapted from Jason Pell's - * multipart classes (see class description). - * - * @param maxSize maximum size post allowed - * @param saveDir the directory to save off the file - * @param servletRequest the request containing the multipart - */ - public PellMultiPartRequest(HttpServletRequest servletRequest, String saveDir, int maxSize) throws IOException { - //this needs to be synchronised, as we should not change the encoding at the same time as - //calling the constructor. See javadoc for MultipartRequest.setEncoding(). - synchronized (this) { - setEncoding(); - multi = new ServletMultipartRequest(servletRequest, saveDir, maxSize); - } - } - - - public Enumeration getFileParameterNames() { - return multi.getFileParameterNames(); - } - - public String[] getContentType(String fieldName) { - return new String[]{multi.getContentType(fieldName)}; - } - - public File[] getFile(String fieldName) { - return new File[]{multi.getFile(fieldName)}; - } - - public String[] getFileNames(String fieldName) { - - // TODO - not sure about this - is this the filename of the actual file or - // TODO - the uploaded filename as provided by the browser? - // TODO - Not sure what version of Pell this class uses as it doesn't seem to be the latest - return new String[]{multi.getFile(fieldName).getName()}; - } - - public String[] getFilesystemName(String fieldName) { - return new String[]{multi.getFileSystemName(fieldName)}; - } - - public String getParameter(String name) { - return multi.getURLParameter(name); - } - - public Enumeration getParameterNames() { - return multi.getParameterNames(); - } - - public String[] getParameterValues(String name) { - Enumeration enumeration = multi.getURLParameters(name); - - if (!enumeration.hasMoreElements()) { - return null; - } - - List values = new ArrayList(); - - while (enumeration.hasMoreElements()) { - values.add(enumeration.nextElement()); - } - - return (String[]) values.toArray(new String[values.size()]); - } - - public List getErrors() { - return Collections.EMPTY_LIST; - } - - /** - * Sets the encoding for the uploaded params. This needs to be set if you are using character sets other than - * ASCII. - *

- * The encoding is looked up from the configuration setting 'webwork.i18n.encoding'. This is usually set in - * default.properties & webwork.properties. - */ - private static void setEncoding() { - String encoding = null; - - try { - encoding = Configuration.getString(WebWorkConstants.WEBWORK_I18N_ENCODING); - - if (encoding != null) { - //NB: This should never be called at the same time as the constructor for - //ServletMultiPartRequest, as it can cause problems. - //See javadoc for MultipartRequest.setEncoding() - http.utils.multipartrequest.MultipartRequest.setEncoding(encoding); - } else { - http.utils.multipartrequest.MultipartRequest.setEncoding("UTF-8"); - } - } catch (IllegalArgumentException e) { - log.info("Could not get encoding property 'webwork.i18n.encoding' for file upload. Using system default"); - } catch (UnsupportedEncodingException e) { - log.error("Encoding " + encoding + " is not a valid encoding. Please check your webwork.properties file."); - } - } -}