Commits

Anonymous committed 6012423
  • Participants
  • Parent commits f2b6b1f

Comments (0)

Files changed (4)

File src/java/com/opensymphony/webwork/dispatcher/multipart/CosMultiPartRequest.java

 
 import javax.servlet.http.HttpServletRequest;
 
-
-/* ------------------------------------------------------------ */
-
 /**
- * Multipart Form Data request adapter for Jason Hunter's multipart
- * utils. You need to watch his license. He requires you to own his
- * book.
+ * 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).
  *
- * @version $Id$
- * @author  Matt Baldree (matt@smallleap.com) modified for WW's use
- * @author  Scott Farquhar (scott@atlassian.com) added i18n handling (WW-109)
+ * @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 {
-    //~ Instance fields ////////////////////////////////////////////////////////
 
-    /* ------------------------------------------------------------ */
     private MultipartRequest multi;
 
-    //~ Constructors ///////////////////////////////////////////////////////////
-
     /**
+     * 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
         }
     }
 
-    //~ Methods ////////////////////////////////////////////////////////////////
-
     public String getContentType(String name) {
         return multi.getContentType(name);
     }
         return multi.getFile(name);
     }
 
-    // Methods only in MultipartRequest
     public Enumeration getFileNames() {
         return multi.getFileNames();
     }
     }
 
     /**
-     * Set the encoding for the uploaded params.  This needs to be set if you are using character sets other than
-     * ASCII.
-     * <p>
+     * Set the encoding for the uploaded parameters. This needs to be set if you are using character sets
+     * other than ASCII.<p>
+     *
      * The encoding is looked up from the configuration setting 'webwork.i18n.encoding'.  This is usually set in
-     * default.properties & webwork.properties.
+     * default.properties and webwork.properties.
      */
     private static String getEncoding() {
         return "utf-8";

File src/java/com/opensymphony/webwork/dispatcher/multipart/MultiPartRequest.java

 
 
 /**
- * Multipart Form Data request.
- * <p>
- * This class decodes the multipart/form-data stream sent by
- * a HTML form that uses a file input item.
+ * Abstract wrapper class HTTP requests to handle multi-part data. <p>
  *
- * @version $Id$
- * @author  Matt Baldree (matt@smallleap.com) modified for WW's use
+ * @author <a href="mailto:matt@smallleap.com">Matt Baldree</a>
+ * @author Patrick Lightbody
+ * @author Bill Lynch (docs)
  */
 public abstract class MultiPartRequest {
-    //~ Static fields/initializers /////////////////////////////////////////////
 
     protected static Log log = LogFactory.getLog(MultiPartRequest.class);
 
-    //~ Methods ////////////////////////////////////////////////////////////////
-
     /**
-     * Is request a multipart request
+     * Returns <tt>true</tt> if the request is multipart form data, <tt>false</tt> otherwise.
+     *
+     * @param request the http servlet request.
+     * @return <tt>true</tt> if the request is multipart form data, <tt>false</tt> otherwise.
      */
     public static boolean isMultiPart(HttpServletRequest request) {
         String content_type = request.getHeader("Content-Type");
         return ((content_type == null) || !content_type.startsWith("multipart/form-data")) ? false : true;
     }
 
+    /**
+     * Returns the content type of the specified file (as supplied by the client browser), or
+     * <tt>null</tt> if the file was not included.
+     *
+     * @param name the name of the file to check
+     * @return the file's content type or <tt>null</tt> if no content type was specified.
+     */
     public abstract String getContentType(String name);
 
+    /**
+     * Returns a {@link java.io.File} object for the filename specified or <tt>null</tt> if the
+     * file was not found.
+     *
+     * @param name the name of the file
+     * @return the File object associated with the given name or <tt>null</tt> if it doesn't exist.
+     */
     public abstract File getFile(String name);
 
-    // Methods only in MultipartRequest
+    /**
+     * Returns a String name list of all uploaded files.
+     *
+     * @return an enumeration of filenames (Strings).
+     */
     public abstract Enumeration getFileNames();
 
+    /**
+     * Returns the file system name of the given file name.
+     *
+     * @param name the name of the file uploaded.
+     * @return the file system name of the given file name.
+     */
     public abstract String getFilesystemName(String name);
 
+    /**
+     * Returns the specified request parameter.
+     *
+     * @param name the name of the parameter to get
+     * @return the parameter or <tt>null</tt> if it was not found.
+     */
     public abstract String getParameter(String name);
 
+    /**
+     * Returns an enumeration of String parameter names.
+     *
+     * @return an enumeration of String parameter names.
+     */
     public abstract Enumeration getParameterNames();
 
+    /**
+     * Returns a list of all parameter values associated with a parameter name. If there is only
+     * one parameter value per name the resulting array will be of length 1.
+     *
+     * @param name the name of the parameter.
+     * @return an array of all values associated with the parameter name.
+     */
     public abstract String[] getParameterValues(String name);
 }

File src/java/com/opensymphony/webwork/dispatcher/multipart/MultiPartRequestWrapper.java

 
 
 /**
- * <code>MultiPartRequestWrapper</code> will parse a multipart request and
- * provide a wrapper around the request. The parse it uses depends on
- * the "webwork.multipart.parser" setting. It should be set to a class which
- * extends com.opensymphony.webwork.dispatcher.multipart.MultiPartRequest.
- * Webwork ships with two implementations,
- * com.opensymphony.webwork.dispatcher.multipart.PellMultiPartRequest and
- * com.opensymphony.webwork.dispatcher.multipart.CosMultiPartRequest. Pell
- * is the default.
- * "pell" for Jason Pell and "cos" for Jason Hunter.
+ * Parses a multipart request and provides a wrapper around the request. The parsing implementation used
+ * depends on the <tt>webwork.multipart.parser</tt> setting. It should be set to a class which
+ * extends {@link com.opensymphony.webwork.dispatcher.multipart.MultiPartRequest}. <p>
  *
- * The files are uploaded when the object is instantiated. If there are
- * any errors they are logged using addError. An action handling a
- * multipart form should first check <code>hasErrors()</code> before doing
- * any other processing.
+ * Webwork ships with two implementations,
+ * {@link com.opensymphony.webwork.dispatcher.multipart.PellMultiPartRequest} and
+ * {@link com.opensymphony.webwork.dispatcher.multipart.CosMultiPartRequest}. The Pell implementation
+ * is the default. The <tt>webwork.multipart.parser</tt> property should be set to <tt>pell</tt> for
+ * the Pell implementation and <tt>cos</tt> for the Jason Hunter implementation. <p>
  *
- * Currently the max file size check just checks the ful
+ * The files are uploaded when the object is instantiated. If there are any errors they are logged using
+ * {@link #addError(String)}. An action handling a multipart form should first check {@link #hasErrors()}
+ * before doing any other processing. <p>
  *
  * @author Matt Baldree
- * @version $Revision$
  */
 public class MultiPartRequestWrapper extends HttpServletRequestWrapper {
-    //~ Static fields/initializers /////////////////////////////////////////////
 
     protected static final Log log = LogFactory.getLog(MultiPartRequestWrapper.class);
 
-    //~ Instance fields ////////////////////////////////////////////////////////
-
     Collection errors;
     MultiPartRequest multi;
 
-    //~ Constructors ///////////////////////////////////////////////////////////
-
     /**
-     * Constructor. Creates the appropriate MultiPartRequest object and processes
-     * the data.
+     * Instantiates the appropriate MultiPartRequest parser implementation and processes the data.
      *
      * @param request the servlet request object
      * @param saveDir directory to save the file(s) to
         }
     }
 
-    //~ Methods ////////////////////////////////////////////////////////////////
-
     /**
-     * Get the content encoding type for the file 'name'. Name is the name field
-     * on the input tag.
+     * Get the content encoding type for the given file name. Name is the name field on the input tag.
      *
      * @param name uploaded filename.
-     * @return content encoding for file 'name'
+     * @return content encoding for file name
      */
     public String getContentType(String name) {
         if (multi == null) {
     }
 
     /**
-     * Returns the error Collection.
+     * Returns a collection of any errors generated when parsing the multipart request.
      *
      * @return the error Collection.
      */
     }
 
     /**
-     * Get a java.io.File for the file 'name'. Name is the name field on the
-     * input tag.
+     * Get a {@link java.io.File} for the give file name. Name is the name field on the input tag.
      *
      * @param name uploaded filename
-     * @return File object for filename
+     * @return File object for file name
      */
     public File getFile(String name) {
         if (multi == null) {
         return multi.getFile(name);
     }
 
-    // Methods only in MultipartRequest
-
     /**
      * Get an enumeration of the filenames uploaded
      *
     }
 
     /**
-     * Get the filename of the file uploaded for the given input field name.
+     * Get the filename of the file uploaded for the given input field name. Returns <tt>null</tt> if the
+     * file is not found.
      *
      * @param name uploaded filename
-     * @return null if name not found.
+     * @return the file system name of the given file or <tt>null</tt> if name not found.
      */
     public String getFilesystemName(String name) {
         if (multi == null) {
     }
 
     /**
-     * The value of the url parameter 'name'.
+     * Returns <tt>true</tt> if any errors occured when parsing the HTTP multipart request, <tt>false</tt> otherwise.
      *
-     * @param name to lookup
-     * @return url parameter value of name
+     * @return <tt>true</tt> if any errors occured when parsing the HTTP multipart request, <tt>false</tt> otherwise.
+     */
+    public boolean hasErrors() {
+        if ((errors == null) || errors.isEmpty()) {
+            return false;
+        } else {
+            return true;
+        }
+    }
+
+    /**
+     * @see javax.servlet.http.HttpServletRequest#getParameter(String)
      */
     public String getParameter(String name) {
         return ((multi == null) || (multi.getParameter(name) == null)) ? super.getParameter(name) : multi.getParameter(name);
     }
 
     /**
-     * An map of all URL Parameters for the current HTTP Request.
-     *
-     * @return map of params
+     * @see javax.servlet.http.HttpServletRequest#getParameterMap()
      */
     public Map getParameterMap() {
         Map map = new HashMap();
     }
 
     /**
-     * An enumeration of all URL Parameter names for the current HTTP Request.
-     *
-     * @return enumeration of names
+     * @see javax.servlet.http.HttpServletRequest#getParameterNames()
      */
     public Enumeration getParameterNames() {
         if (multi == null) {
     }
 
     /**
-     * An array of all URL Parameter values for the current HTTP Request for name.
-     *
-     * @param name key
-     * @return array of values associated with name
+     * @see javax.servlet.http.HttpServletRequest#getParameterValues(String)
      */
     public String[] getParameterValues(String name) {
         return ((multi == null) || (multi.getParameterValues(name) == null)) ? super.getParameterValues(name) : multi.getParameterValues(name);
     }
 
     /**
-     * If any errors have been logged return true.
+     * Adds an error message.
      *
-     * @return true if errors have occured
+     * @param anErrorMessage the error message to report.
      */
-    public boolean hasErrors() {
-        if ((errors == null) || errors.isEmpty()) {
-            return false;
-        } else {
-            return true;
-        }
-    }
-
     protected void addError(String anErrorMessage) {
         if (errors == null) {
             errors = new ArrayList();
         errors.add(anErrorMessage);
     }
 
-    //private
+    /**
+     * Merges 2 enumeration of parameters as one.
+     *
+     * @param params1 the first enumeration.
+     * @param params2 the second enumeration.
+     * @return a single Enumeration of all elements from both Enumerations.
+     */
     protected Enumeration mergeParams(Enumeration params1, Enumeration params2) {
         Vector temp = new Vector();
 

File src/java/com/opensymphony/webwork/dispatcher/multipart/PellMultiPartRequest.java

 import javax.servlet.http.HttpServletRequest;
 
 
-/* ------------------------------------------------------------ */
-
 /**
- * Multipart Form Data request adapter for Jason Pell's multipart utils
+ * Multipart form data request adapter for Jason Pell's multipart utils package.
  *
- * @version $Id$
- * @author  Matt Baldree (matt@smallleap.com) modified for WW's use
- * @author  Scott Farquhar (scott@atlassian.com) added i18n handling (WW-109)
+ * @author <a href="matt@smallleap.com">Matt Baldree</a> (modified for WW's use)
+ * @author <a href="scott@atlassian.com">Scott Farquhar</a> (added i18n handling (WW-109))
  */
 public class PellMultiPartRequest extends MultiPartRequest {
-    //~ Instance fields ////////////////////////////////////////////////////////
 
-    /* ------------------------------------------------------------ */
     private ServletMultipartRequest multi;
 
-    //~ Constructors ///////////////////////////////////////////////////////////
-
     /**
+     * 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
         }
     }
 
-    //~ Methods ////////////////////////////////////////////////////////////////
-
     public String getContentType(String name) {
         return multi.getContentType(name);
     }
         return multi.getFile(name);
     }
 
-    // Methods only in MultipartRequest
     public Enumeration getFileNames() {
         return multi.getFileParameterNames();
     }
     }
 
     /**
-     * Set the encoding for the uploaded params.  This needs to be set if you are using character sets other than
+     * Sets the encoding for the uploaded params.  This needs to be set if you are using character sets other than
      * ASCII.
      * <p>
      * The encoding is looked up from the configuration setting 'webwork.i18n.encoding'.  This is usually set in