KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > struts > upload > MultipartRequestHandler


1 /*
2  * $Id: MultipartRequestHandler.java 54929 2004-10-16 16:38:42Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.struts.upload;
20
21 import java.util.Hashtable JavaDoc;
22 import javax.servlet.ServletException JavaDoc;
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import org.apache.struts.action.ActionServlet;
25 import org.apache.struts.action.ActionMapping;
26
27 /**
28   * MultipartRequestHandler provides an standard interface for struts to
29   * deal with file uploads from forms with enctypes of "multipart/form-data".
30   * Providers must provide a no-argument constructor for initialization.
31   *
32   */

33 public interface MultipartRequestHandler
34 {
35     /**
36      * This is the ServletRequest attribute that should be set when a multipart request is being read
37      * and the maximum length is exceeded. The value is a Boolean. If the maximum length isn't exceeded,
38      * this attribute shouldn't be put in the ServletRequest. It's the job of the implementation to put this
39      * attribute in the request if the maximum length is exceeded; in the handleRequest(HttpServletRequest) method.
40      */

41     public static final String JavaDoc ATTRIBUTE_MAX_LENGTH_EXCEEDED = "org.apache.struts.upload.MaxLengthExceeded";
42
43     /**
44      * Convienience method to set a reference to a working
45      * ActionServlet instance.
46      */

47     public void setServlet(ActionServlet servlet);
48
49     /**
50      * Convienience method to set a reference to a working
51      * ActionMapping instance.
52      */

53     public void setMapping(ActionMapping mapping);
54
55     /**
56      * Get the ActionServlet instance
57      */

58     public ActionServlet getServlet();
59
60     /**
61      * Get the ActionMapping instance for this request
62      */

63     public ActionMapping getMapping();
64
65     /**
66       * After constructed, this is the first method called on
67       * by ActionServlet. Use this method for all your
68       * data-parsing of the ServletInputStream in the request
69       *
70       * @exception ServletException thrown if something goes wrong
71       */

72     public void handleRequest(HttpServletRequest JavaDoc request)
73         throws ServletException JavaDoc;
74
75     /**
76      * This method is called on to retrieve all the text
77      * input elements of the request.
78      *
79      * @return A Hashtable where the keys and values are the names and
80      * values of the request input parameters
81      */

82     public Hashtable JavaDoc getTextElements();
83     
84     /**
85      * This method is called on to retrieve all the FormFile
86      * input elements of the request.
87      * @see org.apache.struts.upload.FormFile
88      * @return A Hashtable where the keys are the input names of the
89      * files and the values are FormFile objects
90      */

91     public Hashtable JavaDoc getFileElements();
92
93     /**
94      * This method returns all elements of a multipart request.
95      * @return A Hashtable where the keys are input names and values
96      * are either Strings or FormFiles
97      */

98     public Hashtable JavaDoc getAllElements();
99
100     /**
101      * This method is called on when there's some sort of problem
102      * and the form post needs to be rolled back. Providers
103      * should remove any FormFiles used to hold information
104      * by setting them to null and also physically delete
105      * them if the implementation calls for writing directly
106      * to disk.
107      * NOTE: Currently implemented but not automatically
108      * supported, ActionForm implementors must call rollback()
109      * manually for rolling back file uploads.
110      */

111     public void rollback();
112
113     /**
114      * This method is called on when a successful form post
115      * has been made. Some implementations will use this
116      * to destroy temporary files or write to a database
117      * or something of that nature.
118      */

119     public void finish();
120
121 }
122
123
Popular Tags