001    //$HeadURL: svn+ssh://jwilden@svn.wald.intevation.org/deegree/base/branches/2.5_testing/src/org/deegree/owscommon_1_1_0/operations/GetCapabilitiesDocument.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.owscommon_1_1_0.operations;
038    
039    import static org.deegree.framework.xml.XMLTools.getElement;
040    import static org.deegree.framework.xml.XMLTools.getNodesAsStringList;
041    import static org.deegree.ogcbase.CommonNamespaces.OWS_1_1_0PREFIX;
042    
043    import java.util.ArrayList;
044    import java.util.List;
045    
046    import org.deegree.framework.xml.XMLFragment;
047    import org.deegree.framework.xml.XMLParsingException;
048    import org.w3c.dom.Element;
049    
050    /**
051     * <code>GetCapabilitiesDocument</code> parses the OWSCommon 1.1.0 part of a
052     * <code>GetCapabilities</code> request.
053     *
054     * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
055     *
056     * @author last edited by: $Author: mschneider $
057     *
058     * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18 Jun 2009) $
059     *
060     */
061    public class GetCapabilitiesDocument extends XMLFragment {
062    
063        private static final long serialVersionUID = -4559202452840295387L;
064    
065        private final static String PRE = OWS_1_1_0PREFIX + ":";
066    
067        /**
068         *
069         * @return a list of versions the client requested or an empty list if no versions were given.
070         * @throws XMLParsingException
071         *             if the node could not be parsed.
072         */
073        public List<String> parseAcceptVersions()
074                                throws XMLParsingException {
075            Element root = getRootElement();
076            List<String> result = new ArrayList<String>();
077            if ( root != null ) {
078                Element acceptVersions = getElement( root, PRE + "AcceptVersions", nsContext );
079                if ( acceptVersions != null ) {
080                    result = getNodesAsStringList( acceptVersions, PRE + "Version", nsContext );
081                }
082            }
083            return result;
084        }
085    
086        /**
087         * @return a list of sections the client requested or an empty list if no sections were given.
088         * @throws XMLParsingException
089         *             if the node could not be parsed.
090         */
091        public List<String> parseSections()
092                                throws XMLParsingException {
093            Element root = getRootElement();
094            List<String> result = new ArrayList<String>();
095            if ( root != null ) {
096                Element sections = getElement( root, PRE + "Sections", nsContext );
097                if ( sections != null ) {
098                    result = getNodesAsStringList( sections, PRE + "Section", nsContext );
099                }
100            }
101            return result;
102        }
103    
104        /**
105         * @return a list of AcceptedFormats the client requested or an empty list if no AcceptedFormats
106         *         were given.
107         * @throws XMLParsingException
108         *             if the node could not be parsed.
109         */
110        public List<String> parseAcceptFormats()
111                                throws XMLParsingException {
112            Element root = getRootElement();
113            List<String> result = new ArrayList<String>();
114            if ( root != null ) {
115                Element acceptFormats = getElement( root, PRE + "AcceptFormats", nsContext );
116                if ( acceptFormats != null ) {
117                    result = getNodesAsStringList( acceptFormats, PRE + "OutputFormat", nsContext );
118                }
119            }
120            return result;
121        }
122    
123        /**
124         *
125         * @return the update sequence string or an empty string if not given.
126         */
127        public String parseUpdateSequence() {
128            Element root = getRootElement();
129            String result = new String();
130            if ( root != null ) {
131                result = root.getAttribute( "updateSequence" );
132            }
133            return result;
134        }
135    
136    }