Class 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 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.
    • Constructor Detail

      • DataSyncTask

        public DataSyncTask()
    • Method Detail

      • getName

        public String getName()
        Specified by:
        getName in interface org.exist.storage.SystemTask
      • configure

        public void configure​(org.exist.util.Configuration config,
                              Properties properties)
                       throws org.exist.EXistException
        Specified by:
        configure in interface org.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:
        execute in interface org.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 calls DBBroker.storeDocument(Txn, XmldbURI, Node, MimeType, Collection) and PermissionFactory.chown(DBBroker, DocumentImpl, Optional, Optional)
        Parameters:
        fileToStore -
        documentInCollection -
        collection -
        transaction -
        broker -
        Throws:
        org.exist.EXistException
        org.exist.security.PermissionDeniedException
        SAXException
        org.exist.util.LockException
        IOException
        Exception
      • afterCheckpoint

        public boolean afterCheckpoint()
        Specified by:
        afterCheckpoint in interface org.exist.storage.SystemTask