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