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