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.config;
006:
007: import org.vfny.geoserver.global.MetaDataLink;
008: import org.vfny.geoserver.global.dto.ServiceDTO;
009: import java.net.URL;
010: import java.util.ArrayList;
011: import java.util.List;
012:
013: /**
014: * ServiceConfig purpose.
015: *
016: * <p>
017: * ServiceConfig is intended to be extended to provide some basic data storage
018: * facilities. This class represents the basic properties of a web service.
019: * </p>
020: *
021: * <p></p>
022: *
023: * @author dzwiers, Refractions Research, Inc.
024: * @version $Id: ServiceConfig.java 6326 2007-03-15 18:36:40Z jdeolive $
025: */
026: public class ServiceConfig {
027: /**
028: * Represents when the web service is enabled/disabled. True when enabled.
029: */
030: private boolean enabled = true;
031:
032: /**
033: * Online Reference URL for the web service. A location to look for when
034: * additional assistance is required.
035: */
036: private URL onlineResource;
037:
038: /** The name of the service. */
039: private String name;
040:
041: /** The title of the service. */
042: private String title;
043:
044: /** A short abstract about the service. */
045: private String _abstract;
046:
047: /** A list of keywords associated with the service. */
048: private List keywords;
049:
050: /**
051: * The fees associated with the service. When there are not any fees, the
052: * value "NONE" is used.
053: */
054: private String fees;
055:
056: /**
057: * The access constraints associated with the service. When there are not
058: * any, the value "NONE" is used.
059: */
060: private String accessConstraints = "NONE";
061:
062: /**
063: * Name of the person who maintains the web service. Should ideally be
064: * contact information such as webmaster&geoserver.org .
065: */
066: private String maintainer;
067: private MetaDataLink metadataLink;
068:
069: /**
070: * ServiceConfig constructor.
071: *
072: * <p>
073: * Creates an empty ServiceConfig representation with default values.
074: * </p>
075: *
076: * @see defaultSettings()
077: */
078: public ServiceConfig() {
079: enabled = true;
080: name = "";
081: title = "";
082: _abstract = "";
083: keywords = new ArrayList();
084: fees = "";
085: accessConstraints = "NONE";
086: maintainer = "";
087: metadataLink = null;
088: }
089:
090: /**
091: * ServiceConfig constructor.
092: *
093: * <p>
094: * This is equivalent to calling the load method. When a null value is
095: * passed in, the default values are used. All non-primary datatypes are
096: * cloned with the exception of Strings (which have a singleton hash
097: * table in memory representation).
098: * </p>
099: *
100: * @param dto The ServiceDTO object to copy into the new ServiceConfig
101: * object.
102: *
103: * @throws NullPointerException if dto was null;
104: */
105: public ServiceConfig(ServiceDTO dto) {
106: if (dto == null) {
107: throw new NullPointerException(
108: "Non null ServiceDTO required");
109: }
110:
111: update(dto);
112: }
113:
114: /**
115: * Implement loadDTO.
116: *
117: * <p>
118: * Takes a ServiceDTO and loads it into this ServiceConfig Object
119: * </p>
120: *
121: * @param dto an instance of ServiceDTO
122: *
123: * @throws NullPointerException if dto is null
124: *
125: * @see org.vfny.geoserver.config.DataStructure#loadDTO(java.lang.Object)
126: */
127: public void update(ServiceDTO dto) {
128: if (dto == null) {
129: throw new NullPointerException(
130: "Service Data Transfer Object required");
131: }
132:
133: ServiceDTO s = (ServiceDTO) dto;
134: enabled = s.isEnabled();
135: name = s.getName();
136: title = s.getTitle();
137: _abstract = s.getAbstract();
138:
139: keywords = new ArrayList(s.getKeywords());
140: fees = s.getFees();
141: accessConstraints = s.getAccessConstraints();
142: maintainer = s.getMaintainer();
143: onlineResource = s.getOnlineResource();
144: metadataLink = s.getMetadataLink();
145: }
146:
147: /**
148: * Implement toDTO.
149: *
150: * <p>
151: * Returns a copy of the data in a ServiceDTO object
152: * </p>
153: *
154: * @return a copy of the data in a ServiceDTO object
155: *
156: * @see org.vfny.geoserver.config.DataStructure#toDTO()
157: */
158:
159: // name needed to not match as the DTOs do not follow the same inheritance struture.
160: public ServiceDTO toServDTO() {
161: ServiceDTO sDto = new ServiceDTO();
162: sDto.setAbstract(_abstract);
163: sDto.setAccessConstraints(accessConstraints);
164: sDto.setEnabled(enabled);
165: sDto.setFees(fees);
166: sDto.setKeywords(new ArrayList(keywords));
167: sDto.setMaintainer(maintainer);
168: sDto.setName(name);
169: sDto.setOnlineResource(onlineResource);
170: sDto.setTitle(title);
171: sDto.setMetadataLink(metadataLink);
172:
173: return sDto;
174: }
175:
176: /**
177: * getName purpose.
178: *
179: * @return
180: */
181: public String getName() {
182: return name;
183: }
184:
185: /**
186: * getOnlineResource purpose.
187: *
188: * @return
189: */
190: public URL getOnlineResource() {
191: return onlineResource;
192: }
193:
194: /**
195: * getTitle purpose.
196: *
197: * @return
198: */
199: public String getTitle() {
200: return title;
201: }
202:
203: /**
204: * setName purpose.
205: *
206: * @param string
207: */
208: public void setName(String string) {
209: name = string;
210: }
211:
212: /**
213: * setOnlineResource purpose.
214: *
215: * @param url
216: */
217: public void setOnlineResource(URL url) {
218: onlineResource = url;
219: }
220:
221: /**
222: * setTitle purpose.
223: *
224: * @param string
225: */
226: public void setTitle(String string) {
227: title = string;
228: }
229:
230: /**
231: * getAbstract purpose.
232: *
233: * @return
234: */
235: public String getAbstract() {
236: return _abstract;
237: }
238:
239: /**
240: * getAccessConstraints purpose.
241: *
242: * @return
243: */
244: public String getAccessConstraints() {
245: return accessConstraints;
246: }
247:
248: /**
249: * isEnabled purpose.
250: *
251: * @return
252: */
253: public boolean isEnabled() {
254: return enabled;
255: }
256:
257: /**
258: * getFees purpose.
259: *
260: * @return
261: */
262: public String getFees() {
263: return fees;
264: }
265:
266: /**
267: * getKeywords purpose.
268: *
269: * @return
270: */
271: public List getKeywords() {
272: return keywords;
273: }
274:
275: /**
276: * getMaintainer purpose.
277: *
278: * @return
279: */
280: public String getMaintainer() {
281: return maintainer;
282: }
283:
284: /**
285: * setAbstract purpose.
286: *
287: * @param string
288: */
289: public void setAbstract(String string) {
290: _abstract = string;
291: }
292:
293: /**
294: * setAccessConstraints purpose.
295: *
296: * @param string
297: */
298: public void setAccessConstraints(String string) {
299: accessConstraints = string;
300: }
301:
302: /**
303: * setEnabled purpose.
304: *
305: * @param b
306: */
307: public void setEnabled(boolean b) {
308: enabled = b;
309: }
310:
311: /**
312: * setFees purpose.
313: *
314: * @param string
315: */
316: public void setFees(String string) {
317: fees = string;
318: }
319:
320: /**
321: * setKeywords purpose.
322: *
323: * @param list
324: */
325: public void setKeywords(List list) {
326: keywords = list;
327: }
328:
329: /**
330: * setMaintainer purpose.
331: *
332: * @param string
333: */
334: public void setMaintainer(String string) {
335: maintainer = string;
336: }
337:
338: /**
339: * @return Returns the metadataLink.
340: *
341: */
342: public MetaDataLink getMetadataLink() {
343: return metadataLink;
344: }
345:
346: /**
347: * @param metadataLink The metadataLink to set.
348: *
349: */
350: public void setMetadataLink(MetaDataLink metadataLink) {
351: this.metadataLink = metadataLink;
352: }
353: }
|