001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/wpvs/configuration/LocalWCSDataSource.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.wcs.WCService; 059 import org.deegree.ogcwebservices.wcs.configuration.InvalidConfigurationException; 060 import org.deegree.ogcwebservices.wcs.configuration.WCSConfiguration; 061 import org.deegree.ogcwebservices.wcs.getcoverage.GetCoverage; 062 import org.deegree.ogcwebservices.wpvs.capabilities.OWSCapabilities; 063 import org.xml.sax.SAXException; 064 065 /** 066 * This class represents a local WCS dataSource object. 067 * 068 * @author <a href="mailto:taddei@lat-lon.de">Ugo Taddei</a> 069 * @author last edited by: $Author: bezema $ 070 * 071 * $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $ 072 * 073 */ 074 public class LocalWCSDataSource extends AbstractDataSource { 075 076 // private static final ILogger LOG = LoggerFactory.getLogger( LocalWCSDataSource .class ); 077 078 private Color[] transparentColors; 079 080 private double configuredMinimalDGMResolution; 081 082 private static Map<URL,WCSConfiguration> cache = new ConcurrentHashMap<URL,WCSConfiguration>(); 083 084 // private static WCSConfiguration wcsConfig = null; 085 086 /** 087 * Creates a new <code>LocalWCSDataSource</code> object from the given parameters. 088 * 089 * @param name 090 * @param owsCapabilities 091 * @param validArea 092 * @param minScaleDenominator 093 * @param maxScaleDenominator 094 * @param filterCondition 095 * a base request //TODO give an example 096 * @param transparentColors 097 */ 098 public LocalWCSDataSource( QualifiedName name, OWSCapabilities owsCapabilities, 099 Surface validArea, double minScaleDenominator, 100 double maxScaleDenominator, GetCoverage filterCondition, 101 Color[] transparentColors ) { 102 103 super( LOCAL_WCS, name, owsCapabilities, validArea, minScaleDenominator, 104 maxScaleDenominator, filterCondition ); 105 this.transparentColors = transparentColors; 106 configuredMinimalDGMResolution = 0; 107 } 108 109 /** 110 * The <code>filterCondition</code> is a GetCoverage object which extends the WCSRequestBase. 111 * 112 * @return Returns the filterCondition as a GetCoverage object. 113 */ 114 public GetCoverage getCoverageFilterCondition() { 115 return (GetCoverage) getFilterCondition(); 116 } 117 118 /** 119 * @return Returns the transparentColors. 120 */ 121 public Color[] getTransparentColors() { 122 return transparentColors; 123 } 124 125 @Override 126 public String toString() { 127 128 StringBuffer sb = new StringBuffer( super.toString() ); 129 130 Color[] colors = getTransparentColors(); 131 for ( int i = 0; i < colors.length; i++ ) { 132 sb.append( "\n color : " ).append( colors[i] ); 133 } 134 135 GetCoverage filter = getCoverageFilterCondition(); 136 try { 137 sb.append( "\n filter : " ); 138 sb.append( "\n -version : " ); 139 sb.append( filter.getVersion() ); 140 sb.append( "\n -id : " ); 141 sb.append( filter.getId() ); 142 sb.append( "\n -serviceName : " ); 143 sb.append( filter.getServiceName() ); 144 sb.append( "\n -sourceCoverage: " ); 145 sb.append( filter.getSourceCoverage() ); 146 } catch ( Exception e ) { 147 e.printStackTrace(); 148 } 149 150 return sb.toString(); 151 } 152 153 /** 154 * @throws OGCWebServiceException 155 * @see org.deegree.ogcwebservices.wpvs.configuration.AbstractDataSource#getOGCWebService() 156 */ 157 @Override 158 public OGCWebService getOGCWebService() 159 throws OGCWebServiceException { 160 WCSConfiguration wcsConfig = null; 161 synchronized ( this ) { 162 URL url = getOwsCapabilities().getOnlineResource(); 163 wcsConfig = cache.get( url ); 164 if ( !cache.containsKey( url ) || wcsConfig == null ) { 165 166 URL caps = getOwsCapabilities().getOnlineResource(); 167 try { 168 wcsConfig = WCSConfiguration.create( caps ); 169 cache.put( url, wcsConfig ); 170 } catch ( InvalidCapabilitiesException e ) { 171 throw new OGCWebServiceException( 172 Messages.getMessage( 173 "WPVS_DATASOURCE_CAP_ERROR", 174 toString() ) 175 + e.getMessage() ); 176 } catch ( InvalidConfigurationException e ) { 177 throw new OGCWebServiceException( 178 Messages.getMessage( 179 "WPVS_DATASOURCE_CAP_ERROR", 180 toString() ) 181 + e.getMessage() ); 182 } catch ( IOException e ) { 183 throw new OGCWebServiceException( 184 Messages.getMessage( 185 "WPVS_DATASOURCE_CAP_ERROR", 186 toString() ) 187 + e.getMessage() ); 188 } catch ( SAXException e ) { 189 throw new OGCWebServiceException( 190 Messages.getMessage( 191 "WPVS_DATASOURCE_CAP_ERROR", 192 toString() ) 193 + e.getMessage() ); 194 } 195 } 196 } 197 return new WCService( wcsConfig ); 198 } 199 200 /** 201 * @return the configuredMinimalDGMResolution. 202 */ 203 public double getConfiguredMinimalDGMResolution() { 204 return configuredMinimalDGMResolution; 205 } 206 207 /** 208 * @param configuredMinimalDGMResolution 209 * An other configuredMinimalDGMResolution value. 210 */ 211 public void setConfiguredMinimalDGMResolution( double configuredMinimalDGMResolution ) { 212 this.configuredMinimalDGMResolution = configuredMinimalDGMResolution; 213 } 214 } 215 216 /*************************************************************************************************** 217 * <code> Changes to this class. What the people have been up to: $Log$ 218 * <code> Changes to this class. What the people have been up to: Revision 1.19 2007/03/06 15:48:07 bezema 219 * <code> 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 220 * <code> Changes to this class. What the people have been up to: 221 * <code> Changes to this class. What the people have been up to: Revision 1.18 2007/01/23 15:10:56 bezema 222 * <code> Changes to this class. What the people have been up to: added a single configuration/capabilities parsing of the datasources 223 * <code> Changes to this class. What the people have been up to: 224 * Revision 1.17 2007/01/15 17:02:13 bezema Updated the capabilities /configuration parsing, and the 225 * construction of their beans 226 * 227 * Revision 1.16 2006/11/27 11:32:27 bezema UPdating javadocs and cleaning up 228 * 229 * Revision 1.15 2006/11/23 11:46:40 bezema The initial version of the new wpvs 230 * 231 * Revision 1.14 2006/08/24 06:42:16 poth File header corrected 232 * 233 * Revision 1.13 2006/06/20 07:45:21 taddei datasources use quali names now 234 * 235 * Revision 1.12 2006/04/06 20:25:24 poth ** empty log message *** 236 * 237 * Revision 1.11 2006/03/30 21:20:25 poth ** empty log message *** 238 * 239 * Revision 1.10 2006/02/22 13:34:00 taddei refactoring: added service, createOGCWebService; also 240 * better except handling 241 * 242 * Revision 1.9 2006/01/30 14:55:07 taddei working getOGCWebService 243 * 244 * Revision 1.8 2006/01/18 08:48:27 taddei added getOGCWebService() 245 * 246 * Revision 1.7 2005/12/23 10:37:29 mays add toString and change object type of filterCondition 247 * 248 * Revision 1.6 2005/12/07 09:45:14 mays redesign of filterCondition request from String to Map form 249 * wcs and wms datasources 250 * 251 * Revision 1.5 2005/12/06 12:48:19 mays move param filterCondition from subclasses to 252 * AbstractDataSource 253 * 254 * Revision 1.4 2005/12/01 15:54:59 mays omitted serviceType in call of constructor, replacing it in 255 * super() by corresponding field 256 * 257 * Revision 1.3 2005/12/01 12:09:42 mays restructuring of data source classes according to xml 258 * schema 259 * 260 * Revision 1.2 2005/12/01 10:30:14 mays add standard footer to all java classes in wpvs package 261 * </code> 262 **************************************************************************************************/