001    //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/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 17:59:14 +0100 (Do, 27 Dez 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.getLogger( DoService.class );
085    
086        private AuthenticationData authenticationData = null;
087    
088        private String dcp = null;
089    
090        private ArrayList<RequestParameter> requestParameters = null;
091    
092        private String payload = null;
093    
094        private URI facadeURL = null;
095    
096        /**
097         * @param id the request id
098         * @param service
099         * @param version
100         * @param authenticationData
101         * @param dcp
102         * @param requestParameters
103         * @param payload
104         * @param facadeURL
105         */
106        public DoService( String id, String service, String version, AuthenticationData authenticationData,
107                         String dcp, ArrayList<RequestParameter> requestParameters, String payload,
108                         URI facadeURL ) {
109            super( id, version, service, "DoService" );
110            this.authenticationData = authenticationData;
111            this.dcp = dcp;
112            this.requestParameters = requestParameters;
113            this.payload = payload;
114            this.facadeURL = facadeURL;
115        }
116    
117        /**
118         * @param id the request id
119         * @param keyValues
120         */
121        public DoService( String id, Map<String, String> keyValues ) {
122            super( id, keyValues );
123            
124            LOG.logDebug( keyValues.toString() );
125            
126            this.authenticationData = new AuthenticationData( new URN( keyValues.get( "AUTHMETHOD" ) ),
127                                                              keyValues.get( "CREDENTIALS" ) );
128            this.dcp = keyValues.get( "DCP" );
129            this.payload = keyValues.get( "SERVICEREQUEST" );
130            try {
131                this.facadeURL = new URI( keyValues.get( "FACADEURL" ) );
132            } catch ( Exception e ) {
133                LOG.logError( e.getMessage(), e );
134            }
135    
136            requestParameters = new ArrayList<RequestParameter>();
137    
138            String requestParams = keyValues.get( "REQUESTPARAMS" );
139            List<String> params = StringTools.toList( requestParams, ",", false );
140    
141            String requestParamValues = keyValues.get( "REQUESTPARAMVALUES" );
142            List<String> paramValues = StringTools.toList( requestParamValues, ",", false );
143    
144            for ( int i = 0; i < params.size(); ++i ) {
145                this.requestParameters.add( new RequestParameter( params.get( i ), paramValues.get( i ) ) );
146            }
147            
148        }
149    
150        /**
151         * @return Returns the authenticationData.
152         */
153        public AuthenticationData getAuthenticationData() {
154            return authenticationData;
155        }
156    
157        /**
158         * @return Returns the dcp.
159         */
160        public String getDcp() {
161            return dcp;
162        }
163    
164        /**
165         * @return Returns the facadeURL.
166         */
167        public URI getFacadeURL() {
168            return facadeURL;
169        }
170    
171        /**
172         * @return Returns the payload.
173         */
174        public String getPayload() {
175            return payload;
176        }
177    
178        /**
179         * @return Returns the requestParameters.
180         */
181        public ArrayList<RequestParameter> getRequestParameters() {
182            return requestParameters;
183        }
184    
185        /**
186         * @param id
187         * @param documentElement
188         * @return a new instance of this class
189         * @throws OGCWebServiceException 
190         */
191        public static OGCWebServiceRequest create( String id, Element documentElement ) throws OGCWebServiceException {
192            try {
193                return new DoServiceDocument().parseDoService( id, documentElement );
194            } catch ( XMLParsingException e ) {
195                LOG.logError( e.getMessage(), e );
196                throw new OGCWebServiceException( e.getMessage() );
197            }
198        }
199    
200        /**
201         * @param id
202         * @param kvp
203         * @return a new instance of this class
204         */
205        public static OGCWebServiceRequest create( String id, Map<String, String> kvp ) {
206            return new DoService( id, kvp );
207        }
208    }