    001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.4_testing/src/org/deegree/ogcwebservices/wass/was/capabilities/WASCapabilitiesDocument.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.was.capabilities;
    038
    039
    040    import java.io.IOException;
    041    import java.net.MalformedURLException;
    042    import java.net.URISyntaxException;
    043    import java.util.ArrayList;
    044
    045    import org.deegree.framework.log.ILogger;
    046    import org.deegree.framework.log.LoggerFactory;
    047    import org.deegree.framework.xml.XMLParsingException;
    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.xml.sax.SAXException;
    058
    059    /**
    060     * Parser for the WAS capabilities according to GDI NRW spec V1.0.
    061     *
    062     * Namespace: http://www.gdi-nrw.org/was
    063     *
    064     * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
    065     * @author last edited by: $Author: mschneider $
    066     *
    067     * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
    068     */
    069    public class WASCapabilitiesDocument extends OWSCapabilitiesBaseDocument_1_0 {
    070
    071        private static final long serialVersionUID = -6646616562364235109L;
    072
    073        private static final ILogger LOG = LoggerFactory.getLogger( WASCapabilitiesDocument.class );
    074
    075        /**
    076         * This is the XML template used for the GetCapabilities response document.
    077         */
    078        public static final String XML_TEMPLATE = "WASCapabilitiesTemplate.xml";
    079
    080        /**
    081         * Creates an empty document from default template.
    082         *
    083         * @throws IOException
    084         * @throws SAXException
    085         */
    086        public void createEmptyDocument()
    087                                throws IOException, SAXException {
    088            super.createEmptyDocument( XML_TEMPLATE );
    089        }
    090
    091        /*
    092         * (non-Javadoc)
    093         *
    094         * @see org.deegree.ogcwebservices.getcapabilities.OGCCapabilitiesDocument#parseCapabilities()
    095         */
    096        @Override
    097        public OGCCapabilities parseCapabilities()
    098                                throws InvalidCapabilitiesException {
    099
    100
    101            WASCapabilities wasCapabilites = null;
    102            try {
    103
    104                ServiceIdentification sf = parseServiceIdentification();
    105                ServiceProvider sp = parseServiceProvider();
    106                OperationsMetadata_1_0 om = parseOperationsMetadata();
    107                String version = parseVersion();
    108                String updateSequence = parseUpdateSequence();
    109
    110                ArrayList<SupportedAuthenticationMethod> am = parseSupportedAuthenticationMethods( CommonNamespaces.GDINRWWAS_PREFIX );
    111                wasCapabilites = new WASCapabilities( version, updateSequence, sf, sp, om, am );
    112
    113            } catch ( XMLParsingException e ) {
    114                LOG.logError( e.getLocalizedMessage(), e );
    115                throw new InvalidCapabilitiesException(
    116                                                        Messages.getMessage(
    117                                                                         "WASS_ERROR_CAPABILITIES_NOT_PARSED",
    118                                                                         "WAS" ) );
    119            } catch ( URISyntaxException e ) {
    120                LOG.logError( e.getLocalizedMessage(), e );
    121                throw new InvalidCapabilitiesException(
    122                                                        Messages.getMessage(
    123                                                                         "WASS_ERROR_URI_NOT_READ",
    124                                                                         new Object[] { "WAS",
    125                                                                                       "(unknown)" } ) );
    126            } catch ( MalformedURLException e ) {
    127                LOG.logError( e.getLocalizedMessage(), e );
    128                throw new InvalidCapabilitiesException(
    129                                                        Messages.getMessage(
    130                                                                         "WASS_ERROR_URL_NOT_READ",
    131                                                                         new Object[] { "WAS",
    132                                                                                       "(unknown)" } ) );
    133            }
    134
    135
    136            return wasCapabilites;
    137        }
    138
    139    }