public final class BitarchiveAdmin extends Object
Modifier and Type | Method and Description |
---|---|
void |
close()
Close down the bitarchive admin.
|
File |
getAtticPath(File existingFile)
Return the path used to store files that are removed by RemoveAndGetFileMessage.
|
File[] |
getFiles()
Return array with references to all files in the archive.
|
File[] |
getFilesMatching(Pattern regexp)
Return an array of all files in this archive that match a given regular expression on the filename.
|
static BitarchiveAdmin |
getInstance()
Get the one and only instance of the bitarchive admin.
|
File |
getTemporaryPath(String arcFileName,
long requestedSize)
Returns a temporary place for the the file to be stored.
|
boolean |
hasEnoughSpace()
Returns true if we have at least one dir with the required amount of space left.
|
protected boolean |
isBitarchiveDirectory(File theDir)
Checks whether a directory is one of the known bitarchive directories.
|
BitarchiveARCFile |
lookup(String arcFileName)
Return the path that a given arc file can be found in.
|
File |
moveToStorage(File tempLocation)
Moves a file from temporary storage to file storage.
|
void |
updateFileList(File basedir)
Method for updating the filelist for a given basedir.
|
void |
verifyFilelistUpToDate()
Checks whether the filelist is up to date.
|
public void verifyFilelistUpToDate()
public void updateFileList(File basedir) throws ArgumentNotValid, UnknownID, IOFailure
basedir
- The basedir to update the filelist for.ArgumentNotValid
- If basedir is null or if it not a proper directory.UnknownID
- If the basedir cannot be found both the archivedFiles map or the archiveTime map.IOFailure
- If it is not possible to retrieve the canonical file for the basedir.public boolean hasEnoughSpace()
public File getTemporaryPath(String arcFileName, long requestedSize) throws ArgumentNotValid, IOFailure
arcFileName
- The simple name (i.e. no dirs) of the ARC file.requestedSize
- How large the file is in bytes.ArgumentNotValid
- If arcFileName is null or empty, or requestedSize is negative.IOFailure
- if there is no more room left to store this file of size=requestedSizepublic File moveToStorage(File tempLocation) throws IOFailure, ArgumentNotValid
Note: It is checked, if tempLocation resides in directory TEMPORARY_DIRECTORY_NAME and whether the parent of tempLocation is a Bitarchive directory.
tempLocation
- The temporary location where the file was stored. This must be a path returned from
getTemporaryPathIOFailure
- if tempLocation is not created from getTemporaryPath or file cannot be moved to Storage
location.ArgumentNotValid
- If the tempLocation file is null.protected boolean isBitarchiveDirectory(File theDir) throws ArgumentNotValid, IOFailure
theDir
- The dir to checkIOFailure
- if theDir or one of the valid archive directories does not existArgumentNotValid
- if theDir is nullpublic File[] getFiles()
public File[] getFilesMatching(Pattern regexp)
regexp
- A precompiled regular expression matching whole filenames. This will probably be given to a
FilenameFilterpublic BitarchiveARCFile lookup(String arcFileName)
arcFileName
- Name of an arc file (with no path)public static BitarchiveAdmin getInstance()
public void close()
public File getAtticPath(File existingFile)
existingFile
- a File object for an existing file in the bitarchiveCopyright © 2005–2015 The Royal Danish Library, the Danish State and University Library, the National Library of France and the Austrian National Library.. All rights reserved.