jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tri...@apache.org
Subject svn commit: r1512568 [4/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...
Date Sat, 10 Aug 2013 05:53:54 GMT
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLogin.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLogin.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLogin.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLogin.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,85 @@
+/*
+ * 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 'mount' command.
+ *
+ */
+public class CmdLogin extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        if (ctx.getVaultFsApp().isLoggedIn() && cl.hasOption(optForce)) {
+            ctx.getVaultFsApp().logout();
+        }
+        ctx.getVaultFsApp().login(
+                (String) cl.getValue(optCreds),
+                (String) cl.getValue(argWorkspace));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Login to the repository";
+    }
+
+    private Option optCreds;
+    private Option optForce;
+    private Argument argWorkspace;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("login")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optCreds = new DefaultOptionBuilder()
+                                .withShortName("c")
+                                .withLongName("credentials")
+                                .withDescription("simple connection credentials")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("user:pass")
+                                        .withMinimum(0)
+                                        .withMaximum(1)
+                                        .create())
+                                .create())
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withShortName("f")
+                                .withLongName("force")
+                                .withDescription("force relogin if already logged in")
+                                .create())
+                        .withOption(argWorkspace = new ArgumentBuilder()
+                                        .withName("workspace")
+                                        .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/CmdLogout.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLogout.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLogout.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLogout.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,48 @@
+/*
+ * 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 'unmount' command.
+ *
+ */
+public class CmdLogout extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        ctx.getVaultFsApp().logout();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Logout from the repository.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("logout")
+                .withDescription(getShortDescription())
+                .create();
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsAggregate.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsAggregate.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsAggregate.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsAggregate.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.cli;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+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.Aggregate;
+import org.apache.jackrabbit.vault.fs.api.Artifact;
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+import org.apache.jackrabbit.vault.util.console.util.Table;
+
+/**
+ * Implements the 'ls' command.
+ *
+ */
+public class CmdLsAggregate extends AbstractCmdLs {
+
+    /**
+     * afct flags
+     */
+    private static final int F_FLAG_TYPE = 0x01;
+
+    private Option optType;
+
+    protected int getFormatFlags(VaultFsConsoleExecutionContext ctx, CommandLine cl) {
+        int fmtFlag = 0;
+        fmtFlag |= cl.hasOption(optType) ? F_FLAG_TYPE : 0;
+        return fmtFlag;
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("ls")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optType = new DefaultOptionBuilder()
+                                .withShortName("t")
+                                .withDescription("display the artfiact type")
+                                .create())
+                        .withOption(argPath)
+                        .create())
+                .create();
+    }
+
+
+    protected void formatFile(ConsoleFile file, Table.Row row, int flags) {
+        try {
+            boolean isDir = false;
+            Aggregate f = (Aggregate) file.unwrap();
+            if (f.allowsChildren()) {
+                isDir = true;
+            }
+            if ((flags & F_FLAG_TYPE) > 0) {
+                if (f.getArtifacts().isEmpty()) {
+                    row.addCol("???");
+                } else {
+                    Artifact primary = f.getArtifacts().getPrimaryData();
+                    if (primary == null) {
+                        row.addCol("");
+                    } else {
+                        row.addCol(primary.getSerializationType().toString());
+                    }
+                }
+            }
+            row.addCol(f.getRelPath() + (isDir ? "/" : ""));
+        } catch (RepositoryException e) {
+            throw new ExecutionException(e);
+        }
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsJcrFs.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsJcrFs.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsJcrFs.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsJcrFs.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,100 @@
+/*
+ * 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.Option;
+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.util.Table;
+
+/**
+ * Implements the 'ls' command.
+ *
+ */
+public class CmdLsJcrFs extends AbstractCmdLs {
+
+    private static final int F_FLAG_SIZE = 0x01;
+    private static final int F_FLAG_TIME = 0x02;
+    private static final int F_FLAG_MIME = 0x04;
+    private static final int F_FLAG_LONG = 0x07;
+
+    private Option optLong;
+
+    private Option optTime;
+
+    private Option optSize;
+
+    private Option optMime;
+
+    protected int getFormatFlags(VaultFsConsoleExecutionContext ctx, CommandLine cl) {
+        int fmtFlag = 0;
+        fmtFlag |= cl.hasOption(optTime) ? F_FLAG_TIME : 0;
+        fmtFlag |= cl.hasOption(optSize) ? F_FLAG_SIZE : 0;
+        fmtFlag |= cl.hasOption(optMime) ? F_FLAG_MIME : 0;
+        fmtFlag |= cl.hasOption(optLong) ? F_FLAG_LONG : 0;
+        return fmtFlag;
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("ls")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optTime = new DefaultOptionBuilder()
+                                .withShortName("t")
+                                .withDescription("display the last modification date")
+                                .create())
+                        .withOption(optSize = new DefaultOptionBuilder()
+                                .withShortName("s")
+                                .withDescription("display the file size")
+                                .create())
+                        .withOption(optMime = new DefaultOptionBuilder()
+                                .withShortName("m")
+                                .withDescription("display the mime type")
+                                .create())
+                        .withOption(optLong = new DefaultOptionBuilder()
+                                .withShortName("l")
+                                .withDescription("combines all format flags")
+                                .create())
+                        .withOption(argPath)
+                        .create())
+                .create();
+    }
+
+
+    protected void formatFile(ConsoleFile file, Table.Row row, int flags) {
+            VaultFile f = (VaultFile) file.unwrap();
+            if ((flags & F_FLAG_TIME) > 0) {
+                row.addCol(formatDate(f.lastModified()), true);
+            }
+            if ((flags & F_FLAG_SIZE) > 0) {
+                row.addCol(formatSize(f.length()), true);
+            }
+            if ((flags & F_FLAG_MIME) > 0) {
+                row.addCol(f.getContentType() == null ? "" : f.getContentType());
+            }
+            row.addCol(f.getName() + (f.isDirectory() ? "/" : ""));
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsRepo.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsRepo.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsRepo.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdLsRepo.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,188 @@
+/*
+ * 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 javax.jcr.Node;
+import javax.jcr.Property;
+import javax.jcr.PropertyType;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.PropertyDefinition;
+
+import org.apache.commons.cli2.CommandLine;
+import org.apache.commons.cli2.Option;
+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.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+import org.apache.jackrabbit.vault.util.console.util.Table;
+
+/**
+ * Implements the 'ls' command.
+ *
+ */
+public class CmdLsRepo extends AbstractCmdLs {
+
+    private static final int F_FLAG_NT = 0x01;
+    private static final int F_FLAG_UUID = 0x02;
+    private static final int F_FLAG_LONG = 0x03;
+
+    private Option optLong;
+
+    private Option optNodeType;
+
+    private Option optUUID;
+
+
+    protected int getFormatFlags(VaultFsConsoleExecutionContext ctx, CommandLine cl) {
+        int fmtFlag = 0;
+        fmtFlag |= cl.hasOption(optNodeType) ? F_FLAG_NT : 0;
+        fmtFlag |= cl.hasOption(optUUID) ? F_FLAG_UUID : 0;
+        fmtFlag |= cl.hasOption(optLong) ? F_FLAG_LONG : 0;
+        return fmtFlag;
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("ls")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optNodeType = new DefaultOptionBuilder()
+                                .withShortName("n")
+                                .withDescription("display the node type of the nodes")
+                                .create())
+                        .withOption(optUUID = new DefaultOptionBuilder()
+                                .withShortName("u")
+                                .withDescription("display the uuid of the referenceable nodes")
+                                .create())
+                        .withOption(optLong = new DefaultOptionBuilder()
+                                .withShortName("l")
+                                .withDescription("combines the flags 'n' and 'u'")
+                                .create())
+                        .withOption(argPath)
+                        .create())
+                .create();
+    }
+
+
+    protected void formatFile(ConsoleFile file, Table.Row row, int flags) {
+        Object item = file.unwrap();
+        if (item instanceof Node) {
+            format((Node) item, row, flags, 0);
+        } else if (item instanceof Property) {
+            format((Property) item, row, flags, 0);
+        } else {
+            throw new ExecutionException("Illegal argument: " + item.getClass().getName());
+        }
+    }
+
+    private void format(Node node, Table.Row r, int flags, int indent) {
+        if ((flags & F_FLAG_UUID) > 0) {
+            try {
+                r.addCol(node.getUUID());
+            } catch (RepositoryException e) {
+                r.addCol("");
+            }
+        }
+        if ((flags & F_FLAG_NT) > 0) {
+            try {
+                r.addCol(node.getPrimaryNodeType().getName());
+            } catch (RepositoryException e) {
+                r.addCol("");
+            }
+        }
+        String mode = " + ";
+        if (node.isModified()) {
+            mode = "*+ ";
+        } else if (node.isNew()) {
+            mode = "++ ";
+        }
+        mode = Table.Col.SPACES.substring(0, indent * 2) + mode;
+        try {
+            if (node.getName().equals("")) {
+                mode += "/";
+            }
+            r.addCol(mode + node.getName());
+        } catch (RepositoryException e) {
+            r.addCol("???");
+        }
+    }
+
+    private void format(Property prop, Table.Row r, int flags, int indent) {
+        PropertyDefinition def;
+        try {
+            def = prop.getDefinition();
+        } catch (RepositoryException e) {
+            throw new ExecutionException(e);
+        }
+        /*
+        if ((flags & LS_FLAG_DEF) > 0) {
+            StringBuffer buf = new StringBuffer();
+            buf.append(def.isAutoCreated() ? "a" : "-");
+            buf.append(def.isMandatory() ? "m" : "-");
+            buf.append(def.isProtected() ? "p  " : "-  ");
+            buf.append(OnParentVersionAction.nameFromValue(def.getOnParentVersion()).substring(0, 3));
+            r.addCol(buf.toString());
+        }
+        */
+        if ((flags & F_FLAG_UUID) > 0) {
+            r.addCol("");
+        }
+        if ((flags & F_FLAG_NT) > 0) {
+            try {
+                r.addCol(PropertyType.nameFromValue(prop.getType()) + (def.isMultiple() ? "[]" : ""));
+            } catch (RepositoryException e) {
+                r.addCol("");
+            }
+        }
+        String mode = " - ";
+        if (prop.isModified()) {
+            mode = "*- ";
+        } else if (prop.isNew()) {
+            mode = "-- ";
+        }
+        mode = Table.Col.SPACES.substring(0, indent * 2) + mode;
+        try {
+            r.addCol(mode + prop.getName());
+        } catch (RepositoryException e) {
+            r.addCol("");
+        }
+        /*
+        if ((flags & LS_FLAG_VALUES) > 0) {
+            if (def.isMultiple()) {
+                Value[] vals = prop.getValues();
+                StringBuffer buf = new StringBuffer();
+                buf.append("{");
+                for (int i=0; i<vals.length; i++) {
+                    if (i>0) {
+                        buf.append(", ");
+                    }
+                    buf.append(AbstractConsole.formatValue(vals[i], 140));
+                }
+                buf.append("}");
+                r.addCol(buf.toString());
+            } else {
+                r.addCol(AbstractConsole.formatValue(prop.getValue(), 140));
+            }
+        }
+        */
+    }
+
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdMixins.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdMixins.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdMixins.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdMixins.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.util.Iterator;
+import java.util.List;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeType;
+
+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.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+
+/**
+ * Implements the 'get' command.
+ *
+ */
+public class CmdMixins extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl)
+            throws Exception {
+        String jcrPath = (String) cl.getValue(argJcrPath);
+
+        List added = cl.getValues(optAdd);
+        List rems = cl.getValues(optRemove);
+
+        ConsoleFile wo = ctx.getFile(jcrPath, true);
+        if (wo instanceof RepositoryCFile) {
+            Node node = (Node) wo.unwrap();
+            try {
+                for (Iterator it = added.iterator(); it.hasNext();) {
+                    node.addMixin((String) it.next());
+                }
+                for (Iterator it = rems.iterator(); it.hasNext();) {
+                    node.removeMixin((String) it.next());
+                }
+                String delim = "Mixins: ";
+                for (NodeType nt: node.getMixinNodeTypes()) {
+                    System.out.print(delim);
+                    System.out.print(nt.getName());
+                    delim = ", ";
+                }
+                System.out.println();
+            } catch (RepositoryException e) {
+                throw new ExecutionException("Error while downloading file: " + e);
+            }
+        } else {
+            throw new ExecutionException("'mixins' only possible in repcontext");
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Prints or manipulates the mixin node types of a repository node.";
+    }
+
+
+    public String getLongDescription() {
+        return  "Prints or manipulates the mixin node types of a repository node.\n" +
+                "\n" +
+                "Usage: mixins <jcr-path> {-a nodetype} {-r nodetype}\n" +
+                "\n" +
+                "Please note that the changes are not saved. use the 'save' command " +
+                "to persist the changes.";
+
+    }
+
+    private Argument argJcrPath;
+
+    private Option optAdd;
+
+    private Option optRemove;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("mixins")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optAdd = new DefaultOptionBuilder()
+                                .withShortName("a")
+                                .withLongName("add")
+                                .withDescription("adds a mixin")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("nodetype")
+                                        .withMinimum(1)
+                                        .create())
+                                .create())
+                        .withOption(optRemove = new DefaultOptionBuilder()
+                                .withShortName("r")
+                                .withLongName("remove")
+                                .withDescription("removes a mixin")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("nodetype")
+                                        .withMinimum(1)
+                                        .create())
+                                .create())
+
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcr-path")
+                                .withDescription("the jcr path")
+                                .withMinimum(1)
+                                .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/CmdMount.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdMount.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdMount.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdMount.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,134 @@
+/*
+ * 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;
+import org.apache.jackrabbit.vault.util.console.util.Table;
+
+/**
+ * Implements the 'mount' command.
+ *
+ */
+public class CmdMount extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        String path = (String) cl.getValue(argPath);
+        if (path == null) {
+            // display mount information
+            if (!ctx.getVaultFsApp().isMounted()) {
+                VaultFsApp.log.info("Not mounted.");
+            } else {
+                Table t = new Table(2);
+                t.addRow("      User:", ctx.getVaultFsApp().getProperty(VaultFsApp.KEY_USER));
+                t.addRow(" Workspace:", ctx.getVaultFsApp().getProperty(VaultFsApp.KEY_WORKSPACE));
+                t.addRow("Mountpoint:", ctx.getVaultFsApp().getProperty(VaultFsApp.KEY_MOUNTPOINT));
+                t.print();
+            }
+        } else {
+            if (!ctx.getVaultFsApp().isLoggedIn()) {
+                VaultFsApp.log.info("Not logged in.");
+            } else {
+                ctx.getVaultFsApp().mount(
+                        null,
+                        null,
+                        path,
+                        (String) cl.getValue(optConfigFile),
+                        (String) cl.getValue(optFilterFile),
+                        cl.hasOption(optForce));
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Mount a Vault filesystem.";
+    }
+
+    private Option optForce;
+    private Option optConfigFile;
+    private Option optFilterFile;
+    private Argument argPath;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("mount")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withShortName("f")
+                                .withLongName("force")
+                                .withDescription("force remount if already mounted")
+                                .create())
+                        .withOption(optConfigFile = new DefaultOptionBuilder()
+                                .withLongName("file")
+                                .withDescription("config.xml for jcrfs")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("file")
+                                        .withMinimum(0)
+                                        .withMaximum(1)
+                                        .create())
+                                .create())
+                        .withOption(optFilterFile = new DefaultOptionBuilder()
+                                .withLongName("filter")
+                                .withDescription("filter.xml for jcrfs")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("filter")
+                                        .withMinimum(0)
+                                        .withMaximum(1)
+                                        .create())
+                                .create())
+                        .withOption(argPath = new ArgumentBuilder()
+                                .withName("root")
+                                .withDescription("the repository path that forms the mount root")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getHelp() {
+        return "Synopsis:\n" +
+               "    mount [option] <path>\n"+
+               "\n" +
+               "Description:\n" +
+               "    Mounts a Vault filesystem. If <path> is omitted it lists\n" +
+                "   the current mountpoint.\n"+
+                "\n" +
+               "Options:\n"+
+               "    -c <user:pwd>  credentials for mount.\n" +
+               "    -w <workspace> workspace for mount\n" +
+               "    -u             force remount if already mounted.\n" +
+               "    -f <file>      config.xml.\n";
+    }
+}
\ No newline at end of file

Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropGet.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropGet.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropGet.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropGet.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,94 @@
+/*
+ * 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.PropGet;
+
+/**
+ * Implements the 'export' command.
+ *
+ */
+public class CmdPropGet extends AbstractVaultCommand {
+
+    private Option optRecursive;
+    private Argument argLocalPath;
+    private Argument argPropName;
+
+    @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.setQuiet(cl.hasOption(OPT_QUIET));
+        PropGet a = new PropGet(localDir,
+            localFiles,
+            !cl.hasOption(optRecursive),
+            (String) cl.getValue(argPropName));
+        vCtx.execute(a);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Print the value of a property on files or directories.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("propget")
+                .withName("pg")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_QUIET)
+                        .withOption(optRecursive = new DefaultOptionBuilder()
+                                .withShortName("R")
+                                .withLongName("recursive")
+                                .withDescription("descend recursively")
+                                .create())
+                        .withOption(argPropName = new ArgumentBuilder()
+                                .withName("propname")
+                                .withDescription("the property name")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to get the property from")
+                                .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/CmdPropList.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropList.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropList.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropList.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.PropList;
+
+/**
+ * Implements the 'export' command.
+ *
+ */
+public class CmdPropList 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.setQuiet(cl.hasOption(OPT_QUIET));
+        PropList a = new PropList(localDir,
+                localFiles,
+                !cl.hasOption(optRecursive));
+        vCtx.execute(a);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Print the properties on files or directories.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("proplist")
+                .withName("pl")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_QUIET)
+                        .withOption(optRecursive = new DefaultOptionBuilder()
+                                .withShortName("R")
+                                .withLongName("recursive")
+                                .withDescription("descend recursively")
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to list the properties from")
+                                .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/CmdPropSet.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropSet.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropSet.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPropSet.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,109 @@
+/*
+ * 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.PropSet;
+
+/**
+ * Implements the 'propset' command.
+ */
+public class CmdPropSet extends AbstractVaultCommand {
+
+    private Option optRecursive;
+    private Argument argLocalPath;
+    private Argument argPropName;
+    private Argument argPropValue;
+
+    @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.setQuiet(cl.hasOption(OPT_QUIET));
+        PropSet a = new PropSet(localDir,
+                localFiles,
+                !cl.hasOption(optRecursive),
+                (String) cl.getValue(argPropName),
+                (String) cl.getValue(argPropValue));
+        vCtx.execute(a);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Set the value of a property on files or directories.";
+    }
+
+    public String getLongDescription() {
+        return "Note: vlt recognizes the following special versioned properties:\n\n" +
+                "vlt:mime-type\n" +
+                "  The mimetype of the file.  Used to determine whether to merge\n" +
+                "  the file. A mimetype beginning with 'text/' (or an absent mimetype)\n" +
+                "  is treated as text. Anything else is treated as binary.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("propset")
+                .withName("ps")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_QUIET)
+                        .withOption(optRecursive = new DefaultOptionBuilder()
+                                .withShortName("R")
+                                .withLongName("recursive")
+                                .withDescription("descend recursively")
+                                .create())
+                        .withOption(argPropName = new ArgumentBuilder()
+                                .withName("propname")
+                                .withDescription("the property name")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create())
+                        .withOption(argPropValue = new ArgumentBuilder()
+                                .withName("propval")
+                                .withDescription("the property value")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to set the property to")
+                                .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/CmdPut.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPut.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPut.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdPut.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,143 @@
+/*
+ * 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.IOException;
+
+import javax.jcr.RepositoryException;
+
+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.api.VaultFsTransaction;
+import org.apache.jackrabbit.vault.util.FileInputSource;
+import org.apache.jackrabbit.vault.util.PathUtil;
+import org.apache.jackrabbit.vault.util.Text;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+
+/**
+ * Implements the 'put' command.
+ *
+ */
+public class CmdPut extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        String name = (String) cl.getValue(argLocalPath);
+        String jcrPath = (String) cl.getValue(argJcrPath);
+
+        VaultFile file;
+        if (jcrPath == null) {
+            jcrPath = Text.getName(name);
+            if (jcrPath.equals("")) {
+                jcrPath = name;
+            }
+        }
+        File local = ctx.getVaultFsApp().getPlatformFile(name, true);
+        VaultFile cwd = ctx.getVaultFsApp().getVaultFile("", true);
+        file = cwd.getFileSystem().getFile(cwd, jcrPath);
+        if (file == null) {
+            // do add
+            jcrPath = PathUtil.makePath(cwd.getPath(), jcrPath);
+            doAdd(local, cwd, jcrPath);
+        } else {
+            doPut(local, file);
+        }
+    }
+
+    private void doPut(File local, VaultFile remote) {
+        try {
+            FileInputSource is = new FileInputSource(local);
+            VaultFsTransaction tx = remote.getFileSystem().startTransaction();
+            tx.modify(remote, is);
+            tx.commit();
+            System.out.println(local.getName() + "  " + local.length() + " bytes.");
+        } catch (IOException e) {
+            throw new ExecutionException("Error while uploading file: " + e);
+        } catch (RepositoryException e) {
+            throw new ExecutionException("Error while uploading file: " + e);
+        }
+    }
+
+    private void doAdd(File local, VaultFile parent, String path) {
+        try {
+            FileInputSource is = new FileInputSource(local);
+            VaultFsTransaction tx = parent.getFileSystem().startTransaction();
+            tx.add(path, is);
+            tx.commit();
+            System.out.println(local.getName() + "  " + local.length() + " bytes.");
+        } catch (IOException e) {
+            throw new ExecutionException("Error while uploading file: " + e);
+        } catch (RepositoryException e) {
+            throw new ExecutionException("Error while uploading file: " + e);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Upload a file";
+    }
+
+
+    public String getLongDescription() {
+        return "Uploads a Vault file from the local file system to the remote " +
+                "Vault filesystem. If no remote path is given it uses the " +
+                "the same name as the local file.";
+    }
+
+    //private Option optForce;
+    private Argument argLocalPath;
+    private Argument argJcrPath;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("put")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                                /*
+                                .withOption(optForce = new DefaultOptionBuilder()
+                                        .withShortName("f")
+                                        .withDescription("force overwrite if local file already exists")
+                                        .create())
+                                */
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("local-path")
+                                .withDescription("the local path")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcrl-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/CmdRcp.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRcp.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRcp.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRcp.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,186 @@
+/*
+ * 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;
+import org.apache.jackrabbit.vault.fs.api.PathFilterSet;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.filter.DefaultPathFilter;
+import org.apache.jackrabbit.vault.util.DefaultProgressListener;
+import org.apache.jackrabbit.vault.util.RepositoryCopier;
+
+/**
+ * Implements the 'rcp' command.
+ *
+ */
+public class CmdRcp extends AbstractVaultCommand {
+
+    protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+        boolean quiet = cl.hasOption(OPT_QUIET);
+        RepositoryAddress src = new RepositoryAddress((String) cl.getValue(srcAddr));
+        RepositoryAddress dst = new RepositoryAddress((String) cl.getValue(dstAddr));
+        boolean recursive = cl.hasOption(optRecursive);
+        RepositoryCopier rcp = new RepositoryCopier();
+        if (!quiet) {
+            rcp.setTracker(new DefaultProgressListener());
+        }
+        if (cl.hasOption(optSize)) {
+            rcp.setBatchSize(Integer.parseInt(cl.getValue(optSize).toString()));
+        }
+        if (cl.hasOption(optThrottle)) {
+            rcp.setThrottle(Integer.parseInt(cl.getValue(optThrottle).toString()));
+        }
+        if (cl.hasOption(optResumeFrom)) {
+            rcp.setResumeFrom(cl.getValue(optResumeFrom).toString());
+        }
+        rcp.setUpdate(cl.hasOption(optUpdate));
+        rcp.setOnlyNewer(cl.hasOption(optNewer));
+        rcp.setNoOrdering(cl.hasOption(optNoOrdering));
+        DefaultWorkspaceFilter srcFilter = new DefaultWorkspaceFilter();
+        PathFilterSet excludes = new PathFilterSet("/");
+        for (Object e: cl.getValues(optExclude)) {
+            excludes.addExclude(new DefaultPathFilter(e.toString()));
+        }
+        srcFilter.add(excludes);
+        rcp.setSourceFilter(srcFilter);
+        rcp.copy(src, dst, recursive);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Remote copy of repository content.";
+    }
+
+    @Override
+    public String getLongDescription() {
+        return "Copies a node tree from one remote repository to another. " +
+               "Note that <src> points at the source node, and <dst>" +
+               "points at the destination path, which parent node must exist.\n" +
+                "\n" +
+                "Note: Due to bug in command line processing, the --exclude options need " +
+                "to be followed by another option before the <src> and <dst> arguments." +
+                "\n" +
+                "Example:\n" +
+                "  vlt rcp -e \".*\\.txt\" -r http://localhost:4502/crx/-/jcr:root/content http://admin:admin@localhost:4503/crx/-/jcr:root/content_copy\n";
+    }
+
+    private Argument srcAddr;
+    private Argument dstAddr;
+    private Option optRecursive;
+    private Option optSize;
+    private Option optExclude;
+    private Option optThrottle;
+    private Option optResumeFrom;
+    private Option optUpdate;
+    private Option optNewer;
+    private Option optNoOrdering;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("rcp")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_QUIET)
+                        .withOption(optRecursive = new DefaultOptionBuilder()
+                                .withShortName("r")
+                                .withLongName("recursive")
+                                .withDescription("descend recursively")
+                                .create())
+                        .withOption(optSize = new DefaultOptionBuilder()
+                                .withShortName("b")
+                                .withLongName("batchSize")
+                                .withDescription("number of nodes until intermediate save")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("size")
+                                        .withMinimum(0)
+                                        .withMaximum(1)
+                                        .create())
+                                .create())
+                        .withOption(optThrottle = new DefaultOptionBuilder()
+                                .withShortName("t")
+                                .withLongName("throttle")
+                                .withDescription("number of seconds to wait after an intermediate save")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("seconds")
+                                        .withMinimum(0)
+                                        .withMaximum(1)
+                                        .create())
+                                .create())
+                        .withOption(optResumeFrom = new DefaultOptionBuilder()
+                                .withShortName("R")
+                                .withLongName("resume")
+                                .withDescription("source path to resume operation after a restart")
+                                .withArgument(new ArgumentBuilder()
+                                        .withName("path")
+                                        .withMinimum(0)
+                                        .withMaximum(1)
+                                        .create())
+                                .create())
+                        .withOption(optUpdate = new DefaultOptionBuilder()
+                                .withShortName("u")
+                                .withLongName("update")
+                                .withDescription("overwrite/delete existing nodes.")
+                                .create())
+                        .withOption(optNewer = new DefaultOptionBuilder()
+                                .withShortName("n")
+                                .withLongName("newer")
+                                .withDescription("respect lastModified properties for update.")
+                                .create())
+                        .withOption(optExclude = new DefaultOptionBuilder()
+                                .withShortName("e")
+                                .withLongName("exclude")
+                                .withDescription("regexp of excluded source paths.")
+                                .withArgument(new ArgumentBuilder()
+                                        .withMinimum(0)
+                                        .create())
+                                .create())
+                        .withOption(optNoOrdering = new DefaultOptionBuilder()
+                                .withLongName("no-ordering")
+                                .withDescription("disable node ordering for updated content")
+                                .create())
+                        .withOption(srcAddr = new ArgumentBuilder()
+                                .withName("src")
+                                .withDescription("the repository address of the source tree")
+                                .withMinimum(1)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .withOption(dstAddr = new ArgumentBuilder()
+                                .withName("dst")
+                                .withDescription("the repository address of the destination node")
+                                .withMinimum(1)
+                                .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/CmdRefresh.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRefresh.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRefresh.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRefresh.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,94 @@
+/*
+ * 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 javax.jcr.Node;
+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.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+
+/**
+ * Implements the 'get' command.
+ *
+ */
+public class CmdRefresh extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl)
+            throws Exception {
+        String jcrPath = (String) cl.getValue(argJcrPath);
+        if (jcrPath == null) {
+            jcrPath = "/";
+        }
+        ConsoleFile wo = ctx.getFile(jcrPath, true);
+        if (wo instanceof RepositoryCFile) {
+            Node node = (Node) wo.unwrap();
+            try {
+                node.refresh(cl.hasOption(optKeepChanges));
+                System.out.println("Modifications refreshed.");
+            } catch (RepositoryException e) {
+                throw new ExecutionException("Error while refreshing: " + e);
+            }
+        } else {
+            throw new ExecutionException("'refresh' only possible in repcontext");
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Refreshs the repository node.";
+    }
+
+
+    private Argument argJcrPath;
+
+    private Option optKeepChanges;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("refresh")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optKeepChanges = new DefaultOptionBuilder()
+                                .withShortName("k")
+                                .withDescription("keep changes")
+                                .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/CmdResolved.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdResolved.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdResolved.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdResolved.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,102 @@
+/*
+ * 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.Resolved;
+
+/**
+ * Implements the 'resolved' command.
+ *
+ */
+public class CmdResolved extends AbstractVaultCommand {
+
+    private Option optRecursive;
+    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.setQuiet(cl.hasOption(OPT_QUIET));
+
+        Resolved a = new Resolved(localDir,
+                localFiles,
+                !cl.hasOption(optRecursive),
+                cl.hasOption(optForce));
+        vCtx.execute(a);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Remove 'conflicted' state on working copy files or directories.";
+    }
+
+    public String getLongDescription() {
+        return "Remove 'conflicted' state on working copy files or directories.\n" +
+                "\n" +
+                "Note:  this subcommand does not semantically resolve conflicts or\n" +
+                "remove conflict markers; it merely removes the conflict-related\n" +
+                "artifact files and allows PATH to be committed again.";
+    }
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("resolved")
+                .withName("res")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_QUIET)
+                        .withOption(optRecursive = new DefaultOptionBuilder()
+                                .withShortName("R")
+                                .withLongName("recursive")
+                                .withDescription("descend recursively")
+                                .create())
+                        .withOption(optForce = new DefaultOptionBuilder()
+                                .withLongName("force")
+                                .withDescription("resolve even if contains conflict markers")
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to resolve")
+                                .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/CmdRevert.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRevert.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRevert.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRevert.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,85 @@
+/*
+ * 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.Revert;
+
+/**
+ * Implements the 'revert' command.
+ */
+public class CmdRevert 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.setQuiet(cl.hasOption(OPT_QUIET));
+        Revert r = new Revert(localDir, localFiles, cl.hasOption(optRecursive));
+        vCtx.execute(r);
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Restore pristine working copy file (undo most local edits).";
+    }
+
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("revert")
+                .withName("rev")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(OPT_QUIET)
+                        .withOption(optRecursive = new DefaultOptionBuilder()
+                                .withShortName("R")
+                                .withLongName("recursive")
+                                .withDescription("descend recursively")
+                                .create())
+                        .withOption(argLocalPath = new ArgumentBuilder()
+                                .withName("file")
+                                .withDescription("file or directory to revert")
+                                .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/CmdRm.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRm.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRm.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdRm.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,88 @@
+/*
+ * 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;
+import org.apache.jackrabbit.vault.fs.impl.AggregateImpl;
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+
+/**
+ * Implements the 'rm' command.
+ *
+ */
+public class CmdRm extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+        String path = (String) cl.getValue(argPath);
+        boolean recursive = cl.hasOption(optRecursive);
+        ConsoleFile file = ctx.getFile(path, true);
+        if (file instanceof AggregateCFile) {
+            AggregateImpl node = (AggregateImpl) file.unwrap();
+            node.remove(recursive);
+        } else {
+            throw new ExecutionException("remove only allowed in afct mode.");
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Remove a file";
+    }
+
+    public String getLongDescription() {
+        return "Removes the file at the given <path>. If the file contains " +
+                "a directory artifact, only the non-directory artifacts are " +
+                "removed unless -r is specified.";
+    }
+
+    private Option optRecursive;
+    private Argument argPath;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("rm")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(optRecursive = new DefaultOptionBuilder()
+                                .withShortName("r")
+                                .withDescription("remove the directory artifacts recursively")
+                                .create())
+                        .withOption(argPath = new ArgumentBuilder()
+                                .withName("path")
+                                .withDescription("the jcrfs path")
+                                .withMinimum(1)
+                                .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/CmdSave.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdSave.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdSave.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdSave.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 javax.jcr.Node;
+import javax.jcr.RepositoryException;
+
+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.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+
+/**
+ * Implements the 'get' command.
+ *
+ */
+public class CmdSave extends AbstractJcrFsCommand {
+
+    protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl)
+            throws Exception {
+        String jcrPath = (String) cl.getValue(argJcrPath);
+        if (jcrPath == null) {
+            jcrPath = "/";
+        }
+        ConsoleFile wo = ctx.getFile(jcrPath, true);
+        if (wo instanceof RepositoryCFile) {
+            Node node = (Node) wo.unwrap();
+            try {
+                node.save();
+                System.out.println("Modifications persisted.");
+            } catch (RepositoryException e) {
+                throw new ExecutionException("Error while saving: " + e);
+            }
+        } else {
+            throw new ExecutionException("'save' only possible in repcontext");
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getShortDescription() {
+        return "Saves the repository node.";
+    }
+
+
+    private Argument argJcrPath;
+
+    protected Command createCommand() {
+        return new CommandBuilder()
+                .withName("save")
+                .withDescription(getShortDescription())
+                .withChildren(new GroupBuilder()
+                        .withName("Options:")
+                        .withOption(argJcrPath = new ArgumentBuilder()
+                                .withName("jcr-path")
+                                .withDescription("the jcr path")
+                                .withMinimum(0)
+                                .withMaximum(1)
+                                .create()
+                        )
+                        .create()
+                )
+                .create();
+    }
+
+}
\ No newline at end of file



Mime
View raw message