001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/wass/wss/operation/DoService.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:
045: package org.deegree.ogcwebservices.wass.wss.operation;
046:
047: import java.net.URI;
048: import java.util.ArrayList;
049: import java.util.List;
050: import java.util.Map;
051:
052: import org.deegree.framework.log.ILogger;
053: import org.deegree.framework.log.LoggerFactory;
054: import org.deegree.framework.util.StringTools;
055: import org.deegree.framework.xml.XMLParsingException;
056: import org.deegree.ogcwebservices.OGCWebServiceException;
057: import org.deegree.ogcwebservices.OGCWebServiceRequest;
058: import org.deegree.ogcwebservices.wass.common.AbstractRequest;
059: import org.deegree.ogcwebservices.wass.common.AuthenticationData;
060: import org.deegree.ogcwebservices.wass.common.URN;
061: import org.w3c.dom.Element;
062:
063: /**
064: * The <code>DoService</code> class represents (a bean) a DoService Operation which is send by a client (or other
065: * server) which is checked by the wss for the right credentials and than send to the requested
066: * serviceprovider. In the case that a client not has the right credentials a ServiceException is
067: * thrown. The Specification does mention the fact that ther might be another response for example:
068: * A client orders A and B but only has the credentials for A -> should we return A and not B or
069: * nothing at all. We do the last, the client gets nothing.
070: *
071: * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
072: * @author last edited by: $Author: apoth $
073: *
074: * @version $Revision: 9348 $, $Date: 2007-12-27 08:59:14 -0800 (Thu, 27 Dec 2007) $
075: */
076:
077: public class DoService extends AbstractRequest {
078:
079: private static final long serialVersionUID = -8538267299180579690L;
080:
081: /**
082: * The logger enhances the quality and simplicity of Debugging within the deegree2 framework
083: */
084: private static final ILogger LOG = LoggerFactory
085: .getLogger(DoService.class);
086:
087: private AuthenticationData authenticationData = null;
088:
089: private String dcp = null;
090:
091: private ArrayList<RequestParameter> requestParameters = null;
092:
093: private String payload = null;
094:
095: private URI facadeURL = null;
096:
097: /**
098: * @param id the request id
099: * @param service
100: * @param version
101: * @param authenticationData
102: * @param dcp
103: * @param requestParameters
104: * @param payload
105: * @param facadeURL
106: */
107: public DoService(String id, String service, String version,
108: AuthenticationData authenticationData, String dcp,
109: ArrayList<RequestParameter> requestParameters,
110: String payload, URI facadeURL) {
111: super (id, version, service, "DoService");
112: this .authenticationData = authenticationData;
113: this .dcp = dcp;
114: this .requestParameters = requestParameters;
115: this .payload = payload;
116: this .facadeURL = facadeURL;
117: }
118:
119: /**
120: * @param id the request id
121: * @param keyValues
122: */
123: public DoService(String id, Map<String, String> keyValues) {
124: super (id, keyValues);
125:
126: LOG.logDebug(keyValues.toString());
127:
128: this .authenticationData = new AuthenticationData(new URN(
129: keyValues.get("AUTHMETHOD")), keyValues
130: .get("CREDENTIALS"));
131: this .dcp = keyValues.get("DCP");
132: this .payload = keyValues.get("SERVICEREQUEST");
133: try {
134: this .facadeURL = new URI(keyValues.get("FACADEURL"));
135: } catch (Exception e) {
136: LOG.logError(e.getMessage(), e);
137: }
138:
139: requestParameters = new ArrayList<RequestParameter>();
140:
141: String requestParams = keyValues.get("REQUESTPARAMS");
142: List<String> params = StringTools.toList(requestParams, ",",
143: false);
144:
145: String requestParamValues = keyValues.get("REQUESTPARAMVALUES");
146: List<String> paramValues = StringTools.toList(
147: requestParamValues, ",", false);
148:
149: for (int i = 0; i < params.size(); ++i) {
150: this .requestParameters.add(new RequestParameter(params
151: .get(i), paramValues.get(i)));
152: }
153:
154: }
155:
156: /**
157: * @return Returns the authenticationData.
158: */
159: public AuthenticationData getAuthenticationData() {
160: return authenticationData;
161: }
162:
163: /**
164: * @return Returns the dcp.
165: */
166: public String getDcp() {
167: return dcp;
168: }
169:
170: /**
171: * @return Returns the facadeURL.
172: */
173: public URI getFacadeURL() {
174: return facadeURL;
175: }
176:
177: /**
178: * @return Returns the payload.
179: */
180: public String getPayload() {
181: return payload;
182: }
183:
184: /**
185: * @return Returns the requestParameters.
186: */
187: public ArrayList<RequestParameter> getRequestParameters() {
188: return requestParameters;
189: }
190:
191: /**
192: * @param id
193: * @param documentElement
194: * @return a new instance of this class
195: * @throws OGCWebServiceException
196: */
197: public static OGCWebServiceRequest create(String id,
198: Element documentElement) throws OGCWebServiceException {
199: try {
200: return new DoServiceDocument().parseDoService(id,
201: documentElement);
202: } catch (XMLParsingException e) {
203: LOG.logError(e.getMessage(), e);
204: throw new OGCWebServiceException(e.getMessage());
205: }
206: }
207:
208: /**
209: * @param id
210: * @param kvp
211: * @return a new instance of this class
212: */
213: public static OGCWebServiceRequest create(String id,
214: Map<String, String> kvp) {
215: return new DoService(id, kvp);
216: }
217: }
|