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
public class DataSyncTask extends Object implements org.exist.storage.SystemTask
Files in a directory specified by the parameterDATA_DIRwill be synchronized to a collection specified by the parameterCOLLECTION_PARAMrecursively. 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 parameterREMOVE_FROM_COLLECTION_PARAM. Owner and group for collections and documents can be provided in parametersOWNERPARAMandGROUPPARAM, otherwise they will be the same as the owner and group of theroot collection. After syncing cache is cleared to prevent problems, this can be turned off via boolean parameterCLEAR_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,DataSyncTaskCronis meant to be scheduled as a cronjob.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCLEAR_CACHE_PARAMstatic StringCLEAR_CACHE_XQshould be placed in the root of your jarstatic StringCOLLECTION_PARAMstatic StringDATA_DIRdefault data dir on filesystem (i.e.static StringDATADIR_PARAMstatic StringGROUPPARAMstatic StringLOGINFO_PARAMstatic StringOWNERPARAMstatic StringREMOVE_FROM_COLLECTION_PARAMstatic StringXMLDBPREFIX
-
Constructor Summary
Constructors Constructor Description DataSyncTask()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanafterCheckpoint()voidconfigure(org.exist.util.Configuration config, Properties properties)voidexecute(org.exist.storage.DBBroker broker, org.exist.storage.txn.Txn transaction)StringgetName()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 Detail
-
DATA_DIR
public static final String DATA_DIR
default data dir on filesystem (i.e. docker mount)- See Also:
- Constant Field Values
-
COLLECTION_PARAM
public static final String COLLECTION_PARAM
- See Also:
- Constant Field Values
-
DATADIR_PARAM
public static final String DATADIR_PARAM
- See Also:
- Constant Field Values
-
REMOVE_FROM_COLLECTION_PARAM
public static final String REMOVE_FROM_COLLECTION_PARAM
- See Also:
- Constant Field Values
-
LOGINFO_PARAM
public static final String LOGINFO_PARAM
- See Also:
- Constant Field Values
-
OWNERPARAM
public static final String OWNERPARAM
- See Also:
- Constant Field Values
-
GROUPPARAM
public static final String GROUPPARAM
- See Also:
- Constant Field Values
-
XMLDBPREFIX
public static final String XMLDBPREFIX
- See Also:
- Constant Field Values
-
CLEAR_CACHE_XQ
public static final String CLEAR_CACHE_XQ
should be placed in the root of your jar- See Also:
- Constant Field Values
-
CLEAR_CACHE_PARAM
public static final String CLEAR_CACHE_PARAM
- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
public String 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
-
-