Source Code Cross Referenced for ValidationTestEditorForm.java in  » GIS » GeoServer » org » vfny » geoserver » form » validation » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeoServer » org.vfny.geoserver.form.validation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Created on Jan 22, 2004
003:         *
004:         * To change the template for this generated file go to
005:         * Window - Preferences - Java - Code Generation - Code and Comments
006:         */
007:        package org.vfny.geoserver.form.validation;
008:
009:        import org.apache.struts.action.ActionError;
010:        import org.apache.struts.action.ActionErrors;
011:        import org.apache.struts.action.ActionForm;
012:        import org.apache.struts.action.ActionMapping;
013:        import org.vfny.geoserver.config.validation.ArgumentConfig;
014:        import org.vfny.geoserver.config.validation.PlugInConfig;
015:        import org.vfny.geoserver.config.validation.TestConfig;
016:        import org.vfny.geoserver.config.validation.ValidationConfig;
017:        import java.beans.PropertyDescriptor;
018:        import java.util.ArrayList;
019:        import java.util.HashMap;
020:        import java.util.List;
021:        import java.util.Map;
022:        import javax.servlet.http.HttpServletRequest;
023:
024:        /**
025:         * ValidationTestEditorForm purpose.
026:         * <p>
027:         * Description of ValidationTestEditorForm ...
028:         * </p>
029:         *
030:         * @author rgould, Refractions Research, Inc.
031:         * @author $Author: emperorkefka $ (last modification)
032:         * @version $Id: ValidationTestEditorForm.java 6177 2007-02-19 10:11:27Z aaime $
033:         */
034:        public class ValidationTestEditorForm extends ActionForm {
035:            private String name;
036:            private String description;
037:            private String plugInName;
038:            private HttpServletRequest request;
039:            private List attributeKeys;
040:            private List attributeHelps;
041:            private List attributeValues;
042:
043:            public void reset(ActionMapping arg0, HttpServletRequest request) {
044:                super .reset(arg0, request);
045:                this .request = request;
046:
047:                TestConfig testConfig = (TestConfig) request.getSession()
048:                        .getAttribute(TestConfig.CURRENTLY_SELECTED_KEY);
049:
050:                name = testConfig.getName();
051:                description = testConfig.getDescription();
052:                plugInName = testConfig.getPlugIn().getName();
053:
054:                attributeKeys = new ArrayList();
055:                attributeHelps = new ArrayList();
056:                attributeValues = new ArrayList();
057:                ArgumentConfig.loadPropertyLists(testConfig, request
058:                        .getLocale(), attributeKeys, attributeHelps,
059:                        attributeValues);
060:            }
061:
062:            public ActionErrors validate(ActionMapping mapping,
063:                    HttpServletRequest request) {
064:                final TestConfig victim = (TestConfig) request.getSession()
065:                        .getAttribute(TestConfig.CURRENTLY_SELECTED_KEY);
066:
067:                // Only used to validate values!
068:                ActionErrors errors = new ActionErrors();
069:
070:                for (int i = 0; i < attributeKeys.size(); i++) {
071:                    String key = (String) attributeKeys.get(i);
072:                    String text = (String) attributeValues.get(i);
073:                    PropertyDescriptor property = victim
074:                            .getPropertyDescriptor(key);
075:
076:                    if ((text == null) || (text.length() == 0)) {
077:                        if (property.isPreferred()) {
078:                            errors.add(key, new ActionError(
079:                                    "validation.test.property.required", key));
080:                        } else {
081:                            // assume null is ok 
082:                        }
083:                    } else {
084:                        try {
085:                            Object value = victim.createArg(key, text);
086:
087:                            if ((value == null) && property.isPreferred()) {
088:                                errors.add(key, new ActionError(
089:                                        "validation.test.property.required",
090:                                        key));
091:                            }
092:                        } catch (Throwable t) {
093:                            errors
094:                                    .add(key, new ActionError(
095:                                            "validation.test.property.invalid",
096:                                            key, t));
097:                        }
098:                    }
099:                }
100:
101:                return errors;
102:            }
103:
104:            /**
105:             * Translate text representation of arguments to real values.
106:             * <p>
107:             * Victim is required for access to BeanInfo
108:             * </p>
109:             */
110:            public Map toArgumentMap(TestConfig victim) throws Exception {
111:                Map map = new HashMap();
112:
113:                for (int i = 0; i < attributeKeys.size(); i++) {
114:                    String key = (String) attributeKeys.get(i);
115:                    String text = (String) attributeValues.get(i);
116:                    PropertyDescriptor property = victim
117:                            .getPropertyDescriptor(name);
118:
119:                    if ((text == null) || (text.length() == 0)) {
120:                        if (property.isPreferred()) {
121:                            throw new IllegalArgumentException(
122:                                    "Required non empty value for " + key);
123:                        }
124:                    }
125:
126:                    Object value = victim.createArg(key, text);
127:
128:                    if (value == null) {
129:                        if (property.isPreferred()) {
130:                            throw new IllegalArgumentException(
131:                                    "Required non empty value for " + key);
132:                        }
133:                    } else {
134:                        map.put(key, value);
135:                    }
136:                }
137:
138:                return map;
139:            }
140:
141:            /**
142:             * List of attribtue keys as text.
143:             * <p>
144:             * These keys are really the propertyName associated with a BeanInfo
145:             * </p>
146:             */
147:            public List getAttributeKeys() {
148:                return attributeKeys;
149:            }
150:
151:            /**
152:             * List of attribtue vales as text.
153:             * <p>
154:             * To convert this value to a real java object you will need to use
155:             * a BeanInfo Property descriptor.
156:             * </p>
157:             */
158:            public List getAttributeValues() {
159:                return attributeValues;
160:            }
161:
162:            /** Help text gernated from PropertyDescriptor.getShortDescription() */
163:            public String[] getAttributeHelps() {
164:                return (String[]) attributeHelps
165:                        .toArray(new String[attributeHelps.size()]);
166:            }
167:
168:            public String getAttributeKey(int index) {
169:                return (String) attributeKeys.get(index);
170:            }
171:
172:            public void setAttributeValues(List list) {
173:                attributeValues = list;
174:            }
175:
176:            public void setAttributeKeys(List list) {
177:                attributeKeys = list;
178:            }
179:
180:            public void setAttributeHelps(List list) {
181:                attributeHelps = list;
182:            }
183:
184:            /**
185:             * Access description property.
186:             *
187:             * @return Returns the description.
188:             */
189:            public String getDescription() {
190:                return description;
191:            }
192:
193:            /**
194:             * Set description to description.
195:             *
196:             * @param description The description to set.
197:             */
198:            public void setDescription(String description) {
199:                this .description = description;
200:            }
201:
202:            /**
203:             * Access name property.
204:             *
205:             * @return Returns the name.
206:             */
207:            public String getName() {
208:                return name;
209:            }
210:
211:            /**
212:             * Set name to name.
213:             *
214:             * @param name The name to set.
215:             */
216:            public void setName(String name) {
217:                this .name = name;
218:            }
219:
220:            /**
221:             * Access plugInName property.
222:             *
223:             * @return Returns the plugInName.
224:             */
225:            public String getPlugInName() {
226:                return plugInName;
227:            }
228:
229:            public String getPlugInDescription() {
230:                ValidationConfig validationConfig = (ValidationConfig) this 
231:                        .getServlet().getServletContext().getAttribute(
232:                                ValidationConfig.CONFIG_KEY);
233:                PlugInConfig config = validationConfig.getPlugIn(plugInName);
234:
235:                return config.getDescription();
236:            }
237:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.