public class VFSBackend extends AbstractBackend
| Constructor and Description | 
|---|
| VFSBackend(org.apache.commons.vfs2.FileObject baseFolder) | 
| Modifier and Type | Method and Description | 
|---|---|
| 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. | 
| protected int | getAsyncWriteExecutorActiveCount()Returns the approximate number of threads that are actively executing asynchronous writing tasks. | 
| protected org.apache.commons.vfs2.FileObject | getBaseFolderObject()Returns the VFS base folder object. | 
| protected org.apache.commons.vfs2.FileObject | getExistingFileObject(DataIdentifier identifier)Returns the identified file object. | 
| long | getLastModified(DataIdentifier identifier)Return lastModified of record identified by identifier. | 
| long | getLength(DataIdentifier identifier)Return length of record identified by identifier. | 
| protected org.apache.commons.vfs2.FileObject | getTouchFileObject(org.apache.commons.vfs2.FileObject fileObject,
                  boolean create)Returns the touch file for the fileObject. | 
| void | init(CachingDataStore store,
    String homeDir,
    String config)This method initialize backend with the configuration. | 
| protected boolean | isTouchFileObject(org.apache.commons.vfs2.FileObject fileObject)Returns true if the fileObject is used for touching purpose. | 
| boolean | isTouchFilePreferred()Returns true if a touch file should be used to save/get the last modified time for a file object. | 
| InputStream | read(DataIdentifier identifier)Return inputstream of record identified by identifier. | 
| protected org.apache.commons.vfs2.FileObject | resolveFileObject(DataIdentifier identifier)Returns a resolved identified file object. | 
| protected String | resolveFileObjectRelPath(DataIdentifier identifier)Returns a resolved relative file object path by the given entry identifier. | 
| void | setTouchFilePreferred(boolean touchFilePreferred)Sets whether or not a touch file should be used to save/get the last modified timestamp for a file object. | 
| 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,
     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. | 
close, createAsyncWriteExecutor, getAsyncWriteExecutor, getAsyncWritePoolSize, getConfig, getDataStore, getHomeDir, setAsyncWritePoolSize, setConfig, setDataStore, setHomeDirpublic void init(CachingDataStore store, String homeDir, String config) throws DataStoreException
init in interface Backendinit in class AbstractBackendstore - CachingDataStorehomeDir - path of repository home dir.config - path of config property file.DataStoreExceptionpublic InputStream read(DataIdentifier identifier) throws DataStoreException
identifier - identifier of record.DataStoreException - if record not found or any error.public long getLength(DataIdentifier identifier) throws DataStoreException
identifier - identifier of record.DataStoreException - if record not found or any error.public long getLastModified(DataIdentifier identifier) throws DataStoreException
identifier - identifier of record.DataStoreException - if record not found or any error.public void write(DataIdentifier identifier, File file) throws DataStoreException
identifier - key of the filefile - file that would be stored in backend.DataStoreException - for any error.public void writeAsync(DataIdentifier identifier, File file, AsyncUploadCallback callback) throws DataStoreException
callback - Callback interface to called after upload succeed or failed.DataStoreExceptionpublic Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException
DataStoreExceptionpublic boolean exists(DataIdentifier identifier, boolean touch) throws DataStoreException
DataStoreExceptionpublic boolean exists(DataIdentifier identifier) throws DataStoreException
identifier - identifier to be checked.DataStoreExceptionpublic void touch(DataIdentifier identifier, long minModifiedDate) throws DataStoreException
DataStoreExceptionpublic void touchAsync(DataIdentifier identifier, long minModifiedDate, AsyncTouchCallback callback) throws DataStoreException
AsyncTouchCallback methods. If identifier's lastModified >
 minModified AsyncTouchCallback.onAbort(AsyncTouchResult) is
 called. Any exception is communicated through
 AsyncTouchCallback.onFailure(AsyncTouchResult) . On successful
 update of lastModified,
 AsyncTouchCallback.onSuccess(AsyncTouchResult)
 is invoked.DataStoreExceptionpublic Set<DataIdentifier> deleteAllOlderThan(long timestamp) throws DataStoreException
Set of identifiers which are deleted.DataStoreExceptionpublic void deleteRecord(DataIdentifier identifier) throws DataStoreException
DataStoreExceptionpublic boolean isTouchFilePreferred()
getBaseFolderObject() is representing a local file system folder (e.g, file://...).
 When returns true, this backend creates a separate file named by the original file base name followed by this touch file name suffix. So, this backend can set the last modified time on the separate touch file instead of trying to do it on the original entry file. For example, WebDAV file system doesn't allow to modify the last modified time on a file.
public void setTouchFilePreferred(boolean touchFilePreferred)
touchFilePreferred - whether or not a touch file should be used to save/get the last modified timestamp for a file objectprotected org.apache.commons.vfs2.FileObject getBaseFolderObject()
protected org.apache.commons.vfs2.FileObject resolveFileObject(DataIdentifier identifier) throws DataStoreException
identifier - data identifierDataStoreException - if any file system exception occursprotected String resolveFileObjectRelPath(DataIdentifier identifier)
identifier - entry identifierprotected org.apache.commons.vfs2.FileObject getExistingFileObject(DataIdentifier identifier) throws DataStoreException
identifier - data identifierDataStoreException - if any file system exception occursprotected boolean isTouchFileObject(org.apache.commons.vfs2.FileObject fileObject)
fileObject - file objectprotected org.apache.commons.vfs2.FileObject getTouchFileObject(org.apache.commons.vfs2.FileObject fileObject,
                                                                boolean create)
                                                         throws DataStoreException
create is false.
 When create is true, it creates a new touch file if no corresponding touch file exists.fileObject - file objectcreate - create a touch file if not existingDataStoreException - if any file system exception occursprotected int getAsyncWriteExecutorActiveCount()
Copyright © 2004–2020 The Apache Software Foundation. All rights reserved.