Package org.nuxeo.ecm.core.blob.binary
Class AbstractBinaryManager
- java.lang.Object
-
- org.nuxeo.ecm.core.blob.binary.AbstractBinaryManager
-
- All Implemented Interfaces:
BinaryManager
- Direct Known Subclasses:
CachingBinaryManager
,GridFSBinaryManager
,LocalBinaryManager
public abstract class AbstractBinaryManager extends Object implements BinaryManager
Abstract BinaryManager implementation that provides a few utilities- Author:
- Florent Guillaume
-
-
Field Summary
Fields Modifier and Type Field Description String
blobProviderId
static int
DEFAULT_DEPTH
static String
DEFAULT_DIGEST
protected BinaryManagerRootDescriptor
descriptor
protected Pattern
digestPattern
static Map<Integer,String>
DIGESTS_BY_LENGTH
protected BinaryGarbageCollector
garbageCollector
static int
MAX_BUF_SIZE
static String
MD5_DIGEST
static int
MD5_DIGEST_LENGTH
Deprecated.since 11.1, unusedstatic int
MIN_BUF_SIZE
protected Map<String,String>
properties
static String
SHA1_DIGEST
Deprecated.since 11.1, unusedstatic int
SHA1_DIGEST_LENGTH
Deprecated.since 11.1, unusedstatic String
SHA256_DIGEST
Deprecated.since 11.1, unusedstatic int
SHA256_DIGEST_LENGTH
Deprecated.since 11.1, unused-
Fields inherited from interface org.nuxeo.ecm.core.blob.binary.BinaryManager
PROP_KEY, PROP_PATH
-
-
Constructor Summary
Constructors Constructor Description AbstractBinaryManager()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description protected void
computeDigestPattern()
protected abstract Binary
getBinary(InputStream in)
Creates a binary value from the given input stream.abstract Binary
getBinary(String digest)
Returns aBinary
corresponding to the given digest.Binary
getBinary(Blob blob)
Saves the given blob into aBinary
.protected String
getDefaultDigestAlgorithm()
Gets the default message digest to use to hash binaries.protected BinaryManagerRootDescriptor
getDescriptor(File configFile)
Gets existing descriptor or creates a default one.String
getDigestAlgorithm()
Returns the digest algorithm used to store and digest binaries.BinaryGarbageCollector
getGarbageCollector()
Returns the Binary Garbage Collector that can be used for this binary manager.void
initialize(String blobProviderId, Map<String,String> properties)
Initializes the binary manager.boolean
isValidDigest(String digest)
void
removeBinaries(Collection<String> digests)
Remove definitively a set of binariesprotected void
setDescriptor(BinaryManagerRootDescriptor descriptor)
protected String
storeAndDigest(InputStream in, OutputStream out)
static String
toHexString(byte[] data)
Deprecated.since 11.1, useHex.encodeHexString(byte[])
directly-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.blob.binary.BinaryManager
close
-
-
-
-
Field Detail
-
MD5_DIGEST
public static final String MD5_DIGEST
- See Also:
- Constant Field Values
-
SHA1_DIGEST
@Deprecated public static final String SHA1_DIGEST
Deprecated.since 11.1, unused- See Also:
- Constant Field Values
-
SHA256_DIGEST
@Deprecated public static final String SHA256_DIGEST
Deprecated.since 11.1, unused- See Also:
- Constant Field Values
-
MD5_DIGEST_LENGTH
@Deprecated public static final int MD5_DIGEST_LENGTH
Deprecated.since 11.1, unused- See Also:
- Constant Field Values
-
SHA1_DIGEST_LENGTH
@Deprecated public static final int SHA1_DIGEST_LENGTH
Deprecated.since 11.1, unused- See Also:
- Constant Field Values
-
SHA256_DIGEST_LENGTH
@Deprecated public static final int SHA256_DIGEST_LENGTH
Deprecated.since 11.1, unused- See Also:
- Constant Field Values
-
DEFAULT_DIGEST
public static final String DEFAULT_DIGEST
- See Also:
- Constant Field Values
-
DEFAULT_DEPTH
public static final int DEFAULT_DEPTH
- See Also:
- Constant Field Values
-
blobProviderId
public String blobProviderId
-
descriptor
protected BinaryManagerRootDescriptor descriptor
-
garbageCollector
protected BinaryGarbageCollector garbageCollector
-
digestPattern
protected Pattern digestPattern
-
MIN_BUF_SIZE
public static final int MIN_BUF_SIZE
- See Also:
- Constant Field Values
-
MAX_BUF_SIZE
public static final int MAX_BUF_SIZE
- See Also:
- Constant Field Values
-
-
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
- Parameters:
blobProviderId
- the blob provider id for this binary managerproperties
- initialization properties- Throws:
IOException
-
setDescriptor
protected void setDescriptor(BinaryManagerRootDescriptor descriptor)
-
getBinary
protected abstract Binary getBinary(InputStream in) throws IOException
Creates a binary value from the given input stream.- Throws:
IOException
-
getBinary
public Binary getBinary(Blob blob) throws IOException
Description copied from interface:BinaryManager
Saves the given blob into aBinary
.Returns a
Binary
representing the stream. TheBinary
includes a digest that is a sufficient representation to persist it.If the blob is a temporary
FileBlob
, then the temporary file may be reused as the final storage location after being moved.- Specified by:
getBinary
in interfaceBinaryManager
- Parameters:
blob
- the blob- Returns:
- the corresponding binary
- Throws:
IOException
-
getBinary
public abstract 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
- Parameters:
digest
- the digest, ornull
- Returns:
- the corresponding binary
-
removeBinaries
public void removeBinaries(Collection<String> digests)
Description copied from interface:BinaryManager
Remove definitively a set of binaries- Specified by:
removeBinaries
in interfaceBinaryManager
- Parameters:
digests
- a set of digests, must not benull
.
-
getDescriptor
protected BinaryManagerRootDescriptor getDescriptor(File configFile) throws IOException
Gets existing descriptor or creates a default one.- Throws:
IOException
-
storeAndDigest
protected String storeAndDigest(InputStream in, OutputStream out) throws IOException
- Throws:
IOException
-
toHexString
@Deprecated public static String toHexString(byte[] data)
Deprecated.since 11.1, useHex.encodeHexString(byte[])
directly
-
computeDigestPattern
protected void computeDigestPattern()
-
isValidDigest
public boolean isValidDigest(String digest)
-
getGarbageCollector
public BinaryGarbageCollector getGarbageCollector()
Description copied from interface:BinaryManager
Returns the Binary Garbage Collector that can be used for this binary manager.Several calls to this method will return the same GC, so that its status can be monitored using
BinaryGarbageCollector.isInProgress()
.- Specified by:
getGarbageCollector
in interfaceBinaryManager
- Returns:
- the binary GC
-
getDigestAlgorithm
public String getDigestAlgorithm()
Description copied from interface:BinaryManager
Returns the digest algorithm used to store and digest binaries.- Specified by:
getDigestAlgorithm
in interfaceBinaryManager
-
getDefaultDigestAlgorithm
protected String getDefaultDigestAlgorithm()
Gets the default message digest to use to hash binaries.- Since:
- 6.0
-
-