SMILA (incubation) API documentation

org.eclipse.smila.binarystorage.internal
Class BinaryStorageServiceImpl

java.lang.Object
  extended by org.eclipse.smila.binarystorage.internal.BinaryStorageServiceImpl
All Implemented Interfaces:
BinaryStorageService

public class BinaryStorageServiceImpl
extends java.lang.Object
implements BinaryStorageService

Binary storage service implementation.

Author:
mcimpean

Field Summary
static java.lang.String CONFIGURATION_DIR
          Path to binary storage configuration file.
static java.lang.String CONFIGURATION_FILE
          Binary storage configuration file name.
 
Constructor Summary
BinaryStorageServiceImpl()
          Default constructor.
 
Method Summary
protected  void activate(ComponentContext context)
          Perform binary storage activation.
protected  void deactivate(ComponentContext context)
          Release binary storage resources.
 byte[] fetchAsByte(java.lang.String id)
          Fetch an already persisted attachment through (BinaryStorageService.storeRecordAttachment) from binary storage as byte array.
 java.io.InputStream fetchAsStream(java.lang.String id)
          Fetch an already persisted attachment through (BinaryStorageService.storeRecordAttachment) from binary storage as InputStream.
 long fetchSize(java.lang.String id)
          Fetch size of persisted attachment.
 void remove(java.lang.String id)
          Removes folder&file structure from the binary storage, based on the passed key.
 void store(java.lang.String id, byte[] blob)
          Save the attachment byte array content in the binary storage location.
 void store(java.lang.String id, java.io.InputStream stream)
          Save the attachment stream in the binary storage location.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURATION_DIR

public static final java.lang.String CONFIGURATION_DIR
Path to binary storage configuration file.

See Also:
Constant Field Values

CONFIGURATION_FILE

public static final java.lang.String CONFIGURATION_FILE
Binary storage configuration file name.

See Also:
Constant Field Values
Constructor Detail

BinaryStorageServiceImpl

public BinaryStorageServiceImpl()
Default constructor.

Method Detail

store

public void store(java.lang.String id,
                  java.io.InputStream stream)
           throws BinaryStorageException
Save the attachment stream in the binary storage location.

Specified by:
store in interface BinaryStorageService
Parameters:
id - String - calculated key (attachment id) from blackboard service based on record Id and file name. The key will serve to identify (persistence scope) current folder & file inside of binary storage.
stream - InputStream - attachment stream
Throws:
BinaryStorageException - in case of any exception
See Also:
BinaryStorageService.store(java.lang.String, java.io.InputStream)

store

public void store(java.lang.String id,
                  byte[] blob)
           throws BinaryStorageException
Save the attachment byte array content in the binary storage location.

Specified by:
store in interface BinaryStorageService
Parameters:
id - String - calculated key (attachment id) from blackboard service based on record Id and file name. The key will serve to identify (persistence scope) current folder & file inside of binary storage.
blob - byte[] - file content to be stored in binary storage
Throws:
BinaryStorageException - in case of any exception
See Also:
org.eclipse.smila.binarystorage.BinaryStorageService#createStorageFile(java.lang.String, java.lang.String, byte[])

fetchAsByte

public byte[] fetchAsByte(java.lang.String id)
                   throws BinaryStorageException
Fetch an already persisted attachment through (BinaryStorageService.storeRecordAttachment) from binary storage as byte array.

Specified by:
fetchAsByte in interface BinaryStorageService
Parameters:
id - String - calculated key (attachment id) from blackboard service based on record Id and file name. The key value passed by the Blackboard service shall be identically with the same one, passed one step previously (through the createStorageFile service) in order to get exactly the same file content.
Returns:
byte[] - file content
Throws:
BinaryStorageException - in case of any exception
See Also:
BinaryStorageService.fetchAsByte(java.lang.String)

fetchAsStream

public java.io.InputStream fetchAsStream(java.lang.String id)
                                  throws BinaryStorageException
Fetch an already persisted attachment through (BinaryStorageService.storeRecordAttachment) from binary storage as InputStream.

Specified by:
fetchAsStream in interface BinaryStorageService
Parameters:
id - String - calculated key (attachment id) from blackboard service based on record Id and file name. The key value passed by the Blackboard service shall be identically with the same one, passed one step previously (through the createStorageFile service) in order to get exactly the same file content.
Returns:
InputStream - file content
Throws:
BinaryStorageException - in case of any exception
See Also:
BinaryStorageService.fetchAsStream(java.lang.String)

remove

public void remove(java.lang.String id)
            throws BinaryStorageException
Removes folder&file structure from the binary storage, based on the passed key.

Specified by:
remove in interface BinaryStorageService
Parameters:
id - String - calculated key (attachment id) from blackboard service based on record Id and file name.
Throws:
BinaryStorageException - in case of any exception
See Also:
org.eclipse.smila.binarystorage.BinaryStorageService#removeRecordAttachment(java.lang.String)

fetchSize

public long fetchSize(java.lang.String id)
               throws BinaryStorageException
Fetch size of persisted attachment.

Specified by:
fetchSize in interface BinaryStorageService
Returns:
int - attachment size
Throws:
BinaryStorageException - in case of any exception
See Also:
BinaryStorageService.fetchSize(java.lang.String)

activate

protected void activate(ComponentContext context)
Perform binary storage activation.

Parameters:
context - ComponentContext

deactivate

protected void deactivate(ComponentContext context)
                   throws BinaryStorageException
Release binary storage resources.

Parameters:
context - ComponentContext.
Throws:
BinaryStorageException

SMILA (incubation) API documentation