001    //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/branches/2.3_testing/src/org/deegree/portal/context/Server.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.portal.context;
037    
038    import java.net.URL;
039    
040    import org.deegree.ogcwebservices.getcapabilities.OGCCapabilities;
041    
042    /**
043     * encapsulates the server description as defined in the OGC Web Map Context specification 1.0.0
044     *
045     * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
046     * @author last edited by: $Author: mschneider $
047     *
048     * @version $Revision: 18195 $, $Date: 2009-06-18 17:55:39 +0200 (Do, 18. Jun 2009) $
049     */
050    public class Server {
051        private String service = null;
052    
053        private String title = null;
054    
055        private String version = null;
056    
057        private URL onlineResource = null;
058    
059        private OGCCapabilities capabilities = null;
060    
061        /**
062         * Creates a new Server object.
063         *
064         * @param title
065         *            the title of the service
066         * @param version
067         *            Version number of the OGC interface specification which corresponds to the service
068         * @param service
069         *            the type of the service according to OGC interfaces, such as WMS, WFS.
070         * @param onlineResource
071         *            the link to the online resource
072         * @param capabilities
073         *
074         * @throws ContextException
075         */
076        public Server( String title, String version, String service, URL onlineResource, OGCCapabilities capabilities )
077                                throws ContextException {
078            setTitle( title );
079            setVersion( version );
080            setService( service );
081            setOnlineResource( onlineResource );
082            setCapabilities( capabilities );
083        }
084    
085        /**
086         * the title of the service (extracted from the Capabilities by the Context document creator)
087         *
088         * @return the title of the service (extracted from the Capabilities by the Context document
089         *         creator)
090         */
091        public String getTitle() {
092            return title;
093        }
094    
095        /**
096         * Version number of the OGC interface specification which corresponds to the service
097         *
098         * @return Version number of the OGC interface specification which corresponds to the service
099         */
100        public String getVersion() {
101            return version;
102        }
103    
104        /**
105         * the type of the service according to OGC interfaces, such as WMS, WFS.
106         *
107         * @return the type of the service according to OGC interfaces, such as WMS, WFS.
108         */
109        public String getService() {
110            return service;
111        }
112    
113        /**
114         * link to the online resource
115         *
116         * @return link to the online resource
117         */
118        public URL getOnlineResource() {
119            return onlineResource;
120        }
121    
122        /**
123         * see also org.deegree.clients.context.Server#getTitle()
124         *
125         * @param title
126         */
127        public void setTitle( String title ) {
128            this.title = title;
129        }
130    
131        /**
132         * see also org.deegree.clients.context.Server#getFeatureVersion()
133         *
134         * @param version
135         *
136         * @throws ContextException
137         */
138        public void setVersion( String version )
139                                throws ContextException {
140            if ( version == null ) {
141                throw new ContextException( "version isn't allowed to be null" );
142            }
143            this.version = version;
144        }
145    
146        /**
147         * see also org.deegree.clients.context.Server#getService()
148         *
149         * @param service
150         *
151         * @throws ContextException
152         */
153        public void setService( String service )
154                                throws ContextException {
155            if ( service == null ) {
156                throw new ContextException( "service isn't allowed to be null" );
157            }
158            this.service = service;
159        }
160    
161        /**
162         * see also org.deegree.clients.context.Server#getOnlineResource()
163         *
164         * @param onlineResource
165         *
166         * @throws ContextException
167         */
168        public void setOnlineResource( URL onlineResource )
169                                throws ContextException {
170            if ( onlineResource == null ) {
171                throw new ContextException( "onlineResource isn't allowed to be null" );
172            }
173            this.onlineResource = onlineResource;
174        }
175    
176        /**
177         * returns the capabilities of the encapsulated server
178         *
179         * @return the capabilities of the encapsulated server
180         */
181        public OGCCapabilities getCapabilities() {
182            return capabilities;
183        }
184    
185        /**
186         * @see #getCapabilities()
187         * @param capabilities
188         */
189        public void setCapabilities( OGCCapabilities capabilities ) {
190            this.capabilities = capabilities;
191        }
192    
193        @Override
194        public boolean equals( Object other ) {
195            if ( other == null || !( other instanceof Server ) ) {
196                return false;
197            }
198            Server os = (Server) other;
199            return os.getOnlineResource().equals( getOnlineResource() ) && os.getService().equals( getService() )
200                   && os.getVersion().equals( getVersion() );
201        }
202    
203    }