001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/ogcwebservices/csw/AbstractCSWRequest.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 Aennchenstr. 19
030 53115 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 package org.deegree.ogcwebservices.csw;
044
045 import java.net.URI;
046 import java.net.URISyntaxException;
047 import java.util.HashMap;
048 import java.util.Map;
049
050 import org.deegree.framework.util.StringTools;
051 import org.deegree.ogcwebservices.AbstractOGCWebServiceRequest;
052 import org.deegree.ogcwebservices.InvalidParameterValueException;
053
054 /**
055 * Abstract base class for requests to catalogue services (CSW).
056 *
057 * @author <a href="mailto:poth@lat-lon.de">Andreas Poth </a>
058 * @author <a href="mailto:schneider@lat-lon.de">Markus Schneider </a>
059 *
060 * @author last edited by: $Author: bezema $
061 *
062 * @version 2.0, $Revision: 6259 $, $Date: 2007-03-20 10:15:15 +0100 (Di, 20 Mär 2007) $
063 *
064 * @since 2.0
065 */
066 public class AbstractCSWRequest extends AbstractOGCWebServiceRequest {
067
068 private static final long serialVersionUID = 726077635012162899L;
069
070 /**
071 * @param version
072 * @param id
073 * @param vendorSpecificParameter
074 */
075 public AbstractCSWRequest(String version, String id, Map<String, String> vendorSpecificParameter) {
076 super( version, id, vendorSpecificParameter );
077 }
078
079 /**
080 * returns 'CSW' as service name
081 */
082 public String getServiceName() {
083 return "CSW";
084 }
085
086 /**
087 * Extracts the namespace-mappings from the given parameter as specified for the
088 * NAMESPACE-parameter in the KVP-encoding.
089 * <p>
090 * Please note that the expected syntax of the CSW NAMESPACE parameter differs from
091 * the NAMESPACE parameter used in the WFS specification.
092 *
093 * @param nsString
094 * contains a list of [prefix:]uri-entries, the entries of the list are separated by
095 * the ','-character
096 * @return keys are Strings (prefixes), values are URIs
097 * @throws InvalidParameterValueException
098 */
099 protected static Map<String, URI> getNSMappings( String nsString )
100 throws InvalidParameterValueException {
101 Map<String, URI> map = new HashMap<String, URI>();
102 if ( nsString != null ) {
103 String[] mappings = StringTools.toArray( nsString, ",", false );
104 for (int i = 0; i < mappings.length; i++) {
105 int idx = mappings[i].indexOf( ":" );
106 String prefix = "";
107 String value = null;
108 if ( idx == -1 ) {
109 value = mappings[i];
110 } else {
111 prefix = mappings[i].substring( 0, idx );
112 if ( idx == mappings[i].length() - 1 ) {
113 throw new InvalidParameterValueException( "Value '"
114 + nsString + "' for parameter NAMESPACE is invalid: Prefix "
115 + prefix + " is mapped to an empty namespace." );
116 }
117 value = mappings[i].substring( idx + 1, mappings[i].length() );
118 }
119 URI uri = null;
120 try {
121 uri = new URI( value );
122 } catch (URISyntaxException e) {
123 throw new InvalidParameterValueException( "Value '"
124 + nsString + "' for parameter NAMESPACE is invalid: Prefix "
125 + prefix + " is not mapped to a valid URI." );
126 }
127 map.put( prefix, uri );
128 }
129 }
130 return map;
131 }
132 }
133
134 /* ********************************************************************
135 Changes to this class. What the people have been up to:
136 $Log$
137 Revision 1.3 2007/03/19 13:30:42 bezema
138 added generics to the map
139
140 Revision 1.2 2006/07/06 10:49:00 mschneider
141 Moved getNSMappings() from AbstractOGCWebServiceRequest.
142
143 Revision 1.1 2006/06/19 19:24:35 mschneider
144 Renamed CSWRequestBase to AbstractCSWRequest.
145
146 Revision 1.4 2006/04/06 20:25:30 poth
147 *** empty log message ***
148
149 Revision 1.3 2006/03/30 21:20:28 poth
150 *** empty log message ***
151
152 Revision 1.2 2005/04/06 12:02:08 poth
153 no message
154
155 Revision 1.1 2005/02/21 11:24:33 poth
156 no message
157
158
159 ********************************************************************** */