Package org.nuxeo.ecm.core.blob.binary
Class LocalBinaryManager
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
-
- org.nuxeo.ecm.core.blob.binary.LocalBinaryManager
-
- All Implemented Interfaces:
BinaryManager
- Direct Known Subclasses:
AESBinaryManager
,DefaultBinaryManager
public class LocalBinaryManager extends AbstractBinaryManager
A simple filesystem-based binary manager. It stores the binaries according to their digest (hash), which means that no transactional behavior needs to be implemented.A garbage collection is needed to purge unused binaries.
The format of the binaries directory is:
- data/ hierarchy with the actual binaries in subdirectories,
- tmp/ temporary storage during creation,
- config.xml a file containing the configuration used.
- Since:
- 5.6
- Author:
- Florent Guillaume
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LocalBinaryManager.DefaultBinaryGarbageCollector
-
Field Summary
Fields Modifier and Type Field Description static String
CONFIG_FILE
Deprecated.since 11.1, useLocalBlobStoreConfiguration
insteadstatic String
DATA
Deprecated.since 11.1, useLocalBlobStoreConfiguration
insteadstatic String
DEFAULT_PATH
Deprecated.since 11.1, useLocalBlobStoreConfiguration
insteadprotected File
storageDir
static String
TMP
Deprecated.since 11.1, useLocalBlobStoreConfiguration
insteadprotected File
tmpDir
static Pattern
WINDOWS_ABSOLUTE_PATH
Deprecated.since 11.1, useLocalBlobStoreConfiguration
instead-
Fields inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
blobProviderId, DEFAULT_DEPTH, DEFAULT_DIGEST, descriptor, digestPattern, DIGESTS_BY_LENGTH, garbageCollector, MAX_BUF_SIZE, MD5_DIGEST, MD5_DIGEST_LENGTH, MIN_BUF_SIZE, properties, SHA1_DIGEST, SHA1_DIGEST_LENGTH, SHA256_DIGEST, SHA256_DIGEST_LENGTH
-
Fields inherited from interface org.nuxeo.ecm.core.blob.binary.BinaryManager
PROP_KEY, PROP_PATH
-
-
Constructor Summary
Constructors Constructor Description LocalBinaryManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
atomicMove(File source, File dest)
Does an atomic move of the tmp (or source) file to the final file.void
close()
Closes the binary manager and releases all resources and temporary objects held by it.protected void
createGarbageCollector()
protected Binary
getBinary(InputStream in)
Creates a binary value from the given input stream.Binary
getBinary(String digest)
Returns aBinary
corresponding to the given digest.File
getFileForDigest(String digest, boolean createDir)
Gets a file representing the storage for a given digest.File
getStorageDir()
void
initialize(String blobProviderId, Map<String,String> properties)
Initializes the binary manager.protected String
storeAndDigest(InputStream in)
static void
touch(File file)
Sets the last modification date to now on a file-
Methods inherited from class org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
computeDigestPattern, getBinary, getDefaultDigestAlgorithm, getDescriptor, getDigestAlgorithm, getGarbageCollector, isValidDigest, removeBinaries, setDescriptor, storeAndDigest, toHexString
-
-
-
-
Field Detail
-
WINDOWS_ABSOLUTE_PATH
@Deprecated public static final Pattern WINDOWS_ABSOLUTE_PATH
Deprecated.since 11.1, useLocalBlobStoreConfiguration
instead
-
DEFAULT_PATH
@Deprecated public static final String DEFAULT_PATH
Deprecated.since 11.1, useLocalBlobStoreConfiguration
instead- See Also:
- Constant Field Values
-
DATA
@Deprecated public static final String DATA
Deprecated.since 11.1, useLocalBlobStoreConfiguration
instead- See Also:
- Constant Field Values
-
TMP
@Deprecated public static final String TMP
Deprecated.since 11.1, useLocalBlobStoreConfiguration
instead- See Also:
- Constant Field Values
-
CONFIG_FILE
@Deprecated public static final String CONFIG_FILE
Deprecated.since 11.1, useLocalBlobStoreConfiguration
instead- See Also:
- Constant Field Values
-
storageDir
protected File storageDir
-
tmpDir
protected File tmpDir
-
-
Method Detail
-
initialize
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
Description copied from interface:BinaryManager
Initializes the binary manager.- Specified by:
initialize
in interfaceBinaryManager
- Overrides:
initialize
in classAbstractBinaryManager
- Parameters:
blobProviderId
- the blob provider id for this binary managerproperties
- initialization properties- Throws:
IOException
-
close
public void close()
Description copied from interface:BinaryManager
Closes the binary manager and releases all resources and temporary objects held by it.
-
getStorageDir
public File getStorageDir()
-
getBinary
protected Binary getBinary(InputStream in) throws IOException
Description copied from class:AbstractBinaryManager
Creates a binary value from the given input stream.- Specified by:
getBinary
in classAbstractBinaryManager
- Throws:
IOException
-
getBinary
public Binary getBinary(String digest)
Description copied from interface:BinaryManager
Returns aBinary
corresponding to the given digest.A
null
is returned if the digest could not be found.- Specified by:
getBinary
in interfaceBinaryManager
- Specified by:
getBinary
in classAbstractBinaryManager
- Parameters:
digest
- the digest, ornull
- Returns:
- the corresponding binary
-
getFileForDigest
public File getFileForDigest(String digest, boolean createDir)
Gets a file representing the storage for a given digest.- Parameters:
digest
- the digestcreateDir
-true
if the directory containing the file itself must be created- Returns:
- the file for this digest
-
storeAndDigest
protected String storeAndDigest(InputStream in) throws IOException
- Throws:
IOException
-
atomicMove
protected void atomicMove(File source, File dest) throws IOException
Does an atomic move of the tmp (or source) file to the final file.Tries to work well with NFS mounts and different filesystems.
- Throws:
IOException
-
createGarbageCollector
protected void createGarbageCollector()
-
touch
public static void touch(File file)
Sets the last modification date to now on a file- Parameters:
file
- the file
-
-