001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/csw/capabilities/CatalogueGetCapabilities.java $
002 /*---------------- FILE HEADER ------------------------------------------
003
004 This file is part of deegree.
005 Copyright (C) 2001-2006 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 Aennchenstr. 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 ---------------------------------------------------------------------------*/
044 package org.deegree.ogcwebservices.csw.capabilities;
045
046 import java.util.Map;
047
048 import org.deegree.framework.util.StringTools;
049 import org.deegree.ogcbase.ExceptionCode;
050 import org.deegree.ogcwebservices.OGCWebServiceException;
051 import org.deegree.ogcwebservices.getcapabilities.GetCapabilities;
052 import org.w3c.dom.Element;
053
054 /**
055 * Class representation of an <code>OGC-GetCapabilities</code> request in <code>CSW</code>
056 * flavour.
057 * <p>
058 * Special to the <code>CSW</code> version of the <code>GetCapabilities</code> request are these
059 * two additional parameters: <table border="1">
060 * <tr>
061 * <th>Name</th>
062 * <th>Occurences</th>
063 * <th>Function</th>
064 * </tr>
065 * <tr>
066 * <td>AcceptVersions</td>
067 * <td align="center">0|1</td>
068 * <td>Protocol versions supported by this service.</td>
069 * </tr>
070 * <tr>
071 * <td>AcceptFormats</td>
072 * <td align="center">0|1</td>
073 * <td>Formats accepted by this service.</td>
074 * </tr>
075 * </table>
076 *
077 * @since 2.0
078 * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </a>
079 * @version $Revision: 6518 $
080 */
081 public class CatalogueGetCapabilities extends GetCapabilities {
082
083 private static final long serialVersionUID = 7690283041658363481L;
084
085 /**
086 * Creates a new <code>CatalogueGetCapabilities</code> instance.
087 *
088 * @param id request identifier
089 * @param updateSequence
090 * @param version
091 * @param acceptVersions
092 * @param acceptFormats
093 * @param sections
094 * @param vendoreSpec
095 */
096 CatalogueGetCapabilities( String id, String updateSequence, String version,
097 String[] acceptVersions, String[] acceptFormats,
098 String[] sections, Map<String,String> vendoreSpec ) {
099 super( id, version, updateSequence, acceptVersions, sections, acceptFormats,
100 vendoreSpec );
101 }
102
103 /**
104 * Creates a <code>CatalogGetCapabilities</code> request from its KVP representation.
105 *
106 * @param kvp
107 * Map containing the key-value pairs
108 * @return created <code>CatalogGetCapabilities</code> object
109 */
110 public static CatalogueGetCapabilities create( Map<String,String> kvp ) {
111
112 String id = getParam( "ID", kvp, null );
113 String version = getParam( "VERSION", kvp, "2.0.0" );
114 String updateSequence = getParam( "UPDATESEQUENCE", kvp, null );
115 String[] acceptVersions = null;
116 if ( kvp.get( "ACCEPTVERSION" ) != null ) {
117 String tmp = getParam( "ACCEPTVERSION", kvp, null );
118 acceptVersions = StringTools.toArray( tmp, ",", false );
119 }
120 String[] acceptFormats = null;
121 if ( kvp.get( "OUTPUTFORMAT" ) != null ) {
122 String tmp = getParam( "OUTPUTFORMAT", kvp, null );
123 acceptFormats = StringTools.toArray( tmp, ",", false );
124 }
125 String[] sections = null;
126 if ( kvp.get( "SECTIONS" ) != null ) {
127 String tmp = getParam( "SECTIONS", kvp, null );
128 sections = StringTools.toArray( tmp, ",", false );
129 }
130 CatalogueGetCapabilities capa =
131 new CatalogueGetCapabilities( id, updateSequence, version, acceptVersions,
132 acceptFormats, sections, kvp );
133
134 return capa;
135 }
136
137 /**
138 * Creates a <code>CatalogGetCapabilities</code> request from its XML representation.
139 *
140 * @param id
141 * unique ID of the request
142 * @param root
143 * XML representation of the request
144 * @return created <code>CatalogGetCapabilities</code> object
145 * @throws OGCWebServiceException
146 * thrown if something in the request is wrong
147 */
148 public static CatalogueGetCapabilities create( String id, Element root )
149 throws OGCWebServiceException {
150
151 CatalogueGetCapabilitiesDocument doc = new CatalogueGetCapabilitiesDocument();
152 doc.setRootElement( root );
153 CatalogueGetCapabilities request;
154 try {
155 request = doc.parse(id);
156 } catch ( Exception e ) {
157 ExceptionCode code = ExceptionCode.INVALID_FORMAT;
158 throw new OGCWebServiceException( "CatalogGetCapabilities", StringTools
159 .stackTraceToString( e ), code );
160 }
161 return request;
162 }
163
164 /**
165 * returns WCS as service name
166 */
167 public String getServiceName() {
168 return "CSW";
169 }
170 }