001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/test/junit/alltests/Configuration.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: package alltests;
045:
046: import java.io.File;
047: import java.net.MalformedURLException;
048: import java.net.URL;
049: import java.util.Properties;
050:
051: /**
052: * Configuration
053: *
054: * @author <a href="mailto:tfr@users.sourceforge.net">Torsten Friebe </a>
055: * @author last edited by: $Author: apoth $
056: *
057: * @version $Revision: 9335 $, $Date: 2007-12-27 02:51:08 -0800 (Thu, 27 Dec 2007) $
058: */
059: public final class Configuration {
060:
061: /* general configuration */
062: public static URL getBaseDir() throws MalformedURLException {
063: return new File(System.getProperty(Messages
064: .getString("Configuration.basedir"))).toURL();
065: }
066:
067: private static Properties userBuildProperties;
068:
069: static {
070: try {
071: userBuildProperties = new Properties();
072: URL propertiesUrl = new URL(Configuration.getBaseDir(),
073: "build.properties");
074: userBuildProperties.load(propertiesUrl.openStream());
075: } catch (Exception e) {
076: AllTests.LOG.logError(
077: "Can't load ant user build.properties:"
078: + e.getMessage(), e);
079: }
080: };
081:
082: public static final URL getResourceDir()
083: throws MalformedURLException {
084: return new URL(getBaseDir(), Messages
085: .getString("Configuration.resource.dir"));
086: }
087:
088: public static final String PROTOCOL = userBuildProperties
089: .getProperty(userBuildProperties.getProperty(
090: "default.server", "tomcat")
091: + ".schema", "http");
092:
093: public static final String HOST = userBuildProperties.getProperty(
094: userBuildProperties.getProperty("default.server", "tomcat")
095: + ".host", "localhost");
096:
097: public static final int PORT = Integer.parseInt(userBuildProperties
098: .getProperty(userBuildProperties.getProperty(
099: "default.server", "tomcat")
100: + ".port", "8080"));
101:
102: public static final String WEB_DIR = Messages
103: .getString("Configuration.web");
104:
105: public static final String GENERATED_DIR = "output";
106:
107: public static final String REQUESTS_DIR = "requests";
108:
109: public static final String DATASTORE_DIR = "datastore";
110:
111: /* WFS specific configuration */
112: public static final String WFS_WEB_CONTEXT = Messages
113: .getString("Configuration.wfs.webcontext");
114:
115: public static final String WFS_SERVLET = Messages
116: .getString("Configuration.wfs.ogcservice.name");
117:
118: public static final String WFS_CONFIGURATION = Messages
119: .getString("Configuration.wfs.configuration");
120:
121: public static final URL getWFSBaseDir()
122: throws MalformedURLException {
123: return new URL(getResourceDir(), Messages
124: .getString("Configuration.wfs.basedir"));
125: }
126:
127: /* CSW specific configuration */
128: public static final String CSW_WEB_CONTEXT = Messages
129: .getString("Configuration.csw.webcontext");
130:
131: public static final String CSW_CAPABILITIES_GENERATED = Messages
132: .getString("Configuration.csw.capabilities.generated");
133:
134: public static final String CSW_CONFIGURATION_EXAMPLE = Messages
135: .getString("Configuration.csw.configuration.example");
136:
137: public static final String CSW_SERVLET = Messages
138: .getString("Configuration.csw.ogcservice.name");
139:
140: public static final String CSW_INTERNALWFS_FILE = Messages
141: .getString("Configuration.csw.internalwfs.configuration");
142:
143: public static final URL getCSWBaseDir()
144: throws MalformedURLException {
145: return new URL(getResourceDir(), Messages
146: .getString("Configuration.csw.basedir"));
147: }
148:
149: /* WCS specific configuration */
150: public static final String WCS_WEB_CONTEXT = Messages
151: .getString("Configuration.wcs.webcontext");
152:
153: public static final String WCS_CONFIGURATION_FILE = Messages
154: .getString("Configuration.wcs.configuration");
155:
156: public static final String WCS_SERVLET = Messages
157: .getString("Configuration.wcs.ogcservice.name");
158:
159: public static final URL getWCSBaseDir()
160: throws MalformedURLException {
161: return new URL(getResourceDir(), Messages
162: .getString("Configuration.wcs.basedir"));
163: }
164:
165: /* WAS specific configuration */
166: public static final String WAS_WEB_CONTEXT = Messages
167: .getString("Configuration.was.webcontext");
168:
169: public static final String WAS_CONFIGURATION_FILE = Messages
170: .getString("Configuration.was.configuration");
171:
172: public static final String WAS_SERVLET = Messages
173: .getString("Configuration.was.ogcservice.name");
174:
175: public static final URL getWASBaseDir()
176: throws MalformedURLException {
177: return new URL(getResourceDir(), Messages
178: .getString("Configuration.was.basedir"));
179: }
180:
181: public static URL getWASConfigurationURL()
182: throws MalformedURLException {
183: return new URL(getWASBaseDir(), WAS_CONFIGURATION_FILE);
184: }
185:
186: /* WMS specific configuration */
187: public static final String WMS_WEB_CONTEXT = Messages
188: .getString("Configuration.wms.webcontext");
189:
190: public static final String WMS_CONFIGURATION_FILE = Messages
191: .getString("Configuration.wms.configuration");
192:
193: public static final String WMS_SERVLET = Messages
194: .getString("Configuration.wms.ogcservice.name");
195:
196: public static final URL getWMSBaseDir()
197: throws MalformedURLException {
198: return new URL(getResourceDir(), Messages
199: .getString("Configuration.wms.basedir"));
200: }
201:
202: public static final URL getWMSConfDir()
203: throws MalformedURLException {
204: return new URL(getResourceDir(), Messages
205: .getString("Configuration.wms.conf"));
206: }
207:
208: /* SOS specific configuration */
209: public static final String SOS_CONFIGURATION_FILE = Messages
210: .getString("Configuration.sos.configuration");
211:
212: /* WMPS specific configuration */
213: public static final String WMPS_WEB_CONTEXT = Messages
214: .getString("Configuration.wmps.webcontext");
215:
216: public static final String WMPS_CONFIGURATION_FILE = Messages
217: .getString("Configuration.wmps.configuration");
218:
219: public static final String WMPS_SERVLET = Messages
220: .getString("Configuration.wmps.ogcservice.name");
221:
222: public static final URL getWMPSBaseDir()
223: throws MalformedURLException {
224: return new URL(getResourceDir(), Messages
225: .getString("Configuration.wmps.basedir"));
226: }
227:
228: public static final URL getWMPSConfDir()
229: throws MalformedURLException {
230: return new URL(getResourceDir(), Messages
231: .getString("Configuration.wmps.conf"));
232: }
233:
234: /* GML specific configuration */
235: public static final String GML_COMPLEX_EXAMPLE = Messages
236: .getString("Configuration.gml.complexexample");
237:
238: public static final URL getGMLBaseDir()
239: throws MalformedURLException {
240: return new URL(getResourceDir(), Messages
241: .getString("Configuration.gml.basedir"));
242: }
243:
244: /* owsProxy configuration */
245: public static final String OWSPROXY_WMSCONFIGURATION_EXAMPLE = Messages
246: .getString("Configuration.owsproxy.configurationwms");
247:
248: public static final String OWSPROXY_WFSCONFIGURATION_EXAMPLE = Messages
249: .getString("Configuration.owsproxy.configurationwfs");
250:
251: public static final String OWSPROXY_CSWCONFIGURATION_EXAMPLE = Messages
252: .getString("Configuration.owsproxy.configurationcsw");
253:
254: public static final URL getOwsProxyBaseDir()
255: throws MalformedURLException {
256: return new URL(getResourceDir(), Messages
257: .getString("Configuration.owsproxy.basedir"));
258: }
259:
260: /* SLD configuration */
261: public static final String SLD1_EXAMPLE = Messages
262: .getString("Configuration.sld.example1");
263:
264: public static final URL getSLDBaseDir()
265: throws MalformedURLException {
266: return new URL(getResourceDir(), Messages
267: .getString("Configuration.sld.basedir"));
268: }
269:
270: // ///////////////////////////////////////////////////////////////////////////////////////////
271:
272: public static final URL getSOSBaseDir()
273: throws MalformedURLException {
274: return new URL(getResourceDir(), Messages
275: .getString("Configuration.sos.basedir"));
276: }
277:
278: public static URL getWFSURL() throws MalformedURLException {
279: return new URL(PROTOCOL, HOST, PORT, WFS_WEB_CONTEXT);
280: }
281:
282: public static URL getCSWURL() throws MalformedURLException {
283: return new URL(PROTOCOL, HOST, PORT, CSW_WEB_CONTEXT);
284: }
285:
286: public static URL getWFSConfigurationURL()
287: throws MalformedURLException {
288: return new URL(getWFSBaseDir(), WFS_CONFIGURATION);
289: }
290:
291: public static URL getGeneratedWFSCapabilitiesURL()
292: throws MalformedURLException {
293: URL generatedDir = new URL(getWFSBaseDir(), GENERATED_DIR + "/");
294: return new URL(generatedDir, "wfs_capabilities.xml");
295: }
296:
297: public static URL getCSWConfigurationURL()
298: throws MalformedURLException {
299: return new URL(getCSWBaseDir(), CSW_CONFIGURATION_EXAMPLE);
300: }
301:
302: public static URL getCSWInternalWFSConfigurationURL()
303: throws MalformedURLException {
304: return new URL(getCSWBaseDir(), CSW_INTERNALWFS_FILE);
305: }
306:
307: public static URL getGeneratedCSWCapabilitiesURL()
308: throws MalformedURLException {
309: URL generatedDir = new URL(getCSWBaseDir(), GENERATED_DIR + "/");
310: return new URL(generatedDir, CSW_CAPABILITIES_GENERATED);
311: }
312:
313: public static URL getWCSConfigurationURL()
314: throws MalformedURLException {
315: return new URL(getWCSBaseDir(), WCS_CONFIGURATION_FILE);
316: }
317:
318: public static URL getWMSConfigurationURL()
319: throws MalformedURLException {
320: return new URL(getWMSBaseDir(), WMS_CONFIGURATION_FILE);
321: }
322:
323: public static URL getWMPSConfigurationURL()
324: throws MalformedURLException {
325: return new URL(getWMPSBaseDir(), WMPS_CONFIGURATION_FILE);
326: }
327:
328: public static URL getSOSConfigurationURL()
329: throws MalformedURLException {
330: return new URL(getSOSBaseDir(), SOS_CONFIGURATION_FILE);
331: }
332:
333: private Configuration() {
334:
335: }
336:
337: }
|