001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/tags/2.1/src/org/deegree/owscommon_new/HTTP.java $
002    /*----------------    FILE HEADER  ------------------------------------------
003     This file is part of deegree.
004     Copyright (C) 2001-2006 by:
005     Department of Geography, University of Bonn
006     http://www.giub.uni-bonn.de/deegree/
007     lat/lon GmbH
008     http://www.lat-lon.de
009     This library is free software; you can redistribute it and/or
010     modify it under the terms of the GNU Lesser General Public
011     License as published by the Free Software Foundation; either
012     version 2.1 of the License, or (at your option) any later version.
013     This library is distributed in the hope that it will be useful,
014     but WITHOUT ANY WARRANTY; without even the implied warranty of
015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
016     Lesser General Public License for more details.
017     You should have received a copy of the GNU Lesser General Public
018     License along with this library; if not, write to the Free Software
019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020     Contact:
021     Andreas Poth
022     lat/lon GmbH
023     Aennchenstraße 19
024     53177 Bonn
025     Germany
026     E-Mail: poth@lat-lon.de
027     Jens Fitzke
028     lat/lon GmbH
029     Aennchenstraße 19
030     53177 Bonn
031     Germany
032     E-Mail: jens.fitzke@uni-bonn.de
033     ---------------------------------------------------------------------------*/
034    package org.deegree.owscommon_new;
035    
036    import java.net.URL;
037    import java.util.ArrayList;
038    import java.util.List;
039    
040    import org.deegree.model.metadata.iso19115.Linkage;
041    import org.deegree.model.metadata.iso19115.OnlineResource;
042    
043    /**
044     * <code>HTTP</code> describes the distributed computing platform which a service uses. In terms
045     * of HTTP: it stores the links where it can be reached.
046     * 
047     * @author <a href="mailto:schmitz@lat-lon.de">Andreas Schmitz</a>
048     * @author last edited by: $Author: aschmitz $
049     * 
050     * @version 2.0, $Revision: 7656 $, $Date: 2007-06-26 16:54:12 +0200 (Di, 26 Jun 2007) $
051     * 
052     * @since 2.0
053     */
054    
055    public class HTTP implements DCP {
056    
057        private static final long serialVersionUID = 989887096571428263L;
058    
059        private List<List<DomainType>> constraints;
060    
061        private List<Type> types;
062    
063        private List<OnlineResource> links;
064    
065        /**
066         * Standard constructor that initializes all encapsulated data.
067         * 
068         * @param links
069         * @param constraints
070         * @param types
071         */
072        public HTTP( List<OnlineResource> links, List<List<DomainType>> constraints, List<Type> types ) {
073            this.links = links;
074            this.constraints = constraints;
075            this.types = types;
076        }
077    
078        /**
079         * @return Returns the constraints.
080         */
081        public List<List<DomainType>> getConstraints() {
082            return constraints;
083        }
084    
085        /**
086         * @return Returns the types.
087         */
088        public List<Type> getTypes() {
089            return types;
090        }
091    
092        /**
093         * @return the links.
094         */
095        public List<OnlineResource> getLinks() {
096            return links;
097        }
098    
099        /**
100         * @return a list of all Get method URLs.
101         */
102        public List<URL> getGetOnlineResources() {
103            List<URL> result = new ArrayList<URL>();
104    
105            for ( int i = 0; i < types.size(); ++i ) {
106                if ( types.get( i ) == Type.Get ) {
107                    result.add( links.get( i ).getLinkage().getHref() );
108                }
109            }
110    
111            return result;
112        }
113    
114        /**
115         * @return a list of all Get method URLs.
116         */
117        public List<URL> getPostOnlineResources() {
118            List<URL> result = new ArrayList<URL>();
119    
120            for ( int i = 0; i < types.size(); ++i ) {
121                if ( types.get( i ) == Type.Post ) {
122                    result.add( links.get( i ).getLinkage().getHref() );
123                }
124            }
125    
126            return result;
127        }
128    
129        /**
130         * @param urlsnew
131         */
132        public void setGetOnlineResources( List<URL> urlsnew ) {
133            List<OnlineResource> result = new ArrayList<OnlineResource>( links.size() );
134            List<Type> typesnew = new ArrayList<Type>( links.size() );
135    
136            for ( int i = 0; i < types.size(); ++i ) {
137                if ( types.get( i ) == Type.Post ) {
138                    result.add( links.get( i ) );
139                    typesnew.add( types.get( i ) );
140                }
141            }
142    
143            for ( URL url : urlsnew ) {
144                result.add( new OnlineResource( new Linkage( url ) ) );
145                typesnew.add( Type.Get );
146            }
147    
148            links = result;
149            types = typesnew;
150        }
151    
152        /**
153         * @param urlsnew
154         */
155        public void setPostOnlineResources( List<URL> urlsnew ) {
156            List<OnlineResource> result = new ArrayList<OnlineResource>( links.size() );
157            List<Type> typesnew = new ArrayList<Type>( links.size() );
158    
159            for ( int i = 0; i < types.size(); ++i ) {
160                if ( types.get( i ) == Type.Get ) {
161                    result.add( links.get( i ) );
162                }
163            }
164    
165            for ( URL url : urlsnew ) {
166                result.add( new OnlineResource( new Linkage( url ) ) );
167                typesnew.add( Type.Post );
168            }
169    
170            links = result;
171            types = typesnew;
172        }
173    
174        /**
175         * Enumeration type indicating the used HTTP request method.
176         * 
177         * @author <a href="mailto:schmitz@lat-lon.de">Andreas Schmitz</a>
178         * @author last edited by: $Author: aschmitz $
179         * 
180         * @version 2.0, $Revision: 7656 $, $Date: 2007-06-26 16:54:12 +0200 (Di, 26 Jun 2007) $
181         * 
182         * @since 2.0
183         */
184        public enum Type {
185            /**
186             * The Get HTTP method.
187             */
188            Get,
189            /**
190             * The Post HTTP method.
191             */
192            Post
193        }
194    
195    }