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.global;
006:
007: import org.geoserver.ows.OWS;
008: import org.vfny.geoserver.global.dto.ServiceDTO;
009: import java.net.URL;
010: import java.nio.charset.Charset;
011: import java.util.LinkedList;
012: import java.util.List;
013: import java.util.Map;
014:
015: /**
016: * Default configuration for services. This class represents all the
017: * commonalities to the WFS and WMS services.
018: *
019: * <p>
020: * WFS wfs = new WFS(dto); Service serv = (Service)WFS;
021: * System.out.println(serv.getName());
022: * </p>
023: *
024: * @author Gabriel Rold?n
025: * @author Chris Holmes
026: * @version $Id: Service.java 6326 2007-03-15 18:36:40Z jdeolive $
027: *
028: * @see WMS
029: * @see WFS
030: */
031: public abstract class Service extends OWS /*extends GlobalLayerSupertype*/{
032: // private boolean enabled;
033: // private URL onlineResource;
034: // private String name;
035: // private String title;
036: // private String serverAbstract;
037: // private String[] keywords = new String[0];
038: // private String fees;
039: // private String accessConstraints;
040: // private String maintainer;
041: private String strategy;
042: private MetaDataLink metadataLink;
043: private int partialBufferSize;
044: private GeoServer gs;
045: private Data dt;
046:
047: /**
048: * Service constructor.
049: *
050: * <p>
051: * Stores the new ServiceDTO data for this service.
052: * </p>
053: *
054: * @param config
055: *
056: * @throws NullPointerException when the param is null
057: */
058: public Service(ServiceDTO dto) {
059: if (dto == null) {
060: throw new NullPointerException();
061: }
062:
063: setEnabled(dto.isEnabled());
064: setName(dto.getName());
065: setTitle(dto.getTitle());
066: setAbtract(dto.getAbstract());
067: setKeywords(dto.getKeywords());
068: setFees(dto.getFees());
069: setAccessConstraints(dto.getAccessConstraints());
070: setMaintainer(dto.getMaintainer());
071: setOnlineResource(dto.getOnlineResource());
072: metadataLink = dto.getMetadataLink();
073: strategy = dto.getStrategy();
074: partialBufferSize = dto.getPartialBufferSize();
075: }
076:
077: /**
078: * load purpose.
079: * <p>
080: * loads a new copy of data into this object.
081: * </p>
082: * @param dto
083: */
084: public void load(ServiceDTO dto) {
085: if (dto == null) {
086: throw new NullPointerException();
087: }
088:
089: setEnabled(dto.isEnabled());
090: setName(dto.getName());
091: setTitle(dto.getTitle());
092: setAbtract(dto.getAbstract());
093: setKeywords(dto.getKeywords());
094: setFees(dto.getFees());
095: setAccessConstraints(dto.getAccessConstraints());
096: setMaintainer(dto.getMaintainer());
097: setOnlineResource(dto.getOnlineResource());
098: metadataLink = dto.getMetadataLink();
099: strategy = dto.getStrategy();
100: partialBufferSize = dto.getPartialBufferSize();
101: }
102:
103: /**
104: * Sets the strategy used by the service when performing a response.
105: *
106: */
107: public void setStrategy(String strategy) {
108: this .strategy = strategy;
109: }
110:
111: /**
112: * @return The strategy used by the service when performing a response.
113: */
114: public String getStrategy() {
115: return strategy;
116: }
117:
118: /**
119: * @return The size of the buffer used by the PARTIAL-BUFFER strategy.
120: * TODO: this should be factored out when config is splittable among modules.
121: */
122: public int getPartialBufferSize() {
123: return partialBufferSize;
124: }
125:
126: /**
127: * Sets the size of the buffer used by the PARTIAL-BUFFER strategy.
128: * TODO: this should be factored out when config is splittable among modules.
129: */
130: public void setPartialBufferSize(int partialBufferSize) {
131: this .partialBufferSize = partialBufferSize;
132: }
133:
134: protected Object toDTO() {
135: ServiceDTO dto = new ServiceDTO();
136: dto.setAccessConstraints(getAccessConstraints());
137: dto.setEnabled(isEnabled());
138: dto.setFees(getFees());
139: dto.setKeywords(getKeywords());
140: dto.setMaintainer(getMaintainer());
141: dto.setName(getName());
142: dto.setOnlineResource(getOnlineResource());
143: dto.setAbstract(getAbstract());
144: dto.setTitle(getTitle());
145: dto.setMetadataLink(metadataLink);
146: dto.setStrategy(strategy);
147: dto.setPartialBufferSize(partialBufferSize);
148:
149: return dto;
150: }
151:
152: /**
153: * Access dt property.
154: *
155: * @return Returns the dt.
156: */
157: public Data getData() {
158: return dt;
159: }
160:
161: /**
162: * Set dt to dt.
163: *
164: * @param dt The dt to set.
165: */
166: public void setData(Data dt) {
167: this .dt = dt;
168: }
169:
170: /**
171: * Access gs property.
172: *
173: * @return Returns the gs.
174: */
175: public GeoServer getGeoServer() {
176: return gs;
177: }
178:
179: /**
180: * Set gs to gs.
181: *
182: * @param gs The gs to set.
183: */
184: public void setGeoServer(GeoServer gs) {
185: this .gs = gs;
186: }
187:
188: /**
189: * @return Returns the metadataLink.
190: *
191: */
192: public MetaDataLink getMetadataLink() {
193: return metadataLink;
194: }
195: }
|