KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > business > library > struts > UploadHTMLForm


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: UploadHTMLForm.java,v $
31  * Revision 1.3 2005/04/10 20:31:58 colinmacleod
32  * Added new themes.
33  * Changed id type to String.
34  * Changed i tag to em and b tag to strong.
35  * Improved PicoContainerFactory with NanoContainer scripts.
36  *
37  * Revision 1.2 2005/04/09 17:19:46 colinmacleod
38  * Changed copyright text to GPL v2 explicitly.
39  *
40  * Revision 1.1.1.1 2005/03/10 17:52:05 colinmacleod
41  * Restructured ivata op around Hibernate/PicoContainer.
42  * Renamed ivata groupware.
43  *
44  * Revision 1.7 2004/12/23 21:01:29 colinmacleod
45  * Updated Struts to v1.2.4.
46  * Changed base classes to use ivata masks.
47  *
48  * Revision 1.6 2004/11/12 18:19:15 colinmacleod
49  * Change action and form classes to extend MaskAction, MaskForm respectively.
50  *
51  * Revision 1.5 2004/07/13 19:47:29 colinmacleod
52  * Moved project to POJOs from EJBs.
53  * Applied PicoContainer to services layer (replacing session EJBs).
54  * Applied Hibernate to persistence layer (replacing entity EJBs).
55  *
56  * Revision 1.4 2004/03/21 21:16:29 colinmacleod
57  * Shortened name to ivata op.
58  *
59  * Revision 1.3 2004/02/10 19:57:24 colinmacleod
60  * Changed email address.
61  *
62  * Revision 1.2 2004/02/01 22:07:31 colinmacleod
63  * Added full names to author tags
64  *
65  * Revision 1.1.1.1 2004/01/27 20:58:42 colinmacleod
66  * Moved ivata openportal to SourceForge..
67  *
68  * Revision 1.2 2003/10/15 14:16:53 colin
69  * fixing for XDoclet
70  *
71  * Revision 1.1 2003/07/08 06:31:33 peter
72  * added to cvs
73  * -----------------------------------------------------------------------------
74  */

75 package com.ivata.groupware.business.library.struts;
76
77 import javax.servlet.http.HttpServletRequest JavaDoc;
78 import javax.servlet.http.HttpSession JavaDoc;
79
80 import org.apache.struts.action.ActionErrors;
81 import org.apache.struts.action.ActionMapping;
82 import org.apache.struts.action.ActionMessage;
83 import org.apache.struts.upload.FormFile;
84
85 import com.ivata.mask.Mask;
86 import com.ivata.mask.validation.ValidationErrors;
87 import com.ivata.mask.web.struts.DialogForm;
88
89
90 /**
91  * <p>This form is used to upload a HTML file straight to pages of an editer library documentr.</p>
92  *
93  * @since 2003-07-02
94  * @author Peter Illes
95  * @version $Revision: 1.3 $
96  *
97  */

98 public class UploadHTMLForm extends DialogForm {
99     /**
100      * <p>the uploaded file</p>
101      */

102     private FormFile file;
103     /**
104      * <p>
105      * Defines the base class of all objects in the value object list.
106      * </p>
107      */

108     private Class JavaDoc baseClass;
109     /**
110      * <p>
111      * Mask containing all the field definitions for this list.
112      * </p>
113      */

114     private Mask mask;
115
116     /**
117      * @see com.ivata.mask.web.struts.MaskForm#clear()
118      */

119     protected void clear() {
120     }
121
122     /**
123      * <p>getter for the file field</p>
124      * @return the uploaded file as <code>FormFile</code>
125      */

126     public FormFile getFile() {
127         return this.file;
128     }
129
130     /**
131      * <p>setter for the file field</p>
132      * @param file the uploaded file as <code>FormFile</code>
133      */

134     public void setFile(FormFile file) {
135         this.file = file;
136     }
137
138     /**
139      * Validate the properties that have been set for this HTTP request,
140      * and return an <code>ActionMessages</code> object that encapsulates any
141      * validation errors that have been found. If no errors are found,
142      * return <code>null</code> or an <code>ActionMessages</code> object with
143      * no recorded error messages.
144      * <p>
145      * The default implementation performs no validation and returns
146      * <code>null</code>. Subclasses must override this method to provide
147      * any validation they wish to perform.
148      *
149      * @param mapping The mapping used to select this instance
150      * @param request The servlet request we are processing
151      */

152     public ActionErrors validate(ActionMapping mapping,
153         HttpServletRequest JavaDoc request) {
154         ActionErrors errors = new ActionErrors();
155
156         if ((file == null) || (file.getFileSize() == 0)) {
157             errors.add("file", new ActionMessage("errors.nullUpload"));
158         } else if (!file.getContentType().equals("text/HTML")) {
159             errors.add("file", new ActionMessage("errors.fileContentType", "HTML"));
160         }
161
162         return errors;
163     }
164
165     /**
166      * @see com.ivata.mask.web.struts.MaskForm#validate
167      */

168     public ValidationErrors validate(HttpServletRequest JavaDoc request, HttpSession JavaDoc session) {
169         // TODO Auto-generated method stub
170
return null;
171     }
172
173     /**
174      * <p>
175      * Defines the base class of all objects in the value object list.
176      * </p>
177      *
178      * @return base class of all objects in the value object list.
179      */

180     public final Class JavaDoc getBaseClass() {
181         return baseClass;
182     }
183
184     /**
185      * <p>
186      * Mask containing all the field definitions for this list.
187      * </p>
188      *
189      * @return mask containing all the field definitions for this list.
190      */

191     public final Mask getMask() {
192         return mask;
193     }
194 }
195
Popular Tags