001: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
002: * This code is licensed under the GPL 2.0 license, availible at the root
003: * application directory.
004: */
005:
006: /*
007: * Created on Dec 23, 2003
008: *
009: * To change the template for this generated file go to
010: * Window>Preferences>Java>Code Generation>Code and Comments
011: */
012: package org.vfny.geoserver.form.wfs;
013:
014: import org.apache.struts.action.ActionError;
015: import org.apache.struts.action.ActionErrors;
016: import org.apache.struts.action.ActionForm;
017: import org.apache.struts.action.ActionMapping;
018: import org.vfny.geoserver.config.WFSConfig;
019: import javax.servlet.ServletContext;
020: import javax.servlet.http.HttpServletRequest;
021:
022: /**
023: * DOCUMENT ME!
024: *
025: * @author User To change the template for this generated type comment go to
026: * Window>Preferences>Java>Code Generation>Code and Comments
027: */
028:
029: /**
030: * DOCUMENT ME!
031: *
032: * @author User To change the template for this generated type comment go to
033: * Window>Preferences>Java>Code Generation>Code and Comments
034: */
035: public final class WFSDescriptionForm extends ActionForm {
036: private String name;
037: private String title;
038: private String accessConstraints;
039: private String fees;
040: private String maintainer;
041: private String keywords;
042: private String _abstract;
043:
044: public WFSDescriptionForm() {
045: }
046:
047: /**
048: * DOCUMENT ME!
049: *
050: * @return
051: */
052: public String getName() {
053: return name;
054: }
055:
056: /**
057: * DOCUMENT ME!
058: *
059: * @return
060: */
061: public String getTitle() {
062: return title;
063: }
064:
065: /**
066: * DOCUMENT ME!
067: *
068: * @param string
069: */
070: public void setName(String string) {
071: name = string;
072: }
073:
074: /**
075: * DOCUMENT ME!
076: *
077: * @param string
078: */
079: public void setTitle(String string) {
080: title = string;
081: }
082:
083: /**
084: * DOCUMENT ME!
085: *
086: * @return
087: */
088: public String get_abstract() {
089: return _abstract;
090: }
091:
092: /**
093: * DOCUMENT ME!
094: *
095: * @return
096: */
097: public String getAccessConstraints() {
098: return accessConstraints;
099: }
100:
101: /**
102: * DOCUMENT ME!
103: *
104: * @return
105: */
106: public String getFees() {
107: return fees;
108: }
109:
110: /**
111: * DOCUMENT ME!
112: *
113: * @return
114: */
115: public String getKeywords() {
116: return keywords;
117: }
118:
119: /**
120: * DOCUMENT ME!
121: *
122: * @return
123: */
124: public String getMaintainer() {
125: return maintainer;
126: }
127:
128: /**
129: * DOCUMENT ME!
130: *
131: * @param string
132: */
133: public void set_abstract(String string) {
134: _abstract = string;
135: }
136:
137: /**
138: * DOCUMENT ME!
139: *
140: * @param string
141: */
142: public void setAccessConstraints(String string) {
143: accessConstraints = string;
144: }
145:
146: /**
147: * DOCUMENT ME!
148: *
149: * @param string
150: */
151: public void setFees(String string) {
152: fees = string;
153: }
154:
155: /**
156: * DOCUMENT ME!
157: *
158: * @param string
159: */
160: public void setKeywords(String string) {
161: keywords = string;
162: }
163:
164: /**
165: * DOCUMENT ME!
166: *
167: * @param string
168: */
169: public void setMaintainer(String string) {
170: maintainer = string;
171: }
172:
173: /* (non-Javadoc)
174: * @see org.apache.struts.action.ActionForm#reset(org.apache.struts.action.ActionMapping, javax.servlet.http.HttpServletRequest)
175: */
176: public void reset(ActionMapping arg0, HttpServletRequest arg1) {
177: super .reset(arg0, arg1);
178:
179: ServletContext context = getServlet().getServletContext();
180: WFSConfig config = (WFSConfig) context
181: .getAttribute(WFSConfig.CONFIG_KEY);
182:
183: this .maintainer = config.getMaintainer();
184: this .title = config.getTitle();
185: this .accessConstraints = config.getAccessConstraints();
186: this .name = config.getName();
187: this ._abstract = config.getAbstract();
188: this .fees = config.getFees();
189:
190: String out = "";
191:
192: for (int i = 0; i < config.getKeywords().size(); i++) {
193: out = out + config.getKeywords().get(i)
194: + System.getProperty("line.separator");
195: }
196:
197: this .keywords = out;
198: }
199:
200: public ActionErrors validate(ActionMapping mapping,
201: HttpServletRequest request) {
202: ActionErrors errors = new ActionErrors();
203:
204: if ((name == null) || (name.length() == 0)) {
205: errors.add("name", new ActionError("error.name.required"));
206: }
207:
208: if ((title == null) || (title.length() == 0)) {
209: errors
210: .add("title", new ActionError(
211: "error.title.required"));
212: }
213:
214: if ((fees == null) || (fees.length() == 0)) {
215: errors.add("fees", new ActionError("error.fees.required"));
216: }
217:
218: if ((accessConstraints == null)
219: || (accessConstraints.length() == 0)) {
220: errors.add("accessConstraints", new ActionError(
221: "error.accessConstraints.required"));
222: }
223:
224: if ((maintainer == null) || (maintainer.length() == 0)) {
225: errors.add("maintainer", new ActionError(
226: "error.maintainer.required"));
227: }
228:
229: if ((_abstract == null) || (_abstract.length() == 0)) {
230: errors.add("abstract", new ActionError(
231: "error.abstract.required"));
232: }
233:
234: String[] array = (keywords != null) ? keywords.split("\n")
235: : new String[0];
236:
237: if (array.length == 0) {
238: errors.add("keywords", new ActionError(
239: "error.keywords.required"));
240: }
241:
242: return errors;
243: }
244: }
|