Package org.dspace.storage.bitstore
Class BaseBitStoreService
java.lang.Object
org.dspace.storage.bitstore.BaseBitStoreService
- All Implemented Interfaces:
BitStoreService
- Direct Known Subclasses:
DSBitStoreService,JCloudBitStoreService,S3BitStoreService
BaseBitStoreService base implementation to store
and organize assets in digits.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected static final Stringprotected static final intprotected static final intprotected booleanprotected static org.apache.logging.log4j.Loggerprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionRetrieves 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.booleanDetermines if a store has been initializedprotected booleanChecks 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 voidprotected 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, waitMethods inherited from interface org.dspace.storage.bitstore.BitStoreService
about, generateId, get, init, isEnabled, put, remove
-
Field Details
-
log
protected static org.apache.logging.log4j.Logger log -
CSA
- See Also:
-
MODIFIED
- See Also:
-
CHECKSUM_ALGORITHM
- See Also:
-
CHECKSUM
- See Also:
-
SIZE_BYTES
- See Also:
-
initialized
protected boolean initialized -
digitsPerLevel
protected static final int digitsPerLevel- See Also:
-
directoryLevels
protected static final int directoryLevels- See Also:
-
-
Constructor Details
-
BaseBitStoreService
public BaseBitStoreService()
-
-
Method Details
-
getIntermediatePath
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
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
Append separator to targetStringBuilder- Parameters:
path-
-
endsWithSeparator
Utility that checks string ending with separator- Parameters:
bufFilename-- Returns:
-
populatePathSplittingId
Splits internalId into several subpaths usingdigitsPerLevelthat indicates the folder name length, anddirecoryLevelsthat indicates the maximum number of subfolders.- Parameters:
internalId- bitStream identifierpath-
-
extractSubstringFrom
Extract substring if is in range, otherwise will truncate to length- Parameters:
internalId-startIndex-endIndex-- Returns:
-
isLonger
Checks if theStringis longer thanendIndex- Parameters:
internalId-endIndex-- Returns:
-
about
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
-
putValueIfExistsKey
-