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