001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/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 17:22:25 +0100 (Do, 27 Dez 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, String[] acceptVersions, String[] sections, 082 String[] acceptFormats, Map<String, String> vendoreSpec ) { 083 this( id, WFService.VERSION, updateSeq, acceptVersions, sections, acceptFormats, vendoreSpec ); 084 } 085 086 /** 087 * Creates a new <code>WFSGetCapabilities</code> instance. 088 * 089 * @param id 090 * request identifier 091 * @param version 092 * the version of the request. (e.g 1.0.0 or 1.1.0) 093 * @param updateSeq 094 * @param acceptVersions 095 * @param sections 096 * @param acceptFormats 097 * @param vendoreSpec 098 */ 099 WFSGetCapabilities( String id, String version, String updateSeq, String[] acceptVersions, String[] sections, 100 String[] acceptFormats, Map<String, String> vendoreSpec ) { 101 super( id, version, updateSeq, acceptVersions, sections, acceptFormats, vendoreSpec ); 102 } 103 104 /** 105 * Creates a <code>WFSGetCapabilities</code> instance from a document that contains the DOM representation of the 106 * request. 107 * 108 * @param id 109 * @param root 110 * element that contains the DOM representation of the request 111 * @return transaction instance 112 * @throws OGCWebServiceException 113 */ 114 public static WFSGetCapabilities create( String id, Element root ) 115 throws OGCWebServiceException { 116 WFSGetCapabilitiesDocument doc = new WFSGetCapabilitiesDocument(); 117 doc.setRootElement( root ); 118 WFSGetCapabilities request; 119 try { 120 request = doc.parse( id ); 121 } catch ( Exception e ) { 122 throw new OGCWebServiceException( "WFSGetCapabilities", e.getMessage() ); 123 } 124 return request; 125 } 126 127 /** 128 * Creates a new <code>WFSGetCapabilities</code> instance from the given key-value pair encoded request. 129 * 130 * @param id 131 * request identifier 132 * @param request 133 * @return new <code>WFSGetCapabilities</code> request 134 * @throws InvalidParameterValueException 135 * @throws MissingParameterValueException 136 */ 137 public static WFSGetCapabilities create( String id, String request ) 138 throws InvalidParameterValueException, 139 MissingParameterValueException { 140 Map<String, String> map = KVP2Map.toMap( request ); 141 map.put( "ID", id ); 142 return create( map ); 143 } 144 145 /** 146 * Creates a new <code>WFSGetCapabilities</code> request from the given map. 147 * 148 * @param request 149 * @return new <code>WFSGetCapabilities</code> request 150 * @throws InvalidParameterValueException 151 * @throws MissingParameterValueException 152 */ 153 public static WFSGetCapabilities create( Map<String, String> request ) 154 throws InvalidParameterValueException, 155 MissingParameterValueException { 156 157 String service = getRequiredParam( "SERVICE", request ); 158 if ( !service.equals( "WFS" ) ) { 159 throw new InvalidParameterValueException( "WFSGetCapabilities", "Parameter 'service' must be 'WFS'." ); 160 } 161 String version = request.get( "VERSION" ); 162 String[] acceptVersions = getParamValues( "ACCEPTVERSIONS", request, WFService.VERSION ); 163 String[] sections = getParamValues( "SECTIONS", request, "" ); 164 String updateSequence = getParam( "UPDATESEQUENCE", request, "" ); 165 String[] acceptFormats = getParamValues( "ACCEPTFORMATS", request, "text/xml" ); 166 167 // TODO generate unique request id 168 String id = null; 169 if ( version == null || "".equals( version.trim() ) ) { 170 return new WFSGetCapabilities( id, updateSequence, acceptVersions, sections, acceptFormats, request ); 171 } 172 return new WFSGetCapabilities( id, version, updateSequence, acceptVersions, sections, acceptFormats, request ); 173 } 174 175 /** 176 * Returns the service name (WFS). 177 * 178 * @return the service name (WFS). 179 */ 180 public String getServiceName() { 181 return "WFS"; 182 } 183 }