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