T - the specific base XML object type being managed@NotThreadSafe public class FilesystemLoadSaveManager<T extends XMLObject> extends AbstractConditionalLoadXMLObjectLoadSaveManager<T>
XMLObjectLoadSaveManager which uses a local filesystem to load and store serialized XML.
The primary required configuration is a base directory path under which files of serialized XML will be located. The file name to use is simply the specified String index key, which is treated as an immediate child file name of the base directory. Callers are required to ensure that index keys are acceptable as file names on the platform(s) on which this manager is used.
| Modifier and Type | Class and Description |
|---|---|
static class |
FilesystemLoadSaveManager.DefaultFileFilter
Default filter used to filter data returned in
listKeys()
and listAll(). |
private class |
FilesystemLoadSaveManager.FileIterable
Iterable which provides lazy iteration over the managed files.
|
private class |
FilesystemLoadSaveManager.FileIterator
Iterator which provides lazy iteration over the managed files.
|
| Modifier and Type | Field and Description |
|---|---|
private File |
baseDirectory
The base directory used for storing individual serialized XML files.
|
private FileFilter |
fileFilter
File filter used in filtering files in
listKeys() and listAll(). |
private Logger |
log
Logger.
|
private net.shibboleth.utilities.java.support.xml.ParserPool |
parserPool
Parser pool instance for deserializing XML from the filesystem.
|
| Constructor and Description |
|---|
FilesystemLoadSaveManager(File baseDir)
Constructor.
|
FilesystemLoadSaveManager(File baseDir,
boolean conditionalLoad)
Constructor.
|
FilesystemLoadSaveManager(File baseDir,
net.shibboleth.utilities.java.support.xml.ParserPool pp)
Constructor.
|
FilesystemLoadSaveManager(File baseDir,
net.shibboleth.utilities.java.support.xml.ParserPool pp,
boolean conditionalLoad)
Constructor.
|
FilesystemLoadSaveManager(String baseDir)
Constructor.
|
FilesystemLoadSaveManager(String baseDir,
boolean conditionalLoad)
Constructor.
|
FilesystemLoadSaveManager(String baseDir,
net.shibboleth.utilities.java.support.xml.ParserPool pp)
Constructor.
|
FilesystemLoadSaveManager(String baseDir,
net.shibboleth.utilities.java.support.xml.ParserPool pp,
boolean conditionalLoad)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
protected File |
buildFile(String key)
Build the target file name from the specified index key and the configured base directory.
|
boolean |
exists(String key)
Evaluate whether an object already exists indexed by the supplied key.
|
protected boolean |
isUnmodifiedSinceLastLoad(String key)
Check whether the data corresponding to the specified key has been modified since the last time
XMLObjectLoadSaveManager.load(String) was called for that key. |
Iterable<net.shibboleth.utilities.java.support.collection.Pair<String,T>> |
listAll()
Return an iterable of all objects under management, along with their associated index key.
|
Set<String> |
listKeys()
Return a set of the index keys of all objects under management.
|
T |
load(String key)
Load a particular object based on the supplied key.
|
boolean |
remove(String key)
Remove the object indexed by the specified key.
|
void |
save(String key,
T xmlObject)
Save a particular object, indexed by the supplied key.
|
void |
save(String key,
T xmlObject,
boolean overwrite)
Save a particular object, indexed by the supplied key.
|
boolean |
updateKey(String currentKey,
String newKey)
Update the key under which a particular object is stored.
|
clearAllLoadLastModified, clearLoadLastModified, getLoadLastModified, isLoadConditionally, updateLoadLastModified, updateLoadLastModifiedprivate Logger log
private File baseDirectory
private net.shibboleth.utilities.java.support.xml.ParserPool parserPool
private FileFilter fileFilter
listKeys() and listAll().public FilesystemLoadSaveManager(@ParameterName(name="baseDir")@Nonnull String baseDir)
baseDir - the base directory, must be an absolute pathpublic FilesystemLoadSaveManager(@ParameterName(name="baseDir")@Nonnull String baseDir, @ParameterName(name="conditionalLoad") boolean conditionalLoad)
baseDir - the base directory, must be an absolute pathconditionalLoad - whether load(String) should behave
as defined in ConditionalLoadXMLObjectLoadSaveManagerpublic FilesystemLoadSaveManager(@ParameterName(name="baseDirFile")@Nonnull File baseDir)
baseDir - the base directory, must be an absolute pathpublic FilesystemLoadSaveManager(@ParameterName(name="baseDirFile")@Nonnull File baseDir, @ParameterName(name="conditionalLoad") boolean conditionalLoad)
baseDir - the base directory, must be an absolute pathconditionalLoad - whether load(String) should behave
as defined in ConditionalLoadXMLObjectLoadSaveManagerpublic FilesystemLoadSaveManager(@ParameterName(name="baseDir")@Nonnull String baseDir, @ParameterName(name="parserPool")@Nullable net.shibboleth.utilities.java.support.xml.ParserPool pp)
baseDir - the base directory, must be an absolute pathpp - the parser pool instance to usepublic FilesystemLoadSaveManager(@ParameterName(name="baseDir")@Nonnull String baseDir, @ParameterName(name="parserPool")@Nullable net.shibboleth.utilities.java.support.xml.ParserPool pp, @ParameterName(name="conditionalLoad") boolean conditionalLoad)
baseDir - the base directory, must be an absolute pathpp - the parser pool instance to useconditionalLoad - whether load(String) should behave
as defined in ConditionalLoadXMLObjectLoadSaveManagerpublic FilesystemLoadSaveManager(@ParameterName(name="baseDirFile")@Nonnull File baseDir, @ParameterName(name="parserPool")@Nullable net.shibboleth.utilities.java.support.xml.ParserPool pp)
baseDir - the base directory, must be an absolute pathpp - the parser pool instance to usepublic FilesystemLoadSaveManager(@ParameterName(name="baseDirFile")@Nonnull File baseDir, @ParameterName(name="parserPool")@Nullable net.shibboleth.utilities.java.support.xml.ParserPool pp, @ParameterName(name="conditionalLoad") boolean conditionalLoad)
baseDir - the base directory, must be an absolute pathpp - the parser pool instance to useconditionalLoad - whether load(String) should behave
as defined in ConditionalLoadXMLObjectLoadSaveManagerpublic Set<String> listKeys() throws IOException
IOException - if there is a fatal error obtaining the keyspublic Iterable<net.shibboleth.utilities.java.support.collection.Pair<String,T>> listAll() throws IOException
IOException - if there is a fatal error loading the managed objectspublic boolean exists(String key) throws IOException
key - the key of the desired objectIOException - if there is a fatal error evaluating object existencepublic T load(String key) throws IOException
key - the key of the desired objectIOException - if there is a fatal error loading the objectprotected boolean isUnmodifiedSinceLastLoad(@Nonnull String key) throws IOException
XMLObjectLoadSaveManager.load(String) was called for that key.isUnmodifiedSinceLastLoad in class AbstractConditionalLoadXMLObjectLoadSaveManager<T extends XMLObject>key - the data keyIOException - if there is a fatal error evaluating the last modified statuspublic void save(String key, T xmlObject) throws IOException
An existing object indexed by the supplied key will not be overwritten.
Instead an IOException will be thrown.
For saving with the overwrite option, see XMLObjectLoadSaveManager.save(String, XMLObject, boolean).
key - the key under which to index the objectxmlObject - the object to saveIOException - if there is a fatal error saving the object, or if an object already exists
indexed by the supplied keypublic void save(String key, T xmlObject, boolean overwrite) throws IOException
key - the key under which to index the objectxmlObject - the object to saveoverwrite - whether or not to overwrite any existing object indexed by the supplied keyIOException - if there is a fatal error saving the object, or if overwrite=false,
if an object already exists indexed by the supplied keypublic boolean remove(String key) throws IOException
key - the key of the object to removeIOException - if there was a fatal error removing the objectpublic boolean updateKey(String currentKey, String newKey) throws IOException
currentKey - the current key under which the object is storednewKey - the new key under which the object should be storedIOException - if there was a fatal error updating the keyprotected File buildFile(String key) throws IOException
key - the target file name index keyIOException - if there is a fatal error constructing or evaluating the candidate target pathCopyright © 1999–2020 Shibboleth Consortium. All rights reserved.