001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/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 08:22:25 -0800 (Thu, 27 Dec 2007) $
078: *
079: * @since 2.0
080: */
081:
082: public class WSSCapabilitiesDocument extends
083: OWSCapabilitiesBaseDocument_1_0 {
084:
085: private static final long serialVersionUID = 4456377564478064784L;
086:
087: /**
088: * The logger enhances the quality and simplicity of Debugging within the deegree2 framework
089: */
090: private static final ILogger LOG = LoggerFactory
091: .getLogger(WSSCapabilitiesDocument.class);
092:
093: /**
094: * This is the XML template used for the GetCapabilities response document.
095: */
096: public static final String XML_TEMPLATE = "WSSCapabilitiesTemplate.xml";
097:
098: private static String PRE = CommonNamespaces.GDINRWWSS_PREFIX + ":";
099:
100: /*
101: * (non-Javadoc)
102: *
103: * @see org.deegree.ogcwebservices.getcapabilities.OGCCapabilitiesDocument#parseCapabilities()
104: */
105: @Override
106: public OGCCapabilities parseCapabilities()
107: throws InvalidCapabilitiesException {
108:
109: WSSCapabilities wssCapabilities = null;
110: try {
111:
112: ServiceIdentification sf = parseServiceIdentification();
113: ServiceProvider sp = parseServiceProvider();
114: OperationsMetadata_1_0 om = parseOperationsMetadata();
115: String version = parseVersion();
116: String updateSequence = parseUpdateSequence();
117:
118: ArrayList<SupportedAuthenticationMethod> am = parseSupportedAuthenticationMethods(CommonNamespaces.GDINRWWSS_PREFIX);
119:
120: String securedServiceType = parseSecuredServiceType();
121:
122: wssCapabilities = new WSSCapabilities(version,
123: updateSequence, sf, sp, om, securedServiceType, am);
124:
125: } catch (XMLParsingException e) {
126: LOG.logError(e.getLocalizedMessage(), e);
127: throw new InvalidCapabilitiesException(Messages.getMessage(
128: "WASS_ERROR_CAPABILITIES_NOT_PARSED", "WSS"));
129: } catch (URISyntaxException e) {
130: LOG.logError(e.getLocalizedMessage(), e);
131: throw new InvalidCapabilitiesException(Messages.getMessage(
132: "WASS_ERROR_URI_NOT_READ", new Object[] { "WSS",
133: "(unknown)" }));
134: } catch (MalformedURLException e) {
135: LOG.logError(e.getLocalizedMessage(), e);
136: throw new InvalidCapabilitiesException(Messages.getMessage(
137: "WASS_ERROR_URL_NOT_READ", new Object[] { "WSS",
138: "(unknown)" }));
139: }
140:
141: return wssCapabilities;
142: }
143:
144: /**
145: * @return the secured service as String
146: * @throws XMLParsingException
147: */
148: public String parseSecuredServiceType() throws XMLParsingException {
149: Element capability = (Element) XMLTools.getRequiredNode(
150: getRootElement(), PRE + "Capability", nsContext);
151: return XMLTools.getRequiredNodeAsString(capability, PRE
152: + "SecuredServiceType", nsContext);
153: }
154:
155: /**
156: * @throws SAXException
157: * @throws IOException
158: *
159: */
160: public void createEmptyDocument() throws IOException, SAXException {
161: super.createEmptyDocument(XML_TEMPLATE);
162: }
163:
164: }
|