View Javadoc

    1   /*
    2    * $Id: MultiPartRequest.java 474191 2006-11-13 08:30:40Z mrdon $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "License"); you may not use this file except in compliance
    10   * with the License.  You may obtain a copy of the License at
    11   *
    12   *  http://www.apache.org/licenses/LICENSE-2.0
    13   *
    14   * Unless required by applicable law or agreed to in writing,
    15   * software distributed under the License is distributed on an
    16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    17   * KIND, either express or implied.  See the License for the
    18   * specific language governing permissions and limitations
    19   * under the License.
    20   */
    21  package org.apache.struts2.dispatcher.multipart;
    22
    23  import java.io.File;
    24  import java.io.IOException;
    25  import java.util.Enumeration;
    26  import java.util.List;
    27
    28  import javax.servlet.http.HttpServletRequest;
    29
    30  import org.apache.commons.logging.Log;
    31  import org.apache.commons.logging.LogFactory;
    32
    33
    34  /***
    35   * Abstract wrapper class HTTP requests to handle multi-part data. <p>
    36   *
    37   */
    38  public interface MultiPartRequest {
    39
    40      public void parse(HttpServletRequest request, String saveDir) throws IOException;
    41
    42      /***
    43       * Returns an enumeration of the parameter names for uploaded files
    44       *
    45       * @return an enumeration of the parameter names for uploaded files
    46       */
    47      public Enumeration<String> getFileParameterNames();
    48
    49      /***
    50       * Returns the content type(s) of the file(s) associated with the specified field name
    51       * (as supplied by the client browser), or <tt>null</tt> if no files are associated with the
    52       * given field name.
    53       *
    54       * @param fieldName input field name
    55       * @return an array of content encoding for the specified input field name or <tt>null</tt> if
    56       *         no content type was specified.
    57       */
    58      public String[] getContentType(String fieldName);
    59
    60      /***
    61       * Returns a {@link java.io.File} object for the filename specified or <tt>null</tt> if no files
    62       * are associated with the given field name.
    63       *
    64       * @param fieldName input field name
    65       * @return a File[] object for files associated with the specified input field name
    66       */
    67      public File[] getFile(String fieldName);
    68
    69      /***
    70       * Returns a String[] of file names for files associated with the specified input field name
    71       *
    72       * @param fieldName input field name
    73       * @return a String[] of file names for files associated with the specified input field name
    74       */
    75      public String[] getFileNames(String fieldName);
    76
    77      /***
    78       * Returns the file system name(s) of files associated with the given field name or
    79       * <tt>null</tt> if no files are associated with the given field name.
    80       *
    81       * @param fieldName input field name
    82       * @return the file system name(s) of files associated with the given field name
    83       */
    84      public String[] getFilesystemName(String fieldName);
    85
    86      /***
    87       * Returns the specified request parameter.
    88       *
    89       * @param name the name of the parameter to get
    90       * @return the parameter or <tt>null</tt> if it was not found.
    91       */
    92      public String getParameter(String name);
    93
    94      /***
    95       * Returns an enumeration of String parameter names.
    96       *
    97       * @return an enumeration of String parameter names.
    98       */
    99      public Enumeration<String> getParameterNames();
    100
    101     /***
    102      * Returns a list of all parameter values associated with a parameter name. If there is only
    103      * one parameter value per name the resulting array will be of length 1.
    104      *
    105      * @param name the name of the parameter.
    106      * @return an array of all values associated with the parameter name.
    107      */
    108     public String[] getParameterValues(String name);
    109
    110     /***
    111      * Returns a list of error messages that may have occurred while processing the request.
    112      * If there are no errors, an empty list is returned. If the underlying implementation
    113      * (ie: pell, cos, jakarta, etc) cannot support providing these errors, an empty list is
    114      * also returned. This list of errors is repoted back to the
    115      * {@link MultiPartRequestWrapper}'s errors field.
    116      *
    117      * @return a list of Strings that represent various errors during parsing
    118      */
    119     public List getErrors();
    120 }