You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by tr...@apache.org on 2013/08/10 07:53:54 UTC

svn commit: r1512568 [3/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-cli...

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCheckout.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCheckout.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCheckout.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCheckout.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,128 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.util.Text;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.actions.Checkout;
+
+/**
+ * Implements the 'checkout' command. there are 2 forms, either:
+ * co rmi://localhost/crx.default/apps/components
+ *
+ * or:
+ * co --mountpoint=rmi://localhost/crx.default /apps/components
+ *
+ *
+ */
+public class CmdCheckout extends AbstractJcrFsCommand {
+
+    private Option optForce;
+    //private Option optExclude;
+    private Argument argLocalPath;
+    private Argument argJcrPath;
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl)
+            throws Exception {
+        // overwrite this, since it takes the mounted vault fs into account
+        String jcrPath = (String) cl.getValue(argJcrPath);
+        String localPath = (String) cl.getValue(argLocalPath);
+
+        VaultFile remoteFile = ctx.getVaultFsApp().getVaultFile(jcrPath, true);
+        RepositoryAddress addr = remoteFile.getAggregate().getManager().getMountpoint();
+
+        if (localPath == null) {
+            if (jcrPath == null) {
+                localPath = Text.getName(addr.toString());
+            } else {
+                localPath = Text.getName(jcrPath);
+            }
+        }
+        File localFile = ctx.getVaultFsApp().getPlatformFile(localPath, false);
+        if (localFile.isFile()) {
+            throw new ExecutionException("Local file must be a directory: " + localFile.getPath());
+        }
+        if (!localFile.exists()) {
+            localFile.mkdir();
+        }
+
+        VltContext vCtx = ctx.getVaultFsApp().createVaultContext(localFile);
+        vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+        vCtx.setQuiet(cl.hasOption(OPT_QUIET));
+        Checkout c = new Checkout(addr, jcrPath, localFile);
+        c.setForce(cl.hasOption(optForce));
+        vCtx.execute(c);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Checkout a Vault file system";
+    }
+
+    public String getLongDescription() {
+        return  "Checkout the Vault file system (starting at <jcrPath> to the " +
+                "local filesystem at <local-path>.";
+    }
+
+    protected Command createCommand() {
+        argJcrPath = new ArgumentBuilder()
+            .withName("jcrPath")
+            .withDescription("remote path")
+            .withMinimum(1)
+            .withMaximum(1)
+            .create();
+        argLocalPath = new ArgumentBuilder()
+            .withName("localPath")
+            .withDescription("local path (optional)")
+            .withMinimum(0)
+            .withMaximum(1)
+            .create();
+        return new CommandBuilder()
+                .withName("checkout")
+                .withName("co")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withLongName("force")
+                                .withDescription("force checkout to overwrite local files if they already exist.")
+                                .create())
+                        .withOption(OPT_VERBOSE)
+                        .withOption(OPT_QUIET)
+                        .withOption(argJcrPath)
+                        .withOption(argLocalPath)
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCheckoutCli.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCheckoutCli.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCheckoutCli.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCheckoutCli.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,173 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.util.Text;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.actions.Checkout;
+
+/**
+ * Implements the 'checkout' command. there are 2 forms, either:
+ * co rmi://localhost/crx.default/apps/components
+ *
+ * or:
+ * co --mountpoint=rmi://localhost/crx.default /apps/components
+ *
+ *
+ */
+public class CmdCheckoutCli extends AbstractVaultCommand {
+
+    private Option optForce;
+    private Option optFilter;
+    private Argument argLocalPath;
+    private Argument argJcrPath;
+    private Argument argMountpoint;
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl)
+            throws Exception {
+        throw new ExecutionException("internal error. command not supported in console");
+    }
+
+    protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+        String jcrPath = (String) cl.getValue(argJcrPath);
+        String localPath = (String) cl.getValue(argLocalPath);
+        String root = (String) cl.getValue(argMountpoint);
+        RepositoryAddress addr = new RepositoryAddress(root);
+
+        // shift arguments
+        if (localPath == null) {
+            localPath = jcrPath;
+            jcrPath = null;
+        }
+        if (jcrPath == null) {
+            jcrPath = addr.getPath();
+            addr = addr.resolve("/");
+        }
+        if (localPath == null) {
+            if (jcrPath == null) {
+                localPath = Text.getName(addr.toString());
+            } else {
+                localPath = Text.getName(jcrPath);
+            }
+        }
+        if (jcrPath == null || jcrPath.length() == 0 || !jcrPath.startsWith("/")) {
+            throw new ExecutionException("JCR path needs to be absolute: " + jcrPath);
+        }
+        File localFile = app.getPlatformFile(localPath, false);
+        if (localFile.isFile()) {
+            throw new ExecutionException("Local file must be a directory: " + localFile.getPath());
+        }
+        if (!localFile.exists()) {
+            localFile.mkdir();
+        }
+        VltContext vCtx = app.createVaultContext(localFile);
+        vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+        vCtx.setQuiet(cl.hasOption(OPT_QUIET));
+        vCtx.setDefaultFilter((String) cl.getValue(optFilter));
+        Checkout c = new Checkout(addr, jcrPath, localFile);
+        c.setForce(cl.hasOption(optForce));
+        vCtx.execute(c);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Checkout a Vault file system";
+    }
+
+    public String getLongDescription() {
+        return  "Checkout the Vault file system (starting at <uri> to the " +
+                "local filesystem at <local-path>.\n" +
+                "A <jcrPath> argument can be provided to checkout a sub directory " +
+                "of the remote tree.\n\n" +
+                "A workspace filters can be specified that will be copied into the " +
+                "META-INF directory.\n\n" +
+                "Examples:\n" +
+                "\n" +
+                "Using the JCR Remoting:\n" +
+                "  vlt --credentials admin:admin co http://localhost:8080/crx/server/crx.default/jcr:root/\n" +
+                "  \n" +
+                "with default workspace:\n" +
+                "  vlt --credentials admin:admin co http://localhost:8080/crx/server/-/jcr:root/\n" +
+                "  \n" +
+                "if URI is incomplete, it will be expanded:\n" +
+                "  vlt --credentials admin:admin co http://localhost:8080/crx\n";
+    }
+
+    protected Command createCommand() {
+        argMountpoint = new ArgumentBuilder()
+            .withName("uri")
+            .withDescription("mountpoint uri")
+            .withMinimum(1)
+            .withMaximum(1)
+            .create();
+        argJcrPath = new ArgumentBuilder()
+            .withName("jcrPath")
+            .withDescription("remote path (optional)")
+            .withMinimum(0)
+            .withMaximum(1)
+            .create();
+        argLocalPath = new ArgumentBuilder()
+            .withName("localPath")
+            .withDescription("local path (optional)")
+            .withMinimum(0)
+            .withMaximum(1)
+            .create();
+        return new CommandBuilder()
+                .withName("checkout")
+                .withName("co")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withLongName("force")
+                                .withDescription("force checkout to overwrite local files if they already exist.")
+                                .create())
+                        .withOption(OPT_VERBOSE)
+                        .withOption(OPT_QUIET)
+                        .withOption(optFilter = new DefaultOptionBuilder()
+                                .withShortName("f")
+                                .withLongName("filter")
+                                .withDescription("specifies auto filters if none defined.")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("file")
+                                        .withMaximum(1)
+                                        .withMinimum(1)
+                                        .create())
+                                .create())
+                        .withOption(argMountpoint)
+                        .withOption(argJcrPath)
+                        .withOption(argLocalPath)
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCommit.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCommit.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCommit.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdCommit.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,95 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.actions.Commit;
+
+/**
+ * Implements the 'export' command.
+ *
+ */
+public class CmdCommit extends AbstractVaultCommand {
+
+    private Option optNonRecursive;
+    private Argument argLocalPath;
+    private Option optForce;
+
+    @SuppressWarnings("unchecked")
+    protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+        List<String> localPaths = cl.getValues(argLocalPath);
+        List<File> localFiles = app.getPlatformFiles(localPaths, false);
+        File localDir = app.getPlatformFile("", true);
+
+        VltContext vCtx = app.createVaultContext(localDir);
+        vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+        vCtx.setQuiet(cl.hasOption(OPT_QUIET));
+        Commit s = new Commit(localDir,
+                localFiles,
+                cl.hasOption(optNonRecursive),
+                cl.hasOption(optForce));
+        vCtx.execute(s);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Send changes from your working copy to the repository.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("commit")
+                .withName("ci")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_VERBOSE)
+                        .withOption(OPT_QUIET)
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withLongName("force")
+                                .withDescription("force comitting even if remote is modified")
+                                .create())
+                        .withOption(optNonRecursive = new DefaultOptionBuilder()
+                                .withShortName("N")
+                                .withLongName("non-recursive")
+                                .withDescription("operate on single directory")
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to commit")
+                                .withMinimum(0)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdConnect.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdConnect.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdConnect.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdConnect.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,79 @@
+/*
+ * 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.cli;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+
+/**
+ * Implements the 'connect' command.
+ *
+ */
+public class CmdConnect extends AbstractJcrFsCommand {
+
+    private Argument argURI;
+
+    private Option optForce;
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        String uri = (String) cl.getValue(argURI);
+        if (uri != null) {
+            ctx.getVaultFsApp().setProperty(VaultFsApp.KEY_DEFAULT_URI, uri);
+        }
+        if (ctx.getVaultFsApp().isConnected() && cl.hasOption(optForce)) {
+            ctx.getVaultFsApp().disconnect();
+        }
+        ctx.getVaultFsApp().connect();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Connect to a repository";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("connect")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withShortName("f")
+                                .withDescription("force reconnect if already connected")
+                                .create())
+                        .withOption(argURI = new ArgumentBuilder()
+                                .withName("rmiuri")
+                                .withDescription("the rmi uri of the repository")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDebug.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDebug.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDebug.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDebug.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.cli;
+
+import java.io.File;
+import java.io.PrintWriter;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.vault.fs.api.DumpContext;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+import org.apache.jackrabbit.vault.util.console.platform.PlatformFile;
+
+/**
+ * Implements the 'export' command.
+ *
+ */
+public class CmdDebug extends AbstractJcrFsCommand {
+
+    private Argument argCommand;
+    private Argument argArgs;
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        String cmd = (String) cl.getValue(argCommand);
+        List args = cl.getValues(argArgs);
+        if (cmd.equals("getRelated")) {
+            if (args.size()<1) {
+                throw new ExecutionException("getRelated. needs path argument.");
+            }
+            String path = (String) args.get(0);
+            ConsoleFile wo = ctx.getFile(path, true);
+            if (wo instanceof VaultFsCFile) {
+                VaultFile file = (VaultFile) wo.unwrap();
+                Collection<? extends VaultFile> related = file.getRelated();
+                if (related == null) {
+                    System.out.println("(null)");                    
+                } else {
+                    for (VaultFile f: related) {
+                        System.out.println(f.getPath());
+                    }
+                }
+            } else {
+                VaultFsApp.log.info("File not a jcrfs file.: {}", path);
+            }
+
+        }
+        if (cmd.equals("test")) {
+            if (args.size()<1) {
+                throw new ExecutionException("test. needs path argument.");
+            }
+            String path = (String) args.get(0);
+            ConsoleFile wo = ctx.getFile(path, true);
+            if (wo instanceof PlatformFile) {
+                File file = (File) wo.unwrap();
+                DefaultWorkspaceFilter r = new DefaultWorkspaceFilter();
+                try {
+                    r.load(file);
+                    DumpContext dCtx = new DumpContext(new PrintWriter(System.out));
+                    r.dump(dCtx, false);
+                    dCtx.flush();
+                    
+                    IOUtils.copy(r.getSource(), System.out);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                    throw new ExecutionException(e);
+                }
+
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Issue debug commands.";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getLongDescription() {
+        return "Issue debug commands.\n" +
+                "\n" +
+                "Sub commands:\n" +
+                "  getRelated <jcr-path>\n"+
+                "  test <repo-path>";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("debug")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(argCommand = new ArgumentBuilder()
+                                .withName("cmd")
+                                .withDescription("the sub command")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .withOption(argArgs = new ArgumentBuilder()
+                                .withName("args")
+                                .withDescription("command arguments")
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDelete.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDelete.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDelete.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDelete.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,86 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.actions.Delete;
+
+/**
+ * Implements the 'delete' command.
+ *
+ */
+public class CmdDelete extends AbstractVaultCommand {
+
+    private Option optForce;
+    private Argument argLocalPath;
+
+    @SuppressWarnings("unchecked")
+    protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+        List<String> localPaths = cl.getValues(argLocalPath);
+        List<File> localFiles = app.getPlatformFiles(localPaths, false);
+        File localDir = app.getPlatformFile("", true);
+        VltContext vCtx = app.createVaultContext(localDir);
+        vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+        vCtx.setQuiet(cl.hasOption(OPT_QUIET));
+        Delete d = new Delete(localDir, localFiles, false, cl.hasOption(optForce));
+        vCtx.execute(d);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Remove files and directories from version control.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("delete")
+                .withName("del")
+                .withName("rm")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_VERBOSE)
+                        .withOption(OPT_QUIET)
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withLongName("force")
+                                .withDescription("force operation to run")
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to delete")
+                                .withMinimum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDiff.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDiff.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDiff.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDiff.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,84 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.actions.Diff;
+
+/**
+ * Implements the 'diff' command.
+ *
+ */
+public class CmdDiff extends AbstractVaultCommand {
+
+    private Option optNonRecursive;
+    private Argument argLocalPath;
+
+    @SuppressWarnings("unchecked")
+    protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+        List<String> localPaths = cl.getValues(argLocalPath);
+        List<File> localFiles = app.getPlatformFiles(localPaths, false);
+        File localDir = app.getPlatformFile("", true);
+
+        VltContext vCtx = app.createVaultContext(localDir);
+        vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+        Diff a = new Diff(localDir, localFiles, cl.hasOption(optNonRecursive));
+        vCtx.execute(a);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Display the differences between two paths.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("diff")
+                .withName("di")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optNonRecursive = new DefaultOptionBuilder()
+                                .withShortName("N")
+                                .withLongName("non-recursive")
+                                .withDescription("operate on single directory")
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to display the diffs from")
+                                .withMinimum(0)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDisconnect.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDisconnect.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDisconnect.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDisconnect.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.cli;
+
+
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.option.Command;
+
+/**
+ * Implements the 'diconnect' command.
+ *
+ */
+public class CmdDisconnect extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        ctx.getVaultFsApp().disconnect();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName() {
+        return "disconnect";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Disconnect from a repository";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("disconnect")
+                .withDescription(getShortDescription())
+                .create();
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDump.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDump.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDump.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdDump.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.cli;
+
+import java.io.File;
+import java.io.PrintWriter;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.vault.fs.api.DumpContext;
+import org.apache.jackrabbit.vault.fs.api.Dumpable;
+import org.apache.jackrabbit.vault.fs.api.VaultFileSystem;
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.platform.PlatformFile;
+
+/**
+ * Implements the 'mount' command.
+ *
+ */
+public class CmdDump extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl)
+            throws Exception {
+        String path = (String) cl.getValue(argPath);
+        VaultFileSystem fs = ctx.getVaultFsApp().getVaultFileSystem();
+        if (fs == null) {
+            VaultFsApp.log.info("Not mounted.");
+        } else if (path != null && !path.equals("")) {
+            if (cl.hasOption(optConfig) || cl.hasOption(optFilter)) {
+                ConsoleFile f = ctx.getCurrentFile();
+                File file;
+                if (f instanceof PlatformFile) {
+                    f = f.getFile(path, false);
+                    file = (File) f.unwrap();
+                } else {
+                    file = ctx.getVaultFsApp().getPlatformFile(path, false);
+                }
+                if (cl.hasOption(optConfig)) {
+                    IOUtils.copy(
+                        fs.getConfig().getSource(),
+                        FileUtils.openOutputStream(file)
+                    );
+                    VaultFsApp.log.info("VaultFs config written to {}", file.getPath());
+                } else {
+                    IOUtils.copy(
+                        fs.getWorkspaceFilter().getSource(),
+                        FileUtils.openOutputStream(file)
+                    );
+                    VaultFsApp.log.info("VaultFs workspace filter written to {}", file.getPath());
+                }
+            } else {
+                Object f = ctx.getCurrentFile().getFile(path, false).unwrap();
+                if (f instanceof Dumpable) {
+                    DumpContext dCtx = new DumpContext(new PrintWriter(System.out));
+                    ((Dumpable) f).dump(dCtx, true);
+                    dCtx.flush();
+                } else {
+                    VaultFsApp.log.info("Object not dumpable: {}", f);
+                }
+            }
+        } else {
+            fs.getAggregateManager().dumpConfig(new PrintWriter(System.out));
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Dump internal structures. Can also be used to write the current " +
+                "config or filter to the local file system.";
+    }
+
+    private Argument argPath;
+
+    private Option optConfig;
+
+    private Option optFilter;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("dump")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optConfig = new DefaultOptionBuilder()
+                                .withShortName("c")
+                                .withLongName("config")
+                                .withDescription("writes the config to the local file")
+                                .create())
+                        .withOption(optFilter = new DefaultOptionBuilder()
+                                .withShortName("f")
+                                .withLongName("filter")
+                                .withDescription("writes the workspace filter to the local file")
+                                .create())
+                        .withOption(argPath = new ArgumentBuilder()
+                                .withName("path")
+                                .withDescription("the path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create())
+                        .create())
+                .create();
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExport.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExport.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExport.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExport.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,133 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.fs.io.AbstractExporter;
+import org.apache.jackrabbit.vault.fs.io.JarExporter;
+import org.apache.jackrabbit.vault.fs.io.PlatformExporter;
+import org.apache.jackrabbit.vault.util.DefaultProgressListener;
+
+/**
+ * Implements the 'export' command.
+ *
+ */
+public class CmdExport extends AbstractJcrFsCommand {
+
+    private Option optType;
+    private Option optPrune;
+    private Argument argLocalPath;
+    private Argument argJcrPath;
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        String localPath = (String) cl.getValue(argLocalPath);
+        String jcrPath = (String) cl.getValue(argJcrPath);
+        boolean verbose = cl.hasOption(OPT_VERBOSE);
+        String type = (String) cl.getValue(optType, "platform");
+        VaultFile vaultFile = ctx.getVaultFsApp().getVaultFile(jcrPath, true);
+        if (localPath == null) {
+            localPath = vaultFile.getName();
+        }
+        File localFile = ctx.getVaultFsApp().getPlatformFile(localPath, false);
+
+        AbstractExporter exporter;
+        if (type.equals("platform")) {
+            if (!localFile.exists()) {
+                localFile.mkdirs();
+            }
+            exporter = new PlatformExporter(localFile);
+            ((PlatformExporter) exporter).setPruneMissing(cl.hasOption(optPrune));
+        } else if (type.equals("jar")) {
+            exporter = new JarExporter(localFile);
+        } else {
+            throw new Exception("Type " + type + " not supported");
+        }
+        if (jcrPath == null || !jcrPath.startsWith("/")) {
+            exporter.setRelativePaths(true);
+        }
+        VaultFsApp.log.info("Exporting {} to {}", vaultFile.getPath(), localFile.getCanonicalPath());
+        if (verbose) {
+            exporter.setVerbose(new DefaultProgressListener());
+        }
+        exporter.export(vaultFile);
+        VaultFsApp.log.info("Exporting done.");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Export the Vault filesystem";
+    }
+
+
+    public String getLongDescription() {
+        return  "Export the Vault filesystem (starting at <jcr-path> to the " +
+                "local filesystem at <local-path>. Both paths can be relative " +
+                "to their respective CWDs.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("export")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_VERBOSE)
+                        .withOption(optType = new DefaultOptionBuilder()
+                                .withShortName("t")
+                                .withDescription("specifies the export type. either 'platform' or 'jar'.")
+                                .withArgument(new ArgumentBuilder()
+                                        .withMinimum(0)
+                                        .withMaximum(1)
+                                        .create())
+                                .create())
+                        .withOption(optPrune = new DefaultOptionBuilder()
+                                .withShortName("P")
+                                .withLongName("prune-missing")
+                                .withDescription("specifies if missing local files should be deleted.")
+                                .create())
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcr-path")
+                                .withDescription("the jcr path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("local-path")
+                                .withDescription("the local path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExportCli.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExportCli.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExportCli.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdExportCli.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,176 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.fs.io.AbstractExporter;
+import org.apache.jackrabbit.vault.fs.io.JarExporter;
+import org.apache.jackrabbit.vault.fs.io.PlatformExporter;
+import org.apache.jackrabbit.vault.util.DefaultProgressListener;
+import org.apache.jackrabbit.vault.util.Text;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+
+/**
+ * Implements the 'export' command.
+ *
+ */
+public class CmdExportCli extends AbstractVaultCommand {
+
+    static final SimpleDateFormat FMT = new SimpleDateFormat("yyyyMMddHHmmss");
+
+    private Option optType;
+    private Option optPrune;
+    private Argument argLocalPath;
+    private Argument argJcrPath;
+    private Argument argMountpoint;
+
+
+    protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+        boolean verbose = cl.hasOption(OPT_VERBOSE);
+        String type = (String) cl.getValue(optType, "platform");
+
+        String jcrPath = (String) cl.getValue(argJcrPath);
+        String localPath = (String) cl.getValue(argLocalPath);
+        String root = (String) cl.getValue(argMountpoint);
+        RepositoryAddress addr = new RepositoryAddress(root);
+        // shift arguments
+        if (localPath == null) {
+            localPath = jcrPath;
+            jcrPath = null;
+        }
+        if (jcrPath == null) {
+            jcrPath = "/";
+        }
+        if (localPath == null) {
+            if (jcrPath .equals("/")) {
+                localPath = Text.getName(addr.toString());
+            } else {
+                localPath = Text.getName(jcrPath);
+            }
+            if (type.equals("jar")) {
+                localPath += "-" + FMT.format(new Date()) + ".jar";
+            } else {
+
+            }
+        }
+        File localFile = app.getPlatformFile(localPath, false);
+
+        AbstractExporter exporter;
+        VltContext vCtx;
+        if (type.equals("platform")) {
+            if (!localFile.exists()) {
+                localFile.mkdirs();
+            }
+            exporter = new PlatformExporter(localFile);
+            ((PlatformExporter) exporter).setPruneMissing(cl.hasOption(optPrune));
+            vCtx = app.createVaultContext(localFile);
+        } else if (type.equals("jar")) {
+            exporter = new JarExporter(localFile);
+            vCtx = app.createVaultContext(localFile.getParentFile());
+        } else {
+            throw new Exception("Type " + type + " not supported");
+        }
+
+        vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+        VaultFile vaultFile = vCtx.getFileSystem(addr).getFile(jcrPath);
+        if (vaultFile == null) {
+            VaultFsApp.log.error("Not such remote file: {}", jcrPath);
+            return;
+        }
+
+        VaultFsApp.log.info("Exporting {} to {}", vaultFile.getPath(), localFile.getCanonicalPath());
+        if (verbose) {
+            exporter.setVerbose(new DefaultProgressListener());
+        }
+        exporter.export(vaultFile);
+        VaultFsApp.log.info("Exporting done.");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Export the Vault filesystem";
+    }
+
+
+    public String getLongDescription() {
+        return  "Export the Vault filesystem mounted at <uri> to the " +
+                "local filesystem at <local-path>. An optional <jcr-path> can be " +
+                "specified in order to export just a sub tree.\n\n" +
+                "Example:\n" +
+                "  vlt export http://localhost:4502/crx /apps/geometrixx myproject";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("export")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_VERBOSE)
+                        .withOption(optType = new DefaultOptionBuilder()
+                                .withShortName("t")
+                                .withLongName("type")
+                                .withDescription("specifies the export type. either 'platform' or 'jar'.")
+                                .withArgument(new ArgumentBuilder()
+                                        .withMinimum(0)
+                                        .withMaximum(1)
+                                        .create())
+                                .create())
+                        .withOption(optPrune = new DefaultOptionBuilder()
+                                .withShortName("p")
+                                .withLongName("prune-missing")
+                                .withDescription("specifies if missing local files should be deleted.")
+                                .create())
+                        .withOption(argMountpoint = new ArgumentBuilder()
+                                .withName("uri")
+                                .withDescription("mountpoint uri")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create())
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcr-path")
+                                .withDescription("the jcr path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("local-path")
+                                .withDescription("the local path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create())
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdGet.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdGet.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdGet.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdGet.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.cli;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+
+/**
+ * Implements the 'get' command.
+ *
+ */
+public class CmdGet extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        boolean forced = cl.hasOption(optForce);
+        String jcrPath = (String) cl.getValue(argJcrPath);
+        String name = (String) cl.getValue(argLocalPath);
+
+        ConsoleFile wo = ctx.getFile(jcrPath, true);
+        if (wo instanceof VaultFsCFile) {
+            VaultFile file = (VaultFile) wo.unwrap();
+            if (name == null) {
+                name = file.getName();
+            }
+            File local = ctx.getVaultFsApp().getPlatformFile(name, false);
+            doGet(file, local, forced);
+        } else {
+            throw new ExecutionException("'get' only possible in jcr fs context");
+        }
+    }
+
+    private void doGet(VaultFile remote, File local, boolean forced) {
+        if (local.exists() && !forced) {
+            throw new ExecutionException("Local file already exists. Use -f to overwrite: " + local.getName());
+        }
+        try {
+            FileOutputStream out = new FileOutputStream(local);
+            remote.getArtifact().spool(out);
+            System.out.println(local.getName() + "  " + local.length() + " bytes.");
+            long lastMod = remote.lastModified();
+            if (lastMod > 0) {
+                local.setLastModified(lastMod);
+            }
+        } catch (IOException e) {
+            throw new ExecutionException("Error while downloading file: " + e);
+        } catch (RepositoryException e) {
+            throw new ExecutionException("Error while downloading file: " + e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Retrieve a file";
+    }
+
+
+    public String getLongDescription() {
+        return  "Retrieve a Jcr file from the repository and stores in to " +
+                "the local filesystem. If no local name is given it uses the " +
+                "the same name as the remote file.";
+
+    }
+
+    private Option optForce;
+    private Argument argJcrPath;
+    private Argument argLocalPath;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("get")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withShortName("f")
+                                .withDescription("force overwrite if local file already exists")
+                                .create())
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcrl-path")
+                                .withDescription("the jcr path")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("local-path")
+                                .withDescription("the local path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImport.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,135 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.fs.io.Archive;
+import org.apache.jackrabbit.vault.fs.io.FileArchive;
+import org.apache.jackrabbit.vault.fs.io.Importer;
+import org.apache.jackrabbit.vault.fs.io.ZipArchive;
+import org.apache.jackrabbit.vault.util.DefaultProgressListener;
+
+/**
+ * Implements the 'import' command.
+ *
+ */
+public class CmdImport extends AbstractJcrFsCommand {
+
+    //private Option optExclude;
+    private Argument argLocalPath;
+    private Argument argJcrPath;
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        String localPath = (String) cl.getValue(argLocalPath);
+        String jcrPath = (String) cl.getValue(argJcrPath);
+        boolean verbose = cl.hasOption(OPT_VERBOSE);
+        /*
+        List excludeList = cl.getValues(optExclude);
+        String[] excludes = Constants.EMPTY_STRING_ARRAY;
+        if (excludeList != null && excludeList.size() > 0) {
+            excludes = (String[]) excludeList.toArray(new String[excludeList.size()]);
+        }
+        */
+        File localFile = ctx.getVaultFsApp().getPlatformFile(localPath, false);
+        VaultFile vaultFile = ctx.getVaultFsApp().getVaultFile(jcrPath, true);
+        VaultFsApp.log.info("Importing {} to {}", localFile.getCanonicalPath(), vaultFile.getPath());
+        Archive archive;
+        if (localFile.isFile()) {
+            archive = new ZipArchive(localFile);
+        } else {
+            archive = new FileArchive(localFile);
+        }
+        Importer importer = new Importer();
+        if (verbose) {
+            importer.getOptions().setListener(new DefaultProgressListener());
+        }
+
+        Session s = vaultFile.getFileSystem().getAggregateManager().getSession();
+        Node importRoot = s.getNode(vaultFile.getPath());
+        importer.run(archive, importRoot);
+        VaultFsApp.log.info("Importing done.");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName() {
+        return "import";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Import a Vault filesystem";
+    }
+
+
+    public String getLongDescription() {
+        return "Import the local filesystem (starting at <local-path> to the " +
+                "Vault filesystem at <jcrl-path>. Both paths can be relative " +
+                "to their respective CWDs.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("import")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_VERBOSE)
+                        /*
+                        .withOption(optExclude = new DefaultOptionBuilder()
+                                .withShortName("e")
+                                .withDescription("specifies the excluded local files. can be multiple.")
+                                .withArgument(new ArgumentBuilder()
+                                        .withMinimum(0)
+                                        .create())
+                                .create())
+                        */
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("local-path")
+                                .withDescription("the local path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcr-path")
+                                .withDescription("the jcr path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdImportCli.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,191 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+import java.io.InputStream;
+
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.fs.io.Archive;
+import org.apache.jackrabbit.vault.fs.io.FileArchive;
+import org.apache.jackrabbit.vault.fs.io.Importer;
+import org.apache.jackrabbit.vault.fs.io.ZipArchive;
+import org.apache.jackrabbit.vault.util.DefaultProgressListener;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+
+/**
+ * Implements the 'import' command.
+ *
+ */
+public class CmdImportCli extends AbstractVaultCommand {
+
+    private Option optSync;
+    private Argument argLocalPath;
+    private Argument argJcrPath;
+    private Argument argMountpoint;
+    private Option optSysView;
+
+    protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+        String localPath = (String) cl.getValue(argLocalPath);
+        String jcrPath = (String) cl.getValue(argJcrPath);
+
+        boolean verbose = cl.hasOption(OPT_VERBOSE);
+        /*
+        List excludeList = cl.getValues(optExclude);
+        String[] excludes = Constants.EMPTY_STRING_ARRAY;
+        if (excludeList != null && excludeList.size() > 0) {
+            excludes = (String[]) excludeList.toArray(new String[excludeList.size()]);
+        }
+        */
+        String root = (String) cl.getValue(argMountpoint);
+        RepositoryAddress addr = new RepositoryAddress(root);
+
+        if (jcrPath == null) {
+            jcrPath = "/";
+        }
+        File localFile = app.getPlatformFile(localPath, false);
+
+        VltContext vCtx = app.createVaultContext(localFile);
+        vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+
+
+        if (cl.hasOption(optSysView)) {
+            if (!localFile.isFile()) {
+                VaultFsApp.log.error("--sysview specified but local path does not point to a file.");
+                return;
+            }
+            // todo: move to another location
+            InputStream ins = FileUtils.openInputStream(localFile);
+            try {
+                Session session = vCtx.getFileSystem(addr).getAggregateManager().getSession();
+                session.getWorkspace().importXML(jcrPath, ins, ImportUUIDBehavior.IMPORT_UUID_COLLISION_REMOVE_EXISTING);
+                return;
+            } finally {
+                IOUtils.closeQuietly(ins);
+            }
+        }
+
+
+        VaultFile vaultFile = vCtx.getFileSystem(addr).getFile(jcrPath);
+
+        VaultFsApp.log.info("Importing {} to {}", localFile.getCanonicalPath(), vaultFile.getPath());
+        Archive archive;
+        if (localFile.isFile()) {
+            archive = new ZipArchive(localFile);
+        } else {
+            if (cl.hasOption(optSync)) {
+                VaultFsApp.log.warn("--sync is not supported yet");
+            }
+            archive = new FileArchive(localFile);
+        }
+        archive.open(false);
+        try {
+            Importer importer = new Importer();
+            if (verbose) {
+                importer.getOptions().setListener(new DefaultProgressListener());
+            }
+            Session s = vaultFile.getFileSystem().getAggregateManager().getSession();
+            Node importRoot = s.getNode(vaultFile.getPath());
+            importer.run(archive, importRoot);
+        } finally {
+            archive.close();
+        }
+        VaultFsApp.log.info("Importing done.");
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getName() {
+        return "import";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Import a Vault filesystem";
+    }
+
+
+    public String getLongDescription() {
+        return "Import the local filesystem (starting at <local-path> to the " +
+                "vault filesystem at <uri>. A <jcr-path> can be specified as " +
+                "import root. If --sync is specified, the imported files are " +
+                "automatically put under vault control.\n\n" +
+                "Example:\n" +
+                "  vlt import http://localhost:4502/crx . /";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("import")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_VERBOSE)
+                        .withOption(optSync = new DefaultOptionBuilder()
+                                .withShortName("s")
+                                .withLongName("sync")
+                                .withDescription("put local files under vault control.")
+                                .create())
+                        .withOption(optSysView = new DefaultOptionBuilder()
+                                .withLongName("sysview")
+                                .withDescription("specifies that the indicated local file has the sysview format")
+                                .create())
+                        .withOption(argMountpoint = new ArgumentBuilder()
+                                .withName("uri")
+                                .withDescription("mountpoint uri")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("local-path")
+                                .withDescription("the local path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcr-path")
+                                .withDescription("the jcr path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdInfo.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdInfo.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdInfo.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdInfo.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,86 @@
+/*
+ * 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.cli;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.actions.Info;
+
+/**
+ * Implements the 'info' command.
+ *
+ */
+public class CmdInfo extends AbstractVaultCommand {
+
+    private Option optRecursive;
+    private Argument argLocalPath;
+
+    @SuppressWarnings("unchecked")
+    protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+        List<String> localPaths = cl.getValues(argLocalPath);
+        List<File> localFiles = app.getPlatformFiles(localPaths, false);
+        File localDir = app.getPlatformFile("", true);
+
+        VltContext vCtx = app.createVaultContext(localDir);
+        vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+        vCtx.setQuiet(cl.hasOption(OPT_QUIET));
+        Info u = new Info(localDir, localFiles, !cl.hasOption(optRecursive));
+        vCtx.execute(u);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Displays information about a local file.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("info")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_VERBOSE)
+                        .withOption(OPT_QUIET)
+                        .withOption(optRecursive = new DefaultOptionBuilder()
+                                .withShortName("R")
+                                .withLongName("recursive")
+                                .withDescription("operate recursive")
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to display info")
+                                .withMinimum(0)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdInvalidate.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdInvalidate.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdInvalidate.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdInvalidate.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,82 @@
+/*
+ * 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.cli;
+
+import org.apache.commons.cli2.Argument;
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.CommandBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.commons.cli2.option.Command;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+
+/**
+ * Implements the 'get' command.
+ *
+ */
+public class CmdInvalidate extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        String jcrPath = (String) cl.getValue(argJcrPath);
+
+        ConsoleFile wo = ctx.getFile(jcrPath, true);
+        if (wo instanceof VaultFsCFile) {
+            VaultFile file = (VaultFile) wo.unwrap();
+            file.invalidate();
+        } else {
+            throw new ExecutionException("'cat' only possible in jcr fs context");
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Invalidate a file";
+    }
+
+
+    public String getLongDescription() {
+        return  "Invalidates a file and it's related.";
+
+    }
+
+    private Argument argJcrPath;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("invalidate")
+                .withName("inv")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcr-path")
+                                .withDescription("the jcr path")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+
+}
\ No newline at end of file