Package org.fryske_akademy.exist.jobs
Class DataSyncTask
java.lang.Object
org.fryske_akademy.exist.jobs.DataSyncTask
- All Implemented Interfaces:
org.exist.storage.SystemTask
- Direct Known Subclasses:
DataSyncTaskCron
Files in a directory specified by the parameter
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 for collections and documents can be provided in parameters OWNERPARAM and GROUPPARAM, otherwise they will be the same as the owner and group of the root collection. 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.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringshould be placed in the root of your jarstatic final Stringstatic final Stringdefault data dir on filesystem (i.e. docker mount)static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidconfigure(org.exist.util.Configuration config, Properties properties) voidexecute(org.exist.storage.DBBroker broker, org.exist.storage.txn.Txn transaction) getName()protected voidstoreInCollection(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 callsDBBroker.storeDocument(Txn, XmldbURI, Node, MimeType, Collection)andPermissionFactory.chown(DBBroker, DocumentImpl, Optional, Optional)
-
Field Details
-
DATA_DIR
default data dir on filesystem (i.e. docker mount)- See Also:
-
COLLECTION_PARAM
- See Also:
-
DATADIR_PARAM
- See Also:
-
REMOVE_FROM_COLLECTION_PARAM
- See Also:
-
LOGINFO_PARAM
- See Also:
-
OWNERPARAM
- See Also:
-
GROUPPARAM
- See Also:
-
XMLDBPREFIX
- See Also:
-
CLEAR_CACHE_XQ
should be placed in the root of your jar- See Also:
-
CLEAR_CACHE_PARAM
- See Also:
-
-
Constructor Details
-
DataSyncTask
public DataSyncTask()
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceorg.exist.storage.SystemTask
-
configure
public void configure(org.exist.util.Configuration config, Properties properties) throws org.exist.EXistException - Specified by:
configurein interfaceorg.exist.storage.SystemTask- Throws:
org.exist.EXistException
-
execute
public void execute(org.exist.storage.DBBroker broker, org.exist.storage.txn.Txn transaction) throws org.exist.EXistException - Specified by:
executein interfaceorg.exist.storage.SystemTask- Throws:
org.exist.EXistException
-
storeInCollection
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) throws Exception This method callsDBBroker.storeDocument(Txn, XmldbURI, Node, MimeType, Collection)andPermissionFactory.chown(DBBroker, DocumentImpl, Optional, Optional)- Parameters:
fileToStore-documentInCollection-collection-transaction-broker-- Throws:
org.exist.EXistExceptionorg.exist.security.PermissionDeniedExceptionSAXExceptionorg.exist.util.LockExceptionIOExceptionException
-
afterCheckpoint
public boolean afterCheckpoint()- Specified by:
afterCheckpointin interfaceorg.exist.storage.SystemTask
-