001 // Copyright 2007, 2008 The Apache Software Foundation
002 //
003 // Licensed under the Apache License, Version 2.0 (the "License");
004 // you may not use this file except in compliance with the License.
005 // You may obtain a copy of the License at
006 //
007 // http://www.apache.org/licenses/LICENSE-2.0
008 //
009 // Unless required by applicable law or agreed to in writing, software
010 // distributed under the License is distributed on an "AS IS" BASIS,
011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 // See the License for the specific language governing permissions and
013 // limitations under the License.
014
015 package org.apache.tapestry5.upload.services;
016
017 import org.apache.commons.fileupload.FileUploadException;
018
019 import javax.servlet.http.HttpServletRequest;
020
021 /**
022 * Responsible for detecting and processing file upload requests, using Jakarta Commons FileUpload. Implementations of
023 * this service typically use the threaded service lifecycle model.
024 */
025 public interface MultipartDecoder
026 {
027
028 /**
029 * @param parameterName Name of the query parameter associated with the uploaded file
030 * @return a file upload with the given name, or null if no such file upload was in the request.
031 */
032 UploadedFile getFileUpload(String parameterName);
033
034 /**
035 * Decodes the request, returning a new {@link javax.servlet.http.HttpServletRequest} implementation that will allow
036 * access to the form fields submitted in the request (but omits uploaded files).
037 *
038 * @param request The incoming servlet request
039 * @return decoded http request
040 */
041 HttpServletRequest decode(HttpServletRequest request);
042
043 /**
044 * Returns the exception the occured during the file upload, or null if the processing of the multipart upload
045 * stream was succesful.
046 */
047 FileUploadException getUploadException();
048 }