Package org.geotools.xml.resolver
Class SchemaCache
- Object
-
- SchemaCache
-
public class SchemaCache extends Object
Cache containing XML schemas. (Should also work for other file types.)If configured to permit downloading, schemas not present in the cache are downloaded from the network.
Only http/https URLs are supported.
Files are stored according to the Simple HTTP Resource Path (see {@link SchemaResolver#getSimpleHttpResourcePath(URI))}.
- Author:
- Ben Caradoc-Davies (CSIRO Earth Science and Resource Engineering)
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROVIDED_CACHE_LOCATION_KEY
Key that should be used to setup a system property that sets the location that should be used for schema cache location.
-
Constructor Summary
Constructors Constructor Description SchemaCache(File directory, boolean download)
A cache of XML schemas (or other file types) rooted in the given directory, with optional downloading.SchemaCache(File directory, boolean download, boolean keepQuery)
A cache of XML schemas (or other file types) rooted in the given directory, with optional downloading.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SchemaCache
buildAutomaticallyConfiguredUsingFileUrl(URL url)
If automatic configuration is enabled, recursively search parent directories of file url for a GeoServer data directory or directory containing an existing cache.static void
disableAutomaticConfiguration()
Turn off support for automatic configuration of a cache in GeoServer data directory or detection of an existing cache.static void
enableAutomaticConfiguration()
The opposite ofdisableAutomaticConfiguration()
.File
getDirectory()
Return the root directory of the cache.File
getTempDirectory()
Return the temp directory for not cached downloads (those occurring during another download, to avoid conflicts among threads).static boolean
isAutomaticConfigurationEnabled()
Is automatic configuration enabled?boolean
isDownloadAllowed()
Are schemas not already present in the cache downloaded from the network?String
resolveLocation(String location)
Return the local file URL of a schema, downloading it if not found in the cache.
-
-
-
Field Detail
-
PROVIDED_CACHE_LOCATION_KEY
public static final String PROVIDED_CACHE_LOCATION_KEY
Key that should be used to setup a system property that sets the location that should be used for schema cache location.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
SchemaCache
public SchemaCache(File directory, boolean download)
A cache of XML schemas (or other file types) rooted in the given directory, with optional downloading.- Parameters:
directory
- the directory in which downloaded schemas are storeddownload
- is downloading of schemas permitted. If false, only schemas already present in the cache will be resolved.
-
SchemaCache
public SchemaCache(File directory, boolean download, boolean keepQuery)
A cache of XML schemas (or other file types) rooted in the given directory, with optional downloading.- Parameters:
directory
- the directory in which downloaded schemas are storeddownload
- is downloading of schemas permitted. If false, only schemas already present in the cache will be resolved.keepQuery
- indicates whether or not the query components should be included in the path. If this is set to true then the query portion is converted to an MD5 message digest and that string is used to identify the file in the cache.
-
-
Method Detail
-
getDirectory
public File getDirectory()
Return the root directory of the cache.
-
getTempDirectory
public File getTempDirectory()
Return the temp directory for not cached downloads (those occurring during another download, to avoid conflicts among threads).
-
isDownloadAllowed
public boolean isDownloadAllowed()
Are schemas not already present in the cache downloaded from the network?
-
resolveLocation
public String resolveLocation(String location)
Return the local file URL of a schema, downloading it if not found in the cache.- Parameters:
location
- the absolute http/https URL of the schema- Returns:
- the canonical local file URL of the schema, or null if not found
-
buildAutomaticallyConfiguredUsingFileUrl
public static SchemaCache buildAutomaticallyConfiguredUsingFileUrl(URL url)
If automatic configuration is enabled, recursively search parent directories of file url for a GeoServer data directory or directory containing an existing cache. If found, use it to create a cache in the "app-schema-cache" subdirectory with downloading enabled.- Parameters:
url
- a URL for a file in a GeoServer data directory.- Returns:
- a cache in the "app-schema-cache" subdirectory or null if not found or automatic configuration disabled.
-
disableAutomaticConfiguration
public static void disableAutomaticConfiguration()
Turn off support for automatic configuration of a cache in GeoServer data directory or detection of an existing cache. Intended for testing. Automatic configuration is enabled by default.
-
enableAutomaticConfiguration
public static void enableAutomaticConfiguration()
The opposite ofdisableAutomaticConfiguration()
. Automatic configuration is enabled by default.
-
isAutomaticConfigurationEnabled
public static boolean isAutomaticConfigurationEnabled()
Is automatic configuration enabled? Automatic configuration is enabled by default.- See Also:
disableAutomaticConfiguration()
-
-