001: /*
002: * $Id: MultiPartRequest.java 474191 2006-11-13 08:30:40Z mrdon $
003: *
004: * Licensed to the Apache Software Foundation (ASF) under one
005: * or more contributor license agreements. See the NOTICE file
006: * distributed with this work for additional information
007: * regarding copyright ownership. The ASF licenses this file
008: * to you under the Apache License, Version 2.0 (the
009: * "License"); you may not use this file except in compliance
010: * with the License. You may obtain a copy of the License at
011: *
012: * http://www.apache.org/licenses/LICENSE-2.0
013: *
014: * Unless required by applicable law or agreed to in writing,
015: * software distributed under the License is distributed on an
016: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017: * KIND, either express or implied. See the License for the
018: * specific language governing permissions and limitations
019: * under the License.
020: */
021: package org.apache.struts2.dispatcher.multipart;
022:
023: import java.io.File;
024: import java.io.IOException;
025: import java.util.Enumeration;
026: import java.util.List;
027:
028: import javax.servlet.http.HttpServletRequest;
029:
030: import org.apache.commons.logging.Log;
031: import org.apache.commons.logging.LogFactory;
032:
033: /**
034: * Abstract wrapper class HTTP requests to handle multi-part data. <p>
035: *
036: */
037: public interface MultiPartRequest {
038:
039: public void parse(HttpServletRequest request, String saveDir)
040: throws IOException;
041:
042: /**
043: * Returns an enumeration of the parameter names for uploaded files
044: *
045: * @return an enumeration of the parameter names for uploaded files
046: */
047: public Enumeration<String> getFileParameterNames();
048:
049: /**
050: * Returns the content type(s) of the file(s) associated with the specified field name
051: * (as supplied by the client browser), or <tt>null</tt> if no files are associated with the
052: * given field name.
053: *
054: * @param fieldName input field name
055: * @return an array of content encoding for the specified input field name or <tt>null</tt> if
056: * no content type was specified.
057: */
058: public String[] getContentType(String fieldName);
059:
060: /**
061: * Returns a {@link java.io.File} object for the filename specified or <tt>null</tt> if no files
062: * are associated with the given field name.
063: *
064: * @param fieldName input field name
065: * @return a File[] object for files associated with the specified input field name
066: */
067: public File[] getFile(String fieldName);
068:
069: /**
070: * Returns a String[] of file names for files associated with the specified input field name
071: *
072: * @param fieldName input field name
073: * @return a String[] of file names for files associated with the specified input field name
074: */
075: public String[] getFileNames(String fieldName);
076:
077: /**
078: * Returns the file system name(s) of files associated with the given field name or
079: * <tt>null</tt> if no files are associated with the given field name.
080: *
081: * @param fieldName input field name
082: * @return the file system name(s) of files associated with the given field name
083: */
084: public String[] getFilesystemName(String fieldName);
085:
086: /**
087: * Returns the specified request parameter.
088: *
089: * @param name the name of the parameter to get
090: * @return the parameter or <tt>null</tt> if it was not found.
091: */
092: public String getParameter(String name);
093:
094: /**
095: * Returns an enumeration of String parameter names.
096: *
097: * @return an enumeration of String parameter names.
098: */
099: 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: }
|