001    //$HeadURL: $
002    /*----------------    FILE HEADER  ------------------------------------------
003     This file is part of deegree.
004     Copyright (C) 2001-2008 by:
005     Department of Geography, University of Bonn
006     http://www.giub.uni-bonn.de/deegree/
007     lat/lon GmbH
008     http://www.lat-lon.de
009    
010     This library is free software; you can redistribute it and/or
011     modify it under the terms of the GNU Lesser General Public
012     License as published by the Free Software Foundation; either
013     version 2.1 of the License, or (at your option) any later version.
014     This library is distributed in the hope that it will be useful,
015     but WITHOUT ANY WARRANTY; without even the implied warranty of
016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
017     Lesser General Public License for more details.
018     You should have received a copy of the GNU Lesser General Public
019     License along with this library; if not, write to the Free Software
020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
021     Contact:
022    
023     Andreas Poth
024     lat/lon GmbH
025     Aennchenstr. 19
026     53177 Bonn
027     Germany
028     E-Mail: poth@lat-lon.de
029    
030     Prof. Dr. Klaus Greve
031     Department of Geography
032     University of Bonn
033     Meckenheimer Allee 166
034     53115 Bonn
035     Germany
036     E-Mail: greve@giub.uni-bonn.de
037     ---------------------------------------------------------------------------*/
038    
039    package org.deegree.ogcwebservices.wcts;
040    
041    import org.deegree.framework.log.ILogger;
042    import org.deegree.framework.log.LoggerFactory;
043    import org.deegree.i18n.Messages;
044    import org.deegree.ogcbase.ExceptionCode;
045    import org.deegree.ogcwebservices.OGCWebService;
046    import org.deegree.ogcwebservices.OGCWebServiceException;
047    import org.deegree.ogcwebservices.OGCWebServiceRequest;
048    import org.deegree.ogcwebservices.getcapabilities.OGCCapabilities;
049    import org.deegree.ogcwebservices.wcts.configuration.WCTSConfiguration;
050    import org.deegree.ogcwebservices.wcts.operation.GetResourceByID;
051    import org.deegree.ogcwebservices.wcts.operation.IsTransformable;
052    import org.deegree.ogcwebservices.wcts.operation.OperationParameter;
053    import org.deegree.ogcwebservices.wcts.operation.WCTSGetCapabilities;
054    import org.deegree.ogcwebservices.wcts.operation.WCTSTransform;
055    
056    /**
057     * The <code>WCTService</code> class TODO add documentation here
058     * 
059     * @author <a href="mailto:bezema@lat-lon.de">Rutger Bezema</a>
060     * 
061     * @author last edited by: $Author:$
062     * 
063     * @version $Revision:$, $Date:$
064     * 
065     */
066    public class WCTService implements OGCWebService {
067        private static ILogger LOG = LoggerFactory.getLogger( WCTService.class );
068    
069        private final WCTSConfiguration config;
070        /**
071         * The version of this wcts, will be read from the configuration.
072         */
073        public static String version = "0.4.0";
074    
075        /**
076         * @param config
077         */
078        public WCTService( WCTSConfiguration config ) {
079            this.config = config;
080            synchronized ( LOG ) {
081                version = config.getVersion();
082                LOG.notifyAll();
083            }
084        }
085    
086        /*
087         * (non-Javadoc)
088         * 
089         * @see org.deegree.ogcwebservices.OGCWebService#doService(org.deegree.ogcwebservices.OGCWebServiceRequest)
090         */
091        public Object doService( OGCWebServiceRequest request )
092                                                               throws OGCWebServiceException {
093            Object result = null;
094            if ( request != null ) {
095                long time = System.currentTimeMillis();
096                LOG.logDebug( "Incoming request with id: " + request.getId() );
097                if ( request instanceof GetResourceByID ) {
098                    // handle transformable.
099                } else if ( request instanceof IsTransformable ) {
100                    // handle IsTransformable.
101                } else if ( request instanceof OperationParameter ) {
102                    // handle transformable.
103                } else if ( request instanceof WCTSGetCapabilities ) {
104                    result = getCapabilities();
105                } else if ( request instanceof WCTSTransform ) {
106                    // handle transformable.
107                } else {
108                    throw new OGCWebServiceException( request.toString(),
109                                                      Messages.getMessage( "WCTS_UNKNOWN_REQUEST" ),
110                                                      ExceptionCode.OPERATIONNOTSUPPORTED );
111                }
112                LOG.logDebug( "The handling of request with id: " + request.getId()
113                              + " took: "
114                              + ( System.currentTimeMillis() - time )
115                              / 1000.
116                              + " seconds" );
117            }
118    
119            return result;
120        }
121    
122        /*
123         * (non-Javadoc)
124         * 
125         * @see org.deegree.ogcwebservices.OGCWebService#getCapabilities()
126         */
127        public OGCCapabilities getCapabilities() {
128            return config;
129        }
130    
131    }