All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vfny.geoserver.config.GlobalConfig Maven / Gradle / Ivy

The newest version!
/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org.  All rights reserved.
 * This code is licensed under the GPL 2.0 license, availible at the root
 * application directory.
 */
package org.vfny.geoserver.config;

import org.vfny.geoserver.global.Data;
import org.vfny.geoserver.global.GeoServer;
import org.vfny.geoserver.global.dto.ContactDTO;
import org.vfny.geoserver.global.dto.DataDTO;
import org.vfny.geoserver.global.dto.GeoServerDTO;
import java.nio.charset.Charset;
import java.util.logging.Level;


/**
 * Global GeoServer Configuration model.
 *
 * 

* GlobalConfig represents the configuration model needed to set up GeoServer * for use. *

* * @author David Zwiers, Refractions Research, Inc. * @version $Id: GlobalConfig.java 10430 2008-10-21 18:57:33Z bmmpxf $ */ public class GlobalConfig { public static final String CONFIG_KEY = "Config.Global"; /** Sets the max number of Features returned by GetFeature */ private int maxFeatures = 20000; /** * XML Verbosity. * *

* Whether newlines and indents should be returned in XML responses. *

* *

* This should be called something other than verbose. Verbose should * control things like printing out "magic" comments that tell people how * to edit the xml files by hand. *

* Default is true */ private boolean verbose = true; /** * Number of decimal places returned in a GetFeature response. * *

* Sets the max number of decimal places past the zero returned in a * GetFeature response. Default is 4. *

* DZ - should it be moved to FeatureTypeInfo level? JG - no WMS also has a * getFeature response */ private int numDecimals = 8; /** * Sets the global character set. * *

* This could use some more testing from international users. What it does * is sets the encoding globally for all postgis database connections (the * charset tag in FeatureTypeInfo), as well as specifying the encoding in * the return * org.vfny.geoserver.config.org.vfny.geoserver.global.xml * header and mime type. *

* *

* The default is UTF-8 *

* *

* Also be warned that GeoServer does not check if the CharSet is valid * before attempting to use it, so it will fail miserably if a bad charset * is used. *

*/ private Charset charSet; /** * The base URL where this servlet will run. * *

* If running locally then http://localhost:8080 (or whatever * port you're running on) should work. *

* *

* If you are serving to the world then this must be the location where the * geoserver servlets appear *

* *

* JG - can we figure this out at runtime? *

*/ private String proxyBaseUrl; /** * Define a base url for the location of the wfs schemas. * *

* By default GeoServer loads and references its own at * /data/capabilities. *

* *

* The standalone Tomcat server needs SchemaBaseUrl defined for validation. *

*/ private String schemaBaseUrl; /** * Defines the Application logging level. * *

* Common options are SEVERE, WARNING, INFO, CONFIG, FINER, FINEST, in * order of Increasing statements logged. *

* *

* There may be more then one point of control - the web containers often * controls logging, the jakarta commons logging system is used by struts, * these names seem taken from the jdk14 logging framework and GeoServer * seems to also use log4j. * * See http://geoserver.org/display/GEOS/GSIP+13+-+Logging * for how this is now implemented. *

*/ private String log4jConfigFile = null; private boolean suppressStdOutLogging = false; /** custom log location **/ private String logLocation = null; private String adminUserName; private String adminPassword; /** Whether the exceptions returned to the client should contain full stack traces */ private boolean verboseExceptions; /** The Server contact person and their contact information. */ private ContactConfig contact = null; private double jaiMemoryCapacity; private double jaiMemoryThreshold; private int jaiTileThreads; private int jaiTilePriority; private boolean jaiRecycling; private boolean imageIOCache; private boolean jaiJPEGNative; private boolean jaiPNGNative; /** tile cache location, full url or relative path */ private String tileCache; private int updateSequence; /** * GlobalConfig constructor. * *

* Creates an instance of GlobalConfig and initializes to default settings. *

* * @see defaultSettings() */ public GlobalConfig() { maxFeatures = 20000; verbose = true; numDecimals = 8; charSet = Charset.forName("UTF-8"); proxyBaseUrl = null; schemaBaseUrl = null; contact = null; verboseExceptions = true; logLocation = null; } /** * Instantiates the global config from the geoServer module. * * @param geoserver The geoServer module. */ public GlobalConfig(GeoServer geoserver) { this((GeoServerDTO) geoserver.toDTO()); } /** * GlobalConfig constructor. * *

* Creates a copy of the GeoServerDTO object provided. Charset is not * cloned, everything else is. *

* * @param g * * @throws NullPointerException DOCUMENT ME! */ public GlobalConfig(GeoServerDTO g) { if (g == null) { throw new NullPointerException(); } maxFeatures = g.getMaxFeatures(); verbose = g.isVerbose(); numDecimals = g.getNumDecimals(); charSet = g.getCharSet(); proxyBaseUrl = g.getProxyBaseUrl(); schemaBaseUrl = g.getSchemaBaseUrl(); adminUserName = g.getAdminUserName(); adminPassword = g.getAdminPassword(); verboseExceptions = g.isVerboseExceptions(); log4jConfigFile = g.getLog4jConfigFile(); suppressStdOutLogging = g.getSuppressStdOutLogging(); logLocation = g.getLogLocation(); jaiMemoryCapacity = g.getJaiMemoryCapacity(); jaiMemoryThreshold = g.getJaiMemoryThreshold(); jaiTileThreads = g.getJaiTileThreads(); jaiTilePriority = g.getJaiTilePriority(); jaiRecycling = g.getJaiRecycling().booleanValue(); imageIOCache = g.getImageIOCache().booleanValue(); jaiJPEGNative = g.getJaiJPEGNative().booleanValue(); jaiPNGNative = g.getJaiPNGNative().booleanValue(); tileCache = g.getTileCache(); updateSequence = g.getUpdateSequence(); if (g.getContact() != null) { contact = new ContactConfig(g.getContact()); } else { contact = new ContactConfig(); } } /** * Implement updateDTO. * *

* Populates this instance with the GeoServerDTO object provided. *

* * @param g A valid GeoServerDTO object to populate this object from * * @throws NullPointerException DOCUMENT ME! * * @see org.vfny.geoserver.config.DataStructure#updateDTO(java.lang.Object) */ public void update(GeoServerDTO g) { if (g == null) { throw new NullPointerException("GeoServer Data Transfer Object required"); } maxFeatures = g.getMaxFeatures(); verbose = g.isVerbose(); numDecimals = g.getNumDecimals(); charSet = g.getCharSet(); schemaBaseUrl = g.getSchemaBaseUrl(); proxyBaseUrl = g.getProxyBaseUrl(); verboseExceptions = g.isVerboseExceptions(); log4jConfigFile = g.getLog4jConfigFile(); suppressStdOutLogging = g.getSuppressStdOutLogging(); logLocation = g.getLogLocation(); jaiMemoryCapacity = g.getJaiMemoryCapacity(); jaiMemoryThreshold = g.getJaiMemoryThreshold(); jaiTileThreads = g.getJaiTileThreads(); jaiTilePriority = g.getJaiTilePriority(); jaiRecycling = g.getJaiRecycling().booleanValue(); imageIOCache = g.getImageIOCache().booleanValue(); jaiJPEGNative = g.getJaiJPEGNative().booleanValue(); jaiPNGNative = g.getJaiPNGNative().booleanValue(); tileCache = g.getTileCache(); updateSequence = g.getUpdateSequence(); if (g.getContact() != null) { contact = new ContactConfig(g.getContact()); } else { contact = new ContactConfig(); } } /** * Implement toDTO. * *

* Creates a copy of the data in a GeoServerDTO representation *

* * @return a copy of the data in a GeoServerDTO representation * * @see org.vfny.geoserver.config.DataStructure#toDTO() */ public GeoServerDTO toDTO() { GeoServerDTO g = new GeoServerDTO(); g.setMaxFeatures(maxFeatures); g.setVerbose(verbose); g.setAdminPassword(adminPassword); g.setAdminUserName(adminUserName); g.setNumDecimals(numDecimals); g.setCharSet(charSet); g.setSchemaBaseUrl(schemaBaseUrl); g.setVerboseExceptions(verboseExceptions); g.setContact((ContactDTO) contact.toDTO()); g.setLog4jConfigFile(log4jConfigFile); g.setSuppressStdOutLogging(suppressStdOutLogging); g.setLogLocation(logLocation); g.setJaiMemoryCapacity(jaiMemoryCapacity); g.setJaiMemoryThreshold(jaiMemoryThreshold); g.setJaiTileThreads(jaiTileThreads); g.setJaiTilePriority(jaiTilePriority); g.setJaiRecycling(Boolean.valueOf(jaiRecycling)); g.setImageIOCache(Boolean.valueOf(imageIOCache)); g.setJaiJPEGNative(Boolean.valueOf(jaiJPEGNative)); g.setJaiPNGNative(Boolean.valueOf(jaiPNGNative)); g.setProxyBaseUrl(proxyBaseUrl); g.setTileCache(tileCache); g.setUpdateSequence(updateSequence); return g; } /** * getBaseUrl purpose. * *

* Description ... *

* * @return */ public String getProxyBaseUrl() { return proxyBaseUrl; } /** * getCharSet purpose. * *

* Description ... *

* * @return */ public Charset getCharSet() { return charSet; } /** * getContact purpose. * *

* Description ... *

* * @return */ public ContactConfig getContact() { return contact; } /** * getMaxFeatures purpose. * *

* Description ... *

* * @return */ public int getMaxFeatures() { return maxFeatures; } /** * getNumDecimals purpose. * *

* Description ... *

* * @return */ public int getNumDecimals() { return numDecimals; } /** * getSchemaBaseUrl purpose. * *

* Description ... *

* * @return */ public String getSchemaBaseUrl() { return schemaBaseUrl; } /** * isVerbose purpose. * *

* Description ... *

* * @return */ public boolean isVerbose() { return verbose; } /** * setBaseUrl purpose. * *

* Description ... *

* * @param url */ public void setProxyBaseUrl(String url) { proxyBaseUrl = url; } /** * setCharSet purpose. * *

* Description ... *

* * @param charset */ public void setCharSet(Charset charset) { if (charset == null) { charset = Charset.forName("ISO-8859-1"); } charSet = charset; } /** * setContact purpose. * *

* Description ... *

* * @param contact */ public void setContact(ContactConfig contact) { if (contact == null) { contact = new ContactConfig(); } this.contact = contact; } /** * setMaxFeatures purpose. * *

* Description ... *

* * @param i */ public void setMaxFeatures(int i) { maxFeatures = i; } /** * setNumDecimals purpose. * *

* Description ... *

* * @param i */ public void setNumDecimals(int i) { numDecimals = i; } /** * setSchemaBaseUrl purpose. * *

* Description ... *

* * @param url */ public void setSchemaBaseUrl(String url) { schemaBaseUrl = url; } /** * setVerbose purpose. * *

* Description ... *

* * @param b */ public void setVerbose(boolean b) { verbose = b; } /** * getLoggingLevel purpose. * *

* Description ... *

* * @return */ public String getLog4jConfigFile() { return log4jConfigFile; } /** * setLoggingLevel purpose. * *

* Description ... *

* * @param level */ public void setLog4jConfigFile(String s) { log4jConfigFile = s; } /** * Gets the user name of the administrator. * * @return The user name to be checked for on login. */ public String getAdminUserName() { return adminUserName; } /** * Gets the password of the administrator. * * @return The password to be checked for on login. */ public String getAdminPassword() { return adminPassword; } /** * Sets the user name of the administrator of GeoServer, for login * purposes. * * @param username the String to set as the admin username. */ public void setAdminUserName(String username) { this.adminUserName = username; } /** * Sets the password of the administrator of GeoServer, for login purposes. * * @param password The password to set as the login password. */ public void setAdminPassword(String password) { this.adminPassword = password; } /** * Should we display stackTraces or not? (And give them a nice little * message instead?) * * @return Returns the showStackTraces. */ public boolean isVerboseExceptions() { return verboseExceptions; } /** * If set to true, response exceptions will throw their stack trace back to * the end user. * * @param showStackTraces The showStackTraces to set. */ public void setVerboseExceptions(boolean showStackTraces) { this.verboseExceptions = showStackTraces; } /** * @return The string representation of the path on disk in which the * server logs to. */ public String getLogLocation() { return logLocation; } /** * @param logLocation The string representation of the path on disk in which * the server logs to. */ public void setLogLocation(String logLocation) { this.logLocation = logLocation; } /** * @return True if the server is logging to file, otherwise false. */ public boolean getSuppressStdOutLogging() { return suppressStdOutLogging; } /** * Toggles server logging to file. */ public void setSuppressStdOutLogging(boolean b) { this.suppressStdOutLogging = b; } public double getJaiMemoryCapacity() { return jaiMemoryCapacity; } public void setJaiMemoryCapacity(double jaiMemoryCapacity) { this.jaiMemoryCapacity = jaiMemoryCapacity; } public boolean isJaiRecycling() { return jaiRecycling; } public void setJaiRecycling(boolean jaiRecycling) { this.jaiRecycling = jaiRecycling; } public boolean isImageIOCache() { return imageIOCache; } public void setImageIOCache(boolean imageIOCache) { this.imageIOCache = imageIOCache; } public boolean isJaiJPEGNative() { return jaiJPEGNative; } public void setJaiJPEGNative(boolean jaiJPEGNative) { this.jaiJPEGNative = jaiJPEGNative; } public boolean isJaiPNGNative() { return jaiPNGNative; } public void setJaiPNGNative(boolean jaiPNGNative) { this.jaiPNGNative = jaiPNGNative; } public double getJaiMemoryThreshold() { return jaiMemoryThreshold; } public void setJaiMemoryThreshold(double jaiMemoryThreshold) { this.jaiMemoryThreshold = jaiMemoryThreshold; } public int getJaiTilePriority() { return jaiTilePriority; } public void setJaiTilePriority(int jaiTilePriority) { this.jaiTilePriority = jaiTilePriority; } public int getJaiTileThreads() { return jaiTileThreads; } public void setJaiTileThreads(int jaiTileThreads) { this.jaiTileThreads = jaiTileThreads; } /** * tile cache parameter * @see GeoServer#getTileCache() */ public String getTileCache() { return tileCache; } public void setTileCache(String tileCache) { this.tileCache = tileCache; } /** * @return the updateSequence */ public int getUpdateSequence() { return updateSequence; } /** * @param updateSequence the updateSequence to set */ public void setUpdateSequence(int updateSequence) { this.updateSequence = updateSequence; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy