Skip to content

Commit 341f6fd

Browse files
authored
Merge pull request #549 from fryske-akademy/props_and_sync
Props and sync
2 parents 77daa1d + a98cb8a commit 341f6fd

File tree

10 files changed

+167
-0
lines changed

10 files changed

+167
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
<para>Below a setup for exist-db for data synchronization.</para>
51+
<sect2 xml:id="classpath">
52+
<title>Include exist-db-addons</title>
53+
<para>For example in a Dockerfile:</para>
54+
<programlisting language="Dockerfile" xlink:href="listings/docker.txt"/>
55+
<para>Or include a dependency in exist-db's pom.xml:</para>
56+
<programlisting language="xml" xlink:href="listings/mavenconf.xml"/>
57+
</sect2>
58+
<sect2 xml:id="conf.xml">
59+
<title>configure in conf.xml</title>
60+
<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>
61+
<programlisting language="xml" xlink:href="listings/existconf.xml"/>
62+
</sect2>
63+
</sect1>
64+
</article>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARG EXISTADDONSERSION=2.3
2+
COPY exist-db-addons-${EXISTADDONSERSION}.jar $EXIST_HOME/lib/
3+
ENV CLASSPATH=$EXIST_HOME/lib/exist.uber.jar:$EXIST_HOME/lib/exist-db-addons-${EXISTADDONSERSION}.jar
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<job class="org.fryske_akademy.exist.jobs.DataSyncTask" type="system" period="10" repeat="0" >
2+
<parameter name="collection" value="xmldb:exist:///db/apps/teidictjson/data"/>
3+
<parameter name="datadir" value="/data"/>
4+
</job>
5+
<job class="org.fryske_akademy.exist.jobs.DataSyncTaskCron" type="system" cron-trigger="0 0 2 ? * *" >
6+
<parameter name="collection" value="xmldb:exist:///db/apps/teidictjson/data"/>
7+
<parameter name="datadir" value="/data"/>
8+
</job>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<dependency>
2+
<groupId>org.fryske-akademy</groupId>
3+
<artifactId>exist-db-addons</artifactId>
4+
<version>2.3</version>
5+
</dependency>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
secrets:
2+
- source: ${APPNAME}.properties
3+
target: teidictjson.properties
4+
mode: 0444
5+
secrets:
6+
fhwbjson.properties:
7+
external: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ARG EXISTADDONSERSION=2.3
2+
COPY exist-db-addons-${EXISTADDONSERSION}.jar $EXIST_HOME/lib/
3+
ENV CLASSPATH=$EXIST_HOME/lib/exist.uber.jar:$EXIST_HOME/lib/exist-db-addons-${EXISTADDONSERSION}.jar
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<module uri="http://exist-db.org/xquery/properties"
2+
class="org.fryske_akademy.exist.properties.PropertiesModule">
3+
<parameter name="basePath" value="/run/secrets"/>
4+
</module>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<dependency>
2+
<groupId>org.fryske-akademy</groupId>
3+
<artifactId>exist-db-addons</artifactId>
4+
<version>2.3</version>
5+
</dependency>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
declare namespace properties="http://exist-db.org/xquery/properties";
2+
3+
declare variable $teidictjson:props := properties:loadProperties("teidictjson.properties");
4+
5+
declare function teidictjson:getProperty($key as xs:string, $default as xs:string) as xs:string {
6+
if (map:contains($teidictjson:props,$key)) then
7+
map:get($teidictjson:props,$key)
8+
else
9+
$default
10+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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>Application properties</title>
7+
<date>3Q20</date>
8+
<keywordset>
9+
<keyword>properties</keyword>
10+
</keywordset>
11+
</info>
12+
13+
<!-- ================================================================== -->
14+
15+
<para>This article provides information on working with property files for exist
16+
applications.</para>
17+
18+
<!-- ================================================================== -->
19+
20+
<sect1 xml:id="intro">
21+
<title>Introduction</title>
22+
23+
<para>For most applications it is a good idea to provide settings in a property file. An
24+
<link xlink:href="https://search.maven.org/search?q=a:exist-db-addons"
25+
>exist-db-addons</link> library, available in maven central, enables you to do so. </para>
26+
</sect1>
27+
28+
<!-- ================================================================== -->
29+
30+
<sect1 xml:id="usage">
31+
<title>usage</title>
32+
<para>Below a setup for exist-db for properties.</para>
33+
<sect2 xml:id="classpath">
34+
<title>Include exist-db-addons</title>
35+
<para>For example in a Dockerfile:</para>
36+
<programlisting language="Dockerfile" xlink:href="listings/docker.txt"/>
37+
<para>Or include a dependency in exist-db's pom.xml:</para>
38+
<programlisting language="xml" xlink:href="listings/mavenconf.xml"/>
39+
</sect2>
40+
<sect2 xml:id="conf.xml">
41+
<title>configure in conf.xml</title>
42+
<para>add the module to exist:</para>
43+
<programlisting language="xml" xlink:href="listings/existconf.xml"/>
44+
</sect2>
45+
<sect2 xml:id="xquery">
46+
<title>use properties in xquery</title>
47+
<para>load and use properties in your xquery</para>
48+
<programlisting language="xquery" xlink:href="listings/xquery.txt"/>
49+
</sect2>
50+
<sect2 xml:id="docker-secret">
51+
<title>optionally mount properties as docker secret</title>
52+
<para>In docker-compose.yml:</para>
53+
<programlisting language="yaml" xlink:href="listings/compose.yml"/>
54+
</sect2>
55+
</sect1>
56+
57+
58+
</article>

0 commit comments

Comments
 (0)