Nuxeo ECM Projects 5.4.3-SNAPSHOT

org.nuxeo.ecm.core.storage.sql
Class DefaultBinaryManager

java.lang.Object
  extended by org.nuxeo.ecm.core.storage.sql.DefaultBinaryManager
All Implemented Interfaces:
BinaryManager
Direct Known Subclasses:
XORBinaryManager

public class DefaultBinaryManager
extends Object
implements BinaryManager

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:

Author:
Florent Guillaume

Nested Class Summary
static class DefaultBinaryManager.DefaultBinaryGarbageCollector
           
static class DefaultBinaryManager.NullBinaryScrambler
          A BinaryScrambler that does nothing.
static class DefaultBinaryManager.ScrambledBinary
          A Binary that is unscrambled on read using a BinaryScrambler.
static class DefaultBinaryManager.ScrambledFileInputStream
          A FileInputStream that is unscrambled on read using a BinaryScrambler.
static class DefaultBinaryManager.ScrambledStreamSource
          A FileSource that is unscrambled on read using a BinaryScrambler.
 
Field Summary
static String CONFIG_FILE
           
static String DATA
           
static int DEFAULT_DEPTH
           
static String DEFAULT_DIGEST
           
static String DEFAULT_PATH
           
static int MAX_BUF_SIZE
           
static int MIN_BUF_SIZE
           
static String TMP
           
 
Constructor Summary
DefaultBinaryManager()
           
 
Method Summary
 Binary getBinary(InputStream in)
          Saves the given input stream into a Binary.
 Binary getBinary(String digest)
          Returns a Binary corresponding to the given digest.
 File getFileForDigest(String digest, boolean createDir)
          Gets a file representing the storage for a given digest.
 BinaryGarbageCollector getGarbageCollector()
          Returns the Binary Garbage Collector that can be used for this binary manager.
 File getStorageDir()
           
 void initialize(RepositoryDescriptor repositoryDescriptor)
          Initializer.
static String toHexString(byte[] data)
           
static void touch(File file)
          Sets the last modification date to now on a file
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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

DEFAULT_PATH

public static final String DEFAULT_PATH
See Also:
Constant Field Values

DATA

public static final String DATA
See Also:
Constant Field Values

TMP

public static final String TMP
See Also:
Constant Field Values

CONFIG_FILE

public static final String CONFIG_FILE
See Also:
Constant Field Values

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
Constructor Detail

DefaultBinaryManager

public DefaultBinaryManager()
Method Detail

initialize

public void initialize(RepositoryDescriptor repositoryDescriptor)
                throws IOException
Description copied from interface: BinaryManager
Initializer.

Specified by:
initialize in interface BinaryManager
Throws:
IOException

getStorageDir

public File getStorageDir()

getBinary

public Binary getBinary(InputStream in)
                 throws IOException
Description copied from interface: BinaryManager
Saves the given input stream into a Binary.

Returns a Binary representing the stream. The Binary includes a digest that is a sufficient representation to persist it.

The stream is closed after use.

Specified by:
getBinary in interface BinaryManager
Parameters:
in - the input stream
Returns:
the corresponding binary
Throws:
IOException

getBinary

public Binary getBinary(String digest)
Description copied from interface: BinaryManager
Returns a Binary corresponding to the given digest.

A null is returned if the digest could not be found.

Specified by:
getBinary in interface BinaryManager
Parameters:
digest - the digest, or null
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 digest
createDir - true if the directory containing the file itself must be created
Returns:
the file for this digest

toHexString

public static String toHexString(byte[] data)

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 interface BinaryManager
Returns:
the binary GC

touch

public static void touch(File file)
Sets the last modification date to now on a file

Parameters:
file - the file

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.