001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wpvs/configuration/RemoteWMSDataSource.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 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
044 package org.deegree.ogcwebservices.wpvs.configuration;
045
046 import java.awt.Color;
047 import java.io.IOException;
048 import java.net.URL;
049 import java.util.Map;
050 import java.util.concurrent.ConcurrentHashMap;
051
052 import org.deegree.datatypes.QualifiedName;
053 import org.deegree.i18n.Messages;
054 import org.deegree.model.spatialschema.Surface;
055 import org.deegree.ogcwebservices.OGCWebService;
056 import org.deegree.ogcwebservices.OGCWebServiceException;
057 import org.deegree.ogcwebservices.getcapabilities.InvalidCapabilitiesException;
058 import org.deegree.ogcwebservices.wms.RemoteWMService;
059 import org.deegree.ogcwebservices.wms.capabilities.WMSCapabilities;
060 import org.deegree.ogcwebservices.wms.capabilities.WMSCapabilitiesDocument;
061 import org.deegree.ogcwebservices.wms.operation.GetMap;
062 import org.deegree.ogcwebservices.wpvs.capabilities.OWSCapabilities;
063 import org.xml.sax.SAXException;
064
065 /**
066 * This class represents a remote WPVS dataSource object.
067 *
068 * @author <a href="mailto:mays@lat-lon.de">Judit Mays</a>
069 * @author last edited by: $Author: bezema $
070 *
071 * @version $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $
072 */
073 public class RemoteWMSDataSource extends LocalWMSDataSource {
074
075 private static Map<URL,WMSCapabilities> cache = new ConcurrentHashMap<URL,WMSCapabilities>();
076
077 /**
078 * Creates a new <code>RemoteWMSDataSource</code> object from the given parameters.
079 *
080 * @param name
081 * @param owsCapabilities
082 * @param validArea
083 * @param minScaleDenominator
084 * @param maxScaleDenominator
085 * @param filterCondition
086 * @param transparentColors
087 */
088 public RemoteWMSDataSource( QualifiedName name, OWSCapabilities owsCapabilities,
089 Surface validArea, double minScaleDenominator,
090 double maxScaleDenominator, GetMap filterCondition,
091 Color[] transparentColors ) {
092
093 super( name, owsCapabilities, validArea, minScaleDenominator, maxScaleDenominator,
094 filterCondition, transparentColors );
095 this.setServiceType( AbstractDataSource.REMOTE_WMS );
096
097 }
098
099 /**
100 * The <code>filterCondition</code> is a map of key-value-pairs of an incomplete WMSRequest.
101 *
102 * @return Returns the filterCondition as a map of key-value-pairs.
103 */
104 public Map getFilterConditionMap() {
105 return (Map) getFilterCondition();
106 }
107
108 /**
109 * @throws OGCWebServiceException
110 * @see org.deegree.ogcwebservices.wpvs.configuration.AbstractDataSource#getOGCWebService()
111 */
112 @Override
113 public OGCWebService getOGCWebService()
114 throws OGCWebServiceException {
115 WMSCapabilities wmsCapabilities = null;
116 synchronized ( this ) {
117
118 URL url = getOwsCapabilities().getOnlineResource();
119 wmsCapabilities = cache.get( url );
120 if ( !cache.containsKey( url ) || wmsCapabilities == null ) {
121 WMSCapabilitiesDocument wmsCapsDoc = new WMSCapabilitiesDocument();
122 try {
123 wmsCapsDoc.load( url );
124 wmsCapabilities = (WMSCapabilities) wmsCapsDoc.parseCapabilities();
125 cache.put( url, wmsCapabilities );
126 } catch ( IOException e ) {
127 throw new OGCWebServiceException(
128 Messages.getMessage(
129 "WPVS_DATASOURCE_CAP_ERROR",
130 toString() )
131 + e.getMessage() );
132 } catch ( SAXException e ) {
133 throw new OGCWebServiceException(
134 Messages.getMessage(
135 "WPVS_DATASOURCE_CAP_ERROR",
136 toString() )
137 + e.getMessage() );
138 } catch ( InvalidCapabilitiesException e ) {
139 throw new OGCWebServiceException(
140 Messages.getMessage(
141 "WPVS_DATASOURCE_CAP_ERROR",
142 toString() )
143 + e.getMessage() );
144 }
145 }
146
147 }
148
149 return new RemoteWMService( wmsCapabilities );
150 }
151 }
152
153 /***************************************************************************************************
154 * Changes to this class. What the people have been up to: $Log$
155 * Changes to this class. What the people have been up to: Revision 1.20 2007/03/06 15:48:07 bezema
156 * Changes to this class. What the people have been up to: changed the caching mechanism's of the Datasources. Also set the kkv option of the cvs repos
157 * Changes to this class. What the people have been up to:
158 * Changes to this class. What the people have been up to: Revision 1.19 2007/03/06 14:56:55 poth
159 * Changes to this class. What the people have been up to: bug fix wpvs accessing a dataservices caps
160 * Changes to this class. What the people have been up to:
161 * Changes to this class. What the people have been up to: Revision 1.18 2007/01/23 15:10:56 bezema
162 * Changes to this class. What the people have been up to: added a single configuration/capabilities parsing of the datasources
163 * Changes to this class. What the people have been up to: Revision 1.17 2006/11/27 11:33:33
164 * bezema UPdating javadocs and cleaning up
165 *
166 * Revision 1.16 2006/11/23 11:46:40 bezema The initial version of the new wpvs
167 *
168 * Revision 1.15 2006/08/29 19:54:14 poth footer corrected
169 *
170 * Revision 1.14 2006/08/24 06:42:16 poth File header corrected
171 *
172 * Revision 1.13 2006/06/20 07:45:21 taddei datasources use quali names now
173 *
174 * Revision 1.12 2006/04/06 20:25:24 poth ** empty log message ***
175 *
176 * Revision 1.11 2006/03/30 21:20:25 poth ** empty log message ***
177 *
178 * Revision 1.10 2006/02/22 13:34:00 taddei refactoring: added service, createOGCWebService; also
179 * better except handling
180 *
181 * Revision 1.9 2006/02/14 15:14:15 taddei printStackTrace
182 *
183 * Revision 1.8 2006/02/10 16:06:05 taddei chnages to accomodate remote WMS
184 *
185 * Revision 1.7 2006/01/18 08:48:27 taddei added getOGCWebService()
186 *
187 * Revision 1.6 2005/12/23 10:37:49 mays change object type of filterCondition
188 *
189 * Revision 1.5 2005/12/07 09:45:14 mays redesign of filterCondition request from String to Map form
190 * wcs and wms datasources
191 *
192 * Revision 1.4 2005/12/06 12:48:19 mays move param filterCondition from subclasses to
193 * AbstractDataSource
194 *
195 * Revision 1.3 2005/12/05 09:42:07 mays revision of comments
196 *
197 * Revision 1.2 2005/12/01 15:54:59 mays omitted serviceType in call of constructor, replacing it in
198 * super() by corresponding field
199 *
200 * Revision 1.1 2005/12/01 12:08:47 mays first implementation of new remote data source classes
201 *
202 **************************************************************************************************/