/** * Looks up for a named string property in the order defined by {@link #getProperty(String, * ApplicationContext)} using the internally cached spring application context. * * <p>Care should be taken when using this method. It should not be called during startup or * from tests cases as the internal context will not have been set. * * @param propertyName The property name to lookup. * @return The property value, or null if not found */ public static String getProperty(String propertyName) { return getProperty(propertyName, context); }
private static String getFramePolicy() { String framePolicy = DEFAULT_FRAME_POLICY; if (StringUtils.isNotEmpty(GeoServerExtensions.getProperty(GEOSERVER_XFRAME_POLICY))) { framePolicy = GeoServerExtensions.getProperty(GEOSERVER_XFRAME_POLICY); } return framePolicy; }
/** * Finds the log location in the "context" (system variable, env variable, servlet context) or * uses the provided base location otherwise. * * <p>This method accepts a servlet context directly for cases where the logging location must * be known but the spring application context may not be initialized yet. */ public static String getLogFileLocation(String baseLocation, ServletContext context) { // accept a servlet context directly in the case of startup where the application context // is not yet available, in other cases (like a logging change) we can fall back on the // app context and dervive the servlet context from that String location = context != null ? GeoServerExtensions.getProperty( LoggingUtils.GEOSERVER_LOG_LOCATION, context) : GeoServerExtensions.getProperty(LoggingUtils.GEOSERVER_LOG_LOCATION); if (location == null) { return baseLocation; } else { return location; } } }
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { String strValue = GeoServerExtensions.getProperty( LoggingUtils.RELINQUISH_LOG4J_CONTROL, applicationContext); relinquishLoggingControl = Boolean.valueOf(strValue); } }
/** * Whether the X-Frame-Option header should be set at all. Check this on the fly for easier * testing and in order to potentially make this a GUI controlled option in the future. * * @return */ private static boolean shouldSetPolicy() { boolean shouldSetPolicy = DEFAULT_SHOULD_SET_POLICY; if (StringUtils.isNotEmpty( GeoServerExtensions.getProperty(GEOSERVER_XFRAME_SHOULD_SET_POLICY))) { shouldSetPolicy = Boolean.parseBoolean( GeoServerExtensions.getProperty(GEOSERVER_XFRAME_SHOULD_SET_POLICY)); } return shouldSetPolicy; }
/** * Should local workspaces include layer groups from the global workspace * * @return */ public static boolean workspaceLayerGroupInherit() { if (groupInherit == null) { // Just sets it based on the property so no need to synchronize String value = GeoServerExtensions.getProperty("GEOSERVER_GLOBAL_LAYER_GROUP_INHERIT"); if (value != null) { groupInherit = Boolean.parseBoolean(value); } else { // Local workspaces inherit global layer groups by default. groupInherit = true; } } return groupInherit; }
private static List<String> defaultDisabledServices() { List<String> list = null; String globalEnv = GeoServerExtensions.getProperty("org.geoserver.service.disabled"); if (isNotBlank(globalEnv)) { list = Arrays.asList(globalEnv.split(",")); } return list == null ? Collections.emptyList() : list; }
public CapabilitiesCacheHeadersCallback(GeoServer gs) { this.gs = gs; // initialize headers processing by grabbing the default from a property final String value = GeoServerExtensions.getProperty("CAPABILITIES_CACHE_CONTROL_ENABLED"); if (value != null) { capabilitiesCacheHeadersEnabled = Boolean.parseBoolean(value); } else { capabilitiesCacheHeadersEnabled = true; } if (LOGGER.isLoggable(Level.FINE)) { LOGGER.fine( "Cache control for capabilities requests and 304 support is enabled: " + capabilitiesCacheHeadersEnabled); } }
/** * Looks up for a named string property into the following contexts (in order): * * <ul> * <li>System Property * <li>web.xml init parameters (only works if the context is a {@link WebApplicationContext} * <li>Environment variable * </ul> * * and returns the first non null, non empty value found. * * @param propertyName The property name to be searched * @param context The Spring context (may be null) * @return The property value, or null if not found */ public static String getProperty(String propertyName, ApplicationContext context) { if (context instanceof WebApplicationContext) { return getProperty(propertyName, ((WebApplicationContext) context).getServletContext()); } else { return getProperty(propertyName, (ServletContext) null); } }
/** * Creates the node data from environment variable, system property, etc... define by {@link * #GEOSERVER_NODE_OPTS} */ public static GeoServerNodeData createFromEnvironment() { return createFromString(GeoServerExtensions.getProperty(GEOSERVER_NODE_OPTS)); }
@Override protected void initApplicationContext(ApplicationContext context) { // load life cycle callbacks callbacks = GeoServerExtensions.extensions(DispatcherCallback.class, context); // setup the xml lookahead value String lookahead = GeoServerExtensions.getProperty("XML_LOOKAHEAD", context); if (lookahead != null) { try { int lookaheadValue = Integer.valueOf(lookahead); if (lookaheadValue <= 0) logger.log( Level.SEVERE, "Invalid XML_LOOKAHEAD value, " + "will use " + XML_LOOKAHEAD + " instead"); XML_LOOKAHEAD = lookaheadValue; } catch (Exception e) { logger.log( Level.SEVERE, "Invalid XML_LOOKAHEAD value, " + "will use " + XML_LOOKAHEAD + " instead"); } } }
serviceStrategy = GeoServerExtensions.getProperty("serviceStrategy");
@Override protected T createInstance() throws Exception { String value = GeoServerExtensions.getProperty(propertyName, applicationContext); Object[] logParams = new Object[] {propertyName, value, getDefaultValue()}; if (value == null || value.isEmpty()) { LOGGER.log( Level.INFO, "{0} was empty or undefined, using default \"{2}\" instead", logParams); return getDefaultBean(); } T bean = createInstance(value); if (bean == null) { LOGGER.log( Level.WARNING, "{0} had unexpected value \"{1}\", using default \"{2}\" instead", logParams); bean = getDefaultBean(); } return bean; }
public void mangleURL( StringBuilder baseURL, StringBuilder path, Map<String, String> kvp, URLType type) { // first check the system property, then fall back to configuration String proxyBase = (GeoServerExtensions.getProperty(Requests.PROXY_PARAM) != null) ? GeoServerExtensions.getProperty(Requests.PROXY_PARAM) : this.geoServer.getSettings().getProxyBaseUrl(); // Mangles the URL base in different ways based on a flag // (for two reasons: a) speed; b) to make the admin aware of // possible security liabilities) baseURL = (this.geoServer.getGlobal().isUseHeadersProxyURL() == true && proxyBase != null) ? this.mangleURLHeaders(baseURL, proxyBase) : this.mangleURLFixedURL(baseURL, proxyBase); }
@Test public void testSystemProperty() { // check for a property we did set up in the setUp assertEquals( "ABC", GeoServerExtensions.getProperty("TEST_PROPERTY", (ApplicationContext) null)); assertEquals( "ABC", GeoServerExtensions.getProperty("TEST_PROPERTY", (ServletContext) null)); }
@Test public void testWebProperty() { ServletContext servletContext = createMock(ServletContext.class); expect(servletContext.getInitParameter("TEST_PROPERTY")).andReturn("DEF").anyTimes(); expect(servletContext.getInitParameter("WEB_PROPERTY")).andReturn("WWW").anyTimes(); replay(servletContext); assertEquals("ABC", GeoServerExtensions.getProperty("TEST_PROPERTY", servletContext)); assertEquals("WWW", GeoServerExtensions.getProperty("WEB_PROPERTY", servletContext)); } }
public static CacheProvider findProvider() { CacheProvider cacheProvider = null; String providerNames = GeoServerExtensions.getProperty(BEAN_NAME_PROPERTY); if (providerNames != null) { for (String providerName : providerNames.split("\\s*,\\s*")) {
@Test public void helperProperty() { assertEquals("ABC", GeoServerExtensions.getProperty("TEST_PROPERTY")); GeoServerExtensionsHelper.property("TEST_PROPERTY", "abc"); assertEquals("abc", GeoServerExtensions.getProperty("TEST_PROPERTY")); GeoServerExtensionsHelper.clear(); assertEquals("ABC", GeoServerExtensions.getProperty("TEST_PROPERTY")); }
GeoToolsLoggingRedirection logging = GeoToolsLoggingRedirection.findValue( GeoServerExtensions.getProperty( LoggingUtils.GT2_LOGGING_REDIRECTION, context)); try { GeoServerExtensions.getProperty(LoggingUtils.RELINQUISH_LOG4J_CONTROL, context); if (Boolean.valueOf(relinquishLoggingControl)) { getLogger()
String whitelistProp = GeoServerExtensions.getProperty(WHITELIST_KEY); if (whitelistProp != null) { String[] wildcards = whitelistProp.split("\\s+|(\\s*;\\s*)");