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 [5/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/CmdStatus.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdStatus.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdStatus.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdStatus.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,115 @@
+/*
+ * 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.Action;
+import org.apache.jackrabbit.vault.vlt.actions.RemoteStatus;
+import org.apache.jackrabbit.vault.vlt.actions.Status;
+
+/**
+ * Implements the 'status' command.
+ *
+ */
+public class CmdStatus extends AbstractVaultCommand {
+
+ private Option optOnlyControlled;
+ private Option optShowUpdate;
+ 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));
+ vCtx.setQuiet(cl.hasOption(optOnlyControlled));
+ Action a = cl.hasOption(optShowUpdate)
+ ? new RemoteStatus(localDir, localFiles, cl.hasOption(optNonRecursive))
+ : new Status(localDir, localFiles, cl.hasOption(optNonRecursive));
+ vCtx.execute(a);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getShortDescription() {
+ return "Print the status of working copy files and directories.";
+ }
+
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getLongDescription() {
+ return "Print the status of working copy files and directories.\n" +
+ "\n" +
+ "If --show-update is specified, each file is checked against " +
+ "the remote version. the second letter then specifies what " +
+ "action would be performed by an update operation.";
+ }
+
+
+ protected Command createCommand() {
+ return new CommandBuilder()
+ .withName("status")
+ .withName("st")
+ .withDescription(getShortDescription())
+ .withChildren(new GroupBuilder()
+ .withName("Options:")
+ .withOption(OPT_VERBOSE)
+ .withOption(optOnlyControlled = new DefaultOptionBuilder()
+ .withShortName("q")
+ .withLongName("quiet")
+ .withDescription("show only status of controlled files")
+ .create())
+ .withOption(optShowUpdate = new DefaultOptionBuilder()
+ .withShortName("u")
+ .withLongName("show-update")
+ .withDescription("display update information")
+ .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 display the status")
+ .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/CmdSync.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdSync.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdSync.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdSync.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,159 @@
+/*
+ * 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.commons.cli2.validation.InvalidArgumentException;
+import org.apache.commons.cli2.validation.Validator;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.actions.Sync;
+
+/**
+ */
+public class CmdSync extends AbstractVaultCommand {
+
+ private Option optUri;
+
+ private Option optForce;
+
+ private Argument argCommand;
+
+ private Argument argLocalPath;
+
+ 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 {
+ Sync.Command cmd = (Sync.Command) cl.getValue(argCommand);
+ if (cmd == null) {
+ cmd = Sync.Command.INIT;
+ }
+ String root = (String) cl.getValue(optUri);
+ RepositoryAddress addr = root == null
+ ? null
+ : new RepositoryAddress(root);
+
+ String localPath = (String) cl.getValue(argLocalPath);
+ File localFile = app.getPlatformFile(localPath == null ? "." : localPath, false).getCanonicalFile();
+ VltContext vCtx = app.createVaultContext(localFile);
+ vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+ vCtx.setQuiet(cl.hasOption(OPT_QUIET));
+ Sync sc = new Sync(cmd, addr, localFile);
+ sc.setForce(cl.hasOption(optForce));
+ vCtx.execute(sc);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getShortDescription() {
+ return "Control vault sync service";
+ }
+
+ public String getLongDescription() {
+ return "Allows to control the vault sync service. Without any arguments this command " +
+ "tries to put the current CWD under sync control. If executed within a vlt checkout, " +
+ "it uses the respective filter and host to configure the syncing. If executed outside of " +
+ "a vlt checkout, it registers synchronization only if the directory is empty.\n\n" +
+ "Subcommands: \n" +
+ " install Installs the Vault Sync service on the remote server\n" +
+ " status (st) Display status information.\n" +
+ " register Register a new sync directory\n" +
+ " unregister Unregisters a sync directory\n" +
+ "\n" +
+ "Most of the commands take an optional local path as argument which then specifies the sync directory. " +
+ "If the --uri is omitted it is auto-detected from the current vault checkout.\n" +
+ "\n" +
+ "Note: the vault sync service creates a .vlt-sync-config.properties in the sync directory. See the inline " +
+ "comments for further options." +
+ "\n\n" +
+ "Examples:\n" +
+ "\n" +
+ "Listing sync roots of a server:\n" +
+ " vlt --credentials admin:admin sync --uri http://localhost:8080/crx status\n" +
+ "\n" +
+ "Add the current CWD as sync directory:\n" +
+ " vlt sync register";
+ }
+
+ protected Command createCommand() {
+ argCommand = new ArgumentBuilder()
+ .withName("command")
+ .withDescription("Sync Command")
+ .withMinimum(0)
+ .withMaximum(1)
+ .withValidator(new Validator() {
+ public void validate(List list) throws InvalidArgumentException {
+ if (list.size() > 0) {
+ String cmd = list.get(0).toString();
+ try {
+ list.set(0, Sync.Command.valueOf(cmd.toUpperCase()));
+ } catch (IllegalArgumentException e) {
+ throw new InvalidArgumentException("Invalid command: " + cmd);
+ }
+ }
+ }
+ })
+ .create();
+ argLocalPath = new ArgumentBuilder()
+ .withName("localPath")
+ .withDescription("local path (optional)")
+ .withMinimum(0)
+ .withMaximum(1)
+ .create();
+ return new CommandBuilder()
+ .withName("sync")
+ .withDescription(getShortDescription())
+ .withChildren(new GroupBuilder()
+ .withName("Options:")
+ .withOption(OPT_VERBOSE)
+ .withOption(optForce = new DefaultOptionBuilder()
+ .withLongName("force")
+ .withDescription("force certain commands to execute.")
+ .create())
+ .withOption(optUri = new DefaultOptionBuilder()
+ .withShortName("u")
+ .withLongName("uri")
+ .withDescription("Specifies the URI of the sync host.")
+ .withArgument(new ArgumentBuilder()
+ .withName("uri")
+ .withMaximum(1)
+ .withMinimum(1)
+ .create())
+ .create())
+ .withOption(argCommand)
+ .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/CmdTree.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdTree.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdTree.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdTree.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,106 @@
+/*
+ * 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.IOException;
+
+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.cli2.validation.NumberValidator;
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+
+/**
+ * Implements the 'tree' command.
+ *
+ */
+public class CmdTree extends AbstractJcrFsCommand {
+
+ protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+ String path = (String) cl.getValue(argPath);
+ int depth = Integer.MAX_VALUE;
+ if (cl.hasOption(optRecursive)) {
+ depth = ((Long) cl.getValue(optRecursive)).intValue();
+ }
+ ConsoleFile file = ctx.getFile(path, true);
+ tree(file, depth, "");
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getShortDescription() {
+ return "Provide a tree-dump of files";
+ }
+
+ /**
+ * Provides a tree dump
+ */
+ private void tree(ConsoleFile file, int depth, String indent)
+ throws IOException {
+ if (file.allowsChildren()) {
+ ConsoleFile[] files = file.listFiles();
+ if (files.length > 0) {
+ for (int i = 0; i < files.length; i++) {
+ String pfx = i == files.length -1 ? "`" : "|";
+ System.out.println(indent + pfx + "-- " + files[i].getName());
+ String ind = i == files.length -1 ? " " : "| ";
+ if (depth > 0) {
+ tree(files[i], depth -1, indent + ind);
+ }
+ }
+ }
+ }
+ }
+
+ private Option optRecursive;
+ private Argument argPath;
+
+ protected Command createCommand() {
+ return new CommandBuilder()
+ .withName("tree")
+ .withDescription(getShortDescription())
+ .withChildren(new GroupBuilder()
+ .withName("Options:")
+ .withOption(optRecursive = new DefaultOptionBuilder()
+ .withShortName("r")
+ .withDescription("limit depth")
+ .withArgument(new ArgumentBuilder()
+ .withName("depth")
+ .withDescription("limit tree to <depth>")
+ .withMinimum(1)
+ .withMaximum(1)
+ .withValidator(NumberValidator.getIntegerInstance())
+ .create())
+ .create())
+ .withOption(argPath = new ArgumentBuilder()
+ .withName("path")
+ .withDescription("the path of the tree")
+ .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/CmdUnmount.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdUnmount.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdUnmount.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdUnmount.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,49 @@
+/*
+ * 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 CmdUnmount extends AbstractJcrFsCommand {
+
+ protected void doExecute(VaultFsConsoleExecutionContext ctx, CommandLine cl) throws Exception {
+ ctx.getVaultFsApp().unmount();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getShortDescription() {
+ return "Unmount the Vault filesystem";
+ }
+
+ protected Command createCommand() {
+ return new CommandBuilder()
+ .withName("unmount")
+ .withDescription(getShortDescription())
+ .create();
+ }
+
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdUpdate.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdUpdate.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdUpdate.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 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.Update;
+
+/**
+ * Implements the 'update' command.
+ *
+ */
+public class CmdUpdate extends AbstractVaultCommand {
+
+ private Option optForce;
+ 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));
+ vCtx.setQuiet(cl.hasOption(OPT_QUIET));
+ Update u = new Update(localDir, localFiles, cl.hasOption(optNonRecursive));
+ u.setForce(cl.hasOption(optForce));
+ vCtx.execute(u);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getShortDescription() {
+ return "Bring changes from the repository into the working copy.";
+ }
+
+ protected Command createCommand() {
+ return new CommandBuilder()
+ .withName("update")
+ .withName("up")
+ .withDescription(getShortDescription())
+ .withChildren(new GroupBuilder()
+ .withName("Options:")
+ .withOption(OPT_VERBOSE)
+ .withOption(OPT_QUIET)
+ .withOption(optForce = new DefaultOptionBuilder()
+ .withLongName("force")
+ .withDescription("force overwrite of local files")
+ .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 update")
+ .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/CmdVaultDebug.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdVaultDebug.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdVaultDebug.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/CmdVaultDebug.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.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.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.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.actions.Debug;
+
+/**
+ * Implements the 'export' command.
+ *
+ */
+public class CmdVaultDebug extends AbstractVaultCommand {
+
+ private Argument argCommand;
+
+ @SuppressWarnings("unchecked")
+ protected void doExecute(VaultFsApp app, CommandLine cl) throws Exception {
+ File localDir = app.getPlatformFile("", true);
+ List<String> commands = cl.getValues(argCommand);
+ for (String cmd: commands) {
+ if (cmd.equals("binary")) {
+ Debug dbg = new Debug(localDir);
+ VltContext vCtx = app.createVaultContext(localDir);
+ vCtx.setVerbose(cl.hasOption(OPT_VERBOSE));
+ vCtx.setQuiet(cl.hasOption(OPT_QUIET));
+ vCtx.execute(dbg);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getShortDescription() {
+ return "Debug.";
+ }
+
+ protected Command createCommand() {
+ return new CommandBuilder()
+ .withName("vltdebug")
+ .withDescription(getShortDescription())
+ .withChildren(new GroupBuilder()
+ .withName("Options:")
+ .withOption(OPT_VERBOSE)
+ .withOption(OPT_QUIET)
+ .withOption(argCommand = new ArgumentBuilder()
+ .withName("cmd")
+ .withDescription("command")
+ .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/PlatformExecutionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/PlatformExecutionContext.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/PlatformExecutionContext.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/PlatformExecutionContext.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.cli;
+
+import java.io.File;
+
+import org.apache.jackrabbit.vault.util.console.commands.CmdCtx;
+import org.apache.jackrabbit.vault.util.console.platform.CmdCd;
+import org.apache.jackrabbit.vault.util.console.platform.CmdLs;
+import org.apache.jackrabbit.vault.util.console.platform.PlatformFile;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements a console/shell that operates on a jcrfs.
+ *
+ */
+public class PlatformExecutionContext extends VaultFsConsoleExecutionContext {
+
+ protected static Logger log = LoggerFactory.getLogger(PlatformExecutionContext.class);
+
+ public PlatformExecutionContext(VaultFsApp app, String name, File rootFile) {
+ super(app, name);
+ installCommand(new CmdCd());
+ installCommand(new CmdCtx());
+ installCommand(new CmdConnect());
+ installCommand(new CmdDisconnect());
+ installCommand(new CmdLogin());
+ installCommand(new CmdLogout());
+ installCommand(new CmdLs());
+ installCommand(new CmdTree());
+ installCommand(new CmdDump());
+ installCommand(new CmdDebug());
+ // vlt commands
+ installCommand(new CmdCheckout());
+ installCommand(new CmdStatus());
+ installCommand(new CmdCommit());
+ installCommand(new CmdUpdate());
+ installCommand(new CmdInfo());
+ installCommand(new CmdRevert());
+ installCommand(new CmdResolved());
+ installCommand(new CmdPropSet());
+ installCommand(new CmdPropGet());
+ installCommand(new CmdPropList());
+ installCommand(new CmdAdd());
+ installCommand(new CmdDelete());
+ installCommand(new CmdDiff());
+
+ setFileSystem(new PlatformFile(rootFile));
+ }
+
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/RepExecutionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/RepExecutionContext.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/RepExecutionContext.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/RepExecutionContext.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 javax.jcr.Node;
+
+import org.apache.jackrabbit.vault.util.console.commands.CmdCtx;
+import org.apache.jackrabbit.vault.util.console.platform.CmdCd;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements a console/shell that operates on a jcrfs.
+ *
+ */
+public class RepExecutionContext extends VaultFsConsoleExecutionContext {
+
+ protected static Logger log = LoggerFactory.getLogger(RepExecutionContext.class);
+
+ public RepExecutionContext(VaultFsApp app, String name, Node rootNode) {
+ super(app, name);
+
+ installCommand(new CmdCd());
+ installCommand(new CmdCtx());
+ installCommand(new CmdLogout());
+ installCommand(new CmdDisconnect());
+ installCommand(new CmdLsRepo());
+ installCommand(new CmdMount());
+ installCommand(new CmdTree());
+ installCommand(new CmdUnmount());
+ installCommand(new CmdDump());
+ installCommand(new CmdMixins());
+ installCommand(new CmdSave());
+ installCommand(new CmdRefresh());
+ installCommand(new CmdDebug());
+
+ setFileSystem(new RepositoryCFile(rootNode));
+
+ }
+
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/RepositoryCFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/RepositoryCFile.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/RepositoryCFile.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/RepositoryCFile.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,110 @@
+/*
+ * 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.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+
+import javax.jcr.Item;
+import javax.jcr.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+
+/**
+ * <code>RepositoryWorkObject</code>...
+ *
+ */
+public class RepositoryCFile implements ConsoleFile {
+
+ private final Item item;
+
+ public RepositoryCFile(Item item) {
+ this.item = item;
+ }
+
+ public Object unwrap() {
+ return item;
+ }
+
+ public String getPath() {
+ try {
+ return item.getPath();
+ } catch (RepositoryException e) {
+ return "";
+ }
+ }
+
+ public ConsoleFile getFile(String path, boolean mustExist)
+ throws IOException {
+ try {
+ if (item.isNode()) {
+ if (path.startsWith("/")) {
+ return new RepositoryCFile(item.getSession().getItem(path));
+ } else {
+ return new RepositoryCFile(((Node) item).getNode(path));
+ }
+ } else {
+ throw new ExecutionException("can't cd into property");
+ }
+ } catch (PathNotFoundException e) {
+ throw new FileNotFoundException(path);
+ } catch (RepositoryException e) {
+ throw new IOException(e.toString());
+ }
+ }
+
+ public ConsoleFile[] listFiles() throws IOException {
+ try {
+ if (item.isNode()) {
+ Node node = (Node) item;
+ ArrayList<RepositoryCFile> ret = new ArrayList<RepositoryCFile>();
+ PropertyIterator piter = node.getProperties();
+ while (piter.hasNext()) {
+ ret.add(new RepositoryCFile(piter.nextProperty()));
+ }
+ NodeIterator niter = node.getNodes();
+ while (niter.hasNext()) {
+ ret.add(new RepositoryCFile(niter.nextNode()));
+ }
+ return ret.toArray(new RepositoryCFile[ret.size()]);
+ } else {
+ return ConsoleFile.EMPTY_ARRAY;
+ }
+ } catch (RepositoryException e) {
+ throw new IOException(e.toString());
+ }
+ }
+
+ public boolean allowsChildren() {
+ return item.isNode();
+ }
+
+ public String getName() {
+ try {
+ return item.getName();
+ } catch (RepositoryException e) {
+ return "";
+ }
+ }
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsApp.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsApp.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsApp.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsApp.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,631 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import javax.jcr.Credentials;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.SimpleCredentials;
+
+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.DefaultOptionBuilder;
+import org.apache.commons.cli2.builder.GroupBuilder;
+import org.apache.jackrabbit.vault.cli.extended.ExtendedOption;
+import org.apache.jackrabbit.vault.cli.extended.XDavEx;
+import org.apache.jackrabbit.vault.cli.extended.XJcrLog;
+import org.apache.jackrabbit.vault.fs.Mounter;
+import org.apache.jackrabbit.vault.fs.api.Aggregate;
+import org.apache.jackrabbit.vault.fs.api.RepositoryAddress;
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.fs.api.VaultFileSystem;
+import org.apache.jackrabbit.vault.fs.api.VaultFsConfig;
+import org.apache.jackrabbit.vault.fs.api.WorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.config.AbstractVaultFsConfig;
+import org.apache.jackrabbit.vault.fs.config.ConfigurationException;
+import org.apache.jackrabbit.vault.fs.config.DefaultWorkspaceFilter;
+import org.apache.jackrabbit.vault.fs.config.ExportRoot;
+import org.apache.jackrabbit.vault.fs.config.MetaInf;
+import org.apache.jackrabbit.vault.util.RepositoryProvider;
+import org.apache.jackrabbit.vault.util.console.AbstractApplication;
+import org.apache.jackrabbit.vault.util.console.Console;
+import org.apache.jackrabbit.vault.util.console.ExecutionContext;
+import org.apache.jackrabbit.vault.util.console.ExecutionException;
+import org.apache.jackrabbit.vault.util.console.commands.CmdConsole;
+import org.apache.jackrabbit.vault.util.console.util.CliHelpFormatter;
+import org.apache.jackrabbit.vault.util.console.util.Log4JConfig;
+import org.apache.jackrabbit.vault.util.console.util.PomProperties;
+import org.apache.jackrabbit.vault.vlt.ConfigCredentialsProvider;
+import org.apache.jackrabbit.vault.vlt.DefaultCredentialsProvider;
+import org.apache.jackrabbit.vault.vlt.VltContext;
+import org.apache.jackrabbit.vault.vlt.VltDirectory;
+import org.apache.jackrabbit.vault.vlt.meta.MetaDirectory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements a console/shell that operates on a jcrfs.
+ *
+ */
+public class VaultFsApp extends AbstractApplication {
+
+ private static final String LOG4J_PROPERTIES = "/org/apache/jackrabbit/vault/cli/log4j.properties";
+
+ public static final String KEY_URI = "uri";
+ public static final String KEY_WORKSPACE = "workspace";
+ public static final String KEY_MOUNTPOINT = "mountpoint";
+
+ public static final String KEY_DEFAULT_WORKSPACE = "conf.workspace";
+ public static final String KEY_DEFAULT_MOUNTPOINT = "conf.mountpoint";
+ public static final String KEY_DEFAULT_CREDS = "conf.credentials";
+ public static final String KEY_DEFAULT_URI = "conf.uri";
+ public static final String KEY_DEFAULT_CONFIG_XML = "conf.configxml";
+ public static final String KEY_DEFAULT_FILTER_XML = "conf.filterxml";
+
+ private static final String DEFAULT_URI = "http://localhost:8080/crx/server/crx.default";
+ private static final String DEFAULT_WSP = "crx.default";
+ private static final String DEFAULT_CREDS = "admin:admin";
+
+ protected static Logger log = LoggerFactory.getLogger(VaultFsApp.class);
+
+ private RepositoryProvider repProvider;
+
+ private DefaultCredentialsProvider defCredsProvider;
+
+ private ConfigCredentialsProvider confCredsProvider;
+
+ private Repository rep;
+
+ private Session session;
+
+ private VaultFileSystem fs;
+
+ //private Option optURI;
+ //private Option optWorkspace;
+ private Option optCreds;
+ //private Option optMountpoint;
+ private Option optConfig;
+
+ private ExtendedOption[] xOpts = new ExtendedOption[]{
+ new XJcrLog(),
+ new XDavEx()
+ };
+
+ private ExecutionContext ctxDefault;
+
+ private VaultFsConsoleExecutionContext ctxPlatform;
+ private VaultFsConsoleExecutionContext ctxRepository;
+ private VaultFsConsoleExecutionContext ctxJcrfs;
+ private VaultFsConsoleExecutionContext ctxAfct;
+
+ private Console console;
+
+ public static void main(String[] args) {
+ new VaultFsApp().run(args);
+ }
+
+
+ public VaultFsApp() {
+ }
+
+ public VltContext createVaultContext(File localFile) {
+ try {
+ // hack for setting the default credentials
+ if (ctxRepository != null) {
+ defCredsProvider.setDefaultCredentials(getProperty(KEY_DEFAULT_CREDS));
+ }
+ File cwd = getPlatformFile("", true).getCanonicalFile();
+ return new VltContext(cwd, localFile, repProvider, confCredsProvider);
+ } catch (IOException e) {
+ throw new ExecutionException(e);
+ } catch (ConfigurationException e) {
+ throw new ExecutionException(e);
+ }
+ }
+
+ protected void login(String creds, String wsp) {
+ if (rep == null) {
+ throw new ExecutionException("Not connected to repository.");
+ }
+ if (session != null) {
+ log.info("Already logged in to repository");
+ return;
+ }
+
+ if (creds == null) {
+ creds = getProperty(KEY_DEFAULT_CREDS);
+ }
+ if (creds == null) {
+ creds = DEFAULT_CREDS;
+ }
+ if (wsp == null) {
+ wsp = getProperty(KEY_DEFAULT_WORKSPACE);
+ }
+ if (wsp == null) {
+ wsp = DEFAULT_WSP;
+ }
+ Credentials defaultCreds;
+ int idx = creds.indexOf(':');
+ if (idx > 0) {
+ defaultCreds = new SimpleCredentials(creds.substring(0, idx), creds.substring(idx + 1).toCharArray());
+ } else {
+ defaultCreds = new SimpleCredentials(creds, new char[0]);
+ }
+ try {
+ session = rep.login(defaultCreds, wsp);
+ } catch (RepositoryException e) {
+ throw new ExecutionException("Failed to login to repository.", e);
+ }
+
+ try {
+ // install repository contexts
+ ctxRepository = new RepExecutionContext(this, "rep", session.getRootNode());
+ console.addContext(ctxRepository);
+ } catch (RepositoryException e) {
+ log.error("Internal error. logging out.");
+ logout();
+ throw new ExecutionException("Error during login", e);
+ }
+
+ setProperty(KEY_WORKSPACE, session.getWorkspace().getName());
+ setProperty(KEY_USER, session.getUserID());
+ setProperty(KEY_PROMPT,
+ "[${" + KEY_USER + "}@${" + KEY_WORKSPACE + "} ${" + KEY_PATH +"}]$ ");
+
+ log.info("Logged into repository as {} on workspace {}", session.getUserID(), session.getWorkspace().getName());
+ }
+
+ protected void logout() {
+ if (session == null) {
+ log.info("Not logged into repository");
+ return;
+ }
+ if (isMounted()) {
+ unmount();
+ }
+ session.logout();
+ session = null;
+ log.info("Logged out from repository.");
+
+ // remove context
+ console.switchContext(ctxPlatform);
+ console.removeContext(ctxRepository);
+ ctxRepository = null;
+ }
+
+ protected boolean isLoggedIn() {
+ return session != null && session.isLive();
+ }
+
+ public VaultFileSystem getVaultFileSystem() {
+ return fs;
+ }
+
+ @Override
+ public String getCopyrightLine() {
+ return "Copyright 2013 by Apache Software Foundation. See LICENSE.txt for more information.";
+ }
+
+ protected void mount(String creds, String wsp, String root, String config,
+ String filter, boolean remount) {
+ if (!isConnected()) {
+ throw new ExecutionException("Not connected to repository.");
+ }
+ if (!isLoggedIn()) {
+ login(creds, wsp);
+ }
+ if (isMounted()) {
+ if (remount) {
+ unmount();
+ } else {
+ log.info("Filesystem already mounted.");
+ return;
+ }
+ }
+
+ if (root == null) {
+ root = getProperty(KEY_DEFAULT_MOUNTPOINT);
+ }
+ if (config == null) {
+ config = getProperty(KEY_DEFAULT_CONFIG_XML);
+ }
+ if (filter == null) {
+ filter = getProperty(KEY_DEFAULT_FILTER_XML);
+ }
+ try {
+ StringBuffer uri = new StringBuffer(getProperty(KEY_DEFAULT_URI));
+ uri.append("/").append(session.getWorkspace().getName());
+ if (root != null && !"/".equals(root)) {
+ uri.append(root);
+ }
+ RepositoryAddress mp =
+ new RepositoryAddress(uri.toString());
+ log.info("Mounting JcrFs on {}", mp.toString());
+
+ ExportRoot exportRoot = ExportRoot.findRoot(getPlatformFile("", true));
+ MetaInf inf = exportRoot == null ? null : exportRoot.getMetaInf();
+
+ // get config
+ VaultFsConfig jcrfsConfig = null;
+ if (config != null) {
+ File configFile = new File(config);
+ if (configFile.canRead()) {
+ jcrfsConfig = AbstractVaultFsConfig.load(configFile);
+ log.info("using {}", configFile.getCanonicalPath());
+ }
+ }
+ if (jcrfsConfig == null && inf != null) {
+ jcrfsConfig = inf.getConfig();
+ if (jcrfsConfig != null) {
+ log.info("using config from {}", exportRoot.getMetaDir().getPath());
+ }
+ }
+ if (jcrfsConfig == null) {
+ log.info("using embeded default config");
+ }
+ // get workspace filter
+ WorkspaceFilter wspFilter = null;
+ if (filter != null) {
+ File filterFile = new File(filter);
+ if (filterFile.canRead()) {
+ wspFilter = new DefaultWorkspaceFilter();
+ ((DefaultWorkspaceFilter) wspFilter).load(filterFile);
+ log.info("using {}", filterFile.getCanonicalPath());
+ }
+ }
+ if (wspFilter == null && inf != null) {
+ wspFilter = inf.getFilter();
+ if (wspFilter != null) {
+ log.info("using filter from {}", exportRoot.getMetaDir().getPath());
+ }
+ }
+ if (wspFilter == null) {
+ log.info("using embeded default filter");
+ }
+ fs = Mounter.mount(jcrfsConfig, wspFilter, mp, null, session);
+ } catch (Exception e) {
+ throw new ExecutionException("Unable to mount filesystem.", e);
+ }
+
+ try {
+ // install aggregate context
+ ctxAfct = new AggregateExecutionContext(this, "agg", fs.getAggregateManager().getRoot());
+ console.addContext(ctxAfct);
+ } catch (RepositoryException e) {
+ log.error("Internal error during mount. unmounting.");
+ try {
+ fs.unmount();
+ } catch (RepositoryException e1) {
+ // ignore
+ }
+ fs = null;
+ throw new ExecutionException("Error during mount.", e);
+ }
+
+ // install vault fs context
+ ctxJcrfs = new VaultFsExecutionContext(this, "vlt", fs.getRoot());
+ console.addContext(ctxJcrfs);
+
+ setProperty(KEY_MOUNTPOINT, root);
+ try {
+ log.info("Filesystem mounted on {}{}", fs.getAggregateManager().getWorkspace(), root);
+ } catch (RepositoryException e) {
+ // ignore
+ }
+ }
+
+ protected boolean isMounted() {
+ return fs != null;
+ }
+
+ protected void unmount() {
+ if (fs == null) {
+ log.info("Filesystem not mounted.");
+ return;
+ }
+ try {
+ fs.unmount();
+ } catch (RepositoryException e) {
+ log.error("Error while unmounting filesystem (ignored)", e);
+ }
+ fs = null;
+ setProperty(KEY_MOUNTPOINT, null);
+
+ // remove context
+ console.switchContext(ctxRepository);
+ console.removeContext(ctxJcrfs);
+ console.removeContext(ctxAfct);
+
+ log.info("Filesystem unmounted");
+ }
+
+ protected VaultFile getVaultFile(String path, boolean mustExist) {
+ return (VaultFile) ctxJcrfs.getFile(path, mustExist).unwrap();
+ }
+
+ protected File getPlatformFile(String path, boolean mustExist) {
+ return (File) ctxPlatform.getFile(path, mustExist).unwrap();
+ }
+
+ protected List<File> getPlatformFiles(List<String> paths, boolean mustExist) {
+ List<File> files = new ArrayList<File>(paths.size());
+ for (String path: paths) {
+ files.add((File) ctxPlatform.getFile(path, mustExist).unwrap());
+ }
+ return files;
+ }
+
+ protected Aggregate getArtifactsNode(String path, boolean mustExist) {
+ return (Aggregate) ctxAfct.getFile(path, mustExist).unwrap();
+ }
+
+
+ protected void assertMounted() {
+ if (fs == null) {
+ throw new IllegalStateException("Filesystem not mounted.");
+ }
+ }
+
+ protected void connect() {
+ if (rep != null) {
+ throw new ExecutionException("Already connected to " + getProperty(KEY_URI));
+ } else {
+ String uri = getProperty(KEY_DEFAULT_URI);
+ try {
+ rep = repProvider.getRepository(new RepositoryAddress(uri));
+ setProperty(KEY_URI, uri);
+ StringBuffer info = new StringBuffer();
+ info.append(rep.getDescriptor(Repository.REP_NAME_DESC)).append(' ');
+ info.append(rep.getDescriptor(Repository.REP_VERSION_DESC));
+ log.info("Connected to {} ({})", uri, info.toString());
+ } catch (Exception e) {
+ rep = null;
+ throw new ExecutionException("Error while connecting to " + uri, e);
+ }
+ }
+ }
+
+ protected boolean isConnected() {
+ return rep != null;
+ }
+
+ protected void disconnect() {
+ if (rep == null) {
+ log.info("Not connected to repository.");
+ } else {
+ if (isLoggedIn()) {
+ logout();
+ }
+ rep = null;
+ setProperty(KEY_URI, null);
+ log.info("Disconnected.");
+ }
+ }
+
+ public PomProperties getPomProperties() {
+ return new PomProperties("org.apache.jackrabbit.vault", "vault-cli");
+ }
+
+ public String getApplicationName() {
+ return "Jackrabbit FileVault";
+ }
+
+ public String getShellCommand() {
+ return "vlt";
+ }
+
+ protected ExecutionContext getDefaultContext() {
+ if (ctxDefault == null) {
+ ctxDefault = new VltExecutionContext(this);
+ ctxDefault.installCommand(new CmdConsole());
+ }
+ return ctxDefault;
+ }
+
+ public Console getConsole() {
+ return console;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void initLogging() {
+ Log4JConfig.init(LOG4J_PROPERTIES);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void init() {
+ super.init();
+
+ // init providers
+ repProvider = new RepositoryProvider();
+ defCredsProvider = new DefaultCredentialsProvider();
+ confCredsProvider = new ConfigCredentialsProvider(defCredsProvider);
+
+ // setup default config
+ setProperty(KEY_DEFAULT_CREDS, null);
+ // read the default URI from the .vlt root if available
+ File cwd;
+ try {
+ cwd = new File(".").getCanonicalFile();
+ } catch (IOException e) {
+ throw new ExecutionException(e);
+ }
+ ExportRoot exportRoot = ExportRoot.findRoot(cwd);
+ RepositoryAddress mountpoint = null;
+ if (exportRoot != null) {
+ try {
+ File dir = new File(exportRoot.getJcrRoot(), VltDirectory.META_DIR_NAME);
+ MetaDirectory rootMeta = VltContext.createMetaDirectory(dir);
+ String addr = rootMeta.getRepositoryUrl();
+ if (addr != null) {
+ mountpoint = new RepositoryAddress(addr);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ if (mountpoint == null) {
+ setProperty(KEY_DEFAULT_URI, DEFAULT_URI);
+ } else {
+ setProperty(KEY_DEFAULT_URI, mountpoint.getSpecificURI().toString());
+ setProperty(KEY_DEFAULT_WORKSPACE, mountpoint.getWorkspace());
+ setProperty(KEY_DEFAULT_MOUNTPOINT, mountpoint.getPath());
+ }
+ setProperty(KEY_PROMPT, "$ ");
+
+ // add platform context
+ console = new VaultFsConsole(this);
+ ctxPlatform = new PlatformExecutionContext(this, "local", cwd);
+ console.addContext(ctxPlatform);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void close() {
+ if (isConnected()) {
+ disconnect();
+ }
+ }
+
+ //------------------------------------------------------------< Command >---
+
+
+ public GroupBuilder addApplicationOptions(GroupBuilder gbuilder) {
+ /*
+ optURI = new DefaultOptionBuilder()
+ .withLongName("uri")
+ .withDescription("The rmi uri in the format '//<host>:<port>/<name>'.")
+ .withArgument(new ArgumentBuilder()
+ .withDescription("defaults to '" + DEFAULT_RMIURI + "'")
+ .withMinimum(0)
+ .withMaximum(1)
+ .create()
+ )
+ .create();
+
+ optWorkspace = new DefaultOptionBuilder()
+ .withLongName("workspace")
+ .withDescription("The default workspace to connect to.")
+ .withArgument(new ArgumentBuilder()
+ .withDescription("If missing the default workspace is used.")
+ .withMinimum(0)
+ .withMaximum(1)
+ .create()
+ )
+ .create();
+ */
+ optCreds = new DefaultOptionBuilder()
+ .withLongName("credentials")
+ .withDescription("The default credentials to use")
+ .withArgument(new ArgumentBuilder()
+ .withDescription("Format: <user:pass>. If missing an anoymous login is used")
+ .withMinimum(0)
+ .withMaximum(1)
+ .create()
+ )
+ .create();
+ /*
+ optMountpoint = new DefaultOptionBuilder()
+ .withLongName("mountpoint")
+ .withDescription("The default mountpoint to use")
+ .withArgument(new ArgumentBuilder()
+ .withDescription("If missing, the root node is used as mountpoint.")
+ .withMinimum(0)
+ .withMaximum(1)
+ .create()
+ )
+ .create();
+ */
+ optConfig = new DefaultOptionBuilder()
+ .withLongName("config")
+ .withDescription("The JcrFs config to use")
+ .withArgument(new ArgumentBuilder()
+ .withDescription("If missing the default config is used.")
+ .withMinimum(0)
+ .withMaximum(1)
+ .create()
+ )
+ .create();
+
+ // register extended options
+ for (ExtendedOption x: xOpts) {
+ gbuilder.withOption(x.getOption());
+ }
+ //gbuilder.withOption(optURI);
+ //gbuilder.withOption(optWorkspace);
+ gbuilder.withOption(optCreds);
+ //gbuilder.withOption(optMountpoint);
+ gbuilder.withOption(optConfig);
+ return super.addApplicationOptions(gbuilder);
+ }
+
+ public void execute(CommandLine commandLine) throws ExecutionException {
+ // TODO: move extended options support the commons-cli2
+ for (ExtendedOption x: xOpts) {
+ if (commandLine.hasOption(x.getOption())) {
+ List l = commandLine.getValues(x.getOption());
+ if (l.isEmpty()) {
+ CliHelpFormatter fmt = CliHelpFormatter.create();
+ fmt.setCmd(x);
+ fmt.setShowUsage(false);
+ fmt.print();
+ return;
+ } else {
+ x.process(l.get(0).toString());
+ }
+ }
+ }
+ super.execute(commandLine);
+ }
+
+ public void prepare(CommandLine cl) throws ExecutionException {
+ super.prepare(cl);
+ /*
+ if (cl.getValue(optURI) != null) {
+ setProperty(KEY_DEFAULT_RMIURI, (String) cl.getValue(optURI));
+ }
+ if (cl.getValue(optWorkspace) != null) {
+ setProperty(KEY_DEFAULT_WORKSPACE, (String) cl.getValue(optWorkspace));
+ }
+ if (cl.getValue(optMountpoint) != null) {
+ setProperty(KEY_DEFAULT_MOUNTPOINT, (String) cl.getValue(optMountpoint));
+ }
+ */
+ if (cl.getValue(optCreds) != null) {
+ String userPass = (String) cl.getValue(optCreds);
+ setProperty(KEY_DEFAULT_CREDS, userPass);
+ confCredsProvider.setDefaultCredentials(userPass);
+ }
+ if (cl.getValue(optConfig) != null) {
+ setProperty(KEY_DEFAULT_CONFIG_XML, (String) cl.getValue(optConfig));
+ }
+ }
+
+
+}
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsCFile.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsCFile.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsCFile.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsCFile.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.FileNotFoundException;
+import java.io.IOException;
+import java.util.Collection;
+
+import javax.jcr.RepositoryException;
+
+import org.apache.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.util.console.ConsoleFile;
+
+/**
+ * <code>OsWorkObject</code>...
+ *
+ */
+public class VaultFsCFile implements ConsoleFile {
+
+ private final VaultFile file;
+
+ public VaultFsCFile(VaultFile file) {
+ this.file = file;
+ }
+
+ public Object unwrap() {
+ return file;
+ }
+
+ public String getPath() {
+ return file.getPath();
+ }
+
+ public ConsoleFile getFile(String path, boolean mustExist) throws IOException {
+ try {
+ VaultFile ret = file.getFileSystem().getFile(file, path);
+ if (ret == null) {
+ throw new FileNotFoundException(path);
+ }
+ return new VaultFsCFile(ret);
+ } catch (RepositoryException e) {
+ throw new IOException(e.toString());
+ }
+ }
+
+ public ConsoleFile[] listFiles() throws IOException {
+ try {
+ Collection<? extends VaultFile> files = file.getChildren();
+ if (files.isEmpty()) {
+ return ConsoleFile.EMPTY_ARRAY;
+ } else {
+ VaultFsCFile[] ret = new VaultFsCFile[files.size()];
+ int i=0;
+ for (VaultFile file: files) {
+ ret[i++] = new VaultFsCFile(file);
+ }
+ return ret;
+ }
+ } catch (RepositoryException e) {
+ throw new IOException(e.toString());
+ }
+ }
+
+ public boolean allowsChildren() {
+ return file.isDirectory();
+ }
+
+ public String getName() {
+ return file.getName();
+ }
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsConsole.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsConsole.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsConsole.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsConsole.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.jackrabbit.vault.util.console.Console;
+
+/**
+ * <code>JcrFsConsole</code>...
+ *
+ */
+public class VaultFsConsole extends Console {
+
+ private final VaultFsApp app;
+
+ public VaultFsConsole(VaultFsApp app) {
+ super(app);
+ this.app = app;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void setup() {
+ try {
+ app.connect();
+ app.mount(null, null, null, null, null, true);
+ } catch (Exception e) {
+ VaultFsApp.log.error("Error during connecting to default repository.", e);
+ // ignore
+ }
+ super.setup();
+ }
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsConsoleExecutionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsConsoleExecutionContext.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsConsoleExecutionContext.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsConsoleExecutionContext.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jackrabbit.vault.cli;
+
+import org.apache.jackrabbit.vault.util.console.ConsoleExecutionContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements a console/shell that operates on a jcrfs.
+ *
+ */
+abstract public class VaultFsConsoleExecutionContext extends ConsoleExecutionContext {
+
+ protected static Logger log = LoggerFactory.getLogger(VaultFsConsoleExecutionContext.class);
+
+ private final VaultFsApp app;
+
+ public VaultFsConsoleExecutionContext(VaultFsApp app, String name) {
+ super(app, name);
+ this.app = app;
+ }
+
+ public VaultFsApp getVaultFsApp() {
+ return app;
+ }
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsExecutionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsExecutionContext.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsExecutionContext.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VaultFsExecutionContext.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,74 @@
+/*
+ * 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.jackrabbit.vault.fs.api.VaultFile;
+import org.apache.jackrabbit.vault.util.console.commands.CmdCtx;
+import org.apache.jackrabbit.vault.util.console.platform.CmdCd;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements a console/shell that operates on a jcrfs.
+ *
+ */
+public class VaultFsExecutionContext extends VaultFsConsoleExecutionContext {
+
+ protected static Logger log = LoggerFactory.getLogger(VaultFsExecutionContext.class);
+
+ public VaultFsExecutionContext(VaultFsApp app, String name, VaultFile rootFile) {
+ super(app, name);
+
+ installCommand(new CmdCd());
+ installCommand(new CmdCtx());
+ installCommand(new CmdLogin());
+ installCommand(new CmdLogout());
+ installCommand(new CmdConnect());
+ installCommand(new CmdDisconnect());
+ installCommand(new CmdExport());
+ installCommand(new CmdGet());
+ installCommand(new CmdCat());
+ installCommand(new CmdInvalidate());
+ installCommand(new CmdImport());
+ installCommand(new CmdLsJcrFs());
+ installCommand(new CmdMount());
+ installCommand(new CmdPut());
+ installCommand(new CmdRm());
+ installCommand(new CmdTree());
+ installCommand(new CmdUnmount());
+ installCommand(new CmdDump());
+ installCommand(new CmdDebug());
+ // vlt commands
+ installCommand(new CmdCheckout());
+ installCommand(new CmdStatus());
+ installCommand(new CmdUpdate());
+ installCommand(new CmdInfo());
+ installCommand(new CmdCommit());
+ installCommand(new CmdRevert());
+ installCommand(new CmdResolved());
+ installCommand(new CmdPropSet());
+ installCommand(new CmdPropGet());
+ installCommand(new CmdPropList());
+ installCommand(new CmdAdd());
+ installCommand(new CmdDelete());
+ installCommand(new CmdDiff());
+
+ setFileSystem(new VaultFsCFile(rootFile));
+ }
+
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VltExecutionContext.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VltExecutionContext.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VltExecutionContext.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/VltExecutionContext.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,62 @@
+/*
+ * 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.jackrabbit.vault.util.console.ExecutionContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements a console/shell that operates on a jcrfs.
+ *
+ */
+public class VltExecutionContext extends ExecutionContext {
+
+ protected static Logger log = LoggerFactory.getLogger(VltExecutionContext.class);
+
+ private final VaultFsApp app;
+
+ public VltExecutionContext(VaultFsApp app) {
+ super(app);
+ this.app = app;
+ installCommand(new CmdExportCli());
+ installCommand(new CmdImportCli());
+ installCommand(new CmdCheckoutCli());
+ installCommand(new CmdStatus());
+ installCommand(new CmdUpdate());
+ installCommand(new CmdInfo());
+ installCommand(new CmdCommit());
+ installCommand(new CmdRevert());
+ installCommand(new CmdResolved());
+ installCommand(new CmdPropGet());
+ installCommand(new CmdPropList());
+ installCommand(new CmdPropSet());
+ installCommand(new CmdAdd());
+ installCommand(new CmdDelete());
+ installCommand(new CmdDiff());
+ installCommand(new CmdRcp());
+ installCommand(new CmdSync());
+
+ //installCommand(new CmdVaultDebug());
+ }
+
+ public VaultFsApp getJcrFsApp() {
+ return app;
+ }
+
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/ExtendedOption.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/ExtendedOption.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/ExtendedOption.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/ExtendedOption.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.extended;
+
+import org.apache.commons.cli2.Option;
+import org.apache.commons.cli2.builder.ArgumentBuilder;
+import org.apache.commons.cli2.builder.DefaultOptionBuilder;
+import org.apache.jackrabbit.vault.util.Text;
+import org.apache.jackrabbit.vault.util.console.CliCommand;
+
+/**
+ * <code>ExtendedOption</code>...
+ */
+abstract public class ExtendedOption implements CliCommand {
+
+ abstract public String getSystemPrefix();
+
+ private final Option option = new DefaultOptionBuilder()
+ .withShortName(getName())
+ .withDescription(getShortDescription())
+ .withArgument(new ArgumentBuilder()
+ .withInitialSeparator(':')
+ .withSubsequentSeparator((char)0)
+ .withMaximum(1)
+ .create()
+ )
+ .create();
+
+ public void process(String args) {
+ // currently just split the args
+ for (String nvp: Text.explode(args, ',')) {
+ String[] nv = Text.explode(nvp, '=');
+ String name = nv[0].trim();
+ String value = nv.length > 1 ? nv[1].trim() : "true";
+ System.setProperty(getSystemPrefix() + name, value);
+ }
+ }
+
+ public Option getOption() {
+ return option;
+ }
+}
\ No newline at end of file
Added: jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/XDavEx.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/XDavEx.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/XDavEx.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/XDavEx.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.extended;
+
+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.GroupBuilder;
+import org.apache.jackrabbit.vault.util.console.ExecutionContext;
+
+/**
+ * <code>XJcrLog</code>...
+ */
+public class XDavEx extends ExtendedOption {
+
+ public boolean execute(ExecutionContext executionContext, CommandLine commandLine)
+ throws Exception {
+ return false;
+ }
+
+ public String getSystemPrefix() {
+ return "jcr.remoting.";
+ }
+
+ public String getName() {
+ return "Xdavex";
+ }
+
+ public String getShortDescription() {
+ return "Extended JCR remoting options (omit argument for help)";
+ }
+
+ public String getLongDescription() {
+ return "Configures extended options for the JCR remoting protocol.";
+ }
+
+ public String getExample() {
+ return "-Xdavex:depth=2,spilog=my.log";
+ }
+
+ public boolean hasName(String s) {
+ return false;
+ }
+
+ public Option getCommand() {
+ return new CommandBuilder()
+ .withName("Xdavex")
+ .withDescription(getShortDescription())
+ .withChildren(new GroupBuilder()
+ .withName("Options:")
+ .withOption(new ArgumentBuilder()
+ .withName("itemcache=<size>")
+ .withDescription("size of the item cache in 1024. default 128")
+ .withMinimum(1)
+ .withMaximum(1)
+ .create())
+ .withOption(new ArgumentBuilder()
+ .withName("spilog=<file>")
+ .withDescription("enable spi log and write to file")
+ .withMinimum(1)
+ .withMaximum(1)
+ .create())
+ .withOption(new ArgumentBuilder()
+ .withName("depth")
+ .withDescription("retrieval depth. default 4")
+ .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/extended/XJcrLog.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/XJcrLog.java?rev=1512568&view=auto
==============================================================================
--- jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/XJcrLog.java (added)
+++ jackrabbit/commons/filevault/trunk/vault-cli/src/main/java/org/apache/jackrabbit/vault/cli/extended/XJcrLog.java Sat Aug 10 05:53:42 2013
@@ -0,0 +1,103 @@
+/*
+ * 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.extended;
+
+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.GroupBuilder;
+import org.apache.jackrabbit.vault.util.console.ExecutionContext;
+
+/**
+ * <code>XJcrLog</code>...
+ */
+public class XJcrLog extends ExtendedOption {
+
+ public boolean execute(ExecutionContext executionContext, CommandLine commandLine)
+ throws Exception {
+ return false;
+ }
+
+ public String getSystemPrefix() {
+ return "jcrlog.";
+ }
+
+ public String getName() {
+ return "Xjcrlog";
+ }
+
+ public String getShortDescription() {
+ return "Extended JcrLog options (omit argument for help)";
+ }
+
+ public String getLongDescription() {
+ return "Enables and controls JcrLog. JcrLog dumps all calls through the\n" +
+ "JCR API to a file and/or stdout.";
+ }
+
+ public String getExample() {
+ return "-Xjcrlog:sysout,retrun,file=my.log";
+ }
+
+ public boolean hasName(String s) {
+ return false;
+ }
+
+ public Option getCommand() {
+ return new CommandBuilder()
+ .withName("Xjcrlog")
+ .withDescription(getShortDescription())
+ .withChildren(new GroupBuilder()
+ .withName("Options:")
+ .withOption(new CommandBuilder()
+ .withName("sysout")
+ .withDescription("enable logging to the stdout")
+ .create())
+ .withOption(new ArgumentBuilder()
+ .withName("file=<file>")
+ .withDescription("log to the specified file")
+ .withMinimum(1)
+ .withMaximum(1)
+ .create())
+ .withOption(new CommandBuilder()
+ .withName("return")
+ .withDescription("enable logging of return values")
+ .create())
+ .withOption(new CommandBuilder()
+ .withName("caller")
+ .withDescription("enable logging of the caller")
+ .create())
+ .withOption(new CommandBuilder()
+ .withName("exception")
+ .withDescription("enable logging of exceptions")
+ .create())
+ .withOption(new CommandBuilder()
+ .withName("stream")
+ .withDescription("enable logging of streams")
+ .create())
+ /*
+ .withOption(new CommandBuilder()
+ .withName("cast")
+ .withDescription("cast to real API")
+ .create())
+ */
+ .create()
+ )
+ .create();
+ }
+}
\ No newline at end of file