jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1512568 [34/39] - in /jackrabbit/commons/filevault/trunk: ./ parent/ vault-cli/ vault-cli/src/ vault-cli/src/main/ vault-cli/src/main/appassembler/ vault-cli/src/main/assembly/ vault-cli/src/main/java/ vault-cli/src/main/java/org/ vault-cl...
Date Sat, 10 Aug 2013 05:53:54 GMT
Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/pom.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/pom.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/pom.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,130 @@
+<?xml version="1.0"?><!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
+    <modelVersion>4.0.0</modelVersion>
+    <!-- ====================================================================== -->
+    <!-- P A R E N T  P R O J E C T  D E S C R I P T I O N                      -->
+    <!-- ====================================================================== -->
+    <parent>
+        <groupId>org.apache.jackrabbit.vault</groupId>
+        <artifactId>parent</artifactId>
+        <relativePath>../parent/pom.xml</relativePath>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <!-- ====================================================================== -->
+    <!-- P R O J E C T  D E S C R I P T I O N                                   -->
+    <!-- ====================================================================== -->
+    <artifactId>vault-hook-externalclass-test</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <name>Apache Jackrabbit FileVault Package Hook Sling Example</name>
+    <description>
+        Provides an example of a package install hook that uses a class not available in bundles classpath
+    </description>
+
+    <!-- ====================================================================== -->
+    <!-- S C M  D E F I N I T I O N                                             -->
+    <!-- ====================================================================== -->
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test</developerConnection>
+        <url>http://svn.apache.org/viewvc/asf/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test</url>
+    </scm>
+
+
+    <!-- ====================================================================== -->
+    <!-- B U I L D   D E F I N I T I O N                                        -->
+    <!-- ====================================================================== -->
+    <build>
+        <plugins>
+            <!-- assemble dist -->
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <version>2.2</version>
+                <executions>
+                    <execution>
+                        <id>assemble-distribution</id>
+                        <configuration>
+                            <descriptors>
+                                <descriptor>assembly.xml</descriptor>
+                            </descriptors>
+                        </configuration>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>directory-inline</goal>
+                            <goal>attached</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <!-- set main class -->
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-jar-plugin</artifactId>
+                <version>2.3.1</version>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>org.apache.jackrabbit.vault.packaging.hooks.ExampleOsgiHook</mainClass>
+                            <addClasspath>true</addClasspath>
+                        </manifest>
+                    </archive>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <!-- ====================================================================== -->
+    <!-- D E P E N D E N C I E S                                                -->
+    <!-- ====================================================================== -->
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.jackrabbit.vault</groupId>
+            <artifactId>org.apache.jackrabbit.vault</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
+
+        <!-- JCR Stuff -->
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <!-- SLF4j / Log4j -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-log4j12</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.3.0</version>
+            <scope>provided</scope>
+            <optional>true</optional>
+        </dependency>
+    </dependencies>
+
+</project>

Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/config.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/config.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/config.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/config.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,93 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<vaultfs version="1.1">
+    <!--
+        Defines the content aggregation. The order of the defined aggregates
+        is important for finding the correct aggregator.
+    -->
+    <aggregates>
+        <!--
+            Defines an aggregate that handles nt:file and nt:resource nodes.
+        -->
+        <aggregate type="file" title="File Aggregate"/>
+
+        <!--
+            Defines an aggregate that handles file/folder like nodes. It matches
+            all nt:hierarchyNode nodes that have or define a jcr:content
+            child node and excludes child nodes that are nt:hierarchyNodes.
+        -->
+        <aggregate type="filefolder" title="File/Folder Aggregate"/>
+
+        <!--
+            Defines an aggregate that handles nt:nodeType nodes and serializes
+            them into .cnd notation.
+        -->
+        <aggregate type="nodetype" title="Node Type Aggregate" />
+
+        <!--
+            Defines an aggregate that defines full coverage for certain node
+            types that cannot be covered by the default aggregator.
+        -->
+        <aggregate type="full" title="Full Coverage Aggregate">
+            <matches>
+                <include nodeType="rep:AccessControl" respectSupertype="true" />
+                <include nodeType="rep:Policy" respectSupertype="true" />
+                <include nodeType="cq:Widget" respectSupertype="true" />
+                <include nodeType="cq:EditConfig" respectSupertype="true" />
+                <include nodeType="cq:WorkflowModel" respectSupertype="true" />
+                <include nodeType="vlt:FullCoverage" respectSupertype="true" />
+                <include nodeType="mix:language" respectSupertype="true" />
+                <include nodeType="sling:OsgiConfig" respectSupertype="true" />
+            </matches>
+        </aggregate>
+
+        <!--
+            Defines an aggregate that handles nt:folder like nodes.
+        -->
+        <aggregate type="generic" title="Folder Aggregate">
+            <matches>
+                <include nodeType="nt:folder" respectSupertype="true" />
+            </matches>
+            <contains>
+                <exclude isNode="true" />
+            </contains>
+        </aggregate>
+
+        <!--
+            Defines the default aggregate
+        -->
+        <aggregate type="generic" title="Default Aggregator" isDefault="true">
+            <matches>
+                <!-- all -->
+            </matches>
+            <contains>
+                <exclude nodeType="nt:hierarchyNode" respectSupertype="true" />
+            </contains>
+        </aggregate>
+
+    </aggregates>
+
+    <!--
+      defines the input handlers
+    -->
+    <handlers>
+        <handler type="folder"/>
+        <handler type="file"/>
+        <handler type="nodetype"/>
+        <handler type="generic"/>
+    </handlers>
+</vaultfs>

Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/definition/.content.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/definition/.content.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/definition/.content.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/definition/.content.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<jcr:root xmlns:vlt="http://www.day.com/jcr/vault/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+    jcr:created="{Date}2009-10-29T14:12:42.626+01:00"
+    jcr:createdBy="admin"
+    jcr:description=""
+    jcr:lastModified="{Date}2009-10-29T14:12:42.627+01:00"
+    jcr:lastModifiedBy="admin"
+    jcr:primaryType="vlt:PackageDefinition"
+    acHandling="ignore"
+    buildCount="1"
+    lastUnwrapped="{Date}2009-10-29T14:12:42.626+01:00"
+    lastUnwrappedBy="admin"
+    version="1.0">
+    <filter jcr:primaryType="nt:unstructured">
+        <f0
+            jcr:primaryType="nt:unstructured"
+            root="/testroot"/>
+    </filter>
+</jcr:root>

Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/filter.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/filter.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/filter.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/filter.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<workspaceFilter version="1.0">
+    <filter root="/testroot"/>
+</workspaceFilter>

Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/nodetypes.cnd
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/nodetypes.cnd?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/nodetypes.cnd (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/nodetypes.cnd Sat Aug 10 05:53:42 2013
@@ -0,0 +1,11 @@
+<'rep'='internal'>
+<'nt'='http://www.jcp.org/jcr/nt/1.0'>
+
+[rep:Configurations]
+  + * (nt:configuration) = nt:configuration abort
+  + * (rep:Configurations) = rep:Configurations abort
+
+[rep:Activities]
+  + * (nt:activity) = nt:activity protected abort
+  + * (rep:Activities) = rep:Activities protected abort
+

Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/properties.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/properties.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/properties.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/META-INF/vault/properties.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+    <comment>FileVault Package Properties</comment>
+    <entry key="createdBy">admin</entry>
+    <entry key="name">osgi-hooktest</entry>
+    <entry key="lastModified">2009-10-29T14:12:42.627+01:00</entry>
+    <entry key="lastModifiedBy">2009-10-29T14:12:42.627+01:00</entry>
+    <entry key="acHandling">ignore</entry>
+    <entry key="created">2009-10-29T14:12:42.980+01:00</entry>
+    <entry key="buildCount">1</entry>
+    <entry key="version">1.0</entry>
+    <entry key="dependencies"></entry>
+    <entry key="packageFormatVersion">2</entry>
+    <entry key="description"></entry>
+    <entry key="group"></entry>
+</properties>

Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/jcr_root/.content.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/jcr_root/.content.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/jcr_root/.content.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/jcr_root/.content.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:rep="internal"
+    jcr:mixinTypes="[rep:AccessControllable]"
+    jcr:primaryType="rep:root">
+    <jcr:system/>
+    <rep:policy/>
+    <etc/>
+    <testroot/>
+    <home/>
+</jcr:root>

Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/jcr_root/testroot/.content.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/jcr_root/testroot/.content.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/jcr_root/testroot/.content.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/content/jcr_root/testroot/.content.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
+    jcr:primaryType="nt:unstructured">
+    <testnode jcr:primaryType="nt:unstructured"/>
+    <testfolder/>
+</jcr:root>

Added: jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/java/org/apache/jackrabbit/vault/packaging/hooks/ExampleOsgiHook.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/java/org/apache/jackrabbit/vault/packaging/hooks/ExampleOsgiHook.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/java/org/apache/jackrabbit/vault/packaging/hooks/ExampleOsgiHook.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-hook-externalclass-test/src/main/java/org/apache/jackrabbit/vault/packaging/hooks/ExampleOsgiHook.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.packaging.hooks;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener;
+import org.apache.jackrabbit.vault.packaging.InstallContext;
+import org.apache.jackrabbit.vault.packaging.InstallHook;
+import org.apache.jackrabbit.vault.packaging.PackageException;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Example hook that uses a class provided by the webapp (org.apache.sling.api.resource.ResourceUtil)
+ * and/or osgi and is not explicitly imported by the vault bundle
+ */
+public class ExampleOsgiHook implements InstallHook {
+
+    /**
+     * default logger
+     */
+    private static final Logger log = LoggerFactory.getLogger(ExampleOsgiHook.class);
+
+    public void execute(InstallContext ctx) throws PackageException {
+        String name = ResourceUtil.getName("/foo/test");
+        log.info("Executing Hook in phase {}. Testing Resource Util: {}", ctx.getPhase(), name);
+        if (ctx.getOptions().getListener() != null) {
+            ctx.getOptions().getListener().onMessage(ProgressTrackerListener.Mode.TEXT, "H", "OSGi Hook Test - " + name);
+        }
+        if (ctx.getPhase() == InstallContext.Phase.INSTALLED) {
+            try {
+                ctx.getSession().getNode("/testroot").setProperty("TestHook", ctx.getPhase().toString());
+                ctx.getSession().save();
+            } catch (RepositoryException e) {
+                throw new PackageException(e);
+            }
+        }
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-rcp/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/pom.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/pom.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/pom.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,161 @@
+<?xml version="1.0"?><!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
+    <modelVersion>4.0.0</modelVersion>
+    <!-- ====================================================================== -->
+    <!-- P A R E N T  P R O J E C T  D E S C R I P T I O N                      -->
+    <!-- ====================================================================== -->
+    <parent>
+        <groupId>org.apache.jackrabbit.vault</groupId>
+        <artifactId>parent</artifactId>
+        <relativePath>../parent/pom.xml</relativePath>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <!-- ====================================================================== -->
+    <!-- P R O J E C T  D E S C R I P T I O N                                   -->
+    <!-- ====================================================================== -->
+    <artifactId>org.apache.jackrabbit.vault.rcp</artifactId>
+    <version>3.0.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <name>Apache Jackrabbit FileVault RCP Server Bundle</name>
+    <description>
+        Builds an OSGi bundle that provides the vlt rcp manager
+    </description>
+
+    <!-- ====================================================================== -->
+    <!-- S C M  D E F I N I T I O N                                             -->
+    <!-- ====================================================================== -->
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/jackrabbit/commons/filevault/trunk/vault-rcp</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/jackrabbit/commons/filevault/trunk/vault-rcp</developerConnection>
+        <url>http://svn.apache.org/viewvc/asf/jackrabbit/commons/filevault/trunk/vault-rcp</url>
+    </scm>
+
+    <!-- ====================================================================== -->
+    <!-- B U I L D                                                             -->
+    <!-- ====================================================================== -->
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>maven-sling-plugin</artifactId>
+                <configuration>
+                    <slingUrlSuffix>/libs/system/install/</slingUrlSuffix>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Build>${buildNumber}</Bundle-Build>
+                        <Bundle-Category>jcr,granite</Bundle-Category>
+                        <Embed-Dependency>
+                            vault-davex,
+                            jackrabbit-spi2dav,
+                            jackrabbit-jcr-client,
+                            jackrabbit-jcr2spi
+                        </Embed-Dependency>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <!-- ====================================================================== -->
+    <!-- D E P E N D E N C I E S                                                -->
+    <!-- ====================================================================== -->
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.jackrabbit.vault</groupId>
+            <artifactId>org.apache.jackrabbit.vault</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <version>2.5</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr2spi</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-client</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi2dav</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-commons</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.json</artifactId>
+            <version>2.0.6</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.classloader</artifactId>
+            <version>1.2.2</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.2.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit.vault</groupId>
+            <artifactId>vault-davex</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
+
+    </dependencies>
+
+</project>

Added: jackrabbit/commons/filevault/trunk/vault-rcp/readme.md
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/readme.md?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/readme.md (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/readme.md Sat Aug 10 05:53:42 2013
@@ -0,0 +1,196 @@
+Vault RCP Server Bundle
+=======================
+The vault rcp server bundle provides a very simple vault remote copy task management that can be controlled via a json/http interface. This special vault rcp version can only be used to **import** content from remote repositories.
+
+Testing and Examples
+--------------------
+The `src/test/resources` directory contains some shell scripts and json payloads that show how the rcp server can be used.
+
+Usage
+-----
+The vault rcp server maintains a list of _remote copy_ that can be controlled via the http interface at `/libs/granite/packaging/rcp`. The request and responses are JSON formatted. 
+
+### List Tasks (GET)
+Simply lists all available tasks. In addition to listing the parameters that were passed when the task was created, it also list some information about the current state of the task.
+
+| Property | Comment |
+| -------- | ------- |
+| state    | Current state of the task. One of `NEW` , `RUNNING`, `ENDED`, `STOPPED` |
+| currentPath | The path that is currently processed. |
+| lastSavedPath | The path of the node that was saved last. Useful for resuming from aborted tasks. |
+| totalNodes | Total number of Nodes already processed |
+| totalSize | Total size of data already processed (approximative) |
+| currentNodes | Number of nodes in the current batch. |
+| currentSize | Data size of current batch (approximative) | 
+
+#### Example
+
+    GET /libs/granite/packaging/rcp HTTP/1.1
+    Host: localhost:4502
+    
+    HTTP/1.1 200 OK
+    Content-Type: application/json;charset=utf-8
+	
+	{
+	"tasks": [{
+	    "id": "test-id-1234",
+        "src": "http://admin:admin@localhost:4503/crx/server/-/jcr:root/content/geometrixx",
+        "dst": "/tmp/test1",
+        "recursive": true,
+        "batchsize": 2048,
+        "update": true,
+        "onlyNewer": false,
+        "throttle": 1,
+        "resumeFrom": null,
+	    "excludes": [
+	        "/content/geometrixx/(en|fr)/tools(/.*)?"
+        ],
+	    "status": {
+            "state": "STOPPED",
+            "currentPath": "/content/geometrixx/en/products/triangle",
+            "lastSavedPath": "/content/geometrixx/en/products",
+            "totalNodes": 10841,
+            "totalSize": 1915798,
+            "currentSize": 122640,
+            "currentNodes": 601
+        }
+    }]
+
+
+### Create Task (POST)
+Creates a new task.
+
+| Property     | Required | Comment |
+| ------------ | -------- | ------- |
+| cmd          | X | Needs to be "**create**". |
+| id           | - | Id for new task. if omitted a random id is used. |
+| src          | X | URI of the remote source repository. |
+| dst          | X | Destination path in the local repository. |
+| batchsize    | - | Size of batch until intermediate size. Default is 1024. |
+| recursive    | - | **true** to descend recursively. Default is _false_. |
+| update       | - | **true** to overwrite and/or delete existing nodes. Default is _false_. |
+| newer        | - | **true** to respect _lastModified_ properties for update. Default is _false_. |
+| throttle     | - | Number of seconds to sleep after each intermediate save. Default is _0_. |
+| resumeFrom   | - | Source path to resume a prior aborted copy. Note that the algorithm simply skips all source nodes until the _resumeFrom_ path is found. It is necessary that the content structure of the source repository does not change in between runs, and that content already needs to be present in the detination location. |
+| excludes     | - | Array of regular expressions that exclude source paths. |
+
+
+#### Example
+    POST /libs/granite/packaging/rcp HTTP/1.1
+    Host: localhost:4502
+    Content-Type: application/json
+    
+	{
+        "cmd":"create",
+        "id":"test-id-1234",
+        "src":"http://admin:admin@localhost:4503/crx/-/jcr:root/content/geometrixx",
+        "dst":"/tmp/test1",
+        "batchsize": 2048,
+        "update": true,
+        "onlyNewer": false,
+        "recursive": true,
+        "throttle": 1,
+        "resumeFrom": "/content/geometrixx/fr",
+        "excludes": [
+            "/content/geometrixx/(en|fr)/tools(/.*)?"
+        ]
+    }
+
+    HTTP/1.1 201 Created
+    Content-Type: application/json;charset=utf-8
+    Location: /libs/granite/packaging/rcp.tasks/test-id-1234
+    
+    {
+        "status": "ok",
+        "id": "test-id-1234"
+    }
+    
+### Start Task (POST)
+Starts a previously created task.
+
+| Property     | Required | Comment                  |
+| ------------ | -------- | ------------------------ |
+| cmd          | X        | Needs to be "**start**". |
+| id           | X        | Task Id to start.        |
+
+
+#### Example
+    POST /libs/granite/packaging/rcp HTTP/1.1
+    Host: localhost:4502
+    Content-Type: application/json
+
+    {
+        "cmd": "start",
+        "id": "test-id-1234"
+    }
+    
+
+    HTTP/1.1 200 OK
+    Content-Type: application/json;charset=utf-8
+
+    {
+        "status": "ok",
+        "id": "test-id-1234"
+    }
+
+
+### Stop Task (POST)
+Stops a previously start task.
+
+| Property     | Required | Comment                  |
+| ------------ | -------- | ------------------------ |
+| cmd          | X        | Needs to be "**stop**".  |
+| id           | X        | Task Id to start.        |
+
+
+#### Example
+    POST /libs/granite/packaging/rcp HTTP/1.1
+    Host: localhost:4502
+    Content-Type: application/json
+
+    {
+        "cmd": "stop",
+        "id": "test-id-1234"
+    }
+    
+
+    HTTP/1.1 200 OK
+    Content-Type: application/json;charset=utf-8
+
+    {
+        "status": "ok",
+        "id": "test-id-1234"
+    }
+
+
+
+### Remove Task (POST)
+Removes a previously start task.
+
+| Property     | Required | Comment                   |
+| ------------ | -------- | ------------------------- |
+| cmd          | X        | Needs to be "**remove**". |
+| id           | X        | Task Id to start.         |
+
+
+#### Example
+    POST /libs/granite/packaging/rcp HTTP/1.1
+    Host: localhost:4502
+    Content-Type: application/json
+
+    {
+        "cmd": "remove",
+        "id": "test-id-1234"
+    }
+    
+
+    HTTP/1.1 200 OK
+    Content-Type: application/json;charset=utf-8
+
+    {
+        "status": "ok",
+        "id": "test-id-1234"
+    }
+
+
+

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpServlet.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpServlet.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpServlet.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.rcp.impl;
+
+import java.io.IOException;
+
+import javax.jcr.Session;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.sling.SlingServlet;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.servlets.SlingAllMethodsServlet;
+import org.apache.sling.commons.json.JSONArray;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.JSONObject;
+import org.apache.sling.commons.json.io.JSONWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ */
+@SlingServlet(paths = {
+        "/libs/granite/packaging/rcp"
+})
+public class RcpServlet extends SlingAllMethodsServlet {
+
+    private static final long serialVersionUID = -4571680968447024900L;
+    public static final String PARAM_SRC = "src";
+    public static final String PARAM_DST = "dst";
+    public static final String PARAM_ID = "id";
+    public static final String PARAM_BATCHSIZE = "batchsize";
+    public static final String PARAM_CMD = "cmd";
+    public static final String PARAM_RECURSIVE = "recursive";
+    public static final String PARAM_STATE = "state";
+    public static final String PARAM_UPDATE = "update";
+    public static final String PARAM_NO_ORDERING = "noOrdering";
+    public static final String PARAM_ONLY_NEWER = "onlyNewer";
+    public static final String PARAM_THROTTLE = "throttle";
+    public static final String PARAM_EXCLUDES = "excludes";
+    public static final String PARAM_RESUME_FROM = "resumeFrom";
+
+    /**
+     * default logger
+     */
+    protected final Logger log = LoggerFactory.getLogger(RcpServlet.class);
+
+    @Reference
+    private RcpTaskManager taskMgr;
+
+    @Override
+    protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response)
+            throws ServletException, IOException {
+
+        response.setContentType("application/json");
+        response.setCharacterEncoding("utf-8");
+        try {
+            JSONWriter w = new JSONWriter(response.getWriter());
+            w.setTidy(true);
+            w.object();
+            w.key("tasks").array();
+            for (RcpTask task: taskMgr.getTasks().values()) {
+                task.write(w);
+            }
+            w.endArray();
+            w.endObject();
+        } catch (JSONException e) {
+            throw new IOException(e.toString());
+        }
+
+    }
+
+    @Override
+    protected void doPost(SlingHttpServletRequest request, SlingHttpServletResponse response)
+            throws ServletException, IOException {
+        String json = IOUtils.toString(request.getReader());
+        JSONObject data;
+        try {
+            data = new JSONObject(json);
+        } catch (JSONException e) {
+            log.error("Error while reading json: {}", e.toString());
+            response.setStatus(500);
+            return;
+        }
+        String cmd = data.optString(PARAM_CMD, "");
+        RcpTask task = null;
+        try {
+            // --------------------------------------------------------------------------------------------< create >---
+            if ("create".equals(cmd)) {
+                String src = data.optString(PARAM_SRC, "");
+                String dst = data.optString(PARAM_DST, "");
+                String id = data.optString(PARAM_ID, null);
+                RepositoryAddress address = new RepositoryAddress(src);
+                task = taskMgr.addTask(address, dst, id);
+
+                // add additional data
+                if (data.has(PARAM_BATCHSIZE)) {
+                    task.getRcp().setBatchSize((int) data.getLong(PARAM_BATCHSIZE));
+                }
+                task.setRecursive(data.optBoolean(PARAM_RECURSIVE, false));
+                task.getRcp().setUpdate(data.optBoolean(PARAM_UPDATE, false));
+                task.getRcp().setOnlyNewer(data.optBoolean(PARAM_ONLY_NEWER, false));
+                task.getRcp().setNoOrdering(data.optBoolean(PARAM_NO_ORDERING, false));
+                if (data.has(PARAM_THROTTLE)) {
+                    task.getRcp().setThrottle(data.getLong(PARAM_THROTTLE));
+                }
+                if (data.has(PARAM_EXCLUDES)) {
+                    JSONArray excludes = data.getJSONArray(PARAM_EXCLUDES);
+                    for (int idx = 0; idx < excludes.length(); idx++) {
+                        task.addExclude(excludes.getString(idx));
+                    }
+                }
+                if (data.has(PARAM_RESUME_FROM)) {
+                    task.getRcp().setResumeFrom(data.getString(PARAM_RESUME_FROM));
+                }
+                response.setStatus(HttpServletResponse.SC_CREATED);
+                String path = "/libs/granite/packaging/rcp.tasks/" + task.getId();
+                response.setHeader("Location", path);
+
+            // ---------------------------------------------------------------------------------------------< start >---
+            } else if ("start".equals(cmd)) {
+                String id = data.optString(PARAM_ID, null);
+                if (id == null || id.length() == 0) {
+                    throw new IllegalArgumentException("Need task id.");
+                }
+                task = taskMgr.getTasks().get(id);
+                if (task == null) {
+                    throw new IllegalArgumentException("No such task with id='" + id + "'");
+                }
+                task.start(request.getResourceResolver().adaptTo(Session.class));
+
+            // ----------------------------------------------------------------------------------------------< stop >---
+            } else if ("stop".equals(cmd)) {
+                String id = data.optString(PARAM_ID, null);
+                if (id == null || id.length() == 0) {
+                    throw new IllegalArgumentException("Need task id.");
+                }
+                task = taskMgr.getTasks().get(id);
+                if (task == null) {
+                    throw new IllegalArgumentException("No such task with id='" + id + "'");
+                }
+                task.stop();
+
+            // --------------------------------------------------------------------------------------------< remove >---
+            } else if ("remove".equals(cmd)) {
+                String id = data.optString(PARAM_ID, null);
+                if (id == null || id.length() == 0) {
+                    throw new IllegalArgumentException("Need task id.");
+                }
+                task = taskMgr.getTasks().get(id);
+                if (task == null) {
+                    throw new IllegalArgumentException("No such task with id='" + id + "'");
+                }
+                task.remove();
+
+            } else {
+                throw new IllegalArgumentException("Invalid command.");
+            }
+            // default response
+            response.setContentType("application/json");
+            response.setCharacterEncoding("utf-8");
+            JSONWriter w = new JSONWriter(response.getWriter());
+            w.setTidy(true);
+            w.object();
+            w.key("status").value("ok");
+            if (task != null) {
+                w.key("id").value(task.getId());
+            }
+            w.endObject();
+
+        } catch (Exception e) {
+            log.error("Error while executing command {}", cmd, e);
+            response.setContentType("application/json");
+            response.setCharacterEncoding("utf-8");
+            response.setStatus(500);
+            JSONWriter w = new JSONWriter(response.getWriter());
+            w.setTidy(true);
+            try {
+                w.object();
+                w.key("status").value("error");
+                w.key("message").value("Error while executing '" + cmd + "': " + e.getMessage());
+                w.endObject();
+            } catch (JSONException e1) {
+                // ignore
+            }
+        }
+    }
+
+}
+

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTask.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.rcp.impl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+import org.apache.jackrabbit.vault.davex.DAVExRepositoryFactory;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.api.ProgressTrackerListener;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
+import org.apache.jackrabbit.vault.util.RepositoryCopier;
+import org.apache.sling.commons.json.JSONException;
+import org.apache.sling.commons.json.io.JSONWriter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>RcpTask</code>...
+ */
+public class RcpTask implements Runnable {
+
+    /**
+     * default logger
+     */
+    private static final Logger log = LoggerFactory.getLogger(RcpTask.class);
+
+    enum STATE {
+        NEW,
+        RUNNING,
+        ENDED,
+        STOPPED
+    }
+    private final RcpTaskManagerImpl mgr;
+
+    private final String id;
+
+    private RepositoryCopier rcp = new RepositoryCopier();
+
+    private final RepositoryAddress src;
+
+    private final String dst;
+
+    private boolean recursive;
+
+    private File logFile;
+
+    private volatile STATE state = STATE.NEW;
+
+    private List<String> excludes = new ArrayList<String>();
+
+    private Thread thread;
+
+    private Session srcSession;
+
+    private Session dstSession;
+
+    public RcpTask(RcpTaskManagerImpl mgr, RepositoryAddress src, String dst, String id) {
+        this.mgr = mgr;
+        this.src = src;
+        this.dst = dst;
+        this.id = id == null || id.length() == 0
+                ? UUID.randomUUID().toString()
+                : id;
+        rcp.setTracker(new ProgressTrackerListener(){
+            public void onMessage(Mode mode, String action, String path) {
+                log.info("{} {}", action, path);
+            }
+
+            public void onError(Mode mode, String path, Exception e) {
+                log.error("{} {}", path, e.toString());
+            }
+        });
+    }
+
+    public String getId() {
+        return id;
+    }
+
+    public RepositoryCopier getRcp() {
+        return rcp;
+    }
+
+    public boolean stop() {
+        // wait for thread
+        if (state != STATE.STOPPED) {
+            if (state == STATE.RUNNING) {
+                rcp.abort();
+            }
+            state = STATE.STOPPED;
+            log.info("Stopping task {}...", id);
+            if (thread != null) {
+                try {
+                    thread.join();
+                } catch (InterruptedException e) {
+                    log.error("Error while waiting for thread: " + thread.getName(), e);
+                }
+                thread = null;
+            }
+            if (srcSession != null) {
+                srcSession.logout();
+                srcSession = null;
+            }
+            if (dstSession != null) {
+                dstSession.logout();
+                dstSession = null;
+            }
+            log.info("Stopping task {}...done", id);
+        }
+        return true;
+    }
+
+    public boolean remove() {
+        stop();
+        mgr.remove(this);
+        return true;
+    }
+
+    public boolean start(Session session) throws RepositoryException {
+        if (state != STATE.NEW) {
+            throw new IllegalStateException("Unable to start task " + id + ". wrong state = " + state);
+        }
+        // clone session
+        dstSession = session.impersonate(new SimpleCredentials(session.getUserID(), new char[0]));
+        ClassLoader dynLoader = mgr.getDynamicClassLoader();
+        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+        Thread.currentThread().setContextClassLoader(dynLoader);
+        try {
+            srcSession = getSourceSession(src);
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldLoader);
+        }
+
+        thread  = new Thread(this, "Vault RCP Task - " + id);
+        thread.setContextClassLoader(dynLoader);
+        thread.start();
+        return true;
+    }
+
+    private Session getSourceSession(RepositoryAddress src) throws RepositoryException {
+        DAVExRepositoryFactory factory = new DAVExRepositoryFactory();
+        Repository srcRepo;
+        try {
+            srcRepo = factory.createRepository(src);
+        } catch (RepositoryException e) {
+            log.error("Error while retrieving src repository {}: {}", src, e.toString());
+            throw e;
+        }
+        try {
+            Credentials srcCreds = src.getCredentials();
+            String wsp = src.getWorkspace();
+            if (wsp == null) {
+                return srcRepo.login(srcCreds);
+            } else {
+                return srcRepo.login(srcCreds, wsp);
+            }
+        } catch (RepositoryException e) {
+            log.error("Error while logging in src repository {}: {}", src, e.toString());
+            throw e;
+        }
+    }
+
+    public void run() {
+        state = STATE.RUNNING;
+        log.info("Starting repository copy task id={}. From {} to {}.", new Object[]{
+                id, src.toString(), dst
+        });
+        rcp.copy(srcSession, src.getPath(), dstSession, dst, recursive);
+        state = STATE.ENDED;
+        // todo: notify manager that we ended.
+    }
+
+    public STATE getState() {
+        return state;
+    }
+
+    public RepositoryAddress getSource() {
+        return src;
+    }
+
+    public String getDestination() {
+        return dst;
+    }
+
+    public void setRecursive(boolean b) {
+        this.recursive = b;
+    }
+
+    public void addExclude(String exclude) {
+        excludes.add(exclude);
+        // could be done better
+        DefaultWorkspaceFilter srcFilter = new DefaultWorkspaceFilter();
+        PathFilterSet filterSet = new PathFilterSet("/");
+        for (String path: excludes) {
+            filterSet.addExclude(new DefaultPathFilter(path));
+        }
+        srcFilter.add(filterSet);
+        rcp.setSourceFilter(srcFilter);
+
+    }
+
+    public void write(JSONWriter w) throws JSONException {
+        w.object();
+        w.key(RcpServlet.PARAM_ID).value(id);
+        w.key(RcpServlet.PARAM_SRC).value(src.toString());
+        w.key(RcpServlet.PARAM_DST).value(dst);
+        w.key(RcpServlet.PARAM_RECURSIVE).value(recursive);
+        w.key(RcpServlet.PARAM_BATCHSIZE).value(rcp.getBatchSize());
+        w.key(RcpServlet.PARAM_UPDATE).value(rcp.isUpdate());
+        w.key(RcpServlet.PARAM_ONLY_NEWER).value(rcp.isOnlyNewer());
+        w.key(RcpServlet.PARAM_NO_ORDERING).value(rcp.isNoOrdering());
+        w.key(RcpServlet.PARAM_THROTTLE).value(rcp.getThrottle());
+        w.key(RcpServlet.PARAM_RESUME_FROM).value(rcp.getResumeFrom());
+        if (excludes.size() > 0) {
+            w.key(RcpServlet.PARAM_EXCLUDES).array();
+            for (String exclude: excludes) {
+                w.value(exclude);
+            }
+            w.endArray();
+        }
+        w.key("status").object();
+        w.key(RcpServlet.PARAM_STATE).value(state.name());
+        w.key("currentPath").value(rcp.getCurrentPath());
+        w.key("lastSavedPath").value(rcp.getLastKnownGood());
+        w.key("totalNodes").value(rcp.getTotalNodes());
+        w.key("totalSize").value(rcp.getTotalSize());
+        w.key("currentSize").value(rcp.getCurrentSize());
+        w.key("currentNodes").value(rcp.getCurrentNumNodes());
+        w.endObject();
+        w.endObject();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManager.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManager.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManager.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManager.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.rcp.impl;
+
+import java.util.Map;
+
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+
+/**
+ * <code>RcpTaskManager</code>...
+ */
+public interface RcpTaskManager {
+
+    Map<String, RcpTask> getTasks();
+
+    RcpTask addTask(RepositoryAddress src, String dst, String id);
+
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImpl.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImpl.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/main/java/org/apache/jackrabbit/vault/rcp/impl/RcpTaskManagerImpl.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.rcp.impl;
+
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.sling.commons.classloader.DynamicClassLoaderManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>RcpTaskManager</code>...
+ */
+@Component
+@Service(value = RcpTaskManager.class)
+public class RcpTaskManagerImpl implements RcpTaskManager {
+
+    /**
+     * default logger
+     */
+    private static final Logger log = LoggerFactory.getLogger(RcpTaskManagerImpl.class);
+
+    @Reference
+    private DynamicClassLoaderManager dynLoaderMgr;
+
+    private final Map<String, RcpTask> tasks = new LinkedHashMap<String, RcpTask>();
+
+    @Deactivate
+    private void deactivate() {
+        log.info("RcpTaskManager deactivated. Stopping running tasks...");
+        while (!tasks.isEmpty()) {
+            tasks.values().iterator().next().remove();
+        }
+        log.info("RcpTaskManager deactivated. Stopping running tasks...done.");
+    }
+
+    public Map<String, RcpTask> getTasks() {
+        return Collections.unmodifiableMap(tasks);
+    }
+
+    public RcpTask addTask(RepositoryAddress src, String dst, String id) {
+        if (id != null && id.length() > 0 && tasks.containsKey(id)) {
+            throw new IllegalArgumentException("Task with id " + id + " already exists.");
+        }
+        RcpTask task = new RcpTask(this, src, dst, id);
+        tasks.put(task.getId(), task);
+        return task;
+    }
+
+    protected void remove(RcpTask task)  {
+        tasks.remove(task.getId());
+    }
+
+    protected ClassLoader getDynamicClassLoader() {
+        return dynLoaderMgr.getDynamicClassLoader();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/create_task.json
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/create_task.json?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/create_task.json (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/create_task.json Sat Aug 10 05:53:42 2013
@@ -0,0 +1,14 @@
+{
+    "cmd":"create",
+    "id":"copy-geometrixx",
+    "src":"http://admin:admin@localhost:4503/crx/-/jcr:root/content/geometrixx",
+    "dst":"/tmp/test_geo",
+    "batchsize": 2048,
+    "update": true,
+    "onlyNewer": true,
+    "recursive": true,
+    "throttle": 1,
+    "excludes": [
+        "/content/geometrixx/en/tools(/.*)?"
+    ]
+}

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/list_tasks.sh
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/list_tasks.sh?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/list_tasks.sh (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/list_tasks.sh Sat Aug 10 05:53:42 2013
@@ -0,0 +1,4 @@
+#!/bin/sh
+curl -u admin:admin http://localhost:4502/libs/granite/packaging/rcp
+echo ""
+

Propchange: jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/list_tasks.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/remove_task.json
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/remove_task.json?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/remove_task.json (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/remove_task.json Sat Aug 10 05:53:42 2013
@@ -0,0 +1,4 @@
+{
+    "cmd":"remove",
+    "id":"copy-geometrixx"
+}

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/send_cmd.sh
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/send_cmd.sh?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/send_cmd.sh (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/send_cmd.sh Sat Aug 10 05:53:42 2013
@@ -0,0 +1,8 @@
+#!/bin/sh
+FILE=$1
+if [ "$FILE" == "" ]; then
+    echo "usage: $0 payload"
+    exit 1;
+fi 
+curl -u admin:admin -X POST --data-binary @$FILE -H "Content-Type: application/json" http://localhost:4502/libs/granite/packaging/rcp
+echo ""

Propchange: jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/send_cmd.sh
------------------------------------------------------------------------------
    svn:executable = *

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/start_task.json
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/start_task.json?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/start_task.json (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/start_task.json Sat Aug 10 05:53:42 2013
@@ -0,0 +1,4 @@
+{
+    "cmd":"start",
+    "id":"copy-geometrixx"
+}

Added: jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/stop_task.json
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/stop_task.json?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/stop_task.json (added)
+++ jackrabbit/commons/filevault/trunk/vault-rcp/src/test/resources/stop_task.json Sat Aug 10 05:53:42 2013
@@ -0,0 +1,4 @@
+{
+    "cmd":"stop",
+    "id":"copy-geometrixx"
+}

Added: jackrabbit/commons/filevault/trunk/vault-sync/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-sync/pom.xml?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-sync/pom.xml (added)
+++ jackrabbit/commons/filevault/trunk/vault-sync/pom.xml Sat Aug 10 05:53:42 2013
@@ -0,0 +1,156 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd ">
+    <modelVersion>4.0.0</modelVersion>
+    <!-- ====================================================================== -->
+    <!-- P A R E N T  P R O J E C T  D E S C R I P T I O N                      -->
+    <!-- ====================================================================== -->
+    <parent>
+        <groupId>org.apache.jackrabbit.vault</groupId>
+        <artifactId>parent</artifactId>
+        <relativePath>../parent/pom.xml</relativePath>
+        <version>3.0.0-SNAPSHOT</version>
+    </parent>
+
+    <!-- ====================================================================== -->
+    <!-- P R O J E C T  D E S C R I P T I O N                                   -->
+    <!-- ====================================================================== -->
+    <artifactId>vault-sync</artifactId>
+    <packaging>bundle</packaging>
+
+    <name>Apache Jackrabbit FileVault Sync Service</name>
+
+    <!-- ====================================================================== -->
+    <!-- S C M  D E F I N I T I O N                                             -->
+    <!-- ====================================================================== -->
+    <scm>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/jackrabbit/commons/filevault/trunk/vault-sync</connection>
+        <developerConnection>scm:svn:https://svn.apache.org/repos/asf/jackrabbit/commons/filevault/trunk/vault-sync</developerConnection>
+        <url>http://svn.apache.org/viewvc/asf/jackrabbit/commons/filevault/trunk/vault-sync</url>
+    </scm>
+
+    <!-- ====================================================================== -->
+    <!-- B U I L D   D E F I N I T I O N                                        -->
+    <!-- ====================================================================== -->
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.sling</groupId>
+                <artifactId>maven-sling-plugin</artifactId>
+                <configuration>
+                    <slingUrlSuffix>/libs/crx/vault/install/</slingUrlSuffix>
+                    <slingUrl>http://localhost:4502/crx/repository/crx.default</slingUrl>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+                <version>1.6.0</version>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.slf4j</groupId>
+                        <artifactId>slf4j-simple</artifactId>
+                        <version>1.6.1</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Category>cq5</Bundle-Category>
+                        <Private-Package>
+                            org.apache.jackrabbit.vault.sync.impl.*,
+                        </Private-Package>
+                        <Embed-Dependency>
+                            commons-jci-fam,jackrabbit-spi,jackrabbit-spi-commons
+                        </Embed-Dependency>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <!-- ====================================================================== -->
+    <!-- D E P E N D E N C I E S                                                -->
+    <!-- ====================================================================== -->
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.jackrabbit.vault</groupId>
+            <artifactId>org.apache.jackrabbit.vault</artifactId>
+            <version>3.0.0-SNAPSHOT</version>
+        </dependency>
+
+        <!-- JCR Stuff -->
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-jcr-commons</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.jackrabbit</groupId>
+            <artifactId>jackrabbit-spi-commons</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.jcr</groupId>
+            <artifactId>jcr</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>commons-io</groupId>
+            <artifactId>commons-io</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-jci-fam</artifactId>
+            <version>1.0</version>
+        </dependency>
+
+        <!-- sling / osgi stuff -->
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <version>1.4.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.jcr.api</artifactId>
+            <version>2.0.6</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.commons.osgi</artifactId>
+            <version>2.0.6</version>
+        </dependency>
+
+        <!-- SLF4j / Log4j -->
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
+
+    </dependencies>
+
+</project>

Added: jackrabbit/commons/filevault/trunk/vault-sync/src/main/java/org/apache/jackrabbit/vault/sync/impl/SyncConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-sync/src/main/java/org/apache/jackrabbit/vault/sync/impl/SyncConfig.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-sync/src/main/java/org/apache/jackrabbit/vault/sync/impl/SyncConfig.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-sync/src/main/java/org/apache/jackrabbit/vault/sync/impl/SyncConfig.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.sync.impl;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Reader;
+import java.io.Writer;
+import java.util.LinkedHashMap;
+import java.util.UUID;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>SyncConfig</code>...
+ */
+public class SyncConfig {
+
+
+    /**
+     * default logger
+     */
+    private static final Logger log = LoggerFactory.getLogger(SyncConfig.class);
+
+    private static final String LINE_ENDING = System.getProperty("line.separator");
+
+    private static final String DEFAULT_CONFIG = "default-config.properties";
+
+    public static final String PROP_SYNC_ONCE = "sync-once";
+
+    public static final String PROP_FILTER = "filter";
+
+    public static final String PROP_DISABLED = "disabled";
+
+    public static final String PROP_SYNC_LOG = "sync-log";
+
+    private final File file;
+
+    private final LinkedHashMap<String, Line> lines = new LinkedHashMap<String, Line>();
+
+    private SyncMode syncOnce;
+
+    private String syncLog;
+
+    private Boolean disabled;
+
+    public SyncConfig(File file) {
+        this.file = file;
+    }
+
+    public File getFile() {
+        return file;
+    }
+
+    public SyncMode getSyncOnce() {
+        return syncOnce;
+    }
+
+    public void setSyncOnce(SyncMode syncOnce) {
+        this.syncOnce = syncOnce;
+    }
+
+    public String getSyncLog() {
+        return syncLog;
+    }
+
+    public void setSyncLog(String syncLog) {
+        this.syncLog = syncLog;
+    }
+
+    public Boolean getDisabled() {
+        return disabled;
+    }
+
+    public void setDisabled(Boolean disabled) {
+        this.disabled = disabled;
+    }
+
+    public boolean isDisabled() {
+        return disabled == null ? false : disabled;
+    }
+
+    public void load() throws IOException {
+        if (!file.isFile()) {
+            return;
+        }
+        Reader r = null;
+        try {
+            r = new InputStreamReader(FileUtils.openInputStream(file), "utf-8");
+            load(r);
+        } finally {
+            IOUtils.closeQuietly(r);
+        }
+    }
+    private void load(Reader r) throws IOException {
+        BufferedReader br = new BufferedReader(r);
+        int lineNo=1;
+        lines.clear();
+        String line;
+        while ((line = br.readLine()) != null) {
+            Line l = new Line(line, lineNo++);
+            lines.put(l.name, l);
+        }
+
+        // update internals
+        String sm = getString(PROP_SYNC_ONCE, "");
+        syncOnce = null;
+        if (sm.length() > 0) {
+            try {
+                syncOnce = SyncMode.valueOf(sm.toUpperCase());
+            } catch (IllegalArgumentException e) {
+                log.warn("Unknown syncOnce value: " + e);
+            }
+        }
+        syncLog = getString(PROP_SYNC_LOG, null);
+        disabled = getBoolean(PROP_DISABLED, false);
+    }
+
+    private String getString(String name, String defaultValue) {
+        Line l = lines.get(name);
+        if (l == null || l.value == null) {
+            return defaultValue;
+        } else {
+            return l.value;
+        }
+    }
+
+    private boolean getBoolean(String name, boolean defaultValue) {
+        Line l = lines.get(name);
+        if (l == null || l.value == null) {
+            return defaultValue;
+        } else {
+            return l.value.equals("true");
+        }
+    }
+
+    private void setProperty(String name, String value) {
+        Line l = lines.get(name);
+        if (l != null) {
+            l.setValue(value);
+        }
+    }
+
+    public void save() throws IOException {
+        setProperty(PROP_SYNC_ONCE, syncOnce == null ? "" : syncOnce.name().toLowerCase());
+        setProperty(PROP_SYNC_LOG, syncLog);
+        setProperty(PROP_DISABLED, String.valueOf(disabled));
+
+        Writer w = null;
+        try {
+            w = new OutputStreamWriter(FileUtils.openOutputStream(file), "utf-8");
+            for (Line l: lines.values()) {
+                w.write(l.getLine());
+                w.write(LINE_ENDING);
+            }
+        } finally {
+            IOUtils.closeQuietly(w);
+        }
+    }
+
+    public void init() throws IOException {
+        if (!file.exists()) {
+            // load default config
+            InputStream in = SyncConfig.class.getResourceAsStream(DEFAULT_CONFIG);
+            if (in == null) {
+                log.error("Unable to load default config.");
+            } else {
+                Reader r = null;
+                try {
+                    r = new InputStreamReader(in, "utf-8");
+                    load(r);
+                } finally {
+                    IOUtils.closeQuietly(r);
+                }
+                try {
+                    save();
+                } catch (IOException e) {
+                    log.warn("Unable to save initial config: " + e.toString());
+                }
+            }
+        } else {
+            load();
+        }
+    }
+
+
+    private class Line {
+
+        private final String name;
+
+        private String line;
+
+        private String value;
+
+        private Line(String name, String value) {
+            this.name = name;
+            setValue(value);
+        }
+
+        public void setValue(String value) {
+            this.value = value;
+            line = name + "=" + value;
+        }
+
+        public String getLine() {
+            return line;
+        }
+
+        private Line(String line, int lineNo) {
+            this.line = line;
+
+            String trimmed = line.trim();
+            if (trimmed.startsWith("#")) {
+                name = "comment-" + UUID.randomUUID();
+            } else if (trimmed.length() == 0) {
+                name = "blank-" + UUID.randomUUID();
+            } else {
+                int idx = trimmed.indexOf('=');
+                if (idx < 0) {
+                    log.warn("Syntax error in {}, line {}: Name/Value pair expected.", file.getAbsolutePath(), lineNo);
+                    name = "error-" + UUID.randomUUID();
+                    return;
+                }
+                name = trimmed.substring(0, idx).trim();
+                value = trimmed.substring(idx + 1);
+            }
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-sync/src/main/java/org/apache/jackrabbit/vault/sync/impl/SyncConstants.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-sync/src/main/java/org/apache/jackrabbit/vault/sync/impl/SyncConstants.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-sync/src/main/java/org/apache/jackrabbit/vault/sync/impl/SyncConstants.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-sync/src/main/java/org/apache/jackrabbit/vault/sync/impl/SyncConstants.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.vault.sync.impl;
+
+/**
+ * <code>SyncConstants</code>...
+ */
+public class SyncConstants {
+
+    public static final String SYNCLOG_FILE_NAME = ".vlt-sync.log";
+
+    public static final String FILTER_FILE_NAME = ".vlt-sync-filter.xml";
+
+    public static final String CONFIG_FILE_NAME = ".vlt-sync-config.properties";
+
+}
\ No newline at end of file



Mime
View raw message