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 StringblobProviderIdstatic intDEFAULT_DEPTHstatic StringDEFAULT_DIGESTprotected BinaryManagerRootDescriptordescriptorprotected PatterndigestPatternstatic Map<Integer,String>DIGESTS_BY_LENGTHprotected BinaryGarbageCollectorgarbageCollectorstatic intMAX_BUF_SIZEstatic StringMD5_DIGESTstatic intMD5_DIGEST_LENGTHDeprecated.since 11.1, unusedstatic intMIN_BUF_SIZEprotected Map<String,String>propertiesstatic StringSHA1_DIGESTDeprecated.since 11.1, unusedstatic intSHA1_DIGEST_LENGTHDeprecated.since 11.1, unusedstatic StringSHA256_DIGESTDeprecated.since 11.1, unusedstatic intSHA256_DIGEST_LENGTHDeprecated.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 voidcomputeDigestPattern()protected abstract BinarygetBinary(InputStream in)Creates a binary value from the given input stream.abstract BinarygetBinary(String digest)Returns aBinarycorresponding to the given digest.BinarygetBinary(Blob blob)Saves the given blob into aBinary.protected StringgetDefaultDigestAlgorithm()Gets the default message digest to use to hash binaries.protected BinaryManagerRootDescriptorgetDescriptor(File configFile)Gets existing descriptor or creates a default one.StringgetDigestAlgorithm()Returns the digest algorithm used to store and digest binaries.BinaryGarbageCollectorgetGarbageCollector()Returns the Binary Garbage Collector that can be used for this binary manager.voidinitialize(String blobProviderId, Map<String,String> properties)Initializes the binary manager.booleanisValidDigest(String digest)voidremoveBinaries(Collection<String> digests)Remove definitively a set of binariesprotected voidsetDescriptor(BinaryManagerRootDescriptor descriptor)protected StringstoreAndDigest(InputStream in, OutputStream out)static StringtoHexString(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:BinaryManagerInitializes the binary manager.- Specified by:
initializein 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:BinaryManagerSaves the given blob into aBinary.Returns a
Binaryrepresenting the stream. TheBinaryincludes 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:
getBinaryin interfaceBinaryManager- Parameters:
blob- the blob- Returns:
- the corresponding binary
- Throws:
IOException
-
getBinary
public abstract Binary getBinary(String digest)
Description copied from interface:BinaryManagerReturns aBinarycorresponding to the given digest.A
nullis returned if the digest could not be found.- Specified by:
getBinaryin interfaceBinaryManager- Parameters:
digest- the digest, ornull- Returns:
- the corresponding binary
-
removeBinaries
public void removeBinaries(Collection<String> digests)
Description copied from interface:BinaryManagerRemove definitively a set of binaries- Specified by:
removeBinariesin 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:BinaryManagerReturns 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:
getGarbageCollectorin interfaceBinaryManager- Returns:
- the binary GC
-
getDigestAlgorithm
public String getDigestAlgorithm()
Description copied from interface:BinaryManagerReturns the digest algorithm used to store and digest binaries.- Specified by:
getDigestAlgorithmin interfaceBinaryManager
-
getDefaultDigestAlgorithm
protected String getDefaultDigestAlgorithm()
Gets the default message digest to use to hash binaries.- Since:
- 6.0
-
-