public class DataSyncTask extends Object implements org.exist.storage.SystemTask
DATA_DIR will be synchronized to a collection specified by the parameter COLLECTION_PARAM recursively. If the target collection does not exist it will be created. Files and collections that are new or newer than the one in the target collection will be written to that collection. Files and collections that are not present in the source directory will be removed from the collection, this can be turned off via a boolean parameter REMOVE_FROM_COLLECTION_PARAM. Owner and group of collections and documents can be provided in parameters OWNERPARAM and GROUPPARAM, otherwise they will be the same as the owner and group of the parent collection of the provided collection parameter. After syncing cache is cleared to prevent problems, this can be turned off via boolean parameter CLEAR_CACHE_PARAM. NOTE that the sync will partially succeed when during syncing an exception occurs, collections and files added or removed before the exception will remain added/removed. Meant to be used as a start-up task, DataSyncTaskCron is meant to be scheduled as a cronjob.| Modifier and Type | Field and Description |
|---|---|
static String |
CLEAR_CACHE_PARAM |
static String |
CLEAR_CACHE_XQ
should be placed in the root of your jar
|
static String |
COLLECTION_PARAM |
static String |
DATA_DIR
default data dir on filesystem (i.e.
|
static String |
DATADIR_PARAM |
static String |
GROUPPARAM |
static String |
OWNERPARAM |
static String |
REMOVE_FROM_COLLECTION_PARAM |
static String |
XMLDBPREFIX |
| Constructor and Description |
|---|
DataSyncTask() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
afterCheckpoint() |
void |
configure(org.exist.util.Configuration config,
Properties properties) |
void |
execute(org.exist.storage.DBBroker broker,
org.exist.storage.txn.Txn transaction) |
String |
getName() |
protected void |
storeInCollection(Path fileToStore,
org.exist.xmldb.XmldbURI documentInCollection,
org.exist.collections.Collection collection,
org.exist.storage.txn.Txn transaction,
org.exist.storage.DBBroker broker)
This method uses either
Collection.store(Txn, DBBroker, IndexInfo, InputSource)
after validation to store the document, or Collection.addBinaryResource(Txn, DBBroker, XmldbURI, InputStream, String, long)
for file types other than xml. |
public static final String DATA_DIR
public static final String COLLECTION_PARAM
public static final String DATADIR_PARAM
public static final String REMOVE_FROM_COLLECTION_PARAM
public static final String OWNERPARAM
public static final String GROUPPARAM
public static final String XMLDBPREFIX
public static final String CLEAR_CACHE_XQ
public static final String CLEAR_CACHE_PARAM
public String getName()
getName in interface org.exist.storage.SystemTaskpublic void configure(org.exist.util.Configuration config,
Properties properties)
throws org.exist.EXistException
configure in interface org.exist.storage.SystemTaskorg.exist.EXistExceptionpublic void execute(org.exist.storage.DBBroker broker,
org.exist.storage.txn.Txn transaction)
throws org.exist.EXistException
execute in interface org.exist.storage.SystemTaskorg.exist.EXistExceptionprotected void storeInCollection(Path fileToStore, org.exist.xmldb.XmldbURI documentInCollection, org.exist.collections.Collection collection, org.exist.storage.txn.Txn transaction, org.exist.storage.DBBroker broker) throws Exception
Collection.store(Txn, DBBroker, IndexInfo, InputSource)
after validation to store the document, or Collection.addBinaryResource(Txn, DBBroker, XmldbURI, InputStream, String, long)
for file types other than xml.fileToStore - documentInCollection - collection - transaction - broker - org.exist.EXistExceptionorg.exist.security.PermissionDeniedExceptionSAXExceptionorg.exist.util.LockExceptionIOExceptionExceptionpublic boolean afterCheckpoint()
afterCheckpoint in interface org.exist.storage.SystemTaskCopyright © 2020–2022 Fryske Akademy. All rights reserved.