KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > webapp > admin > valve > AccessLogValveForm


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

16
17 package org.apache.webapp.admin.valve;
18
19 import javax.servlet.http.HttpServletRequest JavaDoc;
20 import org.apache.struts.action.ActionError;
21 import org.apache.struts.action.ActionErrors;
22 import org.apache.struts.action.ActionForm;
23 import org.apache.struts.action.ActionMapping;
24 import java.util.List JavaDoc;
25
26 /**
27  * Form bean for the accesslog valve page.
28  *
29  * @author Manveen Kaur
30  * @version $Revision: 1.4 $ $Date: 2004/02/27 14:59:06 $
31  */

32
33 public final class AccessLogValveForm extends ValveForm {
34     
35     // ----------------------------------------------------- Instance Variables
36
/**
37      * The text for the debug level.
38      */

39     private String JavaDoc debugLvl = "0";
40   
41     /**
42      * Set of valid values for debug level.
43      */

44     private List JavaDoc debugLvlVals = null;
45     
46     /**
47      * The text for the directory.
48      */

49     private String JavaDoc directory = null;
50     
51     /**
52      * The text for the pattern.
53      */

54     private String JavaDoc pattern = null;
55         
56     /**
57      * The text for the prefix.
58      */

59     private String JavaDoc prefix = null;
60     
61     /**
62      * The text for the suffix.
63      */

64     private String JavaDoc suffix = null;
65       
66     /**
67      * The text for the connection URL.
68      */

69     private String JavaDoc resolveHosts = "false";
70       
71     /**
72      * The text for the rotatable.
73      */

74     private String JavaDoc rotatable = "true";
75        
76     /**
77      * Set of boolean values.
78      */

79     private List JavaDoc booleanVals = null;
80  
81     // ------------------------------------------------------------- Properties
82

83     /**
84      * Return the debugVals.
85      */

86     public List JavaDoc getDebugLvlVals() {
87         
88         return this.debugLvlVals;
89         
90     }
91     
92     /**
93      * Set the debugVals.
94      */

95     public void setDebugLvlVals(List JavaDoc debugLvlVals) {
96         
97         this.debugLvlVals = debugLvlVals;
98         
99     }
100     
101     /**
102      * Return the booleanVals.
103      */

104     public List JavaDoc getBooleanVals() {
105         
106         return this.booleanVals;
107         
108     }
109     
110     /**
111      * Set the booleanVals.
112      */

113     public void setBooleanVals(List JavaDoc booleanVals) {
114         
115         this.booleanVals = booleanVals;
116         
117     }
118     
119     /**
120      * Return the Debug Level Text.
121      */

122     public String JavaDoc getDebugLvl() {
123         
124         return this.debugLvl;
125         
126     }
127     
128     /**
129      * Set the Debug Level Text.
130      */

131     public void setDebugLvl(String JavaDoc debugLvl) {
132         
133         this.debugLvl = debugLvl;
134         
135     }
136     
137     /**
138      * Return the directory.
139      */

140     public String JavaDoc getDirectory() {
141         
142         return this.directory;
143         
144     }
145     
146     /**
147      * Set the directory.
148      */

149     public void setDirectory(String JavaDoc directory) {
150         
151         this.directory = directory;
152         
153     }
154     
155     /**
156      * Return the pattern.
157      */

158     public String JavaDoc getPattern() {
159         
160         return this.pattern;
161         
162     }
163     
164     /**
165      * Set the pattern.
166      */

167     public void setPattern(String JavaDoc pattern) {
168         
169         this.pattern = pattern;
170         
171     }
172     
173     /**
174      * Return the prefix.
175      */

176     public String JavaDoc getPrefix() {
177         
178         return this.prefix;
179         
180     }
181     
182     /**
183      * Set the prefix.
184      */

185     public void setPrefix(String JavaDoc prefix) {
186         
187         this.prefix = prefix;
188         
189     }
190     
191     /**
192      * Return the suffix.
193      */

194     public String JavaDoc getSuffix() {
195         
196         return this.suffix;
197         
198     }
199     
200     /**
201      * Set the suffix.
202      */

203     public void setSuffix(String JavaDoc suffix) {
204         
205         this.suffix = suffix;
206         
207     }
208             
209     /**
210      * Return the resolve hosts.
211      */

212     public String JavaDoc getResolveHosts() {
213         
214         return this.resolveHosts;
215         
216     }
217     
218     /**
219      * Set the resolveHosts.
220      */

221     public void setResolveHosts(String JavaDoc resolveHosts) {
222         
223         this.resolveHosts = resolveHosts;
224         
225     }
226     
227     /**
228      * Return the rotatable.
229      */

230     public String JavaDoc getRotatable() {
231         
232         return this.rotatable;
233         
234     }
235     
236     /**
237      * Set the rotatable.
238      */

239     public void setRotatable(String JavaDoc rotatable) {
240         
241         this.rotatable = rotatable;
242         
243     }
244     
245     // --------------------------------------------------------- Public Methods
246

247     /**
248      * Reset all properties to their default values.
249      *
250      * @param mapping The mapping used to select this instance
251      * @param request The servlet request we are processing
252      */

253     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
254     
255         super.reset(mapping, request);
256         this.debugLvl = "0";
257         
258         this.directory = null;
259         this.prefix = null;
260         this.suffix = null;
261         this.pattern = null;
262         this.resolveHosts = "false";
263         this.rotatable = "true";
264         
265     }
266     
267     /**
268      * Render this object as a String.
269      */

270     public String JavaDoc toString() {
271
272         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("AccessLogValveForm[adminAction=");
273         sb.append(getAdminAction());
274         sb.append("',valveType=");
275         sb.append(getValveType());
276         sb.append(",debugLvl=");
277         sb.append(debugLvl);
278         sb.append(",directory=");
279         sb.append(directory);
280         sb.append("',prefix='");
281         sb.append(prefix);
282         sb.append("',pattern=");
283         sb.append(pattern);
284         sb.append(",resolveHosts=");
285         sb.append(resolveHosts);
286         sb.append(",rotatable=");
287         sb.append(rotatable);
288         sb.append("',objectName='");
289         sb.append(getObjectName());
290         sb.append("]");
291         return (sb.toString());
292
293     }
294     
295     /**
296      * Validate the properties that have been set from this HTTP request,
297      * and return an <code>ActionErrors</code> object that encapsulates any
298      * validation errors that have been found. If no errors are found, return
299      * <code>null</code> or an <code>ActionErrors</code> object with no
300      * recorded error messages.
301      *
302      * @param mapping The mapping used to select this instance
303      * @param request The servlet request we are processing
304      */

305     
306     public ActionErrors validate(ActionMapping mapping,
307     HttpServletRequest JavaDoc request) {
308         
309         ActionErrors errors = new ActionErrors();
310         
311         String JavaDoc submit = request.getParameter("submit");
312         
313         // front end validation when save is clicked.
314
//if (submit != null) {
315

316              // if not specified, default is access_log.
317
// to specify no prefix, specify a 0 length string...
318
if ((prefix == null) || (prefix.length() == 0)){
319                 prefix = "access_log.";
320             }
321             
322             // default is a 0 length string
323
if ((suffix == null) || (suffix.length() < 1)) {
324                 suffix = "";
325             }
326                                     
327             // If no directory attribute is specified, the default
328
// value is "logs".
329
if ((directory == null) || (directory.length() < 1)) {
330                 directory = "logs";
331             }
332
333             if ((pattern == null) || (pattern.length() < 1)) {
334                 errors.add("pattern",
335                 new ActionError("error.pattern.required"));
336             }
337         //}
338

339         return errors;
340     }
341 }
342
Popular Tags