001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/wfs/operation/WFSGetCapabilities.java $
002: /*---------------- FILE HEADER ------------------------------------------
003:
004: This file is part of deegree.
005: Copyright (C) 2001-2008 by:
006: EXSE, Department of Geography, University of Bonn
007: http://www.giub.uni-bonn.de/deegree/
008: lat/lon GmbH
009: http://www.lat-lon.de
010:
011: This library is free software; you can redistribute it and/or
012: modify it under the terms of the GNU Lesser General Public
013: License as published by the Free Software Foundation; either
014: version 2.1 of the License, or (at your option) any later version.
015:
016: This library is distributed in the hope that it will be useful,
017: but WITHOUT ANY WARRANTY; without even the implied warranty of
018: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
019: Lesser General Public License for more details.
020:
021: You should have received a copy of the GNU Lesser General Public
022: License along with this library; if not, write to the Free Software
023: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:
025: Contact:
026:
027: Andreas Poth
028: lat/lon GmbH
029: Aennchenstraße 19
030: 53177 Bonn
031: Germany
032: E-Mail: poth@lat-lon.de
033:
034: Prof. Dr. Klaus Greve
035: Department of Geography
036: University of Bonn
037: Meckenheimer Allee 166
038: 53115 Bonn
039: Germany
040: E-Mail: greve@giub.uni-bonn.de
041:
042: ---------------------------------------------------------------------------*/
043: package org.deegree.ogcwebservices.wfs.operation;
044:
045: import java.util.Map;
046:
047: import org.deegree.framework.util.KVP2Map;
048: import org.deegree.ogcwebservices.InvalidParameterValueException;
049: import org.deegree.ogcwebservices.MissingParameterValueException;
050: import org.deegree.ogcwebservices.OGCWebServiceException;
051: import org.deegree.ogcwebservices.getcapabilities.GetCapabilities;
052: import org.deegree.ogcwebservices.wfs.WFService;
053: import org.w3c.dom.Element;
054:
055: /**
056: * Represents a GetCapabilities request to a web feature service.
057: * <p>
058: * The GetCapabilities request is used to query a capabilities document from a web feature service.
059: *
060: * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
061: * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a>
062: * @author last edited by: $Author: apoth $
063: *
064: * @version $Revision: 9345 $, $Date: 2007-12-27 08:22:25 -0800 (Thu, 27 Dec 2007) $
065: */
066: public class WFSGetCapabilities extends GetCapabilities {
067:
068: private static final long serialVersionUID = 3581485156939911513L;
069:
070: /**
071: * Creates a new <code>WFSGetCapabilities</code> instance. with a wfs version of {@link WFService.VERSION}.
072: *
073: * @param id
074: * request identifier
075: * @param updateSeq
076: * @param acceptVersions
077: * @param sections
078: * @param acceptFormats
079: * @param vendoreSpec
080: */
081: WFSGetCapabilities(String id, String updateSeq,
082: String[] acceptVersions, String[] sections,
083: String[] acceptFormats, Map<String, String> vendoreSpec) {
084: this (id, WFService.VERSION, updateSeq, acceptVersions,
085: sections, acceptFormats, vendoreSpec);
086: }
087:
088: /**
089: * Creates a new <code>WFSGetCapabilities</code> instance.
090: *
091: * @param id
092: * request identifier
093: * @param version
094: * the version of the request. (e.g 1.0.0 or 1.1.0)
095: * @param updateSeq
096: * @param acceptVersions
097: * @param sections
098: * @param acceptFormats
099: * @param vendoreSpec
100: */
101: WFSGetCapabilities(String id, String version, String updateSeq,
102: String[] acceptVersions, String[] sections,
103: String[] acceptFormats, Map<String, String> vendoreSpec) {
104: super (id, version, updateSeq, acceptVersions, sections,
105: acceptFormats, vendoreSpec);
106: }
107:
108: /**
109: * Creates a <code>WFSGetCapabilities</code> instance from a document that contains the DOM representation of the
110: * request.
111: *
112: * @param id
113: * @param root
114: * element that contains the DOM representation of the request
115: * @return transaction instance
116: * @throws OGCWebServiceException
117: */
118: public static WFSGetCapabilities create(String id, Element root)
119: throws OGCWebServiceException {
120: WFSGetCapabilitiesDocument doc = new WFSGetCapabilitiesDocument();
121: doc.setRootElement(root);
122: WFSGetCapabilities request;
123: try {
124: request = doc.parse(id);
125: } catch (Exception e) {
126: throw new OGCWebServiceException("WFSGetCapabilities", e
127: .getMessage());
128: }
129: return request;
130: }
131:
132: /**
133: * Creates a new <code>WFSGetCapabilities</code> instance from the given key-value pair encoded request.
134: *
135: * @param id
136: * request identifier
137: * @param request
138: * @return new <code>WFSGetCapabilities</code> request
139: * @throws InvalidParameterValueException
140: * @throws MissingParameterValueException
141: */
142: public static WFSGetCapabilities create(String id, String request)
143: throws InvalidParameterValueException,
144: MissingParameterValueException {
145: Map<String, String> map = KVP2Map.toMap(request);
146: map.put("ID", id);
147: return create(map);
148: }
149:
150: /**
151: * Creates a new <code>WFSGetCapabilities</code> request from the given map.
152: *
153: * @param request
154: * @return new <code>WFSGetCapabilities</code> request
155: * @throws InvalidParameterValueException
156: * @throws MissingParameterValueException
157: */
158: public static WFSGetCapabilities create(Map<String, String> request)
159: throws InvalidParameterValueException,
160: MissingParameterValueException {
161:
162: String service = getRequiredParam("SERVICE", request);
163: if (!service.equals("WFS")) {
164: throw new InvalidParameterValueException(
165: "WFSGetCapabilities",
166: "Parameter 'service' must be 'WFS'.");
167: }
168: String version = request.get("VERSION");
169: String[] acceptVersions = getParamValues("ACCEPTVERSIONS",
170: request, WFService.VERSION);
171: String[] sections = getParamValues("SECTIONS", request, "");
172: String updateSequence = getParam("UPDATESEQUENCE", request, "");
173: String[] acceptFormats = getParamValues("ACCEPTFORMATS",
174: request, "text/xml");
175:
176: // TODO generate unique request id
177: String id = null;
178: if (version == null || "".equals(version.trim())) {
179: return new WFSGetCapabilities(id, updateSequence,
180: acceptVersions, sections, acceptFormats, request);
181: }
182: return new WFSGetCapabilities(id, version, updateSequence,
183: acceptVersions, sections, acceptFormats, request);
184: }
185:
186: /**
187: * Returns the service name (WFS).
188: *
189: * @return the service name (WFS).
190: */
191: public String getServiceName() {
192: return "WFS";
193: }
194: }
|