Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions src/main/xar-resources/data/datasync/datasync.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<article version="5.0" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink">
<info>
<title>Synchronize directory to a collection</title>
<date>3Q20</date>
<keywordset>
<keyword>synchronize</keyword>
<keyword>filesystem</keyword>
<keyword>collection</keyword>
</keywordset>
</info>

<!-- ================================================================== -->

<para>This article provides information on the synchronization of filesystem data to an exist-db collection.</para>

<!-- ================================================================== -->

<sect1 xml:id="intro">
<title>Introduction</title>

<para>An editing workflow often operates on a filesystem directory that eventually may be published using exist-db.
An <link xlink:href="https://search.maven.org/search?q=a:exist-db-addons">exist-db-addons</link> library,
available in maven central, enables automatic publication of a directory to a collection.
</para>
<para>Files in a directory specified by the parameter <emphasis role="bold"
>datadir</emphasis> will be synchronized to a collection specified by the parameter
<emphasis role="bold">collection</emphasis> 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 <emphasis role="bold"
>removeNotInSource</emphasis>. Owner and group of collections and documents can be
provided in parameters <emphasis role="bold">owner</emphasis> and <emphasis role="bold"
>group</emphasis>, 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 <emphasis role="bold"
>clearCache</emphasis>. 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. </para>
</sect1>

<!-- ================================================================== -->

<sect1 xml:id="usage">
<title>usage</title>
<para>Below a setup for exist-db for data synchronization.</para>
<sect2 xml:id="classpath">
<title>Include exist-db-addons</title>
<para>For example in a Dockerfile:</para>
<programlisting language="Dockerfile" xlink:href="listings/docker.txt"/>
<para>Or include a dependency in exist-db's pom.xml:</para>
<programlisting language="xml" xlink:href="listings/mavenconf.xml"/>
</sect2>
<sect2 xml:id="conf.xml">
<title>configure in conf.xml</title>
<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></para>
<programlisting language="xml" xlink:href="listings/existconf.xml"/>
</sect2>
</sect1>
</article>
3 changes: 3 additions & 0 deletions src/main/xar-resources/data/datasync/listings/docker.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARG EXISTADDONSERSION=2.3
COPY exist-db-addons-${EXISTADDONSERSION}.jar $EXIST_HOME/lib/
ENV CLASSPATH=$EXIST_HOME/lib/exist.uber.jar:$EXIST_HOME/lib/exist-db-addons-${EXISTADDONSERSION}.jar
8 changes: 8 additions & 0 deletions src/main/xar-resources/data/datasync/listings/existconf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<job class="org.fryske_akademy.exist.jobs.DataSyncTask" type="system" period="10" repeat="0" >
<parameter name="collection" value="xmldb:exist:///db/apps/teidictjson/data"/>
<parameter name="datadir" value="/data"/>
</job>
<job class="org.fryske_akademy.exist.jobs.DataSyncTaskCron" type="system" cron-trigger="0 0 2 ? * *" >
<parameter name="collection" value="xmldb:exist:///db/apps/teidictjson/data"/>
<parameter name="datadir" value="/data"/>
</job>
5 changes: 5 additions & 0 deletions src/main/xar-resources/data/datasync/listings/mavenconf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<dependency>
<groupId>org.fryske-akademy</groupId>
<artifactId>exist-db-addons</artifactId>
<version>2.3</version>
</dependency>
7 changes: 7 additions & 0 deletions src/main/xar-resources/data/properties/listings/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
secrets:
- source: ${APPNAME}.properties
target: teidictjson.properties
mode: 0444
secrets:
fhwbjson.properties:
external: true
3 changes: 3 additions & 0 deletions src/main/xar-resources/data/properties/listings/docker.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ARG EXISTADDONSERSION=2.3
COPY exist-db-addons-${EXISTADDONSERSION}.jar $EXIST_HOME/lib/
ENV CLASSPATH=$EXIST_HOME/lib/exist.uber.jar:$EXIST_HOME/lib/exist-db-addons-${EXISTADDONSERSION}.jar
4 changes: 4 additions & 0 deletions src/main/xar-resources/data/properties/listings/existconf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<module uri="http://exist-db.org/xquery/properties"
class="org.fryske_akademy.exist.properties.PropertiesModule">
<parameter name="basePath" value="/run/secrets"/>
</module>
5 changes: 5 additions & 0 deletions src/main/xar-resources/data/properties/listings/mavenconf.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<dependency>
<groupId>org.fryske-akademy</groupId>
<artifactId>exist-db-addons</artifactId>
<version>2.3</version>
</dependency>
10 changes: 10 additions & 0 deletions src/main/xar-resources/data/properties/listings/xquery.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
declare namespace properties="http://exist-db.org/xquery/properties";

declare variable $teidictjson:props := properties:loadProperties("teidictjson.properties");

declare function teidictjson:getProperty($key as xs:string, $default as xs:string) as xs:string {
if (map:contains($teidictjson:props,$key)) then
map:get($teidictjson:props,$key)
else
$default
};
58 changes: 58 additions & 0 deletions src/main/xar-resources/data/properties/properties.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>
<article version="5.0" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink">
<info>
<title>Application properties</title>
<date>3Q20</date>
<keywordset>
<keyword>properties</keyword>
</keywordset>
</info>

<!-- ================================================================== -->

<para>This article provides information on working with property files for exist
applications.</para>

<!-- ================================================================== -->

<sect1 xml:id="intro">
<title>Introduction</title>

<para>For most applications it is a good idea to provide settings in a property file. An
<link xlink:href="https://search.maven.org/search?q=a:exist-db-addons"
>exist-db-addons</link> library, available in maven central, enables you to do so. </para>
</sect1>

<!-- ================================================================== -->

<sect1 xml:id="usage">
<title>usage</title>
<para>Below a setup for exist-db for properties.</para>
<sect2 xml:id="classpath">
<title>Include exist-db-addons</title>
<para>For example in a Dockerfile:</para>
<programlisting language="Dockerfile" xlink:href="listings/docker.txt"/>
<para>Or include a dependency in exist-db's pom.xml:</para>
<programlisting language="xml" xlink:href="listings/mavenconf.xml"/>
</sect2>
<sect2 xml:id="conf.xml">
<title>configure in conf.xml</title>
<para>add the module to exist:</para>
<programlisting language="xml" xlink:href="listings/existconf.xml"/>
</sect2>
<sect2 xml:id="xquery">
<title>use properties in xquery</title>
<para>load and use properties in your xquery</para>
<programlisting language="xquery" xlink:href="listings/xquery.txt"/>
</sect2>
<sect2 xml:id="docker-secret">
<title>optionally mount properties as docker secret</title>
<para>In docker-compose.yml:</para>
<programlisting language="yaml" xlink:href="listings/compose.yml"/>
</sect2>
</sect1>


</article>