jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1512568 [37/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-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Checkout.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Checkout.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Checkout.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Checkout.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,140 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Collections;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.vault.fs.api.DumpContext;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.fs.config.DefaultMetaInf;
+import org.apache.jackrabbit.vault.util.PathUtil;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+
+/**
+ * <code>Checkout</code>...
+ *
+ */
+public class Checkout extends AbstractAction {
+
+    private RepositoryAddress mountPoint;
+
+    private String remoteDir;
+
+    private File localDir;
+
+    private boolean force;
+
+    public Checkout(RepositoryAddress mountPoint, String remoteDir, File localDir) {
+        this.mountPoint = mountPoint;
+        this.remoteDir = remoteDir;
+        this.localDir = localDir;
+    }
+
+    public boolean isForce() {
+        return force;
+    }
+
+    public void setForce(boolean force) {
+        this.force = force;
+    }
+
+    public void run(VltContext ctx) throws VltException {
+        if (!localDir.exists()) {
+            if (!localDir.mkdir()) {
+                throw ctx.error(localDir.getPath(), "could not create directory");
+            }
+        }
+        // check for meta inf
+        if (ctx.getExportRoot().isValid()) {
+            String path = ctx.getExportRoot().getJcrRoot().getPath();
+            if (force) {
+                ctx.printMessage("Checkout " + mountPoint.resolve(remoteDir) + " with local files using root at " + path);
+            } else {
+                throw ctx.error(localDir.getPath(),
+                        "there seems to be already a checkout at " + path + ". " +
+                        "Use --force option to overwrite local files with remote.");
+            }
+        } else {
+            // turn of sync
+            if (force) {
+                ctx.printMessage("Warning: --force was specified but no prior checkout detected. disabling it.");
+                force = false;
+            }
+            try {
+                ctx.getExportRoot().create();
+                localDir = ctx.getExportRoot().getJcrRoot();
+            } catch (IOException e) {
+                throw ctx.exception(localDir.getPath(), "Error while creating meta-info", e);
+            }
+        }
+        try {
+            if (remoteDir == null) {
+                remoteDir = "/";
+            }
+            VaultFile vaultFile = ctx.getFileSystem(mountPoint).getFile(remoteDir);
+            if (vaultFile == null) {
+                throw new VltException(remoteDir, "Error during checkout. Remote directory does not exit.");
+            }
+            // store filter and config
+            if (!force) {
+                DefaultMetaInf inf = (DefaultMetaInf) ctx.getMetaInf();
+                inf.setConfig(vaultFile.getFileSystem().getConfig());
+                inf.setFilter(vaultFile.getFileSystem().getWorkspaceFilter());
+                inf.save(ctx.getExportRoot().getMetaDir());
+            }
+            if (ctx.isVerbose()) {
+                DumpContext dc = new DumpContext(new PrintWriter(ctx.getStdout()));
+                dc.println("Filter");
+                ctx.getMetaInf().getFilter().dump(dc, true);
+                dc.outdent();
+                dc.flush();
+            }
+
+            String path = PathUtil.getRelativeFilePath(ctx.getCwd().getPath(), localDir.getPath());
+            ctx.printMessage("Checking out " + vaultFile.getPath() + " to " + path);
+            VltDirectory dir = new VltDirectory(ctx, localDir);
+            if (dir.isControlled()) {
+                if (!force) {
+                    throw dir.getContext().error(dir.getPath(), "already under vault control.");
+                }
+            } else {
+                dir.control(vaultFile.getPath(), vaultFile.getAggregate().getPath());
+            }
+            ctx.setMountpoint(vaultFile.getAggregate().getManager().getMountpoint());
+            // re-open parent dir to avoid problems with zip-meta-dirs
+            dir = new VltDirectory(ctx, localDir);
+            Update up = new Update(localDir, null, false);
+            up.setOnlyControlled(true);
+            up.setForce(force);
+            dir.applyWithRemote(up, Collections.<String>emptyList(), false);
+            ctx.printMessage("Checkout done.");
+        } catch (IOException e) {
+            throw new VltException(localDir.getPath(), "Error during checkout", e);
+        } catch (RepositoryException e) {
+            throw new VltException(remoteDir, "Error during checkout", e);
+        }
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Commit.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Commit.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Commit.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Commit.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,154 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFsTransaction;
+import org.apache.jackrabbit.vault.fs.impl.TransactionImpl;
+import org.apache.jackrabbit.vault.util.PathComparator;
+import org.apache.jackrabbit.vault.util.Text;
+import org.apache.jackrabbit.vault.vlt.FileAction;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+
+/**
+ * <code>Resolved</code>...
+ *
+ */
+public class Commit extends AbstractAction {
+
+    private File localDir;
+
+    private List<File> localFiles;
+
+    private boolean nonRecursive;
+
+    private boolean force;
+
+    public Commit(File localDir, List<File> localFiles, boolean nonRecursive, boolean force) {
+        this.localDir = localDir;
+        this.localFiles = localFiles;
+        this.nonRecursive = nonRecursive;
+        this.force = force;
+    }
+
+    public void run(VltContext ctx) throws VltException {
+        VltTree infos = new VltTree(ctx, nonRecursive);
+        try {
+            if (localFiles.isEmpty()) {
+                infos.add(localDir);
+            } else {
+                infos.setDirsAsFiles(true);
+                infos.addAll(localFiles);
+            }
+        } catch (IOException e) {
+            throw new VltException("Unable to commit changes.", e);
+        }
+
+        // get common ancestor
+        String localRoot = infos.getRootPath();
+        VltDirectory root = new VltDirectory(ctx, new File(localRoot));
+        // mount fs at the top most directory
+        if (root.isControlled()) {
+            ctx.setFsRoot(root);
+        }
+        int rootLen = ctx.getFsRoot().length();
+
+        // create transaction with all changes
+        VaultFsTransaction tx = ctx.getFileSystem(ctx.getMountpoint()).startTransaction();
+        ctx.printMessage("Collecting commit information...");
+        for (VltTree.Info i: infos.infos()) {
+            i.dir.prepareCommit(tx, i.names, nonRecursive, force);
+        }
+
+        // do commit (assuming all files from the same repo)
+        ctx.printMessage("Transmitting file data...");
+        List<TransactionImpl.Info> txInfos;
+        try {
+            txInfos = new ArrayList<TransactionImpl.Info>(tx.commit());
+        } catch (Exception e) {
+            throw new VltException("Error while committing", e);
+        }
+        // sort them deepest first
+        Collections.sort(txInfos, new Comparator<TransactionImpl.Info>(){
+            private final PathComparator pc = new PathComparator();
+            public int compare(TransactionImpl.Info o1, TransactionImpl.Info o2) {
+                return -pc.compare(o1.getPath(), o2.getPath());
+            }
+        });
+
+        // updating entries
+        infos.clear();
+        for (TransactionImpl.Info info: txInfos) {
+            if (info.getType() == TransactionImpl.Type.ERROR) {
+                ctx.printMessage("Could not process " + info.getPath());
+                continue;
+            }
+            String fileName = Text.getName(info.getPath());
+            // get vlt directory
+            String dirPath = Text.getRelativeParent(info.getPath(), 1);
+            if (dirPath.length() > rootLen && !localRoot.endsWith(dirPath)) {
+                // calculate the fs-root relative path, in case the repo was not mounted at jcr:root
+                dirPath = dirPath.substring(rootLen + 1);
+            } else if (dirPath.length() < rootLen) {
+                // dir path outside of the mounted repo. special case
+                dirPath = "";
+                fileName = "";
+            } else {
+                dirPath = "";
+            }
+            File localDir = new File(localRoot, dirPath);
+            if (!localDir.exists()) {
+                // directory was already deleted, just print message and continue
+                File file = new File(localDir, fileName);
+                ctx.printAction(file.getPath(), FileAction.DELETED, null);
+                continue;
+            }
+
+            VltDirectory dir = new VltDirectory(ctx, localDir);
+
+            // check if local file is a directory
+            File localFile = new File(localDir, fileName);
+            if (localFile.isDirectory()) {
+                dir = new VltDirectory(ctx, localFile);
+            } else {
+                dir.updateComitted(info.getPath(), fileName);
+            }
+
+            // remember directory
+            infos.put(dir);
+        }
+
+        // to be on the save side, issue an update on all directories
+        Update upd = new Update(localDir, null, nonRecursive);
+        infos.put(root);
+        upd.setOnlyControlled(true);
+        for (VltTree.Info i: infos.infos()) {
+            i.dir.applyWithRemote(upd, Collections.<String>emptyList(), nonRecursive);
+        }
+
+        ctx.printMessage("done.");
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Debug.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Debug.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Debug.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Debug.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,68 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>Resolved</code>...
+ *
+ */
+public class Debug extends AbstractAction {
+
+    /**
+     * default logger
+     */
+    private static final Logger log = LoggerFactory.getLogger(Debug.class);
+
+    private final File localDir;
+
+    public Debug(File localDir) {
+        this.localDir = localDir;
+    }
+
+    public void run(VltContext ctx) throws VltException {
+        VltDirectory root = new VltDirectory(ctx, localDir);
+        // mount fs at the top most directory
+        if (root.isControlled()) {
+            ctx.setFsRoot(root);
+        }
+        Session s = ctx.getFileSystem(ctx.getMountpoint()).getAggregateManager().getSession();
+        byte[] buf = new byte[0x5000];
+        try {
+            Node tmp = s.getNode("/tmp");
+            tmp.setProperty("test_binary", new ByteArrayInputStream(buf));
+            tmp.setProperty("test_binary", new ByteArrayInputStream(buf));
+            s.save();
+        } catch (RepositoryException e) {
+            log.error("Failed", e);
+        }
+        ctx.printMessage("done.");
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Delete.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Delete.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Delete.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Delete.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,46 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.FileAction;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * <code>Delete</code>...
+ */
+public class Delete extends BaseAction {
+
+    private boolean force;
+
+    public Delete(File localDir, List<File> localFiles, boolean nonRecursive,
+                  boolean force) {
+        super(localDir, localFiles, nonRecursive);
+        setDirsAsFiles(true);
+        this.force = force;
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile) throws VltException {
+        FileAction action = file.delete(force);
+        dir.getContext().printAction(file, action);
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Diff.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Diff.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Diff.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Diff.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,41 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * <code>Diff</code>...
+ *
+ */
+public class Diff extends BaseAction {
+
+    public Diff(File localDir, List<File> localFiles, boolean nonRecursive) {
+        super(localDir, localFiles, nonRecursive);
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile)
+            throws VltException {
+        file.diff();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Info.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Info.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Info.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Info.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,80 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+import org.apache.jackrabbit.vault.vlt.meta.VltEntry;
+import org.apache.jackrabbit.vault.vlt.meta.VltEntryInfo;
+
+/**
+ * <code>Info</code>...
+ *
+ */
+public class Info extends BaseAction {
+
+    public Info(File localDir, List<File> localFiles, boolean nonRecursive) {
+        super(localDir, localFiles, nonRecursive);
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile) throws VltException {
+        if (file == null) {
+            return;
+        }
+        PrintStream out = dir.getContext().getStdout();
+
+        VltEntry e = file.getEntry();
+        out.printf("  Path: %s%n", dir.getContext().getCwdRelativePath(file.getPath()));
+        out.printf("Status: %s%n", file.getStatus().name().toLowerCase());
+        if (e != null) {
+            RepositoryAddress root = dir.getContext().getMountpoint();
+            RepositoryAddress addr = root.resolve(e.getAggregatePath());
+            addr = addr.resolve(e.getRepoRelPath());
+            out.printf("   URL: %s%n", addr.toString());
+            print(out, "  Work", e.work());
+            print(out, "  Base", e.base());
+            print(out, "  Mine", e.mine());
+            print(out, "Theirs", e.theirs());
+        }
+        out.println();
+    }
+
+    private static final SimpleDateFormat dateFmt = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");
+
+    private static void print(PrintStream out, String name, VltEntryInfo info) {
+        if (info == null) {
+            return;
+        }
+        out.printf("%s: %s, %s, %d, %s%n",
+                name,
+                dateFmt.format(new Date(info.getDate())),
+                info.getContentType(),
+                info.getSize(),
+                info.getMd5()
+        );
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropGet.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropGet.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropGet.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropGet.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,53 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * <code>Resolved</code>...
+ *
+ */
+public class PropGet extends BaseAction {
+
+    private String propName;
+
+    public PropGet(File localDir, List<File> localFiles, boolean nonRecursive,
+                   String propName) {
+        super(localDir, localFiles, nonRecursive);
+        this.propName = propName;
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile)
+            throws VltException {
+        if (file == null) {
+            // nothing to do
+            return;
+        }
+        String value = file.getProperty(propName);
+        if (value != null) {
+            dir.getContext().printMessage(file, propName + "=" + value);
+        }
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropList.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropList.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropList.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropList.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,53 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+import java.util.Properties;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ */
+public class PropList extends BaseAction {
+
+    public PropList(File localDir, List<File> localFiles, boolean nonRecursive) {
+        super(localDir, localFiles, nonRecursive);
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile)
+            throws VltException {
+        if (file == null) {
+            // nothing to do
+            return;
+        }
+        Properties props = file.getProperties();
+        if (props.isEmpty()) {
+            dir.getContext().printMessage("  (empty properties)");
+        } else {
+            for (Object name: props.keySet()) {
+                String value = (String) props.get(name);
+                dir.getContext().printMessage("  " + name + "=" + value);
+            }
+        }
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropSet.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropSet.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropSet.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/PropSet.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,51 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ */
+public class PropSet extends BaseAction {
+
+    private String propName;
+
+    private String propValue;
+
+    public PropSet(File localDir, List<File> localFiles, boolean nonRecursive,
+                   String propName, String propValue) {
+        super(localDir, localFiles, nonRecursive);
+        this.propName = propName;
+        this.propValue = propValue;
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile)
+            throws VltException {
+        if (file == null) {
+            // nothing to do
+            return;
+        }
+        file.setProperty(propName, propValue);
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/RemoteStatus.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/RemoteStatus.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/RemoteStatus.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/RemoteStatus.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,55 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.FileAction;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * <code>RemoteStatus</code>...
+ *
+ */
+public class RemoteStatus extends BaseAction {
+
+    public RemoteStatus(File localDir, List<File> localFiles, boolean nonRecursive) {
+        super(localDir, localFiles, nonRecursive);
+        setWithRemote(true);
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile)
+            throws VltException {
+        if (remoteFile == null && file == null) {
+            // nothing to do
+            return;
+        }
+        FileAction action;
+        if (file == null) {
+            // would be an addition
+            file = new VltFile(dir, remoteFile.getName(), null);
+            action = FileAction.ADDED;
+        } else {
+            action = file.status(remoteFile);
+        }
+        dir.getContext().printRemoteStatus(file, action);
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Resolved.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Resolved.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Resolved.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Resolved.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,47 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * <code>Resolved</code>...
+ *
+ */
+public class Resolved extends BaseAction {
+
+    private boolean forced;
+
+    public Resolved(File localDir, List<File> localFiles, boolean nonRecursive,
+                    boolean forced) {
+        super(localDir, localFiles, nonRecursive);
+        this.forced = forced;
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile)
+            throws VltException {
+        if (file.resolved(forced)) {
+            dir.getContext().printMessage(file, "resolved.");
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Revert.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Revert.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Revert.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Revert.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,43 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * <code>Revert</code>...
+ *
+ */
+public class Revert extends BaseAction {
+
+    public Revert(File localDir, List<File> localFiles, boolean recursive) {
+        super(localDir, localFiles, !recursive);
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile) throws VltException {
+        if (file.revert()) {
+            dir.getContext().printMessage(file, "reverted.");
+        }
+
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Status.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Status.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Status.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Status.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,41 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * <code>Status</code>...
+ *
+ */
+public class Status extends BaseAction {
+
+    public Status(File localDir, List<File> localFiles, boolean nonRecursive) {
+        super(localDir, localFiles, nonRecursive);
+    }
+
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile)
+            throws VltException {
+        dir.getContext().printStatus(file);
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Sync.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Sync.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Sync.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Sync.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,335 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Calendar;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+
+import org.apache.jackrabbit.commons.JcrUtils;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.sync.impl.VaultSyncServiceImpl;
+import org.apache.jackrabbit.vault.util.Text;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.VltException;
+
+/**
+ * <code>Checkout</code>...
+ */
+public class Sync extends AbstractAction {
+
+    public enum Command {
+        STATUS,
+        ST,
+        REGISTER,
+        UNREGISTER,
+        INIT,
+        INSTALL
+    }
+
+    private static final String[] INSTALL_ROOT = {"libs", "crx", "vault", "install"};
+    private static final String CFG_NODE_NAME = VaultSyncServiceImpl.class.getName();
+    private static final String CFG_NODE_PATH = "/libs/crx/vault/config/" + CFG_NODE_NAME;
+    private static final String CFG_ROOTS = VaultSyncServiceImpl.SYNC_SPECS;
+    private static final String CFG_ENABLED = VaultSyncServiceImpl.SYNC_ENABLED;
+    private RepositoryAddress mountPoint;
+
+    private File localDir;
+
+    private final Command cmd;
+
+    private boolean force;
+
+    public Sync(Command cmd, RepositoryAddress mountPoint, File localDir) {
+        this.cmd = cmd;
+        this.mountPoint = mountPoint;
+        this.localDir = localDir;
+    }
+
+    public void setForce(boolean force) {
+        this.force = force;
+    }
+
+    public void run(VltContext ctx) throws VltException {
+        if (mountPoint == null) {
+            mountPoint = ctx.getMountpoint();
+        }
+        if (mountPoint == null) {
+            throw ctx.error(ctx.getCwd().getAbsolutePath(), "No remote specified and not in vlt checkout.");
+        }
+
+        // currently we just read the config node, assuming it's at the correct location
+        Session s = null;
+        try {
+            s = ctx.login(mountPoint);
+            switch (cmd) {
+                case STATUS:
+                case ST:
+                    status(ctx, s);
+                    break;
+                case REGISTER:
+                    register(ctx, s, null);
+                    break;
+                case UNREGISTER:
+                    unregister(ctx, s);
+                    break;
+                case INSTALL:
+                    install(ctx, s);
+                    break;
+                case INIT:
+                    init(ctx, s);
+            }
+        } catch (RepositoryException e) {
+            throw new VltException("Error while performing command", e);
+        } finally {
+            if (s != null) {
+                s.logout();
+            }
+        }
+    }
+
+    private void init(VltContext ctx, Session s) throws VltException, RepositoryException {
+        // check if in vlt checkout
+        if (ctx.getExportRoot().isValid()) {
+            ctx.getStdout().printf("Starting initialization of sync service in existing vlt checkout %s for %s%n",
+                    ctx.getExportRoot().getJcrRoot().getAbsolutePath(),
+                    mountPoint);
+            // check if config is present, assume installed
+            Config cfg = new Config(s);
+            if (!cfg.load(ctx)) {
+                force = true;
+                install(ctx, s);
+            }
+            register(ctx, s, true);
+            ctx.getStdout().printf(
+                    "%nThe directory %1$s is now enabled for syncing.%n" +
+                    "You might perform a 'sync-once' by setting the%n" +
+                    "appropriate flag in the %1$s/.vlt-sync-config.properties file.%n%n",
+                    localDir.getAbsolutePath());
+        } else {
+            ctx.getStdout().printf("Starting initialization of sync service in a non vlt checkout directory %s for %s%n",
+                    localDir.getAbsolutePath(),
+                    mountPoint);
+            // check if empty
+            if (localDir.listFiles().length > 0) {
+                throw new VltException("Aborting initialization since directory is not empty.");
+            }
+            // check if config is present, assume installed
+            Config cfg = new Config(s);
+            if (!cfg.load(ctx)) {
+                force = true;
+                install(ctx, s);
+            }
+            register(ctx, s, true);
+            ctx.getStdout().printf(
+                    "%nThe directory %1$s is now enabled for syncing.%n" +
+                    "You need to configure the filter %1$s/.vlt-sync-filter.xml to setup the%n" +
+                    "proper paths. You might also perform a 'sync-once' by setting the%n" +
+                    "appropriate flag in the %1$s/.vlt-sync-config.properties file.%n%n",
+                    localDir.getAbsolutePath());
+        }
+    }
+
+    private void status(VltContext ctx, Session s) throws RepositoryException {
+        Config cfg = new Config(s);
+        if (!cfg.load(ctx)) {
+            ctx.getStdout().println("No sync-service configured at " + CFG_NODE_PATH);
+            return;
+        }
+        ctx.getStdout().println("Listing sync status for " + mountPoint);
+        ctx.getStdout().println("- Sync service is " + (cfg.enabled ? "enabled." : "disabled."));
+        if (cfg.roots.isEmpty()) {
+            ctx.getStdout().println("- No sync directories configured.");
+        } else {
+            for (String path : cfg.roots) {
+                ctx.getStdout().println("- syncing directory: " + path);
+            }
+        }
+    }
+
+    private void register(VltContext ctx, Session s, Boolean enable) throws RepositoryException {
+        Config cfg = new Config(s);
+        if (!cfg.load(ctx)) {
+            ctx.getStdout().println("No sync-service configured at " + CFG_NODE_PATH);
+            return;
+        }
+        for (String path: cfg.roots) {
+            // need to check canonical path
+            try {
+                File f = new File(path).getCanonicalFile();
+                if (f.equals(localDir)) {
+                    ctx.getStdout().println("Directory is already synced: " + localDir.getAbsolutePath());
+                    return;
+                }
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+        cfg.roots.add(localDir.getAbsolutePath());
+        if (enable != null) {
+            cfg.enabled = enable;
+        }
+        cfg.save(ctx);
+        ctx.getStdout().println("Added new sync directory: " + localDir.getAbsolutePath());
+    }
+
+    private void unregister(VltContext ctx, Session s) throws RepositoryException {
+        Config cfg = new Config(s);
+        if (!cfg.load(ctx)) {
+            ctx.getStdout().println("No sync-service configured at " + CFG_NODE_PATH);
+            return;
+        }
+        boolean found = false;
+        for (String path: cfg.roots) {
+            // need to check canonical path
+            try {
+                File f = new File(path).getCanonicalFile();
+                if (f.equals(localDir)) {
+                    found = true;
+                    break;
+                }
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+        if (!found) {
+            ctx.getStdout().println("Directory is not registered: " + localDir.getAbsolutePath());
+            return;
+        }
+        cfg.roots.remove(localDir.getAbsolutePath());
+        cfg.save(ctx);
+        ctx.getStdout().println("Removed sync directory: " + localDir.getAbsolutePath());
+    }
+
+    private void install(VltContext ctx, Session s) throws RepositoryException, VltException {
+        // get sync jar
+        URLClassLoader cl = (URLClassLoader) VaultSyncServiceImpl.class.getClassLoader();
+        URL resource = null;
+        for (URL url: cl.getURLs()) {
+            if (url.getPath().matches(".*/vault-sync-.*\\.jar")) {
+                resource = url;
+                break;
+            }
+        }
+        if (resource == null) {
+            throw new VltException("Unable to find vault-sync.jar library.");
+        }
+        String jarName = Text.getName(resource.getPath());
+        ctx.getStdout().println("Preparing to install " + jarName + "...");
+
+        Node root = s.getRootNode();
+        for (String name: INSTALL_ROOT) {
+            root = JcrUtils.getOrAddFolder(root, name);
+        }
+        // check if already a bundle is installed
+        for (Node child: JcrUtils.getChildNodes(root)) {
+            if (child.getName().startsWith("vault-sync-")) {
+                if (force) {
+                    ctx.getStdout().println("Detected existing bundle: " + child.getName() + ". Updating");
+                    break;
+                } else {
+                    ctx.getStdout().println("Detected existing bundle: " + child.getName() + ". Aborting installation. Specify --force to update.");
+                    return;
+                }
+            }
+        }
+        InputStream in = null;
+        try {
+            in = resource.openStream();
+            if (root.hasNode(jarName)) {
+                root.getNode(jarName).remove();
+            }
+            JcrUtils.putFile(root, jarName, "application/octet-stream", in, Calendar.getInstance());
+        } catch (IOException e) {
+            throw new VltException("Error while installing bundle", e);
+        } finally {
+            if (in != null) {
+                try {
+                    in.close();
+                } catch (IOException e) {
+                    // ignore
+                }
+            }
+        }
+        ctx.getStdout().println("Updated bundle: " + jarName);
+
+        // update config
+        root = JcrUtils.getOrAddFolder(root.getParent(), "config");
+        if (!root.hasNode(CFG_NODE_NAME)) {
+            root.addNode(CFG_NODE_NAME, "sling:OsgiConfig");
+            Config cfg = new Config(s);
+            cfg.enabled = true;
+            cfg.save(ctx);
+            ctx.getStdout().println("Created new config at " + CFG_NODE_PATH);
+        }
+        s.save();
+    }
+
+    private static class Config {
+
+        private final Session s;
+
+        private boolean enabled = false;
+
+        private Set<String> roots = new LinkedHashSet<String>();
+
+        private Config(Session s) {
+            this.s = s;
+        }
+
+        public boolean load(VltContext ctx) throws RepositoryException {
+            if (!s.nodeExists(CFG_NODE_PATH)) {
+                return false;
+            }
+            Node cfgNode = s.getNode(CFG_NODE_PATH);
+            if (cfgNode.hasProperty(CFG_ENABLED)) {
+                enabled = cfgNode.getProperty(CFG_ENABLED).getBoolean();
+            }
+            if (cfgNode.hasProperty(CFG_ROOTS)) {
+                Property roots = cfgNode.getProperty(CFG_ROOTS);
+                for (Value v : roots.getValues()) {
+                    this.roots.add(v.getString());
+                }
+            }
+            return true;
+        }
+
+        public void save(VltContext ctx) throws RepositoryException {
+            // assume node exists
+            Node cfgNode = s.getNode(CFG_NODE_PATH);
+            cfgNode.setProperty(CFG_ENABLED, enabled);
+            Value[] vals = new Value[roots.size()];
+            int i=0;
+            for (String path: roots) {
+                vals[i++] = s.getValueFactory().createValue(path);
+            }
+            cfgNode.setProperty(CFG_ROOTS, vals);
+            s.save();
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Update.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Update.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Update.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/Update.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,67 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.vlt.FileAction;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * <code>Update</code>...
+ *
+ */
+public class Update extends BaseAction {
+
+    private boolean force;
+
+    public Update(File localDir, List<File> localFiles, boolean nonRecursive) {
+        super(localDir, localFiles, nonRecursive);
+        setWithRemote(true);
+    }
+
+    public boolean isForce() {
+        return force;
+    }
+
+    public void setForce(boolean force) {
+        this.force = force;
+    }
+
+    @Override
+    public void run(VltDirectory dir, VltFile file, VaultFile remoteFile)
+            throws VltException {
+        if (file == null) {
+            if (remoteFile == null) {
+                return;
+            } else {
+                file = new VltFile(dir, remoteFile.getName(), null);
+            }
+        }
+
+        FileAction action = file.update(remoteFile, force);
+
+        // write back entries
+        dir.getEntries().update(file);
+        dir.sync();
+        dir.getContext().printAction(file, action);
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/VltTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/VltTree.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/VltTree.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/actions/VltTree.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,137 @@
+/*
+ * 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.vlt.actions;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.jackrabbit.vault.util.Constants;
+import org.apache.jackrabbit.vault.util.Tree;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+
+/**
+ * <code>VltTree</code>...
+ */
+public class VltTree {
+
+    private final VltContext ctx;
+
+    private final boolean nonRecursive;
+
+    private boolean dirsAsFiles;
+
+    private final Tree<Info> infos = new Tree<Info>(Constants.FS_NATIVE.charAt(0));
+
+    public VltTree(VltContext ctx, boolean nonRecursive) {
+        this.ctx = ctx;
+        this.nonRecursive = nonRecursive;
+    }
+
+    public String getRootPath() {
+        return infos.getRootPath();
+    }
+
+    public void setDirsAsFiles(boolean dirsAsFiles) {
+        this.dirsAsFiles = dirsAsFiles;
+    }
+
+    public void clear() {
+        infos.clear();
+    }
+
+    public void add(File file) throws VltException, IOException {
+        File dir;
+        if (file.isDirectory() && !nonRecursive && !dirsAsFiles) {
+            // if recursive, treat directories as such
+            dir = file;
+            file = null;
+        } else {
+            // if non recursive, treat directories as files
+            dir = file.getParentFile();
+        }
+        String path = dir.getCanonicalPath();
+        Info info = infos.get(path);
+        if (info == null) {
+            info = new Info(new VltDirectory(ctx, dir));
+            infos.put(path, info);
+        }
+        if (file != null) {
+            info.names.add(file.getName());
+        }
+    }
+
+    public void addAll(Collection<File> localFiles) throws IOException, VltException {
+        for (File file: localFiles) {
+            add(file);
+        }
+    }
+
+    public void put(VltDirectory dir) {
+        Info di = infos.get(dir.getPath());
+        if (di == null) {
+            di = new Info(dir);
+            infos.put(di.path, di);
+        }
+    }
+
+    public List<Info> infos() {
+        if (!nonRecursive) {
+            // strip all redundant entries
+            for (Map.Entry<String, Info> e: infos.map().entrySet()) {
+                if (e.getValue().names.isEmpty()) {
+                    infos.removeChildren(e.getKey());
+                }
+            }
+        }
+        LinkedList<Info> dirs = new LinkedList<Info>();
+        dirs.addAll(infos.map().values());
+        return dirs;
+    }
+
+    public static class Info {
+
+        final Set<String> names = new HashSet<String>();
+
+        final VltDirectory dir;
+
+        final String path;
+
+        final String ePath;
+
+        private Info(VltDirectory dir) {
+            this.dir = dir;
+            this.path = dir.getPath();
+            this.ePath = path + Constants.FS_NATIVE;
+        }
+
+        private void dump(VltContext ctx) {
+            ctx.printMessage("dir: " + path);
+            for (String n: names) {
+                ctx.printMessage("   ./" + n);
+            }
+        }
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/Ignored.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,164 @@
+/*
+ * 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.vlt.meta;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.jackrabbit.vault.fs.api.DumpContext;
+import org.apache.jackrabbit.vault.fs.api.PathFilter;
+import org.apache.jackrabbit.vault.fs.api.PathMapping;
+import org.apache.jackrabbit.vault.fs.config.VaultSettings;
+import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
+import org.apache.jackrabbit.vault.util.PlatformNameFormat;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.VltException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * <code>Ignored</code>...
+ */
+public class Ignored implements PathFilter {
+
+    /**
+     * default logger
+     */
+    private static final Logger log = LoggerFactory.getLogger(Ignored.class);
+
+    public static final String FILE_NAME = ".vltignore";
+
+    private final VaultSettings settings;
+
+    private final VltContext ctx;
+
+    private final int rootLength;
+
+    private final File scanRoot;
+
+    private List<PathFilter> ignored;
+
+    public Ignored(VltContext ctx, File scanRoot) {
+        this.ctx = ctx;
+        this.settings = ctx.getExportRoot().getMetaInf().getSettings();
+        this.scanRoot = scanRoot;
+        rootLength = ctx.getExportRoot().getJcrRoot().getAbsolutePath().length();
+    }
+
+    public List<PathFilter> getIgnored() {
+        if (ignored == null) {
+            long now = System.currentTimeMillis();
+            ignored = new LinkedList<PathFilter>();
+            try {
+                scan(scanRoot);
+            } catch (VltException e) {
+                log.error("Error while scanning for " + FILE_NAME, e);
+            } catch (IOException e) {
+                log.error("Error while scanning for " + FILE_NAME, e);
+            }
+            log.info("scanned for .vltignore files below {} in {}ms", scanRoot, System.currentTimeMillis() - now);
+        }
+        return ignored;
+    }
+
+
+    public boolean matches(String path) {
+        for (PathFilter p: getIgnored()) {
+            if (p.matches(path)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public Ignored scan(File dir) throws VltException, IOException {
+        for (File file: dir.listFiles()) {
+            String name = file.getName();
+            if (settings != null && settings.isIgnored(name)) {
+                continue;
+            }
+            if (file.isDirectory()) {
+                scan(file);
+            } else if (name.equals(FILE_NAME)) {
+                addIgnores(dir, file);
+            }
+        }
+        return this;
+    }
+
+    private void addIgnores(File dir, File file) throws VltException, IOException {
+        VltDirectory d = new VltDirectory(ctx, dir);
+        String root = d.getAggregatePath();
+        if (root == null) {
+            root = dir.getAbsolutePath().substring(rootLength);
+            root = PlatformNameFormat.getRepositoryPath(root);
+            log.info("Unable to detect correct repository path for {}. guessed: {}", dir.getPath(), root);
+        }
+        for (Object o: FileUtils.readLines(file, "utf-8")) {
+            addIgnored(root, o.toString());
+        }
+    }
+
+    private void addIgnored(String root, String pattern) {
+        if (pattern.startsWith("#")) {
+            return;
+        }
+        root = root.replace('\\', '/');
+        StringBuffer reg = new StringBuffer("^");
+        reg.append(root).append("/");
+        for (int i=0; i<pattern.length(); i++) {
+            char c = pattern.charAt(i);
+            if (c=='*') {
+                reg.append(".*");
+            } else if (c=='?') {
+                reg.append(".");
+            } else if (c=='.') {
+                reg.append("\\.");
+            } else {
+                reg.append(c);
+            }
+        }
+        reg.append("$");
+        log.info("Adding ignored path: {}", reg.toString());
+        ignored.add(new DefaultPathFilter(reg.toString()));
+    }
+
+    public boolean isAbsolute() {
+        return true;
+    }
+
+    public void dump(DumpContext ctx, boolean isLast) {
+        ctx.printf(isLast, "%s:", getClass().getSimpleName());
+        ctx.indent(isLast);
+        Iterator<PathFilter> iter = getIgnored().iterator();
+        while (iter.hasNext()) {
+            PathFilter e = iter.next();
+            e.dump(ctx, !iter.hasNext());
+        }
+        ctx.outdent();
+    }
+
+    public PathFilter translate(PathMapping mapping) {
+        return this;
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaDirectory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaDirectory.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaDirectory.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaDirectory.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,132 @@
+/*
+ * 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.vlt.meta;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.jackrabbit.vault.vlt.VltException;
+
+/**
+ * Provides an abstraction of a virtual directory that holds additional information about the files under vault
+ * control.
+ */
+public interface MetaDirectory {
+
+    /**
+     * Returns the underlying system file or directory.
+     * @return the system file.
+     */
+    File getFile();
+
+    /**
+     * Checks if this meta directory already exists on the filesystem.
+     * @return <code>true</code> if this meta directory exists.
+     */
+    boolean exists();
+
+    /**
+     * Creates the internal structures for this meta directory and initializes it with the given path.
+     * @param path the platform path relative to the jcr_root of this meta directory.
+     * @throws IOException if an I/O error occurs
+     */
+    void create(String path) throws IOException;
+
+    /**
+     * Deletes the internal structures of this meta directory
+     * @throws IOException if an I/O error occurs
+     */
+    void delete() throws IOException;
+
+    /**
+     * Synchronizes any internal changes to this meta directory with the underlying structures.
+     * @throws IOException if an I/O error occurs
+     */
+    void sync() throws IOException;
+
+    /**
+     * Synchronizes and closes this meta directory.
+     * @throws IOException if an I/O error occurs
+     */
+    void close() throws IOException;
+
+    /**
+     * Returns the repository url defined for this meta directory.
+     * @return the url or <code>null</code> if not defined.
+     * @throws IOException if an I/O error occurs
+     */
+    String getRepositoryUrl() throws IOException;
+
+    /**
+     * Sets the repository url define for this meta directory
+     * @param url the url
+     * @throws IOException if an I/O error occurs
+     */
+    void setRepositoryUrl(String url) throws IOException;
+
+    /**
+     * Returns the entries that are recorded in this meta directory
+     * @return the entries.
+     * @throws VltException if an error during reading of the entries occurrs.
+     */
+    VltEntries getEntries() throws VltException;
+
+    /**
+     * Returns a file of this meta directory.
+     * @param name name of the file
+     * @return the file or <code>null</code> if not found
+     * @throws IOException if an I/O error occurs
+     */
+    MetaFile getFile(String name) throws IOException;
+
+    /**
+     * Returns a file of this meta directory.
+     * @param name name of the file
+     * @param create if <code>true</code> a new file will be created if not exists.
+     * @return the file or <code>null</code> if not found and create is <code>false</code>.
+     * @throws IOException if an I/O error occurs
+     */
+    MetaFile getFile(String name, boolean create) throws IOException;
+
+    /**
+     * Returns a file from the internal temporary storage of this directory.
+     * @param name name of the file.
+     * @param create if <code>true</code> a new file will be created if not exists.
+     * @return the file or <code>null</code> if not found and create is <code>false</code>.
+     * @throws IOException if an I/O error occurs
+     */
+    MetaFile getTmpFile(String name, boolean create) throws IOException;
+
+    /**
+     * Returns a file from the internal base storage of this directory.
+     * @param name name of the file.
+     * @param create if <code>true</code> a new file will be created if not exists.
+     * @return the file or <code>null</code> if not found and create is <code>false</code>.
+     * @throws IOException if an I/O error occurs
+     */
+    MetaFile getBaseFile(String name, boolean create) throws IOException;
+
+    /**
+     * Checks if the file with the given name exists.
+     * @param name name of the file.
+     * @return <code>true</code> if the file exists.
+     * @throws IOException if an I/O error occurs
+     */
+    boolean hasFile(String name) throws IOException;
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaFile.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaFile.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaFile.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,120 @@
+/*
+ * 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.vlt.meta;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+
+import org.apache.jackrabbit.vault.util.MD5;
+
+/**
+ * Provides an abstraction for a file of a {@link MetaDirectory}.
+ */
+public interface MetaFile {
+
+    /**
+     * Returns the meta directory that created this file.
+     * @return the meta directory.
+     */
+    MetaDirectory getDirectory();
+
+    /**
+     * Returns a path of this file which is composed of the path of the meta directory and the name of this file.
+     * @return the path
+     */
+    String getPath();
+
+    /**
+     * Returns the name of this file.
+     * @return the name of this file.
+     */
+    String getName();
+
+    /**
+     * Open an input stream to this file.
+     * @return an input stream
+     * @throws IOException if an I/O error occurs
+     */
+    InputStream getInputStream() throws IOException;
+
+    /**
+     * Opens a reader using the utf-8 encoding
+     * @return a read
+     * @throws IOException if an I/O error occurs
+     */
+    Reader getReader() throws IOException;
+
+    /**
+     * Returns the length in bytes of this file
+     * @return the length.
+     */
+    long length();
+
+    /**
+     * Returns the MD5 checksum of this file. Note that this operation reads the file fully in order to calculate
+     * the checksum.
+     * @return the MD5 checksum.
+     * @throws IOException if an I/O error occurs
+     */
+    MD5 md5() throws IOException;
+
+    /**
+     * Returns the last modified date of this file.
+     * @return the last modified
+     */
+    long lastModified();
+
+    /**
+     * Deletes the file from it's meta directory
+     * @throws IOException if an I/O error occurs
+     */
+    void delete() throws IOException;
+
+    /**
+     * Opens a temporary file that is tied to this file and initializes it with the same content as this file.
+     * @return a temporary file.
+     * @throws IOException if an I/O error occurs
+     */
+    File openTempFile() throws IOException;
+
+    /**
+     * Close the previously opened temporary file. if <code>discard</code> is <code>false</code>, the contents of
+     * the temporary file are copied back to this file.
+     * @param discard <code>true</code> to discard the changes to the temp file
+     * @throws IOException if an I/O error occurs
+     */
+    void closeTempFile(boolean discard) throws IOException;
+
+    /**
+     * Moves this file to another meta file of the same directory
+     * @param dst destination file
+     * @throws IOException if an I/O error occurs
+     */
+    void moveTo(MetaFile dst) throws IOException;
+
+    /**
+     * Copies the contents of this file to the indicated platform file.
+     * @param file destination file
+     * @param preserveFileDate <code>true</code> to update the modification date of the destination file
+     * @throws IOException if an I/O error occurs
+     */
+    void copyTo(File file, boolean preserveFileDate) throws IOException;
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaFileDocSource.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaFileDocSource.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaFileDocSource.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/MetaFileDocSource.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,42 @@
+/*
+ * 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.vlt.meta;
+
+import org.apache.jackrabbit.vault.util.diff.DocumentSource;
+
+/**
+ * <code>MetaFileDocSource</code>...
+ */
+public class MetaFileDocSource implements DocumentSource {
+
+    private final MetaFile file;
+
+    public MetaFileDocSource(MetaFile file) {
+        this.file = file;
+    }
+
+    public String getLabel() {
+        return file.getName();
+    }
+
+    public String getLocation() {
+        return file.getPath();
+    }
+
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/VltEntries.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/VltEntries.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/VltEntries.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/VltEntries.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,72 @@
+/*
+ * 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.vlt.meta;
+
+import java.util.Collection;
+
+import org.apache.jackrabbit.vault.vlt.VltFile;
+
+/**
+ * The vault entries provide meta information about the entries under vault control.
+ * Note that entries are managed by their respective {@link MetaDirectory} and updates to this
+ * entries are only persisted if the directory is synced or closed.
+ */
+public interface VltEntries {
+
+    /**
+     * Returns the platform path of this entries relative to the vault root.
+     * @return the platform path
+     */
+    String getPath();
+
+    /**
+     * Checks if the entry with the given name exists
+     * @param localName name of the entry
+     * @return <code>true</code> if exists
+     */
+    boolean hasEntry(String localName);
+
+    /**
+     * Returns the vault entry for the given name
+     * @param localName the name of the entry
+     * @return the entry or <code>null</code> if not exists.
+     */
+    VltEntry getEntry(String localName);
+
+    /**
+     * Updates the entry with the state contained in the vault file.
+     * @param file the vault file.
+     */
+    void update(VltFile file);
+
+    /**
+     * Updates the paths properties of the entry with <code>localName</code>. If the entry did not exist yet,
+     * a new one is created.
+     * @param localName the name of the entry
+     * @param aggregatePath the new aggregate path
+     * @param repoRelPath the new repository path
+     * @return the entry that was updated.
+     */
+    VltEntry update(String localName, String aggregatePath, String repoRelPath);
+
+    /**
+     * Returns all entries.
+     * @return the entries
+     */
+    Collection<VltEntry> entries();
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/VltEntry.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/VltEntry.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/VltEntry.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-vlt/src/main/java/org/apache/jackrabbit/vault/vlt/meta/VltEntry.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,129 @@
+/*
+ * 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.vlt.meta;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * Represents an entry in of the {@link VltEntries}
+ */
+public interface VltEntry {
+
+    /**
+     * Describes the state of an entry
+     */
+    public enum State {
+
+        CLEAN(" "),
+        ADDED("A"),
+        CONFLICT("C"),
+        DELETED("D");
+
+        public final String letter;
+
+        private State(String shortName) {
+            this.letter = shortName;
+        }
+
+        public String toString() {
+            return name().toLowerCase() + " (" + letter + ")";
+        }
+
+    }
+
+    /**
+     * Returns the name of an entry.
+     * @return the name.
+     */
+    String getName();
+
+    /**
+     * Returns the repository path of this entry.
+     * @return the repository path.
+     */
+    String getRepoRelPath();
+
+    /**
+     * Returns the aggregate path of this entry.
+     * @return the aggregate path.
+     */
+    String getAggregatePath();
+
+    /**
+     * Creates a new entry info for the given type.
+     * @param type info type.
+     * @return the entry info
+     */
+    VltEntryInfo create(VltEntryInfo.Type type);
+
+    /**
+     * Puts and entry info to this entry.
+     * @param info the entry info
+     */
+    void put(VltEntryInfo info);
+
+    /**
+     * Returns the entry info of type {@link VltEntryInfo.Type#WORK}
+     * @return the "work" entry info or <code>null</code> if not defined.
+     */
+    VltEntryInfo work();
+
+    /**
+     * Returns the entry info of type {@link VltEntryInfo.Type#BASE}
+     * @return the "base" entry info or <code>null</code> if not defined.
+     */
+    VltEntryInfo base();
+
+    /**
+     * Returns the entry info of type {@link VltEntryInfo.Type#MINE}
+     * @return the "mine" entry info or <code>null</code> if not defined.
+     */
+    VltEntryInfo mine();
+
+    /**
+     * Returns the entry info of type {@link VltEntryInfo.Type#THEIRS}
+     * @return the "theirs" entry info or <code>null</code> if not defined.
+     */
+    VltEntryInfo theirs();
+
+    /**
+     * Removes the entry info with the given type.
+     * @param type the info type
+     * @return the previously assigned info or <code>null</code>
+     */
+    VltEntryInfo remove(VltEntryInfo.Type type);
+
+    /**
+     * Returns the state of this entry.
+     * @return the vault state
+     */
+    State getState();
+
+    void resolved(MetaFile fileTmp, File fileWork, MetaFile fileBase) throws IOException;
+
+    boolean delete(File fileWork);
+
+    boolean revertConflict(File work) throws IOException;
+
+    void conflict(File work, MetaFile base, MetaFile tmp) throws IOException;
+
+    boolean isDirty();
+
+    boolean isDirectory();
+
+}
\ No newline at end of file



Mime
View raw message