Repository content replication
| This configuration is optional! |
Each namespace can be configured to mirror content to other locations in the domain.xml config file. Add an element called "replicators" to your namespace configuration, usually after the "indexer" element. Replace 'mynamespace' with your namespace name and adjust the path when needed.
<replicators src="config/slide/mynamespace/replicators.xml" />
Next, create the file config/slide/mynamespace/replicators.xml. The file contains the replicators root node, which can contain one or more replicators. Each replicator mirrors the contents of the uri and all its subfolders. Each replicator can have one ore more targets (locations) where to mirror to. The 'rootpath' usually contains the namespace name. All actions on files and folders are mirrored to the specified 'path' in the 'rootpath'.The 'createparents' options allows for automatic creation of parent paths when they don't exists on the target. When absent the value false is set.
An example replicators.xml file:
<?xml version="1.0"?> <replicators> <replicator uri="/files/content"> <location> <host>remotehost</host> <port>60000</port> <user>username</user> <password>password</password> <realm>some realm</realm> <rootpath>/some</rootpath> <path>/files/replicated-content</path> <createparents>false</createparents> <!-- retry if the http method fails --> <retrycount>3</retrycount> <retrydelayseconds>3</retrydelayseconds> <!-- timeout settings --> <connecttimeoutseconds>30</connecttimeoutseconds> <sockettimeoutseconds>180</sockettimeoutseconds> </location> <location> <host>extraserver</host> <port>60000</port> <user>username</user> <password>password</password> <realm>someother realm</realm> <rootpath>/someother</rootpath> <path>/files/other-replicated-content</path> <createparents>false</createparents> <!-- retry if the http method fails --> <retrycount>3</retrycount> <retrydelayseconds>3</retrydelayseconds> <!-- timeout settings --> <connecttimeoutseconds>30</connecttimeoutseconds> <sockettimeoutseconds>180</sockettimeoutseconds> </location> </replicator> <replicator uri="/files/binaries"> <location> <host>remotehost</host> <port>60000</port> <user>username</user> <password>password</password> <realm>some realm</realm> <rootpath>/some</rootpath> <path>/files/replicated-binaries</path> <createparents>true</createparents> <!-- retry if the http method fails --> <retrycount>3</retrycount> <retrydelayseconds>3</retrydelayseconds> <!-- timeout settings --> <connecttimeoutseconds>30</connecttimeoutseconds> <sockettimeoutseconds>180</sockettimeoutseconds> </location> <exclude uri="path1/internally"/> <exclude uri="intranet"/> </replicator> </replicators>
| Optionally, this can also be configured inline, just like the indexer. Create parent paths is available from version 1.2.11 Exclude paths is available from version 1.2.8 |
| Replication of binaries is known to be broken in 1.2.8. |
Using server-side Javascript (Rhino)
| This feature is available since version 1.2.7. |
Version 1.2.7 contains a new replicator location with which you can use a server-side javascript file to define what actions to take for replication. You can configure it like this:
<?xml version="1.0"?> <replicators> <replicator uri="/files/content"> <location type="javascript"> <script>/absolute/path/to/script/file.js</script> <parameter name="firstparam" value="somevalue"/> <parameter name="secondparam" value="1234" type="int"/> <parameter name="thirdparam" value="false" type="boolean"/> </location> </replicator> </replicators>
The parameters are useful to inject things like user names, passwords, port numbers, etc. The only supported "types" are:
- string (default)
- int
- boolean
Your javascript file might look something like this:
/* * Some important things: * * injected global objects: * - "logger" is the Avalon logkit logger: * http://excalibur.apache.org/apidocs/org/apache/avalon/framework/logger/Logger.html * - any parameter you might have listed in your configuration * * * function parameters: * uri: * is a String with the uri of the changed resource * content: * is an InputStream representing the binary content of the resource * properties: * is an Enumeration containing NodeProperty objects * http://jakarta.apache.org/slide/javadoc/org/apache/slide/content/NodeProperty.html * These properties are old or new, but still present. * removedproperties: * is also an Enumeration containing NodeProperty objects * These properties are no longer present. */ function put(uri, content, properties, removedproperties) { if(logger.isDebugEnabled()) { logger.debug("JS: put! "+uri); logger.debug(firstparam); logger.debug(secondparam); logger.debug(thirdparam); } while(properties.hasMoreElements()) { prop = properties.nextElement(); if(logger.isDebugEnabled()) logger.debug("prop: "+prop.getNamespace()+":"+prop.getName()+" -> "+prop.getValue().toString()); } } function remove(uri) { if(logger.isDebugEnabled()) logger.debug("JS: delete! "+uri); } function mkcol(uri, properties, removedproperties) { if(logger.isDebugEnabled()) logger.debug("JS: mkcol! "+uri); }