Package digilib.io
Class CdstarArchiveDocuDirectory
- java.lang.Object
-
- digilib.io.DocuDirectory
-
- digilib.io.CdstarArchiveDocuDirectory
-
- All Implemented Interfaces:
Iterable<DocuDirent>
public class CdstarArchiveDocuDirectory extends DocuDirectory
DocuDirectory backed by a CDSTAR archive. Initialized with the CDSTAR archive URL. Reads and caches all file entries in the archive on first access. Treats all file entries in the archive as files in this DocuDirectory (even if their file names contain slashes). Reads image sizes from "exif:Image.ImageHeight" and "exif:Image.ImageWidth" attributes in CDSTAR file metadata.- Author:
- casties
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
CdstarArchiveDocuDirectory.ArchiveInfo
Small data class with information about the CDSTAR archive.
-
Field Summary
Fields Modifier and Type Field Description protected int
archiveBatchSize
number of files to read in one requestprotected String
archiveUrl
static String
FILES_BATCH_SIZE_KEY
digilib-config key for the info request batch sizestatic int
MAX_INFO_REQUESTS
maximum number of info requestsstatic String
META_IMAGE_HEIGHT_KEY
key for image height in CDSTAR metadatastatic String
META_IMAGE_WIDTH_KEY
key for image width in CDSTAR metadatastatic int
REFRESH_DELAY
time in ms to delay the next archive info call and reuse existing informationstatic String
STORAGE_URL_KEY
digilib-config key for the CDSTAR base URL-
Fields inherited from class digilib.io.DocuDirectory
dirMTime, dirName, fileClass, files, isValid, logger, meta, objectATime, parent
-
-
Constructor Summary
Constructors Constructor Description CdstarArchiveDocuDirectory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(String path, FileOps.FileClass fileClass, DigilibConfiguration dlConfig)
Configure object with digilib directory path and a parent DocuDirCache.String
createFilename(String fn)
Returns a possible file name for path fn.String
createParentName(String fn)
Returns a possible parent directory name for path fn.protected CdstarArchiveDocuDirectory.ArchiveInfo
readArchiveInfo(org.apache.http.impl.client.CloseableHttpClient httpclient, int offset, int limit, CdstarArchiveDocuDirectory.ArchiveInfo info)
boolean
readDir()
Read the filesystem directory and fill this object.protected CdstarArchiveDocuDirectory.ArchiveInfo
readFilesJson(InputStream instream, CdstarArchiveDocuDirectory.ArchiveInfo info)
boolean
refresh()
Check to see if the directory has been modified and reread if necessary.-
Methods inherited from class digilib.io.DocuDirectory
checkMeta, find, get, getAccessTime, getDirMTime, getDirName, getMeta, getParent, indexOf, isBasenameAt, isPrefixBasenameAt, isRead, isValid, iterator, readMeta, setParent, size, touch
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Field Detail
-
META_IMAGE_HEIGHT_KEY
public static final String META_IMAGE_HEIGHT_KEY
key for image height in CDSTAR metadata- See Also:
- Constant Field Values
-
META_IMAGE_WIDTH_KEY
public static final String META_IMAGE_WIDTH_KEY
key for image width in CDSTAR metadata- See Also:
- Constant Field Values
-
REFRESH_DELAY
public static final int REFRESH_DELAY
time in ms to delay the next archive info call and reuse existing information- See Also:
- Constant Field Values
-
FILES_BATCH_SIZE_KEY
public static final String FILES_BATCH_SIZE_KEY
digilib-config key for the info request batch size- See Also:
- Constant Field Values
-
archiveBatchSize
protected int archiveBatchSize
number of files to read in one request
-
MAX_INFO_REQUESTS
public static final int MAX_INFO_REQUESTS
maximum number of info requests- See Also:
- Constant Field Values
-
STORAGE_URL_KEY
public static final String STORAGE_URL_KEY
digilib-config key for the CDSTAR base URL- See Also:
- Constant Field Values
-
archiveUrl
protected String archiveUrl
-
-
Method Detail
-
configure
public void configure(String path, FileOps.FileClass fileClass, DigilibConfiguration dlConfig)
Description copied from class:DocuDirectory
Configure object with digilib directory path and a parent DocuDirCache. Directory names at the given path are appended to the base directories from the cache. The directory is checked on disk and isValid is set.- Overrides:
configure
in classDocuDirectory
- Parameters:
path
- digilib directory path namefileClass
- type of files in this DocuDirectorydlConfig
- digilib config- See Also:
DocuDirectory.readDir()
-
readDir
public boolean readDir()
Description copied from class:DocuDirectory
Read the filesystem directory and fill this object. Clears the List and (re)reads all files.- Specified by:
readDir
in classDocuDirectory
- Returns:
- boolean the directory exists
-
readArchiveInfo
protected CdstarArchiveDocuDirectory.ArchiveInfo readArchiveInfo(org.apache.http.impl.client.CloseableHttpClient httpclient, int offset, int limit, CdstarArchiveDocuDirectory.ArchiveInfo info) throws IOException, URISyntaxException
- Parameters:
httpclient
-offset
-info
-- Returns:
- Throws:
IOException
URISyntaxException
-
readFilesJson
protected CdstarArchiveDocuDirectory.ArchiveInfo readFilesJson(InputStream instream, CdstarArchiveDocuDirectory.ArchiveInfo info)
- Parameters:
instream
-info
-- Returns:
-
refresh
public boolean refresh()
Description copied from class:DocuDirectory
Check to see if the directory has been modified and reread if necessary.- Specified by:
refresh
in classDocuDirectory
- Returns:
- boolean the directory is valid
-
createParentName
public String createParentName(String fn)
Description copied from class:DocuDirectory
Returns a possible parent directory name for path fn.- Specified by:
createParentName
in classDocuDirectory
- Parameters:
fn
- the fn- Returns:
- the parent name
-
createFilename
public String createFilename(String fn)
Description copied from class:DocuDirectory
Returns a possible file name for path fn.- Specified by:
createFilename
in classDocuDirectory
- Parameters:
fn
- the fn- Returns:
- the name
-
-