001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wpvs/configuration/RemoteWFSDataSource.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.io.IOException; 047 import java.net.URL; 048 import java.util.Map; 049 import java.util.concurrent.ConcurrentHashMap; 050 051 import org.deegree.datatypes.QualifiedName; 052 import org.deegree.i18n.Messages; 053 import org.deegree.model.filterencoding.Filter; 054 import org.deegree.model.spatialschema.Surface; 055 import org.deegree.ogcbase.PropertyPath; 056 import org.deegree.ogcwebservices.OGCWebService; 057 import org.deegree.ogcwebservices.OGCWebServiceException; 058 import org.deegree.ogcwebservices.wfs.RemoteWFService; 059 import org.deegree.ogcwebservices.wfs.capabilities.WFSCapabilities; 060 import org.deegree.ogcwebservices.wfs.capabilities.WFSCapabilitiesDocument; 061 import org.deegree.ogcwebservices.wpvs.capabilities.OWSCapabilities; 062 import org.xml.sax.SAXException; 063 064 /** 065 * This class represents a remote WFS dataSource object. 066 * 067 * @author <a href="mailto:mays@lat-lon.de">Judit Mays</a> 068 * @author last edited by: $Author: bezema $ 069 * 070 * $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $ 071 * 072 */ 073 public class RemoteWFSDataSource extends LocalWFSDataSource { 074 075 // private static final ILogger LOG = LoggerFactory.getLogger( RemoteWFSDataSource.class ); 076 private static Map<URL, WFSCapabilities> cache = new ConcurrentHashMap<URL, WFSCapabilities>(); 077 078 /** 079 * Creates a new <code>RemoteWFSDataSource</code> object from the given parameters. 080 * 081 * @param name 082 * @param owsCapabilities 083 * @param validArea 084 * @param minScaleDenominator 085 * @param maxScaleDenominator 086 * @param geometryProperty 087 * @param filterCondition 088 */ 089 public RemoteWFSDataSource( QualifiedName name, OWSCapabilities owsCapabilities, 090 Surface validArea, double minScaleDenominator, 091 double maxScaleDenominator, PropertyPath geometryProperty, 092 Filter filterCondition/* , FeatureCollectionAdapter adapter */) { 093 094 super( name, owsCapabilities, validArea, minScaleDenominator, maxScaleDenominator, 095 geometryProperty, filterCondition/* , adapter */); 096 setServiceType( REMOTE_WFS ); 097 098 } 099 100 @Override 101 public OGCWebService getOGCWebService() 102 throws OGCWebServiceException { 103 WFSCapabilities wfsCapabilities = null; 104 synchronized ( this ) { 105 URL url = getOwsCapabilities().getOnlineResource(); 106 wfsCapabilities = cache.get( url ); 107 if ( !cache.containsKey( url ) || wfsCapabilities == null ) { 108 WFSCapabilitiesDocument wfsCapsDoc = new WFSCapabilitiesDocument(); 109 try { 110 wfsCapsDoc.load( url ); 111 wfsCapabilities = (WFSCapabilities) wfsCapsDoc.parseCapabilities(); 112 cache.put( url, wfsCapabilities ); 113 } catch ( IOException e ) { 114 throw new OGCWebServiceException( 115 Messages.getMessage( 116 "WPVS_DATASOURCE_CAP_ERROR", 117 toString() ) 118 + e.getMessage() ); 119 } catch ( SAXException e ) { 120 throw new OGCWebServiceException( 121 Messages.getMessage( 122 "WPVS_DATASOURCE_CAP_ERROR", 123 toString() ) 124 + e.getMessage() ); 125 } 126 } 127 128 } 129 return new RemoteWFService( wfsCapabilities ); 130 } 131 132 }