001 //$HeadURL: http://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/owscommon_new/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.owscommon_new;
037
038 import java.net.URL;
039 import java.util.ArrayList;
040 import java.util.List;
041
042 import org.deegree.model.metadata.iso19115.Linkage;
043 import org.deegree.model.metadata.iso19115.OnlineResource;
044
045 /**
046 * <code>HTTP</code> describes the distributed computing platform which a service uses. In terms
047 * of HTTP: it stores the links where it can be reached.
048 *
049 * @author <a href="mailto:schmitz@lat-lon.de">Andreas Schmitz</a>
050 * @author last edited by: $Author: mschneider $
051 *
052 * @version 2.0, $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Thu, 18 Jun 2009) $
053 *
054 * @since 2.0
055 */
056
057 public class HTTP implements DCP {
058
059 private static final long serialVersionUID = 989887096571428263L;
060
061 private List<List<DomainType>> constraints;
062
063 private List<Type> types;
064
065 private List<OnlineResource> links;
066
067 /**
068 * Standard constructor that initializes all encapsulated data.
069 *
070 * @param links
071 * @param constraints
072 * @param types
073 */
074 public HTTP( List<OnlineResource> links, List<List<DomainType>> constraints, List<Type> types ) {
075 this.links = links;
076 this.constraints = constraints;
077 this.types = types;
078 }
079
080 /**
081 * @return Returns the constraints.
082 */
083 public List<List<DomainType>> getConstraints() {
084 return constraints;
085 }
086
087 /**
088 * @return Returns the types.
089 */
090 public List<Type> getTypes() {
091 return types;
092 }
093
094 /**
095 * @return the links.
096 */
097 public List<OnlineResource> getLinks() {
098 return links;
099 }
100
101 /**
102 * @return a list of all Get method URLs.
103 */
104 public List<URL> getGetOnlineResources() {
105 List<URL> result = new ArrayList<URL>();
106
107 for ( int i = 0; i < types.size(); ++i ) {
108 if ( types.get( i ) == Type.Get ) {
109 result.add( links.get( i ).getLinkage().getHref() );
110 }
111 }
112
113 return result;
114 }
115
116 /**
117 * @return a list of all Get method URLs.
118 */
119 public List<URL> getPostOnlineResources() {
120 List<URL> result = new ArrayList<URL>();
121
122 for ( int i = 0; i < types.size(); ++i ) {
123 if ( types.get( i ) == Type.Post ) {
124 result.add( links.get( i ).getLinkage().getHref() );
125 }
126 }
127
128 return result;
129 }
130
131 /**
132 * @param urlsnew
133 */
134 public void setGetOnlineResources( List<URL> urlsnew ) {
135 List<OnlineResource> result = new ArrayList<OnlineResource>( links.size() );
136 List<Type> typesnew = new ArrayList<Type>( links.size() );
137
138 for ( int i = 0; i < types.size(); ++i ) {
139 if ( types.get( i ) == Type.Post ) {
140 result.add( links.get( i ) );
141 typesnew.add( types.get( i ) );
142 }
143 }
144
145 for ( URL url : urlsnew ) {
146 result.add( new OnlineResource( new Linkage( url ) ) );
147 typesnew.add( Type.Get );
148 }
149
150 links = result;
151 types = typesnew;
152 }
153
154 /**
155 * @param urlsnew
156 */
157 public void setPostOnlineResources( List<URL> urlsnew ) {
158 List<OnlineResource> result = new ArrayList<OnlineResource>( links.size() );
159 List<Type> typesnew = new ArrayList<Type>( links.size() );
160
161 for ( int i = 0; i < types.size(); ++i ) {
162 if ( types.get( i ) == Type.Get ) {
163 result.add( links.get( i ) );
164 }
165 }
166
167 for ( URL url : urlsnew ) {
168 result.add( new OnlineResource( new Linkage( url ) ) );
169 typesnew.add( Type.Post );
170 }
171
172 links = result;
173 types = typesnew;
174 }
175
176 /**
177 * Enumeration type indicating the used HTTP request method.
178 *
179 * @author <a href="mailto:schmitz@lat-lon.de">Andreas Schmitz</a>
180 * @author last edited by: $Author: mschneider $
181 *
182 * @version 2.0, $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Thu, 18 Jun 2009) $
183 *
184 * @since 2.0
185 */
186 public enum Type {
187 /**
188 * The Get HTTP method.
189 */
190 Get,
191 /**
192 * The Post HTTP method.
193 */
194 Post
195 }
196
197 }