/** * Helper method that infers the directory that contains or will contain GWC configuration. * First we will check if a specific location was set using properties GEOWEBCACHE_CONFIG_DIR * and GEOWEBCACHE_CACHE_DIR, then we will check if a location was provided and then fallback on * the default location. */ private static Resource inferConfigDirectory( ResourceStore resourceStore, String providedConfigDirectory) { // check if a specific location was provided using a context property otherwise use the // provided directory String configDirectoryPath = findFirstDefined(GEOWEBCACHE_CONFIG_DIR_PROPERTY, GEOWEBCACHE_CACHE_DIR_PROPERTY) .orElse(providedConfigDirectory); // if the configuration directory stills not defined we use the default location if (configDirectoryPath == null) { configDirectoryPath = DEFAULT_CONFIGURATION_DIR_NAME; } // instantiate a resource for the configuration directory File configurationDirectory = new File(configDirectoryPath); if (configurationDirectory.isAbsolute()) { return Resources.fromPath(configurationDirectory.getAbsolutePath()); } // configuration directory path is relative to geoserver data directory return resourceStore.get(configDirectoryPath); }