001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/ogcwebservices/getcapabilities/HTTP.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    package org.deegree.ogcwebservices.getcapabilities;
037    
038    import java.net.URL;
039    import java.util.ArrayList;
040    import java.util.List;
041    
042    /**
043     * The HTTP-Protocol, which extends the super-interface {@link Protocol}. It defines the
044     * {@link #getGetOnlineResources()} and the {@link #getPostOnlineResources()} methods.
045     *
046     * @author <a href="mailto:k.lupp@web.de">Katharina Lupp </a>
047     * @author <a href="mailto:mschneider@lat-lon.de">Markus Schneider </a>
048     * @version $Revision: 18195 $ $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
049     */
050    public class HTTP extends Protocol {
051    
052        private static final long serialVersionUID = 2569402046999187710L;
053    
054        private List<URL> getOnlineResource = new ArrayList<URL>();
055    
056        private List<URL> postOnlineResource = new ArrayList<URL>();
057    
058        /**
059         * default constructor
060         */
061        public HTTP() {
062            // why do we need an empty one?
063        }
064    
065        /**
066         * constructor initializing the class with get and post URL
067         *
068         * @param getOnlineResource
069         * @param postOnlineResource
070         */
071        public HTTP( URL[] getOnlineResource, URL[] postOnlineResource ) {
072            setGetOnlineResources( getOnlineResource );
073            setPostOnlineResources( postOnlineResource );
074        }
075    
076        /**
077         * Return the list of online resources for the HTTP GET request. An Online Resource URL intended
078         * for HTTP GET requests, is a URL prefix to which additional parameters must be appended in
079         * order to construct a valid Operation request. A URL prefix is defined as an opaque string
080         * including the protocol, hostname, optional port number, path, a question mark '?', and,
081         * optionally, one or more server-specific parameters ending in an ampersand '&'.
082         *
083         * @return the urls
084         *
085         */
086        public URL[] getGetOnlineResources() {
087            return getOnlineResource.toArray( new URL[getOnlineResource.size()] );
088        }
089    
090        /**
091         * adds a get-online resource to the HTTP protocol class
092         *
093         * @param getOnlineResource
094         */
095        public void addGetOnlineResource( URL getOnlineResource ) {
096            this.getOnlineResource.add( getOnlineResource );
097        }
098    
099        /**
100         * @param getOnlineResource
101         *
102         */
103        public void setGetOnlineResources( URL[] getOnlineResource ) {
104            this.getOnlineResource.clear();
105    
106            if ( getOnlineResource != null ) {
107                for ( int i = 0; i < getOnlineResource.length; i++ ) {
108                    addGetOnlineResource( getOnlineResource[i] );
109                }
110            }
111        }
112    
113        /**
114         * Return the list of online resources for the HTTP GET request. An Online Resource URL intended
115         * for HTTP POST requests is a complete and valid URL to which Clients transmit encoded requests
116         * in the body of the POST document.
117         *
118         * @return the links
119         */
120        public URL[] getPostOnlineResources() {
121            return postOnlineResource.toArray( new URL[postOnlineResource.size()] );
122        }
123    
124        /**
125         * sets URL prefix for post HTTP request method.
126         *
127         * @param postOnlineResource
128         */
129        public void setPostOnlineResources( URL[] postOnlineResource ) {
130            this.postOnlineResource.clear();
131    
132            if ( postOnlineResource != null ) {
133                for ( int i = 0; i < postOnlineResource.length; i++ ) {
134                    addPostOnlineResource( postOnlineResource[i] );
135                }
136            }
137        }
138    
139        /**
140         * adds a post-online resource to the HTTP protocol class
141         *
142         * @param postOnlineResource
143         */
144        public void addPostOnlineResource( URL postOnlineResource ) {
145            this.postOnlineResource.add( postOnlineResource );
146        }
147    }