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.wcs;
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.WCSConfig;
012: import java.net.MalformedURLException;
013: import java.net.URL;
014: import javax.servlet.ServletContext;
015: import javax.servlet.http.HttpServletRequest;
016:
017: /**
018: * DOCUMENT ME!
019: *
020: * @author $Author: Alessio Fabiani (alessio.fabiani@gmail.com) $ (last modification)
021: * @author $Author: Simone Giannecchini (simboss1@gmail.com) $ (last modification)
022: */
023: public class WCSContentForm extends ActionForm {
024: /**
025: * Comment for <code>serialVersionUID</code>
026: */
027: private static final long serialVersionUID = 3977860674510534961L;
028:
029: /**
030: *
031: */
032: private boolean enabled;
033:
034: /**
035: *
036: */
037: private String onlineResource;
038:
039: /**
040: *
041: */
042: private String describeURL;
043:
044: /**
045: *
046: */
047: private boolean enabledChecked = false;
048:
049: /**
050: * DOCUMENT ME!
051: *
052: * @return
053: */
054: public boolean isEnabled() {
055: return enabled;
056: }
057:
058: /**
059: * DOCUMENT ME!
060: *
061: * @return
062: */
063: public String getOnlineResource() {
064: return onlineResource;
065: }
066:
067: /**
068: * DOCUMENT ME!
069: *
070: * @param string
071: */
072: public void setDescribeURL(String string) {
073: describeURL = string;
074: }
075:
076: /**
077: * DOCUMENT ME!
078: *
079: * @param b
080: */
081: public void setEnabled(boolean b) {
082: enabledChecked = true;
083: //System.out.println("setEnabled: enabledCheck/Enabled now " + b);
084: enabled = b;
085: }
086:
087: /**
088: * DOCUMENT ME!
089: *
090: * @param string
091: */
092: public void setOnlineResource(String string) {
093: onlineResource = string;
094: }
095:
096: public void reset(ActionMapping arg0, HttpServletRequest arg1) {
097: super .reset(arg0, arg1);
098:
099: enabledChecked = false;
100:
101: ServletContext context = getServlet().getServletContext();
102: WCSConfig config = (WCSConfig) context
103: .getAttribute(WCSConfig.CONFIG_KEY);
104:
105: this .enabled = config.isEnabled();
106:
107: URL url = config.getOnlineResource();
108:
109: if (url != null) {
110: this .onlineResource = url.toString();
111: } else {
112: this .onlineResource = "";
113: }
114: }
115:
116: public ActionErrors validate(ActionMapping mapping,
117: HttpServletRequest request) {
118: ActionErrors errors = new ActionErrors();
119:
120: if ((onlineResource == null) || onlineResource.equals("")) {
121: errors.add("onlineResource", new ActionError(
122: "error.wcs.onlineResource.required"));
123: } else {
124: try {
125: URL url = new URL(onlineResource);
126: } catch (MalformedURLException badURL) {
127: errors.add("onlineResource", new ActionError(
128: "error.wcs.onlineResource.malformed", badURL));
129: }
130: }
131:
132: return errors;
133: }
134:
135: /**
136: * DOCUMENT ME!
137: *
138: * @return
139: */
140: public boolean isEnabledChecked() {
141: return enabledChecked;
142: }
143:
144: /**
145: * DOCUMENT ME!
146: *
147: * @param b
148: */
149: public void setEnabledChecked(boolean b) {
150: enabledChecked = b;
151: }
152: }
|