Class FSBackend
- java.lang.Object
-
- org.apache.jackrabbit.oak.spi.blob.AbstractSharedBackend
-
- org.apache.jackrabbit.oak.plugins.blob.datastore.FSBackend
-
- All Implemented Interfaces:
SharedBackend
public class FSBackend extends AbstractSharedBackend
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FS_BACKEND_PATH
-
Constructor Summary
Constructors Constructor Description FSBackend()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMetadataRecord(java.io.File input, java.lang.String name)
Adds a metadata record with the specified namevoid
addMetadataRecord(java.io.InputStream input, java.lang.String name)
Adds a metadata record with the specified namevoid
close()
Close backend and release resources like database connection if any.void
deleteAllMetadataRecords(java.lang.String prefix)
Deletes all the metadata records with the specified prefix.boolean
deleteMetadataRecord(java.lang.String name)
Deletes the metadata record with the specified namevoid
deleteRecord(DataIdentifier identifier)
Delete record identified by identifier.boolean
exists(DataIdentifier identifier)
This method check the existence of record in backend.java.util.Iterator<DataIdentifier>
getAllIdentifiers()
Returns identifiers of all records that exists in backend.java.util.List<DataRecord>
getAllMetadataRecords(java.lang.String prefix)
Gets all the metadata with a specified prefix.java.util.Iterator<DataRecord>
getAllRecords()
Returns a list of all DataRecordsDataRecord
getMetadataRecord(java.lang.String name)
Gets the metadata of the specified name.byte[]
getOrCreateReferenceKey()
Returns the reference key of this backend.DataRecord
getRecord(DataIdentifier identifier)
Gets the record with the specified identifiervoid
init()
Initializeboolean
metadataRecordExists(java.lang.String name)
Checks if the metadata record with the specified name exists.java.io.InputStream
read(DataIdentifier identifier)
Return inputstream of record identified by identifier.void
setProperties(java.util.Properties properties)
Properties used to configure the backend.void
write(DataIdentifier identifier, java.io.File file)
Stores file to backend with identifier used as key.
-
-
-
Field Detail
-
FS_BACKEND_PATH
public static final java.lang.String FS_BACKEND_PATH
- See Also:
- Constant Field Values
-
-
Method Detail
-
init
public void init() throws DataStoreException
Description copied from interface:SharedBackend
Initialize- Throws:
DataStoreException
-
read
public java.io.InputStream read(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedBackend
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.
-
write
public void write(DataIdentifier identifier, java.io.File file) throws DataStoreException
Description copied from interface:SharedBackend
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.
-
getRecord
public DataRecord getRecord(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedBackend
Gets the record with the specified identifier- Parameters:
identifier
- the record identifier- Returns:
- the metadata DataRecord
- Throws:
DataStoreException
-
getAllIdentifiers
public java.util.Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
Description copied from interface:SharedBackend
Returns identifiers of all records that exists in backend.- Returns:
- iterator consisting of all identifiers
- Throws:
DataStoreException
-
exists
public boolean exists(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedBackend
This method check the existence of record in backend.- Parameters:
identifier
- identifier to be checked.- Returns:
- true if records exists else false.
- Throws:
DataStoreException
-
deleteRecord
public void deleteRecord(DataIdentifier identifier) throws DataStoreException
Description copied from interface:SharedBackend
Delete record identified by identifier. No-op if identifier not found.- Throws:
DataStoreException
-
addMetadataRecord
public void addMetadataRecord(java.io.InputStream input, java.lang.String name) throws DataStoreException
Description copied from interface:SharedBackend
Adds a metadata record with the specified name- Parameters:
input
- the record input streamname
- the name- Throws:
DataStoreException
-
addMetadataRecord
public void addMetadataRecord(java.io.File input, java.lang.String name) throws DataStoreException
Description copied from interface:SharedBackend
Adds a metadata record with the specified name- Parameters:
input
- the record filename
- the name- Throws:
DataStoreException
-
getMetadataRecord
public DataRecord getMetadataRecord(java.lang.String name)
Description copied from interface:SharedBackend
Gets the metadata of the specified name.- Parameters:
name
- the name of the record- Returns:
- the metadata DataRecord
-
getAllMetadataRecords
public java.util.List<DataRecord> getAllMetadataRecords(java.lang.String prefix)
Description copied from interface:SharedBackend
Gets all the metadata with a specified prefix.- Parameters:
prefix
- the prefix of the records to retrieve- Returns:
- list of all the metadata DataRecords
-
deleteMetadataRecord
public boolean deleteMetadataRecord(java.lang.String name)
Description copied from interface:SharedBackend
Deletes the metadata record with the specified name- Parameters:
name
- the name of the record- Returns:
- boolean to indicate success of deletion
-
deleteAllMetadataRecords
public void deleteAllMetadataRecords(java.lang.String prefix)
Description copied from interface:SharedBackend
Deletes all the metadata records with the specified prefix.- Parameters:
prefix
- the prefix of the record
-
metadataRecordExists
public boolean metadataRecordExists(java.lang.String name)
Description copied from interface:SharedBackend
Checks if the metadata record with the specified name exists.- Parameters:
name
- the name of the record- Returns:
- whether record exists
-
getAllRecords
public java.util.Iterator<DataRecord> getAllRecords()
Description copied from interface:SharedBackend
Returns a list of all DataRecords- Returns:
- iterator over DataRecords
-
close
public void close() throws DataStoreException
Description copied from interface:SharedBackend
Close backend and release resources like database connection if any.- Throws:
DataStoreException
-
getOrCreateReferenceKey
public byte[] getOrCreateReferenceKey() throws DataStoreException
Description copied from class:AbstractSharedBackend
Returns the reference key of this backend. If one does not already exist, it is automatically created in an implementation-specific way. The default implementation simply creates a temporary random key that's valid only until the data store gets restarted. Subclasses can override and/or decorate this method to support a more persistent reference key.This method is called only once during the lifetime of a backend instance and the return value is cached in memory, so it's no problem if the implementation is slow.
- Overrides:
getOrCreateReferenceKey
in classAbstractSharedBackend
- Returns:
- reference key
- Throws:
DataStoreException
- if the key is not available
-
setProperties
public void setProperties(java.util.Properties properties)
Properties used to configure the backend. These are mandatorily to be provided explicitly before calling {init()
is invoked.- Parameters:
properties
- to configure Backend
-
-