org.apache.jackrabbit.core.data
Interface Backend


public interface Backend

The interface defines the backend which can be plugged into CachingDataStore.


Method Summary
 void close()
          Close backend and release resources like database connection if any.
 Set<DataIdentifier> deleteAllOlderThan(long timestamp)
          Delete all records which are older than timestamp.
 void deleteRecord(DataIdentifier identifier)
          Delete record identified by identifier.
 boolean exists(DataIdentifier identifier)
          This method check the existence of record in backend.
 boolean exists(DataIdentifier identifier, boolean touch)
          This method check the existence of record in backend.
 Iterator<DataIdentifier> getAllIdentifiers()
          Returns identifiers of all records that exists in backend.
 long getLastModified(DataIdentifier identifier)
          Return lastModified of record identified by identifier.
 long getLength(DataIdentifier identifier)
          Return length of record identified by identifier.
 void init(CachingDataStore store, String homeDir, String config)
          This method initialize backend with the configuration.
 InputStream read(DataIdentifier identifier)
          Return inputstream of record identified by identifier.
 void write(DataIdentifier identifier, File file)
          Stores file to backend with identifier used as key.
 void writeAsync(DataIdentifier identifier, File file, AsyncUploadCallback callback)
          Write file to backend in asynchronous mode.
 

Method Detail

init

void init(CachingDataStore store,
          String homeDir,
          String config)
          throws DataStoreException
This method initialize backend with the configuration.

Parameters:
store - CachingDataStore
homeDir - path of repository home dir.
config - path of config property file.
Throws:
DataStoreException

read

InputStream read(DataIdentifier identifier)
                 throws DataStoreException
Return inputstream of record identified by identifier.

Parameters:
identifier - identifier of record.
Returns:
inputstream of the record.
Throws:
DataStoreException - if record not found or any error.

getLength

long getLength(DataIdentifier identifier)
               throws DataStoreException
Return length of record identified by identifier.

Parameters:
identifier - identifier of record.
Returns:
length of the record.
Throws:
DataStoreException - if record not found or any error.

getLastModified

long getLastModified(DataIdentifier identifier)
                     throws DataStoreException
Return lastModified of record identified by identifier.

Parameters:
identifier - identifier of record.
Returns:
lastModified of the record.
Throws:
DataStoreException - if record not found or any error.

write

void write(DataIdentifier identifier,
           File file)
           throws DataStoreException
Stores file to backend with identifier used as key. If key pre-exists, it updates the timestamp of the key.

Parameters:
identifier - key of the file
file - file that would be stored in backend.
Throws:
DataStoreException - for any error.

writeAsync

void writeAsync(DataIdentifier identifier,
                File file,
                AsyncUploadCallback callback)
                throws DataStoreException
Write file to backend in asynchronous mode. Backend implmentation may choose not to write asynchronously but it requires to call AsyncUploadCallback#call(DataIdentifier, File, com.day.crx.cloud.s3.ds.AsyncUploadCallback.RESULT) after upload succeed or failed.

Parameters:
identifier -
file -
callback - Callback interface to called after upload succeed or failed.
Throws:
DataStoreException

getAllIdentifiers

Iterator<DataIdentifier> getAllIdentifiers()
                                           throws DataStoreException
Returns identifiers of all records that exists in backend.

Returns:
iterator consisting of all identifiers
Throws:
DataStoreException

exists

boolean exists(DataIdentifier identifier,
               boolean touch)
               throws DataStoreException
This method check the existence of record in backend. Return true if records exists else false. This method also touch record identified by identifier if touch is true.

Parameters:
identifier -
Throws:
DataStoreException

exists

boolean exists(DataIdentifier identifier)
               throws DataStoreException
This method check the existence of record in backend.

Parameters:
identifier - identifier to be checked.
Returns:
true if records exists else false.
Throws:
DataStoreException

close

void close()
           throws DataStoreException
Close backend and release resources like database connection if any.

Throws:
DataStoreException

deleteAllOlderThan

Set<DataIdentifier> deleteAllOlderThan(long timestamp)
                                       throws DataStoreException
Delete all records which are older than timestamp.

Parameters:
timestamp -
Returns:
Set of identifiers which are deleted.
Throws:
DataStoreException

deleteRecord

void deleteRecord(DataIdentifier identifier)
                  throws DataStoreException
Delete record identified by identifier. No-op if identifier not found.

Parameters:
identifier -
Throws:
DataStoreException


Copyright © 2004-2014 The Apache Software Foundation. All Rights Reserved.