001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/src/org/deegree/ogcwebservices/wass/wss/capabilities/WSSCapabilitiesDocument.java $
002 /*---------------- FILE HEADER ------------------------------------------
003
004 This file is part of deegree.
005 Copyright (C) 2001-2008 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 ---------------------------------------------------------------------------*/
044
045 package org.deegree.ogcwebservices.wass.wss.capabilities;
046
047 import java.io.IOException;
048 import java.net.MalformedURLException;
049 import java.net.URISyntaxException;
050 import java.util.ArrayList;
051
052 import org.deegree.framework.log.ILogger;
053 import org.deegree.framework.log.LoggerFactory;
054 import org.deegree.framework.xml.XMLParsingException;
055 import org.deegree.framework.xml.XMLTools;
056 import org.deegree.i18n.Messages;
057 import org.deegree.ogcbase.CommonNamespaces;
058 import org.deegree.ogcwebservices.getcapabilities.InvalidCapabilitiesException;
059 import org.deegree.ogcwebservices.getcapabilities.OGCCapabilities;
060 import org.deegree.ogcwebservices.getcapabilities.ServiceIdentification;
061 import org.deegree.ogcwebservices.getcapabilities.ServiceProvider;
062 import org.deegree.ogcwebservices.wass.common.OWSCapabilitiesBaseDocument_1_0;
063 import org.deegree.ogcwebservices.wass.common.OperationsMetadata_1_0;
064 import org.deegree.ogcwebservices.wass.common.SupportedAuthenticationMethod;
065 import org.w3c.dom.Element;
066 import org.xml.sax.SAXException;
067
068 /**
069 * A <code>WSSCapabilitiesDocument</code> class can parse xml-based requests. The gdi-nrw access
070 * control specification 1.0 defines xml-elements of type owscommon 1.0 hence this class base class
071 * is OWSCapabilitiesBaseDocument_1_0. For creating an empty response document a
072 * XML-Response-Template is located under WSSCapablitiesTemplate.xml .
073 *
074 * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
075 * @author last edited by: $Author: apoth $
076 *
077 * @version 2.0, $Revision: 9345 $, $Date: 2007-12-27 17:22:25 +0100 (Do, 27 Dez 2007) $
078 *
079 * @since 2.0
080 */
081
082 public class WSSCapabilitiesDocument extends OWSCapabilitiesBaseDocument_1_0 {
083
084 private static final long serialVersionUID = 4456377564478064784L;
085
086 /**
087 * The logger enhances the quality and simplicity of Debugging within the deegree2 framework
088 */
089 private static final ILogger LOG = LoggerFactory.getLogger( WSSCapabilitiesDocument.class );
090
091 /**
092 * This is the XML template used for the GetCapabilities response document.
093 */
094 public static final String XML_TEMPLATE = "WSSCapabilitiesTemplate.xml";
095
096 private static String PRE = CommonNamespaces.GDINRWWSS_PREFIX + ":";
097
098 /*
099 * (non-Javadoc)
100 *
101 * @see org.deegree.ogcwebservices.getcapabilities.OGCCapabilitiesDocument#parseCapabilities()
102 */
103 @Override
104 public OGCCapabilities parseCapabilities()
105 throws InvalidCapabilitiesException {
106
107 WSSCapabilities wssCapabilities = null;
108 try {
109
110 ServiceIdentification sf = parseServiceIdentification();
111 ServiceProvider sp = parseServiceProvider();
112 OperationsMetadata_1_0 om = parseOperationsMetadata();
113 String version = parseVersion();
114 String updateSequence = parseUpdateSequence();
115
116 ArrayList<SupportedAuthenticationMethod> am = parseSupportedAuthenticationMethods( CommonNamespaces.GDINRWWSS_PREFIX );
117
118 String securedServiceType = parseSecuredServiceType();
119
120 wssCapabilities = new WSSCapabilities( version, updateSequence, sf, sp, om, securedServiceType, am );
121
122 } catch ( XMLParsingException e ) {
123 LOG.logError( e.getLocalizedMessage(), e );
124 throw new InvalidCapabilitiesException( Messages.getMessage( "WASS_ERROR_CAPABILITIES_NOT_PARSED", "WSS" ) );
125 } catch ( URISyntaxException e ) {
126 LOG.logError( e.getLocalizedMessage(), e );
127 throw new InvalidCapabilitiesException( Messages.getMessage( "WASS_ERROR_URI_NOT_READ",
128 new Object[] { "WSS", "(unknown)" } ) );
129 } catch ( MalformedURLException e ) {
130 LOG.logError( e.getLocalizedMessage(), e );
131 throw new InvalidCapabilitiesException( Messages.getMessage( "WASS_ERROR_URL_NOT_READ",
132 new Object[] { "WSS", "(unknown)" } ) );
133 }
134
135 return wssCapabilities;
136 }
137
138 /**
139 * @return the secured service as String
140 * @throws XMLParsingException
141 */
142 public String parseSecuredServiceType()
143 throws XMLParsingException {
144 Element capability = (Element) XMLTools.getRequiredNode( getRootElement(), PRE + "Capability", nsContext );
145 return XMLTools.getRequiredNodeAsString( capability, PRE + "SecuredServiceType", nsContext );
146 }
147
148 /**
149 * @throws SAXException
150 * @throws IOException
151 *
152 */
153 public void createEmptyDocument()
154 throws IOException, SAXException {
155 super.createEmptyDocument( XML_TEMPLATE );
156 }
157
158 }