001 //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/ogcwebservices/sos/capabilities/SOSGetCapabilities.java $
002 /*----------------------------------------------------------------------------
003 This file is part of deegree, http://deegree.org/
004 Copyright (C) 2001-2009 by:
005 Department of Geography, University of Bonn
006 and
007 lat/lon GmbH
008
009 This library is free software; you can redistribute it and/or modify it under
010 the terms of the GNU Lesser General Public License as published by the Free
011 Software Foundation; either version 2.1 of the License, or (at your option)
012 any later version.
013 This library is distributed in the hope that it will be useful, but WITHOUT
014 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
015 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
016 details.
017 You should have received a copy of the GNU Lesser General Public License
018 along with this library; if not, write to the Free Software Foundation, Inc.,
019 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020
021 Contact information:
022
023 lat/lon GmbH
024 Aennchenstr. 19, 53177 Bonn
025 Germany
026 http://lat-lon.de/
027
028 Department of Geography, University of Bonn
029 Prof. Dr. Klaus Greve
030 Postfach 1147, 53001 Bonn
031 Germany
032 http://www.geographie.uni-bonn.de/deegree/
033
034 e-mail: info@deegree.org
035 ----------------------------------------------------------------------------*/
036 package org.deegree.ogcwebservices.sos.capabilities;
037
038 import java.util.HashMap;
039 import java.util.Map;
040
041 import org.deegree.framework.util.StringTools;
042 import org.deegree.framework.xml.NamespaceContext;
043 import org.deegree.framework.xml.XMLParsingException;
044 import org.deegree.framework.xml.XMLTools;
045 import org.deegree.ogcbase.CommonNamespaces;
046 import org.deegree.ogcwebservices.OGCWebServiceException;
047 import org.deegree.ogcwebservices.getcapabilities.GetCapabilities;
048 import org.w3c.dom.Document;
049
050 /**
051 * represents a sOs getCapabilities Request
052 *
053 * @author <a href="mailto:mkulbe@lat-lon.de">Matthias Kulbe </a>
054 * @author last edited by: $Author:wanhoff$
055 *
056 * @version $Revision: 18195 $, $Date:20.03.2007$
057 */
058 public class SOSGetCapabilities extends GetCapabilities {
059
060 private static final long serialVersionUID = 6229665412183042265L;
061
062 private static final NamespaceContext nsContext = CommonNamespaces.getNamespaceContext();
063
064 /**
065 * creates a GetCapabilities Request from a KVP Map
066 *
067 * @param map
068 * @return the new instance
069 */
070 public static SOSGetCapabilities create( Map<String, String> map ) {
071
072 String id = getParam( "ID", map, "" + System.currentTimeMillis() );
073
074 // optional
075 // String version = getParam( "VERSION", map, null );
076
077 // optional
078 String updateSequence = getParam( "UPDATESEQUENCE", map, null );
079
080 // optional and unbounded
081 String[] sections = null;
082 if ( map.get( "SECTIONS" ) != null ) {
083 String tmp = getParam( "SECTIONS", map, null );
084 sections = StringTools.toArray( tmp, ",", false );
085 }
086
087 // optional and unbounded
088 String[] acceptVersions = null;
089 if ( map.get( "ACCEPTVERSIONS" ) != null ) {
090 String tmp = getParam( "ACCEPTVERSIONS", map, null );
091 acceptVersions = StringTools.toArray( tmp, ",", false );
092 }
093
094 // optional and unbounded
095 String[] acceptFormats = null;
096 if ( map.get( "ACCEPTFORMATS" ) != null ) {
097 String tmp = getParam( "ACCEPTFORMATS", map, null );
098 acceptFormats = StringTools.toArray( tmp, ",", false );
099 }
100
101 return new SOSGetCapabilities( id, updateSequence, acceptVersions, sections, acceptFormats, map );
102
103 }
104
105 /**
106 * creates GetCapabilities Request from XML
107 *
108 * @param id
109 * @param doc
110 * @return the new instance
111 * @throws OGCWebServiceException
112 *
113 */
114 public static SOSGetCapabilities create( String id, Document doc )
115 throws OGCWebServiceException {
116
117 try {
118 // optional
119 // String version = XMLTools.getNodeAsString( doc, "ows:GetCapabilities/@version",
120 // nsContext,
121 // null );
122
123 // optional
124 String updateSequence = XMLTools.getNodeAsString( doc, "ows:GetCapabilities/@updateSequence", nsContext,
125 null );
126
127 // optional and unbounded
128 String[] sections = XMLTools.getNodesAsStrings( doc, "ows:GetCapabilities/ows:Sections/ows:Section/text()",
129 nsContext );
130
131 // optional and unbounded
132 String[] acceptVersions = XMLTools.getNodesAsStrings(
133 doc,
134 "ows:GetCapabilities/ows:AcceptVersions/ows:Version/text()",
135 nsContext );
136
137 // optional and unbounded
138 String[] acceptFormats = XMLTools.getNodesAsStrings(
139 doc,
140 "ows:GetCapabilities/ows:AcceptFormats/ows:OutputFormat/text()",
141 nsContext );
142
143 return new SOSGetCapabilities( id, updateSequence, acceptVersions, sections, acceptFormats,
144 new HashMap<String, String>() );
145
146 } catch ( XMLParsingException e ) {
147 e.printStackTrace();
148 throw new OGCWebServiceException( "sos webservice failure" );
149 }
150 }
151
152 /**
153 * creates GetCapabilities Request
154 *
155 * @param sections
156 * @param acceptFormats
157 * @param acceptVersions
158 * @param id
159 * @param updateSequence
160 * @param vendoreSpec
161 * @return the new instance
162 *
163 */
164 public static SOSGetCapabilities create( String id, String[] sections, String[] acceptFormats,
165 String[] acceptVersions, String updateSequence,
166 Map<String, String> vendoreSpec ) {
167 return new SOSGetCapabilities( id, updateSequence, acceptVersions, sections, acceptFormats, vendoreSpec );
168 }
169
170 /**
171 * @param id
172 * @param updateSequence
173 * @param acceptVersions
174 * @param sections
175 * @param acceptFormats
176 * @param vendoreSpec
177 */
178 public SOSGetCapabilities( String id, String updateSequence, String[] acceptVersions, String[] sections,
179 String[] acceptFormats, Map<String, String> vendoreSpec ) {
180 super( id, null, updateSequence, acceptVersions, sections, acceptFormats, vendoreSpec );
181 }
182
183 /**
184 * fixed 'SOS'
185 *
186 * @return the String "SOS"
187 */
188 public String getServiceName() {
189 return "SOS";
190 }
191 }