mirror of
https://github.com/apache/struts.git
synced 2026-08-05 14:47:09 +00:00
Removing the fileupload-cos dependency. This fileupload implementation
used code from servlets.com, which is under an unfriendly license - http://servlets.com/cos/license.html - unless you happen to _really_ like the book Java Servlet Programming. git-svn-id: https://svn.apache.org/repos/asf/incubator/webwork2@388692 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -28,7 +28,6 @@
|
||||
<conf name="freemarker" deprecated="20060303000000"/>
|
||||
<conf name="velocity"/>
|
||||
<conf name="fileupload"/>
|
||||
<conf name="fileupload-cos" deprecated="20050831000000"/>
|
||||
<conf name="fileupload-pell" deprecated="20050831000000"/>
|
||||
<conf name="sitemesh"/>
|
||||
<conf name="quickstart"/>
|
||||
@@ -89,9 +88,6 @@
|
||||
<!-- fileupload -->
|
||||
<dependency org="apache" name="commons-fileupload" rev="1.1" conf="fileupload->default"/>
|
||||
|
||||
<!-- fileupload-cos -->
|
||||
<dependency org="cos" name="cos" rev="20021105" conf="fileupload-cos->default"/>
|
||||
|
||||
<!-- fileupload-pell -->
|
||||
<dependency org="pell" name="multipartrequest" rev="1.19" conf="fileupload-pell->default"/>
|
||||
|
||||
|
||||
@@ -1,108 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2002-2003 by OpenSymphony
|
||||
* All rights reserved.
|
||||
*/
|
||||
package org.apache.struts.action2.dispatcher.multipart;
|
||||
|
||||
import com.oreilly.servlet.MultipartRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Multipart form data request adapter for Jason Hunter's
|
||||
* <a href="http://www.servlets.com/cos/index.html" target="_blank">multipart utils</a>
|
||||
* (COS == com.oreilly.servlet).
|
||||
*
|
||||
* @author <a href="mailto:matt@smallleap.com">Matt Baldree</a> (modified for WW's use)
|
||||
* @author <a href="mailto:scott@atlassian.com">Scott Farquhar</a> (added i18n handling (WW-109))
|
||||
*/
|
||||
public class CosMultiPartRequest extends MultiPartRequest {
|
||||
|
||||
private MultipartRequest multi;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new request wrapper to handle multi-part data using methods adapted from the COS
|
||||
* 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 CosMultiPartRequest(HttpServletRequest servletRequest, String saveDir, int maxSize) throws IOException {
|
||||
String encoding = getEncoding();
|
||||
|
||||
if (encoding != null) {
|
||||
multi = new MultipartRequest(servletRequest, saveDir, maxSize, encoding);
|
||||
} else {
|
||||
multi = new MultipartRequest(servletRequest, saveDir, maxSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Enumeration getFileParameterNames() {
|
||||
return multi.getFileNames();
|
||||
}
|
||||
|
||||
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) {
|
||||
return new String[]{multi.getFile(fieldName).getName()};
|
||||
}
|
||||
|
||||
public String[] getFilesystemName(String name) {
|
||||
return new String[]{multi.getFilesystemName(name)};
|
||||
}
|
||||
|
||||
public String getParameter(String name) {
|
||||
return multi.getParameter(name);
|
||||
}
|
||||
|
||||
public Enumeration getParameterNames() {
|
||||
return multi.getParameterNames();
|
||||
}
|
||||
|
||||
public String[] getParameterValues(String name) {
|
||||
return multi.getParameterValues(name);
|
||||
}
|
||||
|
||||
public List getErrors() {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the encoding for the uploaded parameters. This needs to be set if you are using character sets
|
||||
* other than ASCII.<p>
|
||||
* <p/>
|
||||
* The encoding is looked up from the configuration setting 'webwork.i18n.encoding'. This is usually set in
|
||||
* default.properties and webwork.properties.
|
||||
*/
|
||||
private static String getEncoding() {
|
||||
return "utf-8";
|
||||
|
||||
//todo: configuration in xwork needs to support non-action level config
|
||||
|
||||
/*
|
||||
String encoding = null;
|
||||
try {
|
||||
|
||||
//encoding = Configuration.getString("webwork.i18n.encoding");
|
||||
} catch (IllegalArgumentException e) {
|
||||
LogFactory.getLog(PellMultiPartRequest.class).info("Could not get encoding property 'webwork.i18n.encoding' for file upload. Using system default");
|
||||
}
|
||||
return encoding;
|
||||
*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user