You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by sf...@apache.org on 2010/01/15 16:35:18 UTC
svn commit: r899665 [2/4] - in /incubator/chemistry/trunk/chemistry: ./
chemistry-shell/ chemistry-shell/scripts/ chemistry-shell/src/
chemistry-shell/src/main/ chemistry-shell/src/main/java/
chemistry-shell/src/main/java/org/ chemistry-shell/src/main/...
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Cd.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Cd.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Cd.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Cd.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+
+@Cmd(syntax = "cd target:item", synopsis = "Change working item")
+public class Cd extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ ensureConnected(app);
+
+ String param = cmdLine.getParameterValue("target");
+
+ Context ctx = app.resolveContext(new Path(param));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve target: " + param);
+ }
+ Folder folder = ctx.as(Folder.class);
+ if (folder != null) {
+ app.setContext(ctx);
+ } else {
+ throw new CommandException("Cannot cd to something that is not a folder");
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Cd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Cd.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Connect.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Connect.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Connect.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Connect.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,43 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="connect|open url", synopsis="Open a new session")
+public class Connect extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ String url = cmdLine.getParameterValue("url");
+ if (url != null) {
+ app.connect(url);
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Connect.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Connect.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Disconnect.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Disconnect.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Disconnect.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Disconnect.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="disconnect|close", synopsis="Close current session")
+public class Disconnect extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ ensureConnected(app);
+ app.disconnect();
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Disconnect.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Disconnect.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Exit.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Exit.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Exit.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Exit.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,41 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.command.ExitException;
+
+@Cmd(syntax = "exit|bye|quit", synopsis = "Exit")
+public class Exit extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ throw new ExitException();
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Exit.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Exit.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Help.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Help.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Help.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Help.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,95 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="help [command:command]", synopsis="Help")
+public class Help extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ String param = cmdLine.getParameterValue("command");
+ if (param != null) {
+ printHelpForCommand(app, param);
+ } else {
+ printHelpForAllCommands(app);
+ }
+ }
+
+ private void printHelpForCommand(Application app, String cmdName) throws CommandException {
+ Command cmd = app.getCommandRegistry().getCommand(cmdName);
+ if (cmd != null) {
+ println(cmd.getHelp());
+ } else {
+ throw new CommandException("Unknown command: " + cmdName);
+ }
+ }
+
+ private void printHelpForAllCommands(Application app) {
+ println(getHelp());
+
+ Command[] cmds = app.getCommandRegistry().getCommands();
+ Arrays.sort(cmds, new CommandComparator());
+ Set<String> seen = new HashSet<String>();
+ StringBuilder buf = new StringBuilder();
+ for (Command cmd : cmds) {
+ String name = cmd.getName();
+ if (seen.contains(name)) {
+ continue;
+ }
+ seen.add(name);
+ buf.setLength(0);
+ buf.append(name);
+ String[] aliases = cmd.getAliases();
+ if (aliases.length > 1) {
+ buf.append(" [");
+ for (int i=1; i<aliases.length; i++) {
+ buf.append(aliases[i]).append("|");
+ }
+ buf.setLength(buf.length()-1);
+ buf.append("]");
+ }
+ buf.append(" - ").append(cmd.getSynopsis());
+ println(buf.toString());
+ }
+ }
+
+ private static class CommandComparator implements Comparator<Command> {
+ public int compare(Command o1, Command o2) {
+ return o1.getName().compareTo(o2.getName());
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Help.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Help.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Id.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Id.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Id.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Id.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+
+@Cmd(syntax="id [item:item]", synopsis="Identity of the specified entry")
+public class Id extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ ensureConnected(app);
+
+ String param = cmdLine.getParameterValue("item");
+
+ Context ctx;
+ if (param != null) {
+ ctx = app.resolveContext(new Path(param));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve target: " + param);
+ }
+ } else {
+ ctx = app.getContext();
+ }
+
+ println(ctx.id());
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Id.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Id.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LCd.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LCd.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LCd.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LCd.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,50 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import java.io.File;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="lcd target:dir", synopsis="Change local working directory")
+public class LCd extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ String target = cmdLine.getParameterValue("target");
+
+ File file = app.resolveFile(target);
+ if (!file.isDirectory()) {
+ throw new CommandException("Target is not a directory: " + file);
+ }
+
+ app.setWorkingDirectory(file);
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LCd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LCd.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPopd.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPopd.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPopd.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPopd.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import java.io.File;
+import java.util.Stack;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="lpopd", synopsis="Pop local directory stack")
+public class LPopd extends Command {
+
+ public static final String WDIR_STACK_KEY = "wdir.stack";
+
+ @Override
+ @SuppressWarnings({"unchecked"})
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ Stack<File> stack = (Stack<File>) app.getData(WDIR_STACK_KEY);
+ if (stack == null) {
+ throw new CommandException("No more directories on the stack");
+ }
+
+ File file = stack.pop();
+ if (stack.isEmpty()) {
+ app.setData(WDIR_STACK_KEY, null);
+ }
+ app.setWorkingDirectory(file);
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPopd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPopd.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPushd.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPushd.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPushd.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPushd.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import java.io.File;
+import java.util.Stack;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="lpushd dir:dir", synopsis="Push local directory stack")
+@SuppressWarnings("unchecked")
+public class LPushd extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ String path = cmdLine.getParameterValue("dir");
+
+ File file = app.resolveFile(path);
+ if (!file.isDirectory()) {
+ throw new CommandException("Not a directory: " + file);
+ }
+
+ Stack<File> stack = (Stack<File>)app.getData(LPopd.WDIR_STACK_KEY);
+ if (stack == null) {
+ stack = new Stack<File>();
+ app.setData(LPopd.WDIR_STACK_KEY, stack);
+ }
+ stack.push(app.getWorkingDirectory());
+ app.setWorkingDirectory(file);
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPushd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPushd.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPwd.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPwd.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPwd.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPwd.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,40 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="lpwd", synopsis="Print local working directory")
+public class LPwd extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ println(app.getWorkingDirectory().getAbsolutePath());
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPwd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/LPwd.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ll.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ll.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ll.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ll.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,52 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import java.io.File;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="lls|ll [target:file]", synopsis="List local directory content")
+public class Ll extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+
+ File file;
+ String param = cmdLine.getParameterValue("target");
+ if (param != null) {
+ file = app.resolveFile(param);
+ } else {
+ file = app.getWorkingDirectory();
+ }
+ for (String f : file.list()) {
+ println(f);
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ll.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ll.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ls.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ls.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ls.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ls.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,67 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.Document;
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+
+@Cmd(syntax = "ls [target:item]", synopsis = "List entries in working directory")
+public class Ls extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ ensureConnected(app);
+
+ String param = cmdLine.getParameterValue("target");
+
+ Context ctx;
+ if (param == null) {
+ ctx = app.getContext();
+ for (String line : ctx.ls()) {
+ println(line);
+ }
+ } else {
+ ctx = app.resolveContext(new Path(param));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve target: " + param);
+ }
+ Document document = ctx.as(Document.class);
+ if (document != null) {
+ println(document.getName());
+ } else {
+ for (String line : ctx.ls()) {
+ println(line);
+ }
+ }
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ls.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Ls.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Match.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Match.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Match.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Match.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,61 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.app.Console;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax = "match [-r] pattern", synopsis = "Fails if last command result doesn't match the pattern")
+public class Match extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ ensureConnected(app);
+
+ String pattern = cmdLine.getParameterValue("pattern");
+ boolean reverse = cmdLine.getParameter("-r") != null;
+
+ String[] lines = Console.getDefault().getLastResult().split("\n");
+ boolean success = false;
+ for (String line : lines) {
+ if (line.matches(pattern)) {
+ success = true;
+ }
+ }
+ if (!reverse && !success) {
+ throw new CommandException("Match failed: pattern \""
+ + pattern + "\" doesn't match last result");
+ }
+ if (reverse && success) {
+ throw new CommandException("Reverse match failed: pattern \""
+ + pattern + "\" matches last result");
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Match.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Match.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Popd.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Popd.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Popd.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Popd.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,56 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import java.util.Stack;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="popd", synopsis="Pop directory stack")
+public class Popd extends Command {
+
+ public static final String CTX_STACK_KEY = "ctx.stack";
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ Stack<Context> stack = (Stack<Context>) app.getData(CTX_STACK_KEY);
+ if (stack == null || stack.isEmpty()) {
+ throw new CommandException("Context stack is empty");
+ }
+
+ Context ctx = stack.pop();
+ app.setContext(ctx);
+ if (stack.isEmpty()) {
+ app.setData(CTX_STACK_KEY, null);
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Popd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Popd.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pushd.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pushd.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pushd.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pushd.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,69 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import java.util.Stack;
+
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+
+@Cmd(syntax="pushd [target:item]", synopsis="Push directory stack")
+public class Pushd extends Command {
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+
+ String param = cmdLine.getParameterValue("target");
+
+ Context oldContext = app.getContext();
+
+ Context ctx = app.resolveContext(new Path(param));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve target: " + param);
+ }
+
+ Folder folder = ctx.as(Folder.class);
+ if (folder != null) {
+ app.setContext(ctx);
+ } else {
+ throw new CommandException("Cannot cd to something that is not a folder");
+ }
+
+ Stack<Context> stack = (Stack<Context>) app.getData(Popd.CTX_STACK_KEY);
+ if (stack == null) {
+ stack = new Stack<Context>();
+ app.setData(Popd.CTX_STACK_KEY, stack);
+ }
+ stack.push(oldContext);
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pushd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pushd.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pwd.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pwd.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pwd.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pwd.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,40 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.base;
+
+import org.apache.chemistry.shell.app.Application;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.Command;
+import org.apache.chemistry.shell.command.CommandLine;
+
+@Cmd(syntax="pwd", synopsis="Print working directory")
+public class Pwd extends Command {
+
+ @Override
+ public void run(Application app, CommandLine cmdLine) throws Exception {
+ println(app.getContext().getPath().toString());
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pwd.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/base/Pwd.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Cat.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Cat.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Cat.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Cat.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,72 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import java.io.InputStream;
+
+import org.apache.chemistry.ContentStream;
+import org.apache.chemistry.Document;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimplePropertyManager;
+
+@Cmd(syntax="cat target:item", synopsis="Read the stream of the target document to the console")
+public class Cat extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+
+ String target = cmdLine.getParameterValue("target");
+
+ Context ctx = app.resolveContext(new Path(target));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve target: " + target);
+ }
+
+ Document obj = ctx.as(Document.class);
+ if (obj == null) {
+ throw new CommandException("Your target must be a document");
+ }
+
+ ContentStream cs = new SimplePropertyManager(obj).getStream();
+ if (cs == null) {
+ throw new CommandException("Your target doesn't have a stream");
+ }
+
+ InputStream in = cs.getStream();
+ try {
+ print(in);
+ } finally {
+ in.close();
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Cat.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Cat.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFile.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFile.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFile.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFile.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,63 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimpleCreator;
+
+@Cmd(syntax="mkfile|mkdoc [-t|--type:*] target:item", synopsis="Create a document of the given name")
+public class CreateFile extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+ String param = cmdLine.getParameterValue("target");
+ String typeName = cmdLine.getParameterValue("-t");
+ if (typeName == null) {
+ typeName = "cmis:document";
+ }
+
+ Path path = new Path(param);
+ String name = path.getLastSegment();
+ Path parent = path.getParent();
+
+ Context ctx = app.resolveContext(parent);
+ Folder folder = ctx.as(Folder.class);
+ if (folder == null) {
+ throw new CommandException(parent+" doesn't exist or is not a folder");
+ }
+
+ new SimpleCreator(folder).createFile(typeName, name);
+ ctx.reset();
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFile.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFile.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFolder.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFolder.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFolder.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFolder.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,63 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimpleCreator;
+
+@Cmd(syntax="mkdir [-t|--type:*] target:item", synopsis="Create a folder given its name")
+public class CreateFolder extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+ String param = cmdLine.getParameterValue("target");
+ String typeName = cmdLine.getParameterValue("-t");
+ if (typeName == null) {
+ typeName = "cmis:folder";
+ }
+
+ Path path = new Path(param);
+ String name = path.getLastSegment();
+ Path parent = path.getParent();
+
+ Context ctx = app.resolveContext(parent);
+ Folder folder = ctx.as(Folder.class);
+ if (folder == null) {
+ throw new CommandException(parent+" doesn't exist or is not a folder");
+ }
+
+ new SimpleCreator(folder).createFolder(typeName, name);
+ ctx.reset();
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFolder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/CreateFolder.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpProps.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpProps.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpProps.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpProps.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,69 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimplePropertyManager;
+
+// TODO: remove
+@Cmd(syntax="props [item:item]", synopsis="(Obsolete) Print the value of all the properties of the current context object")
+public class DumpProps extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+
+ String param = cmdLine.getParameterValue("item");
+
+ Context ctx;
+ if (param != null) {
+ ctx = app.resolveContext(new Path(param));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve "+param);
+ }
+ } else {
+ ctx = app.getContext();
+ }
+
+ CMISObject obj = ctx.as(CMISObject.class);
+ if (obj != null) {
+ new SimplePropertyManager(obj).dumpProperties();
+ } else {
+ // print server props
+ println("Server URL = "+app.getServerUrl());
+ println("Host = "+app.getHost());
+ println("Username = "+app.getUsername());
+ println("Working directory = "+app.getWorkingDirectory());
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpProps.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpProps.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpTree.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpTree.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpTree.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpTree.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,63 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimpleBrowser;
+
+@Cmd(syntax="dump|tree [target:item]", synopsis="Dump a subtree")
+public class DumpTree extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+ String target = cmdLine.getParameterValue("target");
+
+ Context ctx;
+ if (target != null) {
+ ctx = app.resolveContext(new Path(target));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve "+target);
+ }
+ } else {
+ ctx = app.getContext();
+ }
+
+ Folder folder = ctx.as(Folder.class);
+ if (folder != null) {
+ new SimpleBrowser(folder).browse();
+ } else {
+ throw new CommandException("Target "+target+" is not a folder");
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpTree.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/DumpTree.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Get.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Get.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Get.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Get.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,81 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+
+import org.apache.chemistry.ContentStream;
+import org.apache.chemistry.Document;
+import org.apache.commons.io.IOUtils;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimplePropertyManager;
+
+// TODO: add an optional local name for the file
+@Cmd(syntax="get|getstream target:item", synopsis="Downloads the stream of the target document")
+public class Get extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+
+ String target = cmdLine.getParameterValue("target");
+
+ Context ctx = app.resolveContext(new Path(target));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve "+target);
+ }
+
+ Document obj = ctx.as(Document.class);
+ if (obj == null) {
+ throw new CommandException("Your target must be a document");
+ }
+
+ ContentStream cs = new SimplePropertyManager(obj).getStream();
+ if (cs == null) {
+ throw new CommandException("Your target doesn't have a stream");
+ }
+
+ String name = cs.getFileName();
+ InputStream in = cs.getStream();
+ File file = app.resolveFile(name);
+ FileOutputStream out = new FileOutputStream(file);
+ try {
+ IOUtils.copy(in, out);
+ println("Object stream saved to local file: " + file);
+ } finally {
+ out.close();
+ in.close();
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Get.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Get.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/PropGet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/PropGet.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/PropGet.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/PropGet.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimplePropertyManager;
+
+@Cmd(syntax="propget target:item [key]", synopsis="Print the value of the given property on the current context object")
+public class PropGet extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+
+ String target = cmdLine.getParameterValue("target");
+ String key = cmdLine.getParameterValue("key");
+
+ Context ctx = app.resolveContext(new Path(target));
+ if (ctx == null) {
+ throw new CommandException("Cannot resolve "+target);
+ }
+
+ CMISObject obj = ctx.as(CMISObject.class);
+ if (obj == null) {
+ throw new CommandException("Cannot resolve "+target);
+ }
+
+ if (key != null) {
+ String propValue = new SimplePropertyManager(obj).getPropertyAsString(key);
+ println(propValue);
+ } else {
+ new SimplePropertyManager(obj).dumpProperties();
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/PropGet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/PropGet.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Put.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Put.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Put.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Put.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,89 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+import org.apache.chemistry.Document;
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimpleCreator;
+import org.apache.chemistry.shell.util.SimplePropertyManager;
+
+@Cmd(syntax="put [-t|--type:*] source:file [target:item]", synopsis="Uploads the stream of the target document")
+public class Put extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+
+ String source = cmdLine.getParameterValue("source");
+ String target = cmdLine.getParameterValue("target");
+ if (target == null) {
+ target = new Path(source).getLastSegment();
+ }
+ String typeName = cmdLine.getParameterValue("-t");
+ if (typeName == null) {
+ typeName = "cmis:document";
+ }
+
+ Context targetCtx = app.resolveContext(new Path(target));
+
+ // Create document if it doesn't exist
+ if (targetCtx == null) {
+ Context currentCtx = app.getContext();
+ Folder folder = currentCtx.as(Folder.class);
+ if (folder != null) {
+ new SimpleCreator(folder).createFile(typeName, target);
+ currentCtx.reset();
+ targetCtx = app.resolveContext(new Path(target));
+ }
+ }
+ if (targetCtx == null) {
+ throw new CommandException("Cannot create target document");
+ }
+
+ Document obj = targetCtx.as(Document.class);
+ if (obj == null) {
+ throw new CommandException("Your target must be a document");
+ }
+
+ File file = app.resolveFile(source);
+ FileInputStream in = new FileInputStream(file);
+ try {
+ new SimplePropertyManager(obj).setStream(in, file.getName());
+ } finally {
+ in.close();
+ }
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Put.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Put.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Remove.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Remove.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Remove.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Remove.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,76 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.Folder;
+import org.apache.chemistry.Unfiling;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+
+@Cmd(syntax="rm|del [-r] target:item", synopsis="Removes an object of the given name")
+public class Remove extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+ String param = cmdLine.getParameterValue("target");
+ boolean recurse = cmdLine.getParameter("-r") != null;
+
+ Path path = new Path(param);
+ String name = path.getLastSegment();
+ Path parent = path.getParent();
+
+ Context ctx = app.resolveContext(parent);
+ Folder folder = ctx.as(Folder.class);
+ if (folder == null) {
+ throw new CommandException(parent+" doesn't exist or is not a folder");
+ }
+
+ boolean success = false;
+ for (CMISObject child : folder.getChildren()) {
+ // TODO: use wildcard but make sure it's safe
+ // if (StringUtils.matches(name, child.getName())) {
+ if (name.equals(child.getName())) {
+ if (recurse && child instanceof Folder) {
+ ((Folder) child).deleteTree(Unfiling.UNFILE);
+ } else {
+ child.delete();
+ }
+ success = true;
+ }
+ }
+ if (!success) {
+ throw new CommandException("No match");
+ }
+ ctx.reset();
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Remove.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/Remove.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/SetProp.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/SetProp.java?rev=899665&view=auto
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/SetProp.java (added)
+++ incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/SetProp.java Fri Jan 15 15:35:14 2010
@@ -0,0 +1,57 @@
+/*
+ * (C) Copyright 2009-2010 Nuxeo SA (http://nuxeo.com/) and contributors.
+ *
+ * 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.
+ *
+ * Contributors:
+ * Bogdan Stefanescu (bs@nuxeo.com), Nuxeo
+ * Stefane Fermigier (sf@nuxeo.com), Nuxeo
+ * Florent Guillaume (fg@nuxeo.com), Nuxeo
+ */
+
+package org.apache.chemistry.shell.cmds.cmis;
+
+import org.apache.chemistry.CMISObject;
+import org.apache.chemistry.shell.app.ChemistryApp;
+import org.apache.chemistry.shell.app.ChemistryCommand;
+import org.apache.chemistry.shell.app.Context;
+import org.apache.chemistry.shell.command.Cmd;
+import org.apache.chemistry.shell.command.CommandException;
+import org.apache.chemistry.shell.command.CommandLine;
+import org.apache.chemistry.shell.util.Path;
+import org.apache.chemistry.shell.util.SimplePropertyManager;
+
+@Cmd(syntax="propset target:item key value", synopsis="Set the value of a property on the current context object")
+public class SetProp extends ChemistryCommand {
+
+ @Override
+ protected void execute(ChemistryApp app, CommandLine cmdLine)
+ throws Exception {
+
+ String target = cmdLine.getParameterValue("target");
+ String key = cmdLine.getParameterValue("key");
+ String value = cmdLine.getParameterValue("value");
+
+ Context ctx = app.resolveContext(new Path(target));
+ CMISObject obj = ctx.as(CMISObject.class);
+ if (obj == null) {
+ throw new CommandException("Cannot resolve "+target);
+ }
+
+ new SimplePropertyManager(obj).setProperty(key, value);
+ }
+
+}
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/SetProp.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/chemistry/trunk/chemistry/chemistry-shell/src/main/java/org/apache/chemistry/shell/cmds/cmis/SetProp.java
------------------------------------------------------------------------------
svn:keywords = Id