public abstract class AbstractBinaryManager extends Object implements BinaryManager
Modifier and Type | Field and Description |
---|---|
protected String |
blobProviderId |
static int |
DEFAULT_DEPTH |
static String |
DEFAULT_DIGEST |
protected BinaryManagerRootDescriptor |
descriptor |
static HashMap<Integer,String> |
DIGESTS_BY_LENGTH |
protected BinaryGarbageCollector |
garbageCollector |
static int |
MAX_BUF_SIZE |
static String |
MD5_DIGEST |
static int |
MD5_DIGEST_LENGTH |
static int |
MIN_BUF_SIZE |
static String |
SHA1_DIGEST |
static int |
SHA1_DIGEST_LENGTH |
static String |
SHA256_DIGEST |
static int |
SHA256_DIGEST_LENGTH |
PROP_KEY, PROP_PATH
Constructor and Description |
---|
AbstractBinaryManager() |
Modifier and Type | Method and Description |
---|---|
Binary |
getBinary(Blob blob)
Saves the given blob into a
Binary . |
protected abstract Binary |
getBinary(InputStream in)
Creates a binary value from the given input stream.
|
abstract Binary |
getBinary(String digest)
Returns a
Binary corresponding to the given digest. |
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.
|
void |
removeBinaries(Collection<String> digests)
Remove definitively a set of binaries
|
protected String |
storeAndDigest(InputStream in,
OutputStream out) |
static String |
toHexString(byte[] data) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close
public static final String MD5_DIGEST
public static final String SHA1_DIGEST
public static final String SHA256_DIGEST
public static final int MD5_DIGEST_LENGTH
public static final int SHA1_DIGEST_LENGTH
public static final int SHA256_DIGEST_LENGTH
public static final HashMap<Integer,String> DIGESTS_BY_LENGTH
public static final String DEFAULT_DIGEST
public static final int DEFAULT_DEPTH
protected String blobProviderId
protected BinaryManagerRootDescriptor descriptor
protected BinaryGarbageCollector garbageCollector
public static final int MIN_BUF_SIZE
public static final int MAX_BUF_SIZE
public AbstractBinaryManager()
public void initialize(String blobProviderId, Map<String,String> properties) throws IOException
BinaryManager
initialize
in interface BinaryManager
blobProviderId
- the blob provider id for this binary managerproperties
- initialization propertiesIOException
protected abstract Binary getBinary(InputStream in) throws IOException
IOException
public Binary getBinary(Blob blob) throws IOException
BinaryManager
Binary
.
Returns a Binary
representing the stream. The Binary
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.
getBinary
in interface BinaryManager
blob
- the blobIOException
public abstract Binary getBinary(String digest)
BinaryManager
Binary
corresponding to the given digest.
A null
is returned if the digest could not be found.
getBinary
in interface BinaryManager
digest
- the digest, or null
public void removeBinaries(Collection<String> digests)
BinaryManager
removeBinaries
in interface BinaryManager
digests
- a set of digests, must not be null
.protected BinaryManagerRootDescriptor getDescriptor(File configFile) throws IOException
IOException
protected String storeAndDigest(InputStream in, OutputStream out) throws IOException
IOException
public static String toHexString(byte[] data)
public BinaryGarbageCollector getGarbageCollector()
BinaryManager
Several calls to this method will return the same GC, so that its status can be monitored using
BinaryGarbageCollector.isInProgress()
.
getGarbageCollector
in interface BinaryManager
public String getDigestAlgorithm()
BinaryManager
getDigestAlgorithm
in interface BinaryManager
protected String getDefaultDigestAlgorithm()
Copyright © 2015 Nuxeo SA. All rights reserved.