Package org.apache.jackrabbit.core.data
Interface Backend
-
- All Known Implementing Classes:
AbstractBackend
,FSBackend
public interface Backend
The interface defines the backend which can be plugged intoCachingDataStore
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Close backend and release resources like database connection if any.java.util.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.java.util.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, java.lang.String homeDir, java.lang.String config)
This method initialize backend with the configuration.java.io.InputStream
read(DataIdentifier identifier)
Return inputstream of record identified by identifier.void
touch(DataIdentifier identifier, long minModifiedDate)
Update the lastModified of record if it's lastModified < minModifiedDate.void
touchAsync(DataIdentifier identifier, long minModifiedDate, AsyncTouchCallback callback)
Update the lastModified of record if it's lastModified < minModifiedDate asynchronously.void
write(DataIdentifier identifier, java.io.File file)
Stores file to backend with identifier used as key.void
writeAsync(DataIdentifier identifier, java.io.File file, AsyncUploadCallback callback)
Write file to backend in asynchronous mode.
-
-
-
Method Detail
-
init
void init(CachingDataStore store, java.lang.String homeDir, java.lang.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
java.io.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, java.io.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 filefile
- file that would be stored in backend.- Throws:
DataStoreException
- for any error.
-
writeAsync
void writeAsync(DataIdentifier identifier, java.io.File file, AsyncUploadCallback callback) throws DataStoreException
Write file to backend in asynchronous mode.- Parameters:
identifier
-file
-callback
- Callback interface to called after upload succeed or failed.- Throws:
DataStoreException
-
getAllIdentifiers
java.util.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
-
touch
void touch(DataIdentifier identifier, long minModifiedDate) throws DataStoreException
Update the lastModified of record if it's lastModified < minModifiedDate.- Parameters:
identifier
-minModifiedDate
-- Throws:
DataStoreException
-
touchAsync
void touchAsync(DataIdentifier identifier, long minModifiedDate, AsyncTouchCallback callback) throws DataStoreException
Update the lastModified of record if it's lastModified < minModifiedDate asynchronously. Result of update is passed using appropriateAsyncTouchCallback
methods. If identifier's lastModified > minModifiedAsyncTouchCallback.onAbort(AsyncTouchResult)
is called. Any exception is communicated throughAsyncTouchCallback.onFailure(AsyncTouchResult)
. On successful update of lastModified,AsyncTouchCallback.onSuccess(AsyncTouchResult)
is invoked.- Parameters:
identifier
-minModifiedDate
-callback
-- Throws:
DataStoreException
-
close
void close() throws DataStoreException
Close backend and release resources like database connection if any.- Throws:
DataStoreException
-
deleteAllOlderThan
java.util.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
-
-