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