org.geotools.xml.resolver
Class SchemaCache

Object
  extended by 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 SchemaResolver#getSimpleHttpResourcePath(URI)).

Author:
Ben Caradoc-Davies (CSIRO Earth Science and Resource Engineering)

Constructor Summary
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
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 of disableAutomaticConfiguration().
 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.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 stored
download - 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 stored
download - 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 of disableAutomaticConfiguration(). Automatic configuration is enabled by default.


isAutomaticConfigurationEnabled

public static boolean isAutomaticConfigurationEnabled()
Is automatic configuration enabled? Automatic configuration is enabled by default.

See Also:
disableAutomaticConfiguration()


Copyright © 1996-2014 Geotools. All Rights Reserved.