001 //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/portal/standard/csw/configuration/CSWClientConfiguration.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.portal.standard.csw.configuration;
038
039 import java.net.URL;
040 import java.util.ArrayList;
041 import java.util.Arrays;
042 import java.util.HashMap;
043 import java.util.Iterator;
044 import java.util.List;
045 import java.util.Map;
046 import java.util.Set;
047
048 import org.deegree.framework.util.StringTools;
049 import org.deegree.i18n.Messages;
050 import org.deegree.model.spatialschema.Envelope;
051
052 /**
053 * This class stores the parameters defined in the WMC, so that the csw module can use them
054 *
055 * @author <a href="mailto:mays@lat-lon.de">Judit Mays</a>
056 * @author last edited by: $Author: mschneider $
057 *
058 * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
059 */
060 public class CSWClientConfiguration {
061
062 private int maxRecords = 10;
063
064 /**
065 * key<String> = catalog name; value<String> = catalog address
066 */
067 private Map<String, String> catalogToUrlMap;
068
069 /**
070 * key<String> = catalog name; value<List<String>> = list of supported protocols ( e.g. POST, SOAP )
071 */
072 private Map<String, List<String>> catalogToProtocolMap;
073
074 /**
075 * key<String> = catalog name; value<List<String>> = list of supported formats ( e.g. ISO19115, ISO19119, OGCCORE )
076 */
077 private Map<String, List<String>> catalogToFormatMap;
078
079 /**
080 * key<String> = profile name ( e.g. Profile.ISO19115, Profile.OGCCORE, etc. ); value<HashMap<String,String>> =
081 * key: e.g. brief, summary, full; value: e.g. metaList2html.xsl
082 */
083 private Map<String, HashMap<String, String>> profilesToXsl;
084
085 private String srs = null;
086
087 private String xPathToDataIdentifier = null;
088
089 private String xPathToDataTitle = null;
090
091 private String xPathToServiceIdentifier = null;
092
093 private String xPathToServiceTitle = null;
094
095 private String xPathToServiceOperatesOnTitle = null;
096
097 private String xPathToServiceAddress = null;
098
099 private String xPathToServiceType = null;
100
101 private String xPathToServiceTypeVersion = null;
102
103 // is needed for shopping cart, but shopping cart is currently disabled.
104 private String mapContextTemplatePath = null;
105
106 /*
107 * ignorig for now private HashMap thesauri = null; private Download download = null; private CCatalog[] ccatalog =
108 * null; private int maxInactiveInterval = 0; private String[] filterIDs = null; private int queryScope = 0; private
109 * GM_Envelope rootBoundingBox = null; private WMSClientConfiguration wmsCConfig = null; // seems to be not needed
110 */
111
112 /**
113 *
114 */
115 public CSWClientConfiguration() {
116 catalogToUrlMap = new HashMap<String, String>( 5 );
117 profilesToXsl = new HashMap<String, HashMap<String, String>>( 5 );
118 catalogToProtocolMap = new HashMap<String, List<String>>( 5 );
119 catalogToFormatMap = new HashMap<String, List<String>>( 5 );
120 }
121
122 /**
123 * @return Returns the names of all served catalogs
124 */
125 public String[] getCatalogNames() {
126 Set<String> keySet = catalogToUrlMap.keySet();
127 return keySet.toArray( new String[keySet.size()] );
128 }
129
130 /**
131 * @return Returns the addresses of all served catalogs
132 */
133 public String[] getCatalogServerAddresses() {
134 String[] addresses = new String[catalogToUrlMap.size()];
135 Iterator it = catalogToUrlMap.values().iterator();
136 for ( int i = 0; i < addresses.length && it.hasNext(); i++ ) {
137 addresses[i] = (String) it.next();
138 }
139 return addresses;
140 }
141
142 /**
143 * @param catalogName
144 * @return Returns the address of the submitted catalog, or <tt>null</tt> if the map contains no mapping for this
145 * key.
146 */
147 public String getCatalogServerAddress( String catalogName ) {
148 return catalogToUrlMap.get( catalogName );
149 }
150
151 /**
152 * @return Returns the catalogToFormatMap.
153 */
154 public Map getCatalogToFormatMap() {
155 return catalogToFormatMap;
156 }
157
158 /**
159 * @param catalogName
160 * The name of the catalog
161 * @return Returns the format types of a given catalog, e.g. "ISO19115" or "ISO19119". May be null, if the passed
162 * catalogName is unknown.
163 */
164 public List getCatalogFormats( String catalogName ) {
165 return catalogToFormatMap.get( catalogName );
166 }
167
168 /**
169 * @return Returns the catalogToProtocolMap.
170 */
171 public Map getCatalogToProtocolMap() {
172 return catalogToProtocolMap;
173 }
174
175 /**
176 * @param catalogName
177 * The name of the catalog
178 * @return Returns the protocol type of a given catalog, e.g. "POST" or "SOAP". May be null, if the passed
179 * catalogName is unknown.
180 */
181 public List getCatalogProtocols( String catalogName ) {
182 return catalogToProtocolMap.get( catalogName );
183 }
184
185 /**
186 * @return Returns the catalogToUrlMap.
187 */
188 public Map getCatalogToUrlMap() {
189 return catalogToUrlMap;
190 }
191
192 /**
193 *
194 * @return Returns a List of the service metadata catalogues.
195 */
196 public List<String> getServiceMetadataCatalogs() {
197 List<String> serviceCatalogs = new ArrayList<String>( 10 );
198
199 Iterator it = catalogToFormatMap.keySet().iterator();
200 while ( it.hasNext() ) {
201 String catalog = (String) it.next();
202 List formats = getCatalogFormats( catalog );
203 String smf = ServiceMetadataFormats.getString( "CSWClientConfiguration.serviceMetadata" );
204 String[] s = StringTools.toArray( smf, ",", true );
205 List<String> list = new ArrayList<String>( Arrays.asList( s ) );
206 for ( int i = 0; i < formats.size(); i++ ) {
207 if ( list.contains( formats.get( i ) ) ) {
208 serviceCatalogs.add( catalog );
209 break;
210 }
211 }
212 }
213
214 return serviceCatalogs;
215 }
216
217 /**
218 * @return Returns an array of IDs that marks UDK objects that are valid for the catalog
219 */
220 public String[] getFilterIDs() {
221 throw new UnsupportedOperationException( Messages.getMessage( "IGEO_STD_CSW_UNSUPPORTED_METHOD",
222 "getFilterIDs()" ) );
223 }
224
225 /**
226 * @param catalogField
227 * @return Returns the catalog (iso-) elements that shall be targeted by a html form element
228 */
229 public String[] getFormElements( String catalogField ) {
230 throw new UnsupportedOperationException( Messages.getMessage( "IGEO_STD_CSW_UNSUPPORTED_METHOD",
231 "getFormElements()" ) );
232 }
233
234 /**
235 * Method is needed for shopping cart, but shopping cart is currently disabled
236 * TODO when shopping cart is enabled again, please adjust javadoc!
237 *
238 * @return Returns the mapContextTemplatePath.
239 */
240 public String getMapContextTemplatePath() {
241 return mapContextTemplatePath;
242 }
243
244 /**
245 * @return Returns the maximum number records requested in a GetRecord request.
246 */
247 public int getMaxRecords() {
248 return maxRecords;
249 }
250
251 /**
252 * @return Returns the maximun time a session will be alive after the last change in seconds
253 */
254 public int getMaxSessionLifeTime() {
255 return 3600;// maxInactiveInterval;
256 }
257
258 /**
259 * @return Returns the profilesToXsl.
260 */
261 public Map getProfilesToXsl() {
262 return profilesToXsl;
263 }
264
265 /**
266 * @param profileName
267 * @return Returns the profiles to xsl for the passed profile or <tt>null</tt> if the profile map contains no
268 * mapping for this key.
269 */
270 public HashMap getProfileXSL( String profileName ) {
271 return this.profilesToXsl.get( profileName );
272 }
273
274 /**
275 * @return Returns the names of possible protocol types
276 */
277 public String[] getProtocolNames() {
278 Set<String> keySet = catalogToProtocolMap.keySet();
279 return keySet.toArray( new String[keySet.size()] );
280 }
281
282 /**
283 * @return Returns the maximum number (iterations) to cascaded catalogs that shall be performed.
284 */
285 public int getQueryScope() {
286 return 9999;// queryScope;
287 }
288
289 /**
290 * @return Returns the bounding box of the maximum area that shall be searched for (meta)data. This parameter will
291 * be extracted from the searchmap parameter
292 */
293 public Envelope getRootBoundingBox() {
294 throw new UnsupportedOperationException( Messages.getMessage( "IGEO_STD_CSW_UNSUPPORTED_METHOD",
295 "getRootBoundingBox()" ) );
296 // return rootBoundingBox;
297 }
298
299 /**
300 * @return Returns the srs.
301 */
302 public String getSrs() {
303 return srs;
304 }
305
306 /**
307 * @param thesaurus
308 * @return Returns the address of the submitted thesaurus
309 */
310 public URL getThesaurusAddress( String thesaurus ) {
311 throw new UnsupportedOperationException( Messages.getMessage( "IGEO_STD_CSW_UNSUPPORTED_METHOD",
312 "getThesaurusAddress()" ) );
313 // return (URL)thesauri.get( thesaurus );
314 }
315
316 /**
317 * @return Returns the names of the thesauri known by the client
318 */
319 public String[] getThesaurusNames() {
320 throw new UnsupportedOperationException( Messages.getMessage( "IGEO_STD_CSW_UNSUPPORTED_METHOD",
321 "getThesaurusNames()" ) );
322 // String[] tn = new String[thesauri.size()];
323 // return (String[])thesauri.keySet().toArray( tn );
324 }
325
326 /**
327 * @return Returns the xPathToDataIdentifier.
328 */
329 public String getXPathToDataIdentifier() {
330 return xPathToDataIdentifier;
331 }
332
333 /**
334 * @return Returns the xPathToDataTitle.
335 */
336 public String getXPathToDataTitle() {
337 return xPathToDataTitle;
338 }
339
340 /**
341 * @return Returns the xPathToServiceAddress.
342 */
343 public String getXPathToServiceAddress() {
344 return xPathToServiceAddress;
345 }
346
347 /**
348 * @return Returns the xPathToServiceIdentifier.
349 */
350 public String getXPathToServiceIdentifier() {
351 return xPathToServiceIdentifier;
352 }
353
354 /**
355 * @return Returns the xPathToServiceOperatesOnTitle.
356 */
357 public String getXPathToServiceOperatesOnTitle() {
358 return xPathToServiceOperatesOnTitle;
359 }
360
361 /**
362 * @return Returns the xPathToServiceTitle.
363 */
364 public String getXPathToServiceTitle() {
365 return xPathToServiceTitle;
366 }
367
368 /**
369 * @return Returns the xPathToServiceType.
370 */
371 public String getXPathToServiceType() {
372 return xPathToServiceType;
373 }
374
375 /**
376 * @return Returns the xPathToServiceTypeVersion.
377 */
378 public String getXPathToServiceTypeVersion() {
379 return xPathToServiceTypeVersion;
380 }
381
382 // ###########################################################
383
384 /**
385 * method is needed for shopping cart, but shopping cart is currently disabled
386 * TODO when shopping cart is enabled again, please adjust javadoc!
387 *
388 * @param mapContextTemplatePath
389 * The mapContextTemplatePath to set.
390 */
391 public void setMapContextTemplatePath( String mapContextTemplatePath ) {
392 this.mapContextTemplatePath = mapContextTemplatePath;
393 }
394
395 /**
396 * @param maxRecords
397 */
398 public void setMaxRecords( int maxRecords ) {
399 this.maxRecords = maxRecords;
400 }
401
402 /**
403 * @param srs
404 * The srs to set.
405 */
406 public void setSrs( String srs ) {
407 this.srs = srs;
408 }
409
410 /**
411 * @param pathToIdentifier
412 * The xPath to the FileIdentifier to set.
413 */
414 public void setXPathToDataIdentifier( String pathToIdentifier ) {
415 this.xPathToDataIdentifier = pathToIdentifier;
416 }
417
418 /**
419 * @param pathToDataTitle
420 * The xPathToDataTitle to set.
421 */
422 public void setXPathToDataTitle( String pathToDataTitle ) {
423 xPathToDataTitle = pathToDataTitle;
424 }
425
426 /**
427 * @param pathToServiceAddress
428 * The xPathToServiceAddress to set.
429 */
430 public void setXPathToServiceAddress( String pathToServiceAddress ) {
431 xPathToServiceAddress = pathToServiceAddress;
432 }
433
434 /**
435 * @param pathToServiceIdentifier
436 * The xPathToServiceIdentifier to set.
437 */
438 public void setXPathToServiceIdentifier( String pathToServiceIdentifier ) {
439 xPathToServiceIdentifier = pathToServiceIdentifier;
440 }
441
442 /**
443 * @param pathToServiceOperatesOnTitle
444 * The xPathToServiceOperatesOnTitle to set.
445 */
446 public void setXPathToServiceOperatesOnTitle( String pathToServiceOperatesOnTitle ) {
447 xPathToServiceOperatesOnTitle = pathToServiceOperatesOnTitle;
448 }
449
450 /**
451 * @param pathToServiceTitle
452 * The xPathToServiceTitle to set.
453 */
454 public void setXPathToServiceTitle( String pathToServiceTitle ) {
455 xPathToServiceTitle = pathToServiceTitle;
456 }
457
458 /**
459 * @param pathToServiceType
460 * The xPathToServiceType to set.
461 */
462 public void setXPathToServiceType( String pathToServiceType ) {
463 xPathToServiceType = pathToServiceType;
464 }
465
466 /**
467 * @param pathToServiceTypeVersion
468 * The xPathToServiceTypeVersion to set.
469 */
470 public void setXPathToServiceTypeVersion( String pathToServiceTypeVersion ) {
471 xPathToServiceTypeVersion = pathToServiceTypeVersion;
472 }
473
474 // ###########################################################
475
476 /**
477 * @param catalogueName
478 * @param formatList
479 */
480 public void addCatalogueFormat( String catalogueName, List<String> formatList ) {
481 this.catalogToFormatMap.put( catalogueName, formatList );
482 }
483
484 /**
485 * @param catalogueName
486 * @param protocolList
487 */
488 public void addCatalogueProtocol( String catalogueName, List<String> protocolList ) {
489 this.catalogToProtocolMap.put( catalogueName, protocolList );
490 }
491
492 /**
493 * @param catalogueName
494 * @param catURL
495 */
496 public void addCatalogueURL( String catalogueName, String catURL ) {
497 this.catalogToUrlMap.put( catalogueName, catURL );
498 }
499
500 /**
501 * @param profileName
502 * The name of the profile (ie: Profiles.ISO19115, Profiles.ISO19119, Profiles.OGCCORE)
503 * @param elementSetKeyToXSL
504 * HashMap containing the elementset name as key and the xsl file name as value.
505 */
506 public void addProfileXSL( String profileName, HashMap<String, String> elementSetKeyToXSL ) {
507 this.profilesToXsl.put( profileName, elementSetKeyToXSL );
508 }
509 }