Package org.dspace.storage.bitstore
Class BaseBitStoreService
- java.lang.Object
-
- org.dspace.storage.bitstore.BaseBitStoreService
-
- All Implemented Interfaces:
BitStoreService
- Direct Known Subclasses:
DSBitStoreService,S3BitStoreService
public abstract class BaseBitStoreService extends Object implements BitStoreService
BaseBitStoreService base implementation to store and organize assets in digits.
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringCHECKSUMprotected static StringCHECKSUM_ALGORITHMprotected static StringCSAprotected static intdigitsPerLevelprotected static intdirectoryLevelsprotected booleaninitializedprotected static org.apache.logging.log4j.Loggerlogprotected static StringMODIFIEDprotected static StringSIZE_BYTES
-
Constructor Summary
Constructors Constructor Description BaseBitStoreService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>about(File file, List<String> attrs)Retrieves a map of useful metadata about the File (size, checksum, modified)protected voidappendSeparator(StringBuilder path)Append separator to targetStringBuilderprotected booleanendsWithSeparator(StringBuilder bufFilename)Utility that checks string ending with separatorprotected StringextractSubstringFrom(String internalId, int startIndex, int endIndex)Extract substring if is in range, otherwise will truncate to lengthprotected StringgetIntermediatePath(String internalId)Return the intermediate path derived from the internal_id.booleanisInitialized()Determines if a store has been initializedprotected booleanisLonger(String internalId, int endIndex)Checks if theStringis longer thanendIndexprotected voidpopulatePathSplittingId(String internalId, StringBuilder path)Splits internalId into several subpaths usingdigitsPerLevelthat indicates the folder name length, anddirecoryLevelsthat indicates the maximum number of subfolders.protected voidputValueIfExistsKey(List<String> attrs, Map<String,Object> metadata, String key, Object value)protected StringsanitizeIdentifier(String sInternalId)Sanity Check: If the internal ID contains a pathname separator, it's probably an attempt to make a path traversal attack, so ignore the path prefix.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.dspace.storage.bitstore.BitStoreService
about, generateId, get, init, isEnabled, put, remove
-
-
-
-
Field Detail
-
log
protected static org.apache.logging.log4j.Logger log
-
CSA
protected static final String CSA
- See Also:
- Constant Field Values
-
MODIFIED
protected static final String MODIFIED
- See Also:
- Constant Field Values
-
CHECKSUM_ALGORITHM
protected static final String CHECKSUM_ALGORITHM
- See Also:
- Constant Field Values
-
CHECKSUM
protected static final String CHECKSUM
- See Also:
- Constant Field Values
-
SIZE_BYTES
protected static final String SIZE_BYTES
- See Also:
- Constant Field Values
-
initialized
protected boolean initialized
-
digitsPerLevel
protected static final int digitsPerLevel
- See Also:
- Constant Field Values
-
directoryLevels
protected static final int directoryLevels
- See Also:
- Constant Field Values
-
-
Method Detail
-
getIntermediatePath
protected String getIntermediatePath(String internalId)
Return the intermediate path derived from the internal_id. This method splits the id into groups which become subdirectories.- Parameters:
internalId- The internal_id- Returns:
- The path based on the id without leading or trailing separators
-
sanitizeIdentifier
protected String sanitizeIdentifier(String sInternalId)
Sanity Check: If the internal ID contains a pathname separator, it's probably an attempt to make a path traversal attack, so ignore the path prefix. The internal-ID is supposed to be just a filename, so this will not affect normal operation.- Parameters:
sInternalId-- Returns:
- Sanitized id
-
appendSeparator
protected void appendSeparator(StringBuilder path)
Append separator to targetStringBuilder- Parameters:
path-
-
endsWithSeparator
protected boolean endsWithSeparator(StringBuilder bufFilename)
Utility that checks string ending with separator- Parameters:
bufFilename-- Returns:
-
populatePathSplittingId
protected void populatePathSplittingId(String internalId, StringBuilder path)
Splits internalId into several subpaths usingdigitsPerLevelthat indicates the folder name length, anddirecoryLevelsthat indicates the maximum number of subfolders.- Parameters:
internalId- bitStream identifierpath-
-
extractSubstringFrom
protected String extractSubstringFrom(String internalId, int startIndex, int endIndex)
Extract substring if is in range, otherwise will truncate to length- Parameters:
internalId-startIndex-endIndex-- Returns:
-
isLonger
protected boolean isLonger(String internalId, int endIndex)
Checks if theStringis longer thanendIndex- Parameters:
internalId-endIndex-- Returns:
-
about
public Map<String,Object> about(File file, List<String> attrs) throws IOException
Retrieves a map of useful metadata about the File (size, checksum, modified)- Parameters:
file- The File to analyzeattrs- The list of requested metadata values- Returns:
- Map of updated metadatas / attrs
- Throws:
IOException
-
isInitialized
public boolean isInitialized()
Description copied from interface:BitStoreServiceDetermines if a store has been initialized- Specified by:
isInitializedin interfaceBitStoreService- Returns:
booleantrue if initialized, false otherwise
-
-