|
| 1 | +<?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" schematypens="http://relaxng.org/ns/structure/1.0"?> |
| 2 | +<?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?> |
| 3 | +<article version="5.0" xmlns="http://docbook.org/ns/docbook" |
| 4 | + xmlns:xlink="http://www.w3.org/1999/xlink"> |
| 5 | + <info> |
| 6 | + <title>Synchronize directory to a collection</title> |
| 7 | + <date>3Q20</date> |
| 8 | + <keywordset> |
| 9 | + <keyword>synchronize</keyword> |
| 10 | + <keyword>filesystem</keyword> |
| 11 | + <keyword>collection</keyword> |
| 12 | + </keywordset> |
| 13 | + </info> |
| 14 | + |
| 15 | + <!-- ================================================================== --> |
| 16 | + |
| 17 | + <para>This article provides information on the synchronization of filesystem data to an exist-db collection.</para> |
| 18 | + |
| 19 | + <!-- ================================================================== --> |
| 20 | + |
| 21 | + <sect1 xml:id="intro"> |
| 22 | + <title>Introduction</title> |
| 23 | + |
| 24 | + <para>An editing workflow often operates on a filesystem directory that eventually may be published using exist-db. |
| 25 | + An <link xlink:href="https://search.maven.org/search?q=a:exist-db-addons">exist-db-addons</link> library, |
| 26 | + available in maven central, enables automatic publication of a directory to a collection. |
| 27 | + </para> |
| 28 | + <para>Files in a directory specified by the parameter <emphasis role="bold" |
| 29 | + >datadir</emphasis> will be synchronized to a collection specified by the parameter |
| 30 | + <emphasis role="bold">collection</emphasis> recursively. If the target collection |
| 31 | + does not exist it will be created. Files and collections that are new or newer than the |
| 32 | + one in the target collection will be written to that collection. Files and collections |
| 33 | + that are not present in the source directory will be removed from the collection, this |
| 34 | + can be turned off via a boolean parameter <emphasis role="bold" |
| 35 | + >removeNotInSource</emphasis>. Owner and group of collections and documents can be |
| 36 | + provided in parameters <emphasis role="bold">owner</emphasis> and <emphasis role="bold" |
| 37 | + >group</emphasis>, otherwise they will be the same as the owner and group of the |
| 38 | + parent collection of the provided collection parameter. After syncing cache is cleared |
| 39 | + to prevent problems, this can be turned off via boolean parameter <emphasis role="bold" |
| 40 | + >clearCache</emphasis>. NOTE that the sync will partially succeed when during |
| 41 | + syncing an exception occurs, collections and files added or removed before the exception |
| 42 | + will remain added/removed. Meant to be used as a start-up task, DataSyncTaskCron is |
| 43 | + meant to be scheduled as a cronjob. </para> |
| 44 | + </sect1> |
| 45 | + |
| 46 | + <!-- ================================================================== --> |
| 47 | + |
| 48 | + <sect1 xml:id="usage"> |
| 49 | + <title>usage</title> |
| 50 | + <sect2> |
| 51 | + <title>Include exist-db-addons</title> |
| 52 | + <para>For example in a Dockerfile:</para> |
| 53 | + <para> |
| 54 | + <programlisting> |
| 55 | +ARG EXISTADDONSERSION=1.6 |
| 56 | +COPY exist-db-addons-${EXISTADDONSERSION}.jar $EXIST_HOME/lib/ |
| 57 | +ENV CLASSPATH=$EXIST_HOME/lib/exist.uber.jar:$EXIST_HOME/lib/exist-db-addons-${EXISTADDONSERSION}.jar |
| 58 | + </programlisting> |
| 59 | + </para> |
| 60 | + </sect2> |
| 61 | + <sect2> |
| 62 | + <title>configure in conf.xml</title> |
| 63 | + <para>The first job below will sync at start-up, the second will sync at 2am, <link xlink:href="../scheduler/scheduler.xml">see scheduler</link> |
| 64 | + <programlisting language="xml"><![CDATA[ |
| 65 | +<job class="org.fryske_akademy.exist.jobs.DataSyncTask" type="system" period="10" repeat="0" > |
| 66 | + <parameter name="collection" value="xmldb:exist:///db/apps/teidictjson/data"/> |
| 67 | + <parameter name="datadir" value="/data"/> |
| 68 | +</job> |
| 69 | +<job class="org.fryske_akademy.exist.jobs.DataSyncTaskCron" type="system" cron-trigger="0 0 2 ? * *" > |
| 70 | + <parameter name="collection" value="xmldb:exist:///db/apps/teidictjson/data"/> |
| 71 | + <parameter name="datadir" value="/data"/> |
| 72 | +</job> |
| 73 | + ]]> |
| 74 | + </programlisting></para> |
| 75 | + </sect2> |
| 76 | + </sect1> |
| 77 | +</article> |
0 commit comments