001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/ogcwebservices/wps/WPService.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.ogcwebservices.wps;
037    
038    import org.deegree.framework.log.ILogger;
039    import org.deegree.framework.log.LoggerFactory;
040    import org.deegree.framework.trigger.TriggerProvider;
041    import org.deegree.ogcwebservices.OGCWebService;
042    import org.deegree.ogcwebservices.OGCWebServiceException;
043    import org.deegree.ogcwebservices.OGCWebServiceRequest;
044    import org.deegree.ogcwebservices.getcapabilities.OGCCapabilities;
045    import org.deegree.ogcwebservices.wps.capabilities.WPSGetCapabilities;
046    import org.deegree.ogcwebservices.wps.configuration.WPSConfiguration;
047    import org.deegree.ogcwebservices.wps.describeprocess.DescribeProcessRequest;
048    import org.deegree.ogcwebservices.wps.describeprocess.DescribeProcessRequestHandler;
049    import org.deegree.ogcwebservices.wps.execute.ExecuteRequest;
050    import org.deegree.ogcwebservices.wps.execute.ExecuteRequestHandler;
051    
052    /**
053     * WPService.java
054     *
055     * Created on 08.03.2006. 17:34:15h
056     *
057     * @author <a href="mailto:christian@kiehle.org">Christian Kiehle</a>
058     * @author <a href="mailto:christian.heier@gmx.de">Christian Heier</a>
059     * @version 1.0.
060     * @since 2.0
061     */
062    
063    public class WPService implements OGCWebService {
064    
065        private static final ILogger LOG = LoggerFactory.getLogger( WPService.class );
066    
067        private static final TriggerProvider TP = TriggerProvider.create( WPService.class );
068    
069        private WPSConfiguration configuration = null;
070    
071        /**
072         *
073         * @param configuration
074         */
075        public WPService( WPSConfiguration configuration ) {
076            this.configuration = configuration;
077        }
078    
079        /**
080         * @return Returns the configuration.
081         */
082        public WPSConfiguration getConfiguration() {
083            return configuration;
084        }
085    
086        /*
087         * (non-Javadoc)
088         *
089         * @see org.deegree.ogcwebservices.OGCWebService#getCapabilities()
090         */
091        public OGCCapabilities getCapabilities() {
092            return configuration;
093        }
094    
095        /*
096         * (non-Javadoc)
097         *
098         * @see org.deegree.ogcwebservices.OGCWebService#doService(org.deegree.ogcwebservices.OGCWebServiceRequest)
099         */
100        public Object doService( OGCWebServiceRequest request )
101                                throws OGCWebServiceException {
102    
103            request = (OGCWebServiceRequest) TP.doPreTrigger( this, request )[0];
104    
105            Object response = null;
106            if ( request instanceof WPSGetCapabilities ) {
107                LOG.logDebug( "recieved a get capabilities request" );
108                response = configuration;
109            } else if ( request instanceof DescribeProcessRequest ) {
110                LOG.logDebug( "recieved a describe process request" );
111                DescribeProcessRequestHandler describeProcessRequestHandler = new DescribeProcessRequestHandler( this );
112                response = describeProcessRequestHandler.handleRequest( (DescribeProcessRequest) request );
113            } else if ( request instanceof ExecuteRequest ) {
114                LOG.logDebug( "recieved a execute request" );
115                ExecuteRequestHandler executeRequestHandler = new ExecuteRequestHandler( this );
116                response = executeRequestHandler.handleRequest( (ExecuteRequest) request );
117            }
118    
119            return TP.doPostTrigger( this, response )[0];
120        }
121    
122    }