kward 2002/11/08 17:24:56
Modified: java/scratchpad/admin/src/org/apache/xindice/admin
XindiceAdmin.java
java/scratchpad/admin/src/org/apache/xindice/admin/commandline
BaseCommand.java BasePrompt.java
CommandException.java CommandRegister.java
ShellPrompt.java XindiceTools.java
java/scratchpad/admin/src/org/apache/xindice/admin/commands
CreateCommand.java DirCommand.java ExitCommand.java
HelpCommand.java ListCommand.java QueryCommand.java
RunScriptCommand.java TimeCommand.java
URLCommand.java UseCommand.java
java/scratchpad/admin/src/org/apache/xindice/admin/utility
URLUtils.java
Log:
added license and correct file versions...
Revision Changes Path
1.2 +61 -11
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/XindiceAdmin.java
Index: XindiceAdmin.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/XindiceAdmin.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XindiceAdmin.java 9 Nov 2002 01:13:47 -0000 1.1
+++ XindiceAdmin.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,22 +1,72 @@
+package org.apache.xindice.admin;
+
/*
- * Created by IntelliJ IDEA.
- * User: kward
- * Date: Oct 30, 2002
- * Time: 9:57:34 PM
- * To change template for new class use
- * Code Style | Class Templates options (Tools | IDE Options).
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
*/
import org.apache.xindice.admin.commandline.ShellPrompt;
-import java.util.Iterator;
-
/**
- * Example program that creates a ShellPrompt and then starts it. Type
- * exit to exit.
+ * Command line tools
+ * Author: kward <[EMAIL PROTECTED]>
*/
-public class XindiceAdmin {
+public class XindiceAdmin {
public static void main(String args[]) {
ShellPrompt prompt = new ShellPrompt("Xindice ");
prompt.start();
1.2 +103 -52
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/BaseCommand.java
Index: BaseCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/BaseCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BaseCommand.java 9 Nov 2002 01:13:47 -0000 1.1
+++ BaseCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,59 +1,109 @@
package org.apache.xindice.admin.commandline;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
+import org.apache.xmlrpc.XmlRpc;
+import org.apache.xmlrpc.XmlRpcClient;
+
import java.util.Iterator;
import java.util.Vector;
import java.util.Hashtable;
-
/**
- * Base class for creating named commands. The BaseCommand constructor should
- * be called from the constructor of a derived class that is the actual
- * command. For example:
- * <p><pre>
- * class ExitCommand extends BaseCommand {
- * ExitCommand() {
- * super("exit", 0, "calls the System to exit");
- * }
- * }
- * </pre>
- * <p>
- * For a complete example of creating a command, see the RunScriptCommand.
- * @see RunScriptCommand
+ * Base class for creating named commands.
+ * Author: kward <[EMAIL PROTECTED]>
*/
-public abstract class BaseCommand implements Command {
+
+public abstract class BaseCommand implements CommandInterface {
protected String name_;
protected int numArgs_;
protected CommandRegister register_;
protected String help_;
+ protected static XmlRpcClient client;
+
protected static BasePrompt prompt = null;
-
- /**
- * All inheriting classes are required to call this constructor using
- * <pre>super(name, numArgs, help)</pre>.
- *
- * @param name the name of the command - an exception will be thrown if
- * a command already exists with this name
- * @param numArgs the number of arguments this command takes.
- * -1 can be specified if the command takes a variable number of
- * arguments, in which case it is up to the derived command to carefully
- * check the arguments.
- * @param help this string is returned to the user when they request
- * help about a command. It should include a brief description of what
- * the command accomplishes and what each of the required arguments is.
- */
+
public BaseCommand(String name, int numArgs, String help) {
name_ = name;
numArgs_ = numArgs;
help_ = help;
+ XmlRpc.setEncoding("UTF8");
+ //System.out.println("created XML-RPC client in command " + name);
+ try {
+ XmlRpc.setDriver("xerces");
+ } catch(Exception e) {
+ System.out.println("XML-RPC requires Xerces for UTF-8 support.");
+ }
+ try {
+ client = new XmlRpcClient("http://localhost:8080/Xindice");
+ } catch(Exception e){
+ System.out.println("Error connecting to Xindice");
+ }
}
/**
- * This method is called by the CommandRegister whenever a new command
- * is registered - this gives commands access to help information for
- * other commands - eg. see the HelpCommand.
+ * This method is called by the CommandRegister whenever a new command
is registered
*/
+
public void set(CommandRegister cregister) {
register_ = cregister;
}
@@ -75,13 +125,7 @@
}
public String getName() { return name_; }
-
- /**
- * This method enables a command to be used independently of the
- * command prompt. You instantiate a command, and then execute it
- * by passing a string containing the arguments. If the arguments are
- * not properly formatted, an error will be printed.
- */
+
public void execute(String args)
{
if (register_ == null) {
@@ -91,17 +135,12 @@
}
execute(register_.parseCommand(args));
}
-
- /**
- * This method should be overloaded by each command that is defined -
- * it will be called by the CommandRegister after the number of
- * arguments have been checked.
- */
+
public abstract void execute(String args[]);
/**
- * This method is called internally whenever a command is executed to
- * check the arguments. After checking arguments, it will call the
+ * This method is called internally whenever a command is executed to
+ * check the arguments. After checking arguments, it will call the
* execute(String[]) method for the specific command.
*/
public void execute(Iterator iter) {
@@ -122,7 +161,7 @@
prompt.out.println(getHelp());
return;
}
- // unknown number of arguments indicated by -1
+
} else {
Vector vector = new Vector(10);
while(iter.hasNext()) {
@@ -135,10 +174,22 @@
}
/**
- * Return a the help string for this command. This is basically the help
- * string required in the constructor for all BaseCommands.
+ * Return a the help string for this command.
*/
public String getHelp() {
- return "usage:\n" + name_ + " " + help_;
+ return "usage: " + name_ + " " + help_;
}
+
+ public Hashtable run(Hashtable message) {
+ Vector params = new Vector();
+ params.addElement(message);
+ Hashtable result = new Hashtable();
+ try {
+ result = (Hashtable) client.execute("run", params);
+ } catch(Exception e){
+ prompt.out.println(e);
+ }
+ return (result);
+ }
+
}
1.2 +67 -117
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/BasePrompt.java
Index: BasePrompt.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/BasePrompt.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- BasePrompt.java 9 Nov 2002 01:13:47 -0000 1.1
+++ BasePrompt.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,5 +1,64 @@
package org.apache.xindice.admin.commandline;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import java.util.StringTokenizer;
import java.util.Hashtable;
import java.util.Vector;
@@ -7,17 +66,10 @@
import java.io.*;
/**
- * Base class for all command prompts. This class handles the
- * prompt-independent processing, such as the basic user-interaction loop and
- * command execution.
- *
- * Optionally, System.in, System.err, System.out can be redirected to the
- * prompt's streams.
- *
- * @see ShellPrompt
- * @see TextAreaPrompt
+ * Base class for all command prompts.
+ * Author: kward <[EMAIL PROTECTED]>
*/
-public class BasePrompt extends Thread implements Prompt {
+public class BasePrompt extends Thread implements PromptInterface {
private String name_;
private BufferedReader reader_;
@@ -26,13 +78,6 @@
public PrintStream out;
public PrintStream err;
public InputStream in;
-
- // If System streams are redirected, a handle to the originals must
- // be kept so that we can reset them if asked to exit
- //
- private PrintStream defaultOut_;
- private PrintStream defaultErr_;
- private InputStream defaultIn_;
protected BasePrompt( String name,
CommandRegister
register,
@@ -56,61 +101,20 @@
BaseCommand.setPrompt(this);
}
- public void redirectSystemIOToPrompt() {
-
- // maintain a handle to the default System.out and System.err
- // streams so that we can reset these when we exit
- //
- defaultOut_ = System.out;
- defaultErr_ = System.err;
- defaultIn_ = System.in;
-
- // reassign standard output, error and input to the same as
that
- // being used by the prompt. The whole idea here is to still be
- // able to write "System.out.println()" in your code and have
this
- // automatically redirected to the command prompt.
- //
- System.setOut(out);
-
- // At one time, I was prefixing all error messages with "Error:
".
- // However, this acts somewhat funny for multi-line error
messages.
- // System.setErr(new PrefixPrintStream(error, "Error: "));
- //
- System.setErr(err);
-
- System.setIn(in);
- }
/**
- * This method is called to register a new command to be used with this
- * prompt. Note, every prompt contains a reference to a CommandRegister
- * that keeps track of available commands.
+ * This method is called to register a new command to be used with the
prompt.
*/
- public void registerCommand(Command command) {
+ public void registerCommand(CommandInterface command) {
register_.add(command);
}
- public void registerPackage(XindiceToolBuilder ci) {
+ public void registerPackage(XindiceToolAssemblyInterface ci) {
register_.add(ci);
}
-
- /**
- * Iterates through all the registered packages and tells them we are
- * exiting - just in case they have resources to free.
- */
- public void exit() {
+ public void exit() {
register_.exit();
-
- // reset the output Streams to the defaults
- // (some messages might be displayed on exit, however these will
- // not be visible if the out and err streams are directed to a
- // TextArea and this is no longer visible)
- //
- System.setOut(defaultOut_);
- System.setErr(defaultErr_);
- System.setIn(defaultIn_);
-
System.exit(0);
}
@@ -118,12 +122,7 @@
out.print(name_ + "> ");
out.flush();
}
-
- /**
- * This method starts the prompt in interactive mode. Note that this is
- * the starting point for a new thread of execution whcih blocks until
- * the user enters input into the input stream.
- */
+
public void run() {
for(;;) {
printPrompt();
@@ -140,54 +139,5 @@
}
}
}
-
- /**
- * Ask the user a boolean question. Eg. "How are you today?"
- * @return true if the user responds "yes" or "y", false if they respond
- * "no" or "n" - all case insensitive.
- */
- public boolean askBooleanQuestion(String question) {
- String response = askQuestion(question, "n");
- if (response.equalsIgnoreCase("yes") ||
- response.equalsIgnoreCase("y")) {
- return true;
- }
- return false;
- }
-
- /**
- * Ask the user a question.
- * @return a string containing the typed response.
- */
- public String askQuestion(String question) {
- return askQuestion(question, null);
- }
-
- /**
- * Ask the user a question and provide a default answer (to save the
- * user typing if it is a likely default).
- * @return a string containing the typed response, or the default answer
- * if the user just hits enter.
- */
- public String askQuestion(String question, String defaultAns) {
- out.print(question);
- if (defaultAns != null) {
- out.print(" (" + defaultAns + ")");
- }
- out.print(": ");
- out.flush();
- String response = "";
- try {
- response = reader_.readLine();
- if (defaultAns != null &&
- (response.equalsIgnoreCase("") ||
- response.equalsIgnoreCase("\n"))) {
- return defaultAns;
- }
- } catch (IOException e) {
- err.println("could not read response");
- }
- return response;
- }
}
1.2 +62 -5
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/CommandException.java
Index: CommandException.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/CommandException.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CommandException.java 9 Nov 2002 01:13:47 -0000 1.1
+++ CommandException.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,12 +1,69 @@
package org.apache.xindice.admin.commandline;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
/**
- * If an unrecoverable error occurs when executing a command (eg. invalid
- * parameters etc.), a CommandException should be thrown that will
- * cleanly be handled by the prompt. The user can then retry the command
- * with the correct parameters, or atleast they will have an idea why the
- * command is failing.
+ * Exception Handler
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class CommandException extends RuntimeException {
String error_;
1.2 +79 -62
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/CommandRegister.java
Index: CommandRegister.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/CommandRegister.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CommandRegister.java 9 Nov 2002 01:13:47 -0000 1.1
+++ CommandRegister.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,46 +1,97 @@
package org.apache.xindice.admin.commandline;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import java.util.StringTokenizer;
import java.util.Iterator;
import java.util.Hashtable;
import java.util.Vector;
/**
- * This class is used internally by the BasePrompt to maintain a table
- * of registered commands. You should never be required to interact with it
- * using the cline package.
+ * Maintains a table of registered commands.
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class CommandRegister extends Hashtable {
private Hashtable packages_ = new Hashtable(20);
public CommandRegister() {
super(100);
-
- // always register the basic XindiceTools
- add(new XindiceTools());
+ add(new XindiceTools());
}
- public final void add(Command command) {
+ public final void add(CommandInterface command) {
command.set(this);
put(command.getName(), command);
}
- /**
- * Registers an entire Java package for use with the command line. All
- * commands returned by this packages getCommands() method will be
- * registerred when this method is called.
- */
- public void add(XindiceToolBuilder ci) {
- String key = ci.getClass().getName();
+ public void add(XindiceToolAssemblyInterface xta) {
+ String key = xta.getClass().getName();
if (packages_.contains(key)) {
System.err.println("attempt to register duplicate
package");
return;
}
- packages_.put(key, ci);
+ packages_.put(key, xta);
- // now register all the commands from this package
- Command[] commands = ci.getCommands();
+ CommandInterface[] commands = xta.getCommands();
for (int i=0; i<commands.length; i++) {
add(commands[i]);
}
@@ -49,56 +100,35 @@
public void exit() {
Iterator iter = packages_.values().iterator();
while (iter.hasNext()) {
- XindiceToolBuilder ci = (XindiceToolBuilder)iter.next();
+ XindiceToolAssemblyInterface ci =
(XindiceToolAssemblyInterface)iter.next();
ci.exit();
}
}
-
- /**
- * This method returns the tokens from a String that does not contain
- * any quotations.
- */
+
private final Iterator parseCommandNoQuotes(String input) {
StringTokenizer tokenizer = new StringTokenizer(input, " \t");
- // convert from an Enumeration to an Iterator to try and be
- // consistent with our use of Collections
- //
Vector tokens = new Vector();
while (tokenizer.hasMoreElements()) {
tokens.add(tokenizer.nextElement());
}
return tokens.iterator();
}
-
- /**
- * This command returns the tokens from a string. If the string contains
- * a quote, the words between the quotes are returned as a single token.
- */
+
final Iterator parseCommand(String input) {
if (input.indexOf('"') == -1) {
return parseCommandNoQuotes(input);
}
- // else we might have to parse between quotations
- // For example, the string below:
- // question "how are you" 2
- // contains three tokens (question, how are you, 2)
-
int curIndex = 0;
int endIndex = input.length();
- // used to hold the arguments of the command
- Vector vector = new Vector(4); // 4 args is a large command
+ Vector vector = new Vector(4);
while (curIndex < endIndex) {
int spaceIndex = input.indexOf(' ', curIndex);
int quotationIndex = input.indexOf('"', curIndex);
- //System.out.println("spaceIndex: [" + spaceIndex +
- // "] quotationIndex: [" + quotationIndex +
- // "] curIndex: [" + curIndex + "]");
-
String next = null;
if (quotationIndex == -1) {
Iterator iter = parseCommandNoQuotes(
@@ -110,16 +140,14 @@
} else if (spaceIndex != -1 && spaceIndex <
quotationIndex) {
next = input.substring(curIndex, spaceIndex);
curIndex = spaceIndex+1;
- } else { // quotationIndex != -1
- // we have to extract a string between
quotations
+ } else {
+
int matchingQuote = input.indexOf('"',
quotationIndex+1);
if (matchingQuote == -1) {
throw new CommandException("quotations
do not match");
}
next = input.substring(quotationIndex+1,
matchingQuote);
- // this assumes that an end quote will always
be followed
- // by a space
curIndex = matchingQuote+2;
}
vector.add(next);
@@ -127,34 +155,23 @@
return vector.iterator();
}
- public final Command getCommand(String name) {
+ public final CommandInterface getCommand(String name) {
if (containsKey(name)) {
- return (Command)get(name);
+ return (CommandInterface)get(name);
}
return null;
}
-
- /**
- * Parses a string containing a command name and arguments and then
- * executes the command if it was well structured (the string 'command'
- * will be parsed - looking for the name of the command and any
- * arguments required for that command).
- */
+
public void execute(String command) {
executeCommand(parseCommand(command));
}
-
- /**
- * Execute a command - the first String in the iterator should be the
- * name of the command, the following strings are the parameters that
- * will be passed to the command.
- */
+
private final void executeCommand(Iterator iter) {
if (!iter.hasNext()) {
throw new CommandException("no command specified");
}
String name = (String)iter.next();
- Command command = getCommand(name);
+ CommandInterface command = getCommand(name);
if (command != null) {
command.execute(iter);
} else {
1.2 +63 -15
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/ShellPrompt.java
Index: ShellPrompt.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/ShellPrompt.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ShellPrompt.java 9 Nov 2002 01:13:47 -0000 1.1
+++ ShellPrompt.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,32 +1,80 @@
package org.apache.xindice.admin.commandline;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import java.util.StringTokenizer;
import java.util.Enumeration;
import java.util.Hashtable;
import java.io.*;
/**
- * Command prompt to be used within a xterm or DOS-shell.
- *
- * @see BasePrompt
- * @see TextAreaPrompt
+ * CommandInterface prompt
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class ShellPrompt extends BasePrompt {
-
- /**
- * The shell prompt is an easy one - it just makes use of System.out,
- * System.err and System.in. The second parameter is a register of
- * commands - which might have been created before we needed to allocate
- * a ShellPrompt.
- */
+
public ShellPrompt(String name, CommandRegister register) {
super(name, register, System.out, System.err, System.in);
}
- /**
- * Same idea as the other constructor, however will construct a new
- * CommandRegister for use with the prompt.
- */
public ShellPrompt(String name) {
super(name, null, System.out, System.err, System.in);
}
1.2 +68 -9
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/XindiceTools.java
Index: XindiceTools.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commandline/XindiceTools.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- XindiceTools.java 9 Nov 2002 01:13:47 -0000 1.1
+++ XindiceTools.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,25 +1,84 @@
package org.apache.xindice.admin.commandline;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import org.apache.xindice.admin.commands.*;
/**
- * Package containing all commands that will be automatically registered for
- * use with the command prompt. These include basic commands such as the
- * HelpCommand, RunScriptCommand etc.
+ * Register the commands to be made availabe; this could easily be modified
+ * to create a 'read only' version of the command line tools by compiling
with
+ * without AddCommand, CreateCommand, etc.
+ * Author: kward <[EMAIL PROTECTED]>
*/
-class XindiceTools implements XindiceToolBuilder {
+class XindiceTools implements XindiceToolAssemblyInterface {
- public Command[] getCommands() {
- Command[] commands = {
- // Help,Dir and Time are util commands
+ public CommandInterface[] getCommands() {
+ CommandInterface[] commands = {
new HelpCommand(),
new DirCommand(),
new TimeCommand(),
- new GetConfigCommand(),
+ new InfoCommand(),
new ListCommand(),
new UseCommand(),
- new AddDocumentCommand(),
+ new AddCommand(),
new CreateCommand(),
new QueryCommand(),
new RunScriptCommand(),
1.2 +64 -4
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/CreateCommand.java
Index: CreateCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/CreateCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CreateCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ CreateCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,19 +1,79 @@
package org.apache.xindice.admin.commands;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import java.util.Iterator;
import java.util.Set;
import org.apache.xindice.admin.commandline.BaseCommand;
-import org.apache.xindice.admin.commandline.Command;
+import org.apache.xindice.admin.commandline.CommandInterface;
/**
- * This command is used to query information about any command that has
- * been registered with the prompt.
+ * CommandInterface for creating collections
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class CreateCommand extends BaseCommand {
public CreateCommand() {
- super("create", 1, "creates a new collection in the current
collection");
+ super("create", 1, "collection" + "creates a new collection in
the current collection");
}
public void execute(String args[]) {
1.2 +63 -5
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/DirCommand.java
Index: DirCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/DirCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DirCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ DirCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,18 +1,76 @@
package org.apache.xindice.admin.commands;
-import org.apache.xindice.admin.commandline.BaseCommand;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+import org.apache.xindice.admin.commandline.BaseCommand;
import java.io.File;
/**
- * Command to display the contents of the current working directory.
- * Probably not available when running in an Applet.
+ * CommandInterface for listing working directory contents
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class DirCommand extends BaseCommand {
public DirCommand() {
- super("ls", 0,
- "\n- lists the contents of the current working
directory");
+ super("ls", 0, "\n- lists the contents of the current working
directory");
}
public void execute(String args[]) {
1.2 +63 -4
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/ExitCommand.java
Index: ExitCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/ExitCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExitCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ ExitCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,16 +1,75 @@
package org.apache.xindice.admin.commands;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import org.apache.xindice.admin.commandline.BaseCommand;
/**
- * Command to exit the program. This command calls the prompt to exit the
- * System and therefore requires special permissions - usually not available
- * when running in an Applet.
+ * CommandInterface fto exit the applicaton
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class ExitCommand extends BaseCommand {
public ExitCommand() {
- super("exit", 0,"\n- closes the prompt and any registered
command packages");
+ super("exit", 0,"\n- exits the admin tool");
}
public void execute(String args[]) {
1.2 +66 -12
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/HelpCommand.java
Index: HelpCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/HelpCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- HelpCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ HelpCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,36 +1,90 @@
package org.apache.xindice.admin.commands;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import java.util.Iterator;
import java.util.Set;
-
import org.apache.xindice.admin.commandline.BaseCommand;
-import org.apache.xindice.admin.commandline.Command;
+import org.apache.xindice.admin.commandline.CommandInterface;
/**
- * This command is used to query information about any command that has
- * been registered with the prompt.
+ * CommandInterface for displaying help
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class HelpCommand extends BaseCommand {
public HelpCommand() {
- super("help", 1, "command" +
- "\n- prints out help information for a command");
+ super("help", 1, "help|help command");
}
public void execute(String args[]) {
String topic = args[0];
- Command command = getRegister().getCommand(topic);
+ CommandInterface command = getRegister().getCommand(topic);
if (command == null) {
prompt.out.println("No help available for " + topic);
} else {
prompt.out.println(command.getHelp());
}
}
-
- /**
- * This method overloads the BaseCommand help function - the HelpCommand
- * is the only class where this makes sense.
- */
+
public String getHelp() {
String help = super.getHelp();
1.2 +77 -22
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/ListCommand.java
Index: ListCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/ListCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ListCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ ListCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,49 +1,104 @@
package org.apache.xindice.admin.commands;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import org.apache.xindice.admin.commandline.BaseCommand;
-import org.apache.xmlrpc.XmlRpc;
-import org.apache.xmlrpc.XmlRpcClient;
import java.util.Hashtable;
import java.util.Vector;
import java.util.Date;
/**
- * Simple command to prints out the current date/time.
+ * CommandInterface for listing collections and documents
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class ListCommand extends BaseCommand {
public ListCommand() {
- super("list", 0, "\n- prints the current collection's
structure.");
+ super("list", 1, "collections|documents" + "\n- prints a list
of collections|documents");
}
public void execute(String args[]) {
- XmlRpcClient client = null;
-
- try {
- XmlRpc.setEncoding("UTF8");
- XmlRpc.setDriver("xerces");
- } catch(Exception e) {
-
- }
-
- try {
- client = new XmlRpcClient("http://localhost:8080/Xindice");
- } catch(Exception e) {
+ String option = args[0];
+ String rpcmessage = null;
+ if(option.startsWith("col")){
+ rpcmessage = "ListCollections";
+ } else if (option.startsWith("doc")){
+ rpcmessage = "ListDocuments";
+ } else {
+ prompt.out.println("Invalid option");
+ return;
}
Hashtable message = new Hashtable();
- message.put("message", "ListCollections");
+ message.put("message", rpcmessage);
message.put("collection", "/db");
Hashtable result = null;
- Vector params = new Vector();
- params.addElement( message );
try {
- result = (Hashtable) client.execute("run", params);
+ result = (Hashtable) run(message);
} catch(Exception e) {
-
+ prompt.out.println(e);
+ } finally {
+ prompt.out.println("\t"+result.get("result"));
}
- prompt.out.println("\t"+result.get("result"));
}
}
1.2 +64 -6
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/QueryCommand.java
Index: QueryCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/QueryCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- QueryCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ QueryCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,23 +1,81 @@
package org.apache.xindice.admin.commands;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import java.util.Iterator;
import java.util.Set;
-
import org.apache.xindice.admin.commandline.BaseCommand;
-import org.apache.xindice.admin.commandline.Command;
+import org.apache.xindice.admin.commandline.CommandInterface;
/**
- * This command is used to query information about any command that has
- * been registered with the prompt.
+ * CommandInterface for querying collections and documents
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class QueryCommand extends BaseCommand {
public QueryCommand() {
- super("query", 0, "executes an XPath or XUpdate query against a
document or collection");
+ super("query", 2, "XPath/XUpdate query" + "\nexecutes an XPath
or XUpdate query against a document or collection");
}
public void execute(String args[]) {
- //String collection = args[0];
prompt.out.println("Query results...");
}
1.2 +63 -8
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/RunScriptCommand.java
Index: RunScriptCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/RunScriptCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RunScriptCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ RunScriptCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,23 +1,78 @@
package org.apache.xindice.admin.commands;
-import org.apache.xindice.admin.commandline.CommandException;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+import org.apache.xindice.admin.commandline.CommandException;
import java.util.Iterator;
import java.net.URL;
import java.io.*;
/**
- * This command reads in a text file (or URL) containing a list of commands.
- * It is basically a utility for batch executions. Each line of the file
- * should contain a command to be executed. Comment lines can be inserted
- * by placing a '#' at the start of the line. By convention, I name all my
- * scripts with a .scr ending (good old ms-dos syntax).
+ * CommandInterface for running batch scripts
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class RunScriptCommand extends URLCommand {
public RunScriptCommand() {
- super("exec", 1, "url" +
- "\n- reads the specified url containing a list of
commands");
+ super("execute", 1, "url" + "\n- reads the specified url
containing a list of commands");
}
public void execute(String args[]) {
1.2 +63 -3
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/TimeCommand.java
Index: TimeCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/TimeCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- TimeCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ TimeCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,12 +1,72 @@
package org.apache.xindice.admin.commands;
-import org.apache.xindice.admin.commandline.BaseCommand;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+import org.apache.xindice.admin.commandline.BaseCommand;
import java.util.Date;
/**
- * Simple command to prints out the current date/time.
+ * CommandInterface for displaying the current time
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class TimeCommand extends BaseCommand {
public TimeCommand() {
@@ -15,6 +75,6 @@
}
public void execute(String args[]) {
- prompt.out.println("Current time is: " + (new
Date()).toString());
+ prompt.out.println("\tCurrent time is: " + (new
Date()).toString());
}
}
1.2 +63 -11
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/URLCommand.java
Index: URLCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/URLCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- URLCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ URLCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,21 +1,76 @@
package org.apache.xindice.admin.commands;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import org.apache.xindice.admin.utility.URLUtils;
import org.apache.xindice.admin.commandline.BaseCommand;
-
import java.util.Iterator;
import java.util.Vector;
import java.net.URL;
import java.io.*;
/**
- * Any command that loads a URL (eg. file) for input should extend this
- * command. It basically checks that the Strings representing the URLs
- * are valid and returns URL instances as an enumeration (takes some of
- * the pain out of creating URLs). It is used by the RunScriptCommand.
- *
- * @see RunScriptCommand
+ * CommandInterface for handling file urls
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public abstract class URLCommand extends BaseCommand {
protected URLCommand(String name, int numArgs, String help) {
@@ -34,10 +89,7 @@
}
return urls.iterator();
}
-
- /**
- * Utility method
- */
+
public BufferedReader getBufferedReader(URL url) {
BufferedReader reader = null;
try {
1.2 +64 -6
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/UseCommand.java
Index: UseCommand.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/commands/UseCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- UseCommand.java 9 Nov 2002 01:13:48 -0000 1.1
+++ UseCommand.java 9 Nov 2002 01:24:55 -0000 1.2
@@ -1,25 +1,83 @@
package org.apache.xindice.admin.commands;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import java.util.Iterator;
import java.util.Set;
-
import org.apache.xindice.admin.commandline.BaseCommand;
-import org.apache.xindice.admin.commandline.Command;
+import org.apache.xindice.admin.commandline.CommandInterface;
/**
- * This command is used to query information about any command that has
- * been registered with the prompt.
+ * CommandInterface for setting the working collection
+ * Author: kward <[EMAIL PROTECTED]>
*/
+
public class UseCommand extends BaseCommand {
public UseCommand() {
- super("use", 1, "command sets the current database collection");
+ super("use", 1, "collection" + "\ncommand sets the current
database collection");
}
public void execute(String args[]) {
String collection = args[0];
prompt.out.println("Collection changed to "+ collection);
-
}
}
1.2 +59 -6
xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/utility/URLUtils.java
Index: URLUtils.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/scratchpad/admin/src/org/apache/xindice/admin/utility/URLUtils.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- URLUtils.java 9 Nov 2002 01:13:48 -0000 1.1
+++ URLUtils.java 9 Nov 2002 01:24:56 -0000 1.2
@@ -1,5 +1,64 @@
package org.apache.xindice.admin.utility;
+/*
+ * The Apache Software License, Version 1.1
+ *
+ *
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Xindice" and "Apache Software Foundation" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written
+ * permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ * nor may "Apache" appear in their name, without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation and was
+ * originally based on software copyright (c) 1999-2001, The dbXML
+ * Group, L.L.C., http://www.dbxmlgroup.com. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * $Id$
+ */
+
import java.io.File;
import java.net.URL;
import java.net.MalformedURLException;
@@ -12,7 +71,6 @@
} else if ( string.indexOf("/") != -1 ||
string.indexOf("\\") != -1 ) {
- // this might be a file, this is expensive but we need
to try
URL test = createURL(string);
if (test != null) {
return true;
@@ -40,11 +98,6 @@
try {
url = file.toURL();
} catch (MalformedURLException e) {
- // if the command has mixed fileName and
integer (or non-file
- // name) arguments, we might be trying to
create a URL for
- // an integer argument - just skip this name
and return null
- // System.err.println(
- // "URL path '" + name + "' is not valid:
" + e);
return null;
}
}