[prev in list] [next in list] [prev in thread] [next in thread]
List: xindice-dev
Subject: svn commit: r578602 [1/2] - in
From: natalia () apache ! org
Date: 2007-09-23 20:33:33
Message-ID: 20070923203335.83EE61A9832 () eris ! apache ! org
[Download RAW message or body]
Author: natalia
Date: Sun Sep 23 13:33:31 2007
New Revision: 578602
URL: http://svn.apache.org/viewvc?rev=578602&view=rev
Log:
Cleanup, removed obsolete/unused parameters.
Command arguments are passed as Config object.
Added new attributes to the ant task (DeploymentTask).
Modified:
xml/xindice/trunk/java/src/org/apache/xindice/tools/DeploymentTask.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddCollection.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddDocument.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddIndexer.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddResource.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Command.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteCollection.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteDocument.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteIndexer.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ExportTree.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/HelpCommand.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ImportTree.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollectionDocuments.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollections.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListIndexers.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/RetrieveDocument.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/TextQuery.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XPathQuery.java
xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XUpdate.java
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/DeploymentTask.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/DeploymentTask.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/DeploymentTask.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/DeploymentTask.java Sun Sep \
23 13:33:31 2007 @@ -30,87 +30,114 @@
* @version $Revision$, $Date$
*/
public class DeploymentTask extends Task {
-
- private String collection = "test/ocs";
- private String db = "Database";
private String home = "";
- private XMLTools admin = null;
+ private XMLTools.Config config = null;
/**
* Constructor for creating a new DeploymentTask.
*/
public DeploymentTask() {
- admin = new XMLTools();
+ config = new XMLTools.Config();
}
/**
- * Sets the Name to use for the document or XMLObject. This method always
- * sets both documentName and Name on the admin object
+ * Sets the action name to be performed.
*
- * @param name The new Name value
+ * @param action The name of the action
*/
- public void setName(String name) {
- admin.setDocumentName(name);
- admin.setName(name);
+ public void setAction(String action) {
+ config.setString(XMLTools.ACTION, action);
}
-
/**
- * Sets the Home attribute of the DeploymentTask object
+ * Sets collection context.
*
- * @param name The new Home value
+ * @param context Target collection URL
*/
- public void setHome(String name) {
- this.home = name;
+ public void setCollection(String context) {
+ config.setString(XMLTools.COLLECTION, context);
}
+ /**
+ * Sets the Name to use for the document or collection.
+ *
+ * @param name The new Name value
+ */
+ public void setName(String name) {
+ config.setString(XMLTools.NAME_OF, name);
+ }
/**
- * Sets the Path attribute of the DeploymentTask object
+ * Sets the filer to use for the collection.
*
- * @param name The new Path value
+ * @param filer The new Name value
*/
- public void setPath(String name) {
- admin.setFilePath(name);
+ public void setFiler(String filer) {
+ config.setString(XMLTools.FILER, filer);
}
+ /**
+ * Sets the page size attribute for collection.
+ *
+ * @param pageSize The new Name value
+ */
+ public void setPageSize(String pageSize) {
+ config.setString(XMLTools.PAGE_SIZE, pageSize);
+ }
/**
- * Sets the Collection attribute of the DeploymentTask object
+ * Sets the page count attribute for collection.
*
- * @param name The new Collection value
+ * @param pageCount The new Name value
*/
- public void setCollection(String name) {
- this.collection = name;
+ public void setPageCount(String pageCount) {
+ config.setString(XMLTools.PAGE_COUNT, pageCount);
}
+ /**
+ * Sets index pattern.
+ *
+ * @param pattern The new Name value
+ */
+ public void setPattern(String pattern) {
+ config.setString(XMLTools.PATTERN, pattern);
+ }
/**
- * Sets the Database attribute of the DeploymentTask object
+ * Sets index type.
*
- * @param name The new Database value
+ * @param type The new Name value
*/
- public void setDatabase(String name) {
- this.db = name;
+ public void setType(String type) {
+ config.setString(XMLTools.PATTERN, type);
}
+ /**
+ * Sets the Home attribute of the DeploymentTask object
+ *
+ * @param name The new Home value
+ */
+ public void setHome(String name) {
+ this.home = name;
+ }
/**
- * Sets the Activity attribute of the DeploymentTask object
+ * Sets the Path attribute of the DeploymentTask object
*
- * @param name The new Activity value
+ * @param name The new Path value
*/
- public void setActivity(String name) {
- admin.setAction(name);
+ public void setPath(String name) {
+ config.setString(XMLTools.FILE_PATH, name);
}
/**
- * Sets the Implementation class attribute of the DeploymentTask object
+ * Sets the Activity attribute of the DeploymentTask object
*
* @param name The new Activity value
+ * @deprecated
*/
- public void setClass(String name) {
- admin.setImplementClass(name);
+ public void setActivity(String name) {
+ config.setString(XMLTools.ACTION, name);
}
/**
@@ -120,20 +147,15 @@
*/
public void execute() throws BuildException {
if (this.home.equals("")) {
- throw new BuildException(
- "You must specify the home attribute for deployment");
+ throw new BuildException("You must specify the home attribute for \
deployment"); }
// Set the home directory so the XMLAdmin object can find its configuration.
System.getProperties().put(Xindice.PROP_XINDICE_HOME, home);
- // Add the parameters that had defaults
- admin.setDatabaseServer(db);
- admin.setCollectionName(collection);
-
// Run the task.
try {
- admin.execute();
+ new XMLTools(config).execute();
} catch (Exception e) {
e.printStackTrace();
throw new BuildException("Error executing deployment task", e);
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java (original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/XMLTools.java Sun Sep 23 \
13:33:31 2007 @@ -34,12 +34,14 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
-import java.util.Hashtable;
import java.util.NoSuchElementException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
/**
- * XMLAdmin is designed to take command line arguments and give
- * user Xindice management flexibility within the current Database.
+ * XMLTools parses command line arguments and executes corresponding command
+ * to give user Xindice management flexibility within the current Database.
*
* @version $Revision$, $Date$
*/
@@ -53,31 +55,21 @@
public static final String NAME_OF = "nameOf";
public static final String PATTERN = "pattern";
public static final String QUERY = "query";
- public static final String URI = "uri";
public static final String VERBOSE = "verbose";
public static final String HELP = "help";
public static final String TYPE = "type";
public static final String PAGE_SIZE = "pagesize";
public static final String MAX_KEY_SIZE = "maxkeysize";
- public static final String DB_SERVER = "dbServ";
- public static final String PORT = "port";
- public static final String HOST = "host";
- public static final String USER = "user";
public static final String LOCAL = "local";
public static final String DB_CONFIG = "dbconfig";
- public static final String PASSWORD = "password";
- public static final String AUTO_KEY = "autoKey";
public static final String NAMESPACES = "namespaces";
- public static final String IMPL_CLASS = "implClass";
public static final String COMMAND_LIST = "__command_list__";
public static final String PAGE_COUNT = "pagecount";
- private Hashtable table;
+ private Config config;
private boolean initialized;
- //private Document commandsDocument;
- private NodeList commandsList;
-
+ private List commandsList;
public static void main(String[] args) {
XMLTools tools = new XMLTools();
@@ -85,7 +77,7 @@
tools.process(args);
} catch (Exception e) {
System.err.println(e.getMessage());
- if (tools.isVerbose()) {
+ if (tools.config.getBoolean(VERBOSE)) {
e.printStackTrace();
}
}
@@ -96,13 +88,14 @@
* command line.
*/
public XMLTools() {
- table = new Hashtable();
- // defaults for command switches
- table.put(FILE_PATH, "");
- table.put(EXTENSION, "");
- table.put(QUERY, "");
- table.put(AUTO_KEY, "");
- table.put(VERBOSE, "false");
+ config = new Config();
+ }
+
+ /**
+ * Constructor for XMLTools based on existing Config.
+ */
+ public XMLTools(Config config) {
+ this.config = config;
}
/**
@@ -127,12 +120,23 @@
list = node.getElementsByTagName("command");
}
+ List commandList = new ArrayList();
+ for (int i = 0; i < list.getLength(); i++) {
+ Element e = (Element) list.item(i);
+ String switchName = e.getAttribute("switch");
+ String fullName = e.getAttribute("name");
+ String className = e.getAttribute("class");
+ String descr = e.getAttribute("description");
+ String helpClass = e.getAttribute("helpclass");
+ commandList.add(new Action(className, descr, helpClass, switchName, \
fullName)); + }
+
// Return the list generated
- commandsList = list;
+ commandsList = commandList;
// Add the command list so that the HelpCommand can access it and
// print specific help information.
- table.put(COMMAND_LIST, commandsList);
+ config.setActions(commandsList);
}
/**
@@ -149,7 +153,7 @@
* Returns the <command> elements from the Commands Document this
* tool can execute.
*/
- protected NodeList getCommands() {
+ protected List getCommands() {
return commandsList;
}
@@ -160,7 +164,6 @@
*/
public void process(String[] args) throws XindiceException {
try {
- init();
parseArguments(args);
execute();
} catch (IllegalArgumentException e) {
@@ -176,7 +179,7 @@
/**
* Parses and validated the arguments of the command line. The arguments are
- * stored into the <tt>table</tt> array.
+ * stored into the <tt>Config</tt> object.
*
* @exception IllegalArgumentException if an error is found
*/
@@ -189,64 +192,56 @@
}
// Action should always be the second token, if not there show help
- table.put(ACTION, at.nextToken());
+ config.setString(ACTION, at.nextToken());
// Loop over remaining command line arguments, populating hashtable
while (at.hasMoreTokens()) {
String token = at.nextToken();
if (token.equalsIgnoreCase("-h") || token.equalsIgnoreCase("--help")) {
- table.put(HELP, "true");
+ config.setBoolean(HELP, true);
} else if (token.equalsIgnoreCase("-c") || \
token.equalsIgnoreCase("--collection")) { String colname = at.nextSwitchToken();
if (!colname.startsWith("/") && \
!colname.startsWith("xmldb:xindice")) {
throw new IllegalArgumentException("The name of a collection \
must start with '/'"); }
- table.put(COLLECTION, colname);
+ config.setString(COLLECTION, colname);
} else if (token.equalsIgnoreCase("--filer")) {
- table.put(FILER, at.nextSwitchToken());
+ config.setString(FILER, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("-e") || \
token.equalsIgnoreCase("--extension")) {
- table.put(EXTENSION, at.nextSwitchToken());
+ config.setString(EXTENSION, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("-f") || \
token.equalsIgnoreCase("--filepath")) {
- table.put(FILE_PATH, at.nextSwitchToken());
+ config.setString(FILE_PATH, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("-n") || \
token.equalsIgnoreCase("--nameOf")) {
- table.put(NAME_OF, at.nextSwitchToken());
+ config.setString(NAME_OF, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("-p") || \
token.equalsIgnoreCase("--pattern")) {
- table.put(PATTERN, at.nextSwitchToken());
+ config.setString(PATTERN, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("-q") || \
token.equalsIgnoreCase("--query")) {
- table.put(QUERY, at.nextSwitchToken());
- } else if (token.equalsIgnoreCase("-u") || \
token.equalsIgnoreCase("--uri")) {
- table.put(URI, at.nextSwitchToken());
+ config.setString(QUERY, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("-v") || \
token.equalsIgnoreCase("--verbose")) {
- table.put(VERBOSE, "true");
+ config.setBoolean(VERBOSE, true);
} else if (token.equalsIgnoreCase("-l") || \
token.equalsIgnoreCase("--localdb")) {
- table.put(LOCAL, "true");
+ config.setBoolean(LOCAL, true);
} else if (token.equalsIgnoreCase("-d") || \
token.equalsIgnoreCase("--dbconfig")) { String configFile = at.nextSwitchToken();
if (!new File(configFile).isAbsolute()) {
configFile = new File(System.getProperty("user.dir"), \
configFile).getAbsolutePath(); }
System.setProperty(Xindice.PROP_XINDICE_CONFIGURATION, configFile);
- table.put(DB_CONFIG, configFile);
+ config.setString(DB_CONFIG, configFile);
} else if (token.equalsIgnoreCase("-s") || \
token.equalsIgnoreCase("--namespaces")) {
- table.put(NAMESPACES, at.nextSwitchToken());
+ config.setString(NAMESPACES, at.nextSwitchToken());
// Index specific options
} else if (token.equalsIgnoreCase("-t") || \
token.equalsIgnoreCase("--type")) {
- table.put(TYPE, at.nextSwitchToken());
- } else if (token.equalsIgnoreCase("+trim")) {
- if (!table.containsKey(TYPE)) {
- table.put(TYPE, "trimmed");
- }
- } else if (token.equalsIgnoreCase("-trim")) {
- if (!table.containsKey(TYPE)) {
- table.put(TYPE, "string");
- }
+ config.setString(TYPE, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("--pagesize")) {
- table.put(PAGE_SIZE, at.nextSwitchToken());
+ config.setString(PAGE_SIZE, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("--maxkeysize")) {
- table.put(MAX_KEY_SIZE, at.nextSwitchToken());
+ config.setString(MAX_KEY_SIZE, at.nextSwitchToken());
} else if (token.equalsIgnoreCase("--pagecount")) {
- table.put(PAGE_COUNT, at.nextSwitchToken());
+ config.setString(PAGE_COUNT, at.nextSwitchToken());
+ } else {
+ // todo: unrecognized switch
}
}
}
@@ -256,18 +251,17 @@
*/
public boolean execute() throws Exception {
init();
- String action = (String) table.get(ACTION);
+ String action = config.getString(ACTION);
// get command class name
String commandClass = null;
if (action != null) {
// search for the tool Class associated with the given action
- NodeList commands = getCommands();
- for (int i = 0; i < commands.getLength(); i++) {
- Element e = (Element) commands.item(i);
- if (action.equals(e.getAttribute("switch")) ||
- action.equals(e.getAttribute("name"))) {
- commandClass = e.getAttribute("class");
+ List commands = getCommands();
+ for (int i = 0; i < commands.size(); i++) {
+ Action a = (Action) commands.get(i);
+ if (action.equals(a.switchName) || action.equals(a.fullName)) {
+ commandClass = a.className;
}
}
}
@@ -279,7 +273,7 @@
Command command;
try {
command = (Command) Class.forName(commandClass).newInstance();
- if ("true".equals(table.get(HELP))) {
+ if (config.getBoolean(HELP)) {
// show command help
command.usage();
} else {
@@ -288,304 +282,82 @@
DatabaseManager.registerDatabase(db);
// Execute command class
- command.execute(table);
+ command.execute(config);
}
return true;
} catch (XMLDBException e) {
System.err.println("XMLDB Exception " + e.errorCode + ": " + \
e.getMessage());
- if (isVerbose()) {
+ if (config.getBoolean(VERBOSE)) {
e.printStackTrace(System.err);
}
return false;
} catch (Exception e) {
System.err.println("ERROR : " + e.getMessage());
- if (isVerbose()) {
+ if (config.getBoolean(VERBOSE)) {
e.printStackTrace(System.err);
}
return false;
} finally {
// Close Database
- if ("true".equals(table.get(LOCAL))) {
+ if (config.getBoolean(LOCAL)) {
command = new org.apache.xindice.tools.command.Shutdown();
- command.execute(table);
+ command.execute(config);
}
}
}
- public boolean handleOption(String option, ArgTokenizer at) {
- return false;
- }
-
- /**
- * @param verbose new value of verbose mode
- */
- public void setVerbose(boolean verbose) {
- table.put(XMLTools.VERBOSE, verbose ? "true" : "false");
- }
-
- /**
- * @return true if operating in verbose mode
- */
- public boolean isVerbose() {
- return "true".equals(table.get(XMLTools.VERBOSE));
- }
-
- /**
- * setAction sets the action type that will be passed to the command line.
- *
- * @param actionType The action value
- */
- public void setAction(String actionType) {
- table.put(XMLTools.ACTION, actionType);
- }
-
- /**
- * getAction returns the action type that will be passed to the command line
- * tool.
- *
- * @return The action value
- */
- public String getAction() {
- return (String) table.get(XMLTools.ACTION);
- }
-
- /**
- * setCollectionName sets the collection name that will be passed
- * to the command line.
- *
- * @param collectionName The collection value
- */
- public void setCollectionName(String collectionName) {
- table.put(COLLECTION, collectionName);
- }
-
- /**
- * getCollectionName returns the collection name that will be passed
- * to the command line tool.
- *
- * @return The collection value
- */
- public String getCollectionName() {
- return (String) table.get(COLLECTION);
- }
-
- /**
- * setDocumentName sets the document that will be passed to the
- * command line tool.
- *
- * @param documentName The docName value
- */
- public void setDocumentName(String documentName) {
- table.put(XMLTools.NAME_OF, documentName);
- }
-
- /**
- * getDocumentName returns the document that will be passed to the
- * command line tool.
- *
- * @return The docName value
- */
- public String getDocumentName() {
- return (String) table.get(XMLTools.NAME_OF);
- }
-
- /**
- * setQuery sets the Query variable for Document Query from the command line.
- *
- * @param query - The query string
- */
- public void setQuery(String query) {
- table.put(XMLTools.QUERY, query);
- }
-
- /**
- * getQuery returns the Query for Document passed to the command line tool.
- */
- public String getQuery() {
- return (String) table.get(XMLTools.QUERY);
- }
-
- /**
- * setName sets the name for XMLObjects passed to the command line tool.
- *
- * @param name The docName value
- */
- public void setName(String name) {
- table.put(XMLTools.NAME_OF, name);
- }
-
- /**
- * getName returns the name for XMLObjects that will be passed to the
- * command line tool.
- *
- * @return The nameOf value
- */
- public String getName() {
- return (String) table.get(XMLTools.NAME_OF);
- }
-
- /**
- * setDatabaseServer sets the Database server name that will be
- * passed to the command line tool.
- *
- * @param appName The dbServ value
- */
- public void setDatabaseServer(String appName) {
- table.put(XMLTools.DB_SERVER, appName);
- }
-
- /**
- * getDatabaseServer returns the Database server that will be
- * passed to the command line tool.
- *
- * @return The dbServ value
- */
- public String getDatabaseServer() {
- return (String) table.get(XMLTools.DB_SERVER);
- }
-
- /**
- * setPort sets the port that will passed to the command line tool.
- *
- * @param portName The port value
- */
- public void setPort(String portName) {
- table.put(XMLTools.PORT, portName);
- }
-
- /**
- * getPort returns the port that will be passed to the command line tool.
- *
- * @return The port value
- */
- public String getPort() {
- return (String) table.get(XMLTools.PORT);
- }
-
- /**
- * setHost sets the host that will passed to the command line tool.
- *
- * @param hostName The host value
- */
- public void setHost(String hostName) {
- table.put(HOST, hostName);
- }
-
- /**
- * getPort returns the host that will be passed to the command line tool.
- *
- * @return The host value
- */
- public String getHost() {
- return (String) table.get(HOST);
- }
+ public static class Config {
+ private HashMap config;
- /**
- * setFilePath sets the file path that will passed to the command line tool.
- *
- * @param fPath The filePath value
- */
- public void setFilePath(String fPath) {
- table.put(XMLTools.FILE_PATH, fPath);
- }
+ public Config() {
+ config = new HashMap();
- /**
- * getFilePath returns the file path that will be passed to the command
- *
- * @return The filePath value
- */
- public String getFilePath() {
- return (String) table.get(XMLTools.FILE_PATH);
- }
-
- /**
- * setURI sets the database URI (protocol://host:port/name) that
- * will be passed to the command line
- *
- * @param URI The URI for the database
- */
- public void setURI(String URI) {
- table.put(XMLTools.URI, URI);
- }
-
- /**
- * getURI gets returns the database URI (protocol://host:port/name)
- * that will be passed to the command line tool
- *
- * @return The URI for the database
- */
- public String getURI() {
- return (String) table.get(XMLTools.URI);
- }
-
- /**
- * setImplementClass sets the implemented class path that will be passed
- * to the command line tool.
- *
- * @param imClassName The implClass value
- */
- public void setImplementClass(String imClassName) {
- table.put(XMLTools.IMPL_CLASS, imClassName);
- }
-
- /**
- * getImplementClass returns the implmented class path that will be passed
- * to the command line tool.
- *
- * @return The implClass value
- */
- public String getImplementClass() {
- return (String) table.get(XMLTools.IMPL_CLASS);
- }
+ // defaults for command switches
+ setString(FILE_PATH, "");
+ setString(EXTENSION, "");
+ setString(QUERY, "");
+ setBoolean(VERBOSE, false);
+ }
+ public String getString(String param) {
+ return (String) config.get(param);
+ }
- /**
- * The following Security methods are simply a starting point. User names and
- * their related passwords will not be this simple. Until Encryption for
- * Passwords are developed, and KeyStorage is set-up, this will do for now.
- * In the future, these methods will change as needed to be more efficient
- * for Xindice.
- */
+ public void setString(String param, String value) {
+ config.put(param, value);
+ }
+ public boolean getBoolean(String param) {
+ return Boolean.TRUE.equals(config.get(param));
+ }
- /**
- * setUser sets the user that will be passed to the command line tool and
- * will be used in Security issues.
- *
- * @param userName The user value
- */
- public void setUser(String userName) {
- table.put(XMLTools.USER, userName);
- }
+ public void setBoolean(String param, boolean value) {
+ config.put(param, Boolean.valueOf(value));
+ }
- /**
- * getUser returns the user that will be passed to the command line tool and
- * will be used in Security issues.
- *
- * @return The user value
- */
- public String getUser() {
- return (String) table.get(XMLTools.USER);
- }
+ public List getActions() {
+ return (List) config.get(COMMAND_LIST);
+ }
- /**
- * setPassword sets the password that will be passed to the command line tool
- * and will be used in conjunction with the userName value.
- *
- * @param pswd The passwrd value
- */
- public void setPassword(String pswd) {
- table.put(PASSWORD, pswd);
+ public void setActions(List value) {
+ config.put(COMMAND_LIST, value);
+ }
}
- /**
- * getPassword returns the password that will be passed to the command line
- * tool and will be used in conjunction with the userName value.
- *
- * @return The password value
- */
- public String getPassword() {
- return (String) table.get(PASSWORD);
+ public static class Action {
+ public final String helpclass;
+ public final String className;
+ public final String description;
+ public final String switchName;
+ public final String fullName;
+
+ public Action(String className, String description, String helpclass, String \
switchName, String fullName) { + this.helpclass = helpclass;
+ this.className = className;
+ this.description = description;
+ this.switchName = switchName;
+ this.fullName = fullName;
+ }
}
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddCollection.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddCollection.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddCollection.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddCollection.java \
Sun Sep 23 13:33:31 2007 @@ -32,7 +32,6 @@
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
-import java.util.Hashtable;
import java.io.InputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -48,20 +47,20 @@
/**
* Creates collection
*/
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
- if (table.get(XMLTools.COLLECTION) == null) {
+ if (table.getString(XMLTools.COLLECTION) == null) {
System.out.println("ERROR : Collection and switch required");
return false;
}
- if ("".equals(table.get(XMLTools.FILE_PATH)) && table.get(XMLTools.NAME_OF) \
== null) { + if ("".equals(table.getString(XMLTools.FILE_PATH)) && \
table.getString(XMLTools.NAME_OF) == null) {
System.out.println("ERROR : New Collection name required or File path \
required"); return false;
}
Document config;
- if (!"".equals(table.get(XMLTools.FILE_PATH))) {
+ if (!"".equals(table.getString(XMLTools.FILE_PATH))) {
// configuration was passed in a file
config = readConfig(table);
} else {
@@ -74,8 +73,8 @@
Collection tempcol = null;
try {
// Get a Collection reference to pass on to individual commands
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL)); + String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL));
col = DatabaseManager.getCollection(colstring);
if (col == null) {
@@ -87,15 +86,15 @@
CollectionManager colman = (CollectionManager) \
col.getService("CollectionManager", XMLDBAPIVERSION);
String colPath;
- if (!"".equals(table.get(XMLTools.FILE_PATH))) {
+ if (!"".equals(table.getString(XMLTools.FILE_PATH))) {
colPath = \
config.getDocumentElement().getAttributeNode("name").getNodeValue(); } else {
- colPath = (String) table.get(XMLTools.NAME_OF);
+ colPath = table.getString(XMLTools.NAME_OF);
}
tempcol = colman.createCollection(colPath, config);
- System.out.println("Created : " + table.get(XMLTools.COLLECTION) + "/" + \
colPath); + System.out.println("Created : " + \
table.getString(XMLTools.COLLECTION) + "/" + colPath); } finally {
// Release the collection objects
if (col != null) {
@@ -109,10 +108,10 @@
return true;
}
- private Document readConfig(Hashtable table) throws Exception {
+ private Document readConfig(XMLTools.Config table) throws Exception {
InputStream fis = null;
try {
- File file = new File((String) table.get(XMLTools.FILE_PATH));
+ File file = new File(table.getString(XMLTools.FILE_PATH));
fis = new FileInputStream(file);
// check if top element has necessary attribute 'name'
@@ -132,8 +131,8 @@
}
}
- private Document buildConfig(Hashtable table) throws Exception {
- String colPath = (String) table.get(XMLTools.NAME_OF);
+ private Document buildConfig(XMLTools.Config table) throws Exception {
+ String colPath = table.getString(XMLTools.NAME_OF);
String colName;
// get the part after last /, any collection before / must already exist
@@ -161,8 +160,8 @@
Element filEle = doc.createElement("filer");
String filerClass = "org.apache.xindice.core.filer.BTreeFiler";
// see if user specified filer type
- if (table.containsKey(XMLTools.FILER)) {
- String filer = (String) table.get(XMLTools.FILER);
+ if (table.getString(XMLTools.FILER) != null) {
+ String filer = table.getString(XMLTools.FILER);
if ("HashFiler".equals(filer)) {
filerClass = "org.apache.xindice.core.filer.HashFiler";
} else if (!"BTreeFiler".equals(filer)) {
@@ -171,20 +170,20 @@
}
filEle.setAttribute("class", filerClass);
- if (table.containsKey(XMLTools.PAGE_SIZE)) {
- filEle.setAttribute(XMLTools.PAGE_SIZE, (String) \
table.get(XMLTools.PAGE_SIZE)); + if (table.getString(XMLTools.PAGE_SIZE) != \
null) { + filEle.setAttribute(XMLTools.PAGE_SIZE, \
table.getString(XMLTools.PAGE_SIZE)); }
- if (table.containsKey(XMLTools.MAX_KEY_SIZE)) {
- filEle.setAttribute(XMLTools.MAX_KEY_SIZE, (String) \
table.get(XMLTools.MAX_KEY_SIZE)); + if \
(table.getString(XMLTools.MAX_KEY_SIZE) != null) { + \
filEle.setAttribute(XMLTools.MAX_KEY_SIZE, table.getString(XMLTools.MAX_KEY_SIZE)); \
}
- if (table.containsKey(XMLTools.PAGE_COUNT)) {
- filEle.setAttribute(XMLTools.PAGE_COUNT, (String) \
table.get(XMLTools.PAGE_COUNT)); + if (table.getString(XMLTools.PAGE_COUNT) != \
null) { + filEle.setAttribute(XMLTools.PAGE_COUNT, \
table.getString(XMLTools.PAGE_COUNT)); }
colEle.appendChild(filEle);
// If in verbose mode, show....
- if ("true".equals(table.get(XMLTools.VERBOSE))) {
+ if (table.getBoolean(XMLTools.VERBOSE)) {
String colstr = TextWriter.toString(doc);
System.out.println("Collection node element = ");
System.out.println("\t" + colstr + "\n");
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddDocument.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddDocument.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddDocument.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddDocument.java Sun \
Sep 23 13:33:31 2007 @@ -31,7 +31,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.util.Hashtable;
/**
* AddDocument is designed to let the user add single document
@@ -45,31 +44,32 @@
/**
* Adds a document to the collection
*/
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
- Collection col = null;
- if (table.get(XMLTools.COLLECTION) == null) {
+ if (table.getString(XMLTools.COLLECTION) == null) {
System.out.println("ERROR : Collection and switch required");
return false;
}
- if ("".equals(table.get(XMLTools.FILE_PATH))) {
+ if ("".equals(table.getString(XMLTools.FILE_PATH))) {
System.out.println("ERROR : File path required");
return false;
}
+ Collection col = null;
+ InputStream fis = null;
try {
// Create a collection instance
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL)); + String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL)); col = DatabaseManager.getCollection(colstring);
if (col == null) {
System.out.println("ERROR : Collection not found!");
return false;
}
- File file = new File((String) table.get(XMLTools.FILE_PATH));
- InputStream fis = new FileInputStream(file);
+ File file = new File(table.getString(XMLTools.FILE_PATH));
+ fis = new FileInputStream(file);
// Parse in XML using Xerces
SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance();
@@ -80,22 +80,21 @@
reader.setContentHandler(ser);
reader.setProperty("http://xml.org/sax/properties/lexical-handler", \
ser); reader.parse(new InputSource(fis));
- fis.close();
// Create the XMLResource and store the document
- Resource resource = col.createResource((String) \
table.get(XMLTools.NAME_OF),
- "XMLResource");
+ Resource resource = \
col.createResource(table.getString(XMLTools.NAME_OF), "XMLResource"); \
resource.setContent(ser.toString()); col.storeResource(resource);
- System.out.println("Added document " + table.get(XMLTools.COLLECTION) + \
"/" +
- resource.getId());
- resource = null;
+ System.out.println("Added document " + \
table.getString(XMLTools.COLLECTION) + "/" + resource.getId()); } finally {
if (col != null) {
col.close();
}
- col = null;
+
+ if (fis != null) {
+ fis.close();
+ }
}
return true;
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddIndexer.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddIndexer.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddIndexer.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddIndexer.java Sun \
Sep 23 13:33:31 2007 @@ -31,7 +31,6 @@
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
-import java.util.Hashtable;
import java.io.File;
import java.io.InputStream;
import java.io.FileInputStream;
@@ -44,21 +43,21 @@
*/
public class AddIndexer extends Command {
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
- if (table.get(XMLTools.COLLECTION) == null) {
+ if (table.getString(XMLTools.COLLECTION) == null) {
System.out.println("ERROR : Collection and switch required");
return false;
}
- if ("".equals(table.get(XMLTools.FILE_PATH)) &&
- (table.get(XMLTools.NAME_OF) == null || table.get(XMLTools.PATTERN) == \
null)) { + if ("".equals(table.getString(XMLTools.FILE_PATH)) &&
+ (table.getString(XMLTools.NAME_OF) == null || \
table.getString(XMLTools.PATTERN) == null)) {
System.out.println("ERROR : Name and Pattern required or File path \
required"); return false;
}
Document config;
- if (!"".equals(table.get(XMLTools.FILE_PATH))) {
+ if (!"".equals(table.getString(XMLTools.FILE_PATH))) {
// configuration was passed in a file
config = readConfig(table);
} else {
@@ -69,8 +68,8 @@
Collection col = null;
try {
// Get a Collection reference to the collection
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL)); + String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL));
col = DatabaseManager.getCollection(colstring);
if (col == null) {
@@ -94,10 +93,10 @@
return true;
}
- private Document readConfig(Hashtable table) throws Exception {
+ private Document readConfig(XMLTools.Config table) throws Exception {
InputStream fis = null;
try {
- File file = new File((String) table.get(XMLTools.FILE_PATH));
+ File file = new File(table.getString(XMLTools.FILE_PATH));
fis = new FileInputStream(file);
return DOMParser.toDocument(fis);
@@ -110,17 +109,17 @@
}
}
- private Document buildConfig(Hashtable table) throws Exception {
+ private Document buildConfig(XMLTools.Config table) throws Exception {
Document config = new DocumentImpl();
// Create the index element to hold attributes
Element idxEle = config.createElement("index");
idxEle.setAttribute("class", XINDICE_VAL_INDEXER);
- idxEle.setAttribute("name", (String) table.get(XMLTools.NAME_OF));
+ idxEle.setAttribute("name", table.getString(XMLTools.NAME_OF));
// Setup optional index attributes
- if (table.containsKey(XMLTools.TYPE)) {
- String type = (String) table.get(XMLTools.TYPE);
+ String type = table.getString(XMLTools.TYPE);
+ if (type != null) {
if (type.equalsIgnoreCase("name")) {
idxEle.setAttribute("class", XINDICE_NAME_INDEXER);
} else if (type.equalsIgnoreCase("text")) {
@@ -132,18 +131,18 @@
// LuceneIndexer configuration is different
if (idxEle.getAttribute("class").equals(XINDICE_TEXT_INDEXER)) {
- addPatterns(config, idxEle, (String) table.get(XMLTools.PATTERN));
+ addPatterns(config, idxEle, table.getString(XMLTools.PATTERN));
} else {
- idxEle.setAttribute("pattern", (String) table.get(XMLTools.PATTERN));
+ idxEle.setAttribute("pattern", table.getString(XMLTools.PATTERN));
- if (table.containsKey(XMLTools.PAGE_SIZE)) {
- idxEle.setAttribute(XMLTools.PAGE_SIZE, (String) \
table.get(XMLTools.PAGE_SIZE)); + if (table.getString(XMLTools.PAGE_SIZE) \
!= null) { + idxEle.setAttribute(XMLTools.PAGE_SIZE, \
table.getString(XMLTools.PAGE_SIZE)); }
- if (table.containsKey(XMLTools.MAX_KEY_SIZE)) {
- idxEle.setAttribute(XMLTools.MAX_KEY_SIZE, (String) \
table.get(XMLTools.MAX_KEY_SIZE)); + if \
(table.getString(XMLTools.MAX_KEY_SIZE) != null) { + \
idxEle.setAttribute(XMLTools.MAX_KEY_SIZE, table.getString(XMLTools.MAX_KEY_SIZE)); \
}
- if (table.containsKey(XMLTools.PAGE_COUNT)) {
- idxEle.setAttribute(XMLTools.PAGE_COUNT, (String) \
table.get(XMLTools.PAGE_COUNT)); + if \
(table.getString(XMLTools.PAGE_COUNT) != null) { + \
idxEle.setAttribute(XMLTools.PAGE_COUNT, table.getString(XMLTools.PAGE_COUNT)); }
}
@@ -151,7 +150,7 @@
config.appendChild(idxEle);
// If in verbose mode, show....
- if ("true".equals(table.get(XMLTools.VERBOSE))) {
+ if (table.getBoolean(XMLTools.VERBOSE)) {
String indexstr = TextWriter.toString(config);
System.out.println("Index node element = ");
System.out.println("\t" + indexstr + "\n");
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java \
Sun Sep 23 13:33:31 2007 @@ -26,7 +26,6 @@
import java.io.File;
import java.io.FilenameFilter;
-import java.util.Hashtable;
/**
* AddMultipleDocuments.java is designed to let the user add several Documents
@@ -39,42 +38,37 @@
*/
public class AddMultipleDocuments extends Command {
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
+
+ // Verify that user has supplied necessary arguments
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection and switch required");
+ return false;
+ }
+
+ if ("".equals(table.getString(XMLTools.FILE_PATH))) {
+ System.out.println("ERROR : Directory name and switch required");
+ return false;
+ }
Collection col = null;
try {
- // Verify that user has supplied necessary arguments
- if (table.get(XMLTools.COLLECTION) == null) {
- System.out.println("ERROR : Collection and switch required");
- return false;
- }
-
- if ("".equals(table.get(XMLTools.FILE_PATH))) {
- System.out.println("ERROR : Directory name and switch required");
- return false;
- }
-
- final String local = (String) table.get(XMLTools.LOCAL);
-
// Get a Collection reference to the collection
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- local);
+ String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL)); col = DatabaseManager.getCollection(colstring);
if (col == null) {
System.out.println("ERROR : Collection not found!");
return false;
}
- // Create a collection manager instance for the collection
- // CollectionManager colman = \
(CollectionManager)col.getService("CollectionManager",XMLDBAPIVERSION);
-
// Get a File object for the Directory passed in
- File dir = new File((String) table.get(XMLTools.FILE_PATH));
+ File dir = new File(table.getString(XMLTools.FILE_PATH));
if (dir.isDirectory()) {
String[] children = new String[]{};
- final String ext = (String) table.get(XMLTools.EXTENSION);
+ final String ext = table.getString(XMLTools.EXTENSION);
// If the user supplied a file extension, filter on it, else use \
entire contents of the directory if (!ext.equals("")) {
@@ -93,10 +87,10 @@
final Command cmd = new AddDocument();
// Command parameters
- Hashtable localtable = new Hashtable();
- localtable.put(XMLTools.COLLECTION, table.get(XMLTools.COLLECTION));
- if (local != null) {
- localtable.put(XMLTools.LOCAL, local);
+ XMLTools.Config localtable = new XMLTools.Config();
+ localtable.setString(XMLTools.COLLECTION, \
table.getString(XMLTools.COLLECTION)); + if \
(table.getBoolean(XMLTools.LOCAL)) { + \
localtable.setBoolean(XMLTools.LOCAL, true); }
// Loop over documents, adding to db
@@ -106,18 +100,18 @@
if (file.isFile()) {
try {
// Populate hashtable to pass to AddDocument class
- localtable.put(XMLTools.NAME_OF, file.getName());
- localtable.put(XMLTools.FILE_PATH, file.getPath());
+ localtable.setString(XMLTools.NAME_OF, file.getName());
+ localtable.setString(XMLTools.FILE_PATH, \
file.getPath());
// Execute the class!
cmd.execute(localtable);
} catch (Exception e) {
System.out.println("Error Adding File: " + \
file.getName());
- // System.out.println(e);
- continue;
+ if (table.getBoolean(XMLTools.VERBOSE)) {
+ e.printStackTrace();
+ }
}
- } else
- continue;
+ }
} // for loop
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddResource.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddResource.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddResource.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/AddResource.java Sun \
Sep 23 13:33:31 2007 @@ -28,7 +28,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
-import java.util.Hashtable;
/**
* AddResource is designed to let the user add single binary resource
@@ -42,23 +41,24 @@
/**
* Adds a resource to the collection
*/
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
- Collection col = null;
- if (table.get(XMLTools.COLLECTION) == null) {
+ if (table.getString(XMLTools.COLLECTION) == null) {
System.out.println("ERROR : Collection and switch required");
return false;
}
- if ("".equals(table.get(XMLTools.FILE_PATH))) {
+ if ("".equals(table.getString(XMLTools.FILE_PATH))) {
System.out.println("ERROR : File path required");
return false;
}
+ Collection col = null;
+ InputStream fis = null;
try {
// Create a collection instance
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL)); + String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL)); col = DatabaseManager.getCollection(colstring);
if (col == null) {
System.out.println("ERROR : Collection not found!");
@@ -66,26 +66,25 @@
}
// Read data
- File file = new File((String) table.get(XMLTools.FILE_PATH));
- InputStream fis = new FileInputStream(file);
+ File file = new File(table.getString(XMLTools.FILE_PATH));
+ fis = new FileInputStream(file);
byte[] data = new byte[fis.available()];
fis.read(data);
- fis.close();
// Create the BinaryResource and store the resource
- Resource resource = col.createResource((String) \
table.get(XMLTools.NAME_OF),
- "BinaryResource");
+ Resource resource = \
col.createResource(table.getString(XMLTools.NAME_OF), "BinaryResource"); \
resource.setContent(data); col.storeResource(resource);
- System.out.println("Added resource " + table.get(XMLTools.COLLECTION) + \
"/" +
- resource.getId());
- resource = null;
+ System.out.println("Added resource " + \
table.getString(XMLTools.COLLECTION) + "/" + resource.getId()); } finally {
if (col != null) {
col.close();
}
- col = null;
+
+ if (fis != null) {
+ fis.close();
+ }
}
return true;
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Command.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Command.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Command.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Command.java Sun Sep \
23 13:33:31 2007 @@ -19,7 +19,7 @@
package org.apache.xindice.tools.command;
-import java.util.Hashtable;
+import org.apache.xindice.tools.XMLTools;
/**
* Command is the standard interface command line arguments
@@ -41,12 +41,12 @@
public static final String XINDICE_NAME_INDEXER = \
"org.apache.xindice.core.indexer.NameIndexer";
public static final String XINDICE_TEXT_INDEXER = \
"org.apache.xindice.core.indexer.LuceneIndexer";
- public abstract boolean execute(Hashtable table) throws Exception;
+ public abstract boolean execute(XMLTools.Config table) throws Exception;
public abstract void usage();
// public class to return normalized CollectionURI for creation of a Collection \
object
- public String normalizeCollectionURI(String uri, String local) {
+ public String normalizeCollectionURI(String uri, boolean local) {
// Check to see if this uri starts with "xmldb:" , if so treat as absolute
if (uri.startsWith("xmldb:")) {
// URI is absolute, leave alone
@@ -54,10 +54,10 @@
} else if (uri.startsWith("xindice:") || uri.startsWith("xindice-embed:")) {
return (XMLDBURI + uri);
} else {
- if ((local != null) && local.equals("true")) {
+ // URI passed in is not absoulte, build the full URI
+ if (local) {
return (XMLDBURI + XINDICELOCALURI + uri);
} else {
- // URI passed in is not absoulte, build the full URI
return (XMLDBURI + XINDICEURI + uri);
}
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteCollection.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteCollection.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteCollection.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteCollection.java \
Sun Sep 23 13:33:31 2007 @@ -25,8 +25,6 @@
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
-import java.util.Hashtable;
-
/**
* DeleteCollection.java is designed to let the user delete or drop
* a named Collection or Nested Collection from the Database or Parent
@@ -36,31 +34,37 @@
*/
public class DeleteCollection extends Command {
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
+
+ // Verify that the collection passed in is not null
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection and switch required");
+ return false;
+ }
+
+ if (table.getString(XMLTools.NAME_OF) == null) {
+ System.out.println("ERROR : Name and switch required");
+ return false;
+ }
Collection col = null;
try {
- // Verify that the collection passed in is not null
- if (table.get(XMLTools.COLLECTION) != null && \
table.get(XMLTools.NAME_OF) != null) { + // Get a Collection reference to \
the collection to be deleted + String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL)); + col = \
DatabaseManager.getCollection(colstring); + if (col == null) {
+ System.out.println("ERROR : Collection not found!");
+ return false;
+ }
+
+ // Create a collection manager instance for the parent of the collection
+ CollectionManager colman = (CollectionManager) \
col.getService("CollectionManager", XMLDBAPIVERSION); +
+ // Drop the collection
+ colman.dropCollection(table.getString(XMLTools.NAME_OF));
- // Get a Collection reference to the collection to be deleted
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL));
- col = DatabaseManager.getCollection(colstring);
- if (col == null) {
- System.out.println("ERROR : Collection not found!");
- return false;
- }
-
- // Create a collection manager instance for the parent of the \
collection
- CollectionManager colman = (CollectionManager) \
col.getService("CollectionManager", XMLDBAPIVERSION);
-
- // Drop the collection
- colman.dropCollection((String) table.get(XMLTools.NAME_OF));
-
- System.out.println("Deleted: " + table.get(XMLTools.COLLECTION) + \
"/" + (String) table.get(XMLTools.NAME_OF));
- } else
- System.out.println("Error : Collection Context and Name required");
+ System.out.println("Deleted: " + table.getString(XMLTools.COLLECTION) + \
"/" + table.getString(XMLTools.NAME_OF));
} finally {
if (col != null) {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteDocument.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteDocument.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteDocument.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteDocument.java \
Sun Sep 23 13:33:31 2007 @@ -25,8 +25,6 @@
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.Resource;
-import java.util.Hashtable;
-
/**
* DeleteDocument.java is designed to let the user delete or drop
* a Document, referred by the Key, from a specific Collection or Nested
@@ -36,35 +34,33 @@
*/
public class DeleteDocument extends Command {
- public boolean execute(Hashtable table) throws Exception {
- Collection col = null;
+ public boolean execute(XMLTools.Config table) throws Exception {
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection and switch required");
+ return false;
+ }
+
+ if (table.getString(XMLTools.NAME_OF) == null) {
+ System.out.println("ERROR : Document Key and switch required");
+ return false;
+ }
+ Collection col = null;
try {
- if (table.get(XMLTools.COLLECTION) != null) {
- // Get a Collection reference to the collection to be deleted
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL));
-
- col = DatabaseManager.getCollection(colstring);
- if (col == null) {
- System.out.println("ERROR : Collection not found!");
- return false;
- }
-
- if (table.get(XMLTools.NAME_OF) != null) {
- Resource colresource = col.getResource((String) \
table.get(XMLTools.NAME_OF));
-
- col.removeResource(colresource);
- System.out.println("DELETED: " + table.get(XMLTools.COLLECTION) \
+ "/" + table.get(XMLTools.NAME_OF));
- } else {
- // User did not supply document name
- System.out.println("ERROR : Document Key and switch required");
- }
-
- } else
- // User did not supply collection name
- System.out.println("ERROR : Collection and switch required");
+ // Get a Collection reference to the collection to be deleted
+ String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL)); +
+ col = DatabaseManager.getCollection(colstring);
+ if (col == null) {
+ System.out.println("ERROR : Collection not found!");
+ return false;
+ }
+
+ Resource colresource = \
col.getResource(table.getString(XMLTools.NAME_OF));
+ col.removeResource(colresource);
+ System.out.println("DELETED: " + table.getString(XMLTools.COLLECTION) + \
"/" + table.getString(XMLTools.NAME_OF)); } finally {
if (col != null) {
col.close();
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteIndexer.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteIndexer.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteIndexer.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/DeleteIndexer.java \
Sun Sep 23 13:33:31 2007 @@ -25,8 +25,6 @@
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
-import java.util.Hashtable;
-
/**
* DeleteIndexer.java is designed to let the user delete or drop
* an Indexer from a named Collection or a nested Collection within
@@ -36,32 +34,34 @@
*/
public class DeleteIndexer extends Command {
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
+
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection and switch required");
+ return false;
+ }
+
+ if (table.getString(XMLTools.NAME_OF) == null) {
+ System.out.println("ERROR : Name switch and Indexer name required");
+ return false;
+ }
Collection col = null;
try {
- if (table.get(XMLTools.COLLECTION) != null) {
- // Get a Collection reference to the collection
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL));
- col = DatabaseManager.getCollection(colstring);
- if (col == null) {
- System.out.println("ERROR : Collection not found!");
- return false;
- }
-
- // Create a collection manager instance for the collection
- CollectionManager colman = (CollectionManager) \
col.getService("CollectionManager", XMLDBAPIVERSION);
-
- if (table.get(XMLTools.NAME_OF) != null) {
- colman.dropIndexer((String) table.get(XMLTools.NAME_OF));
- System.out.println("DELETED: " + (String) \
table.get(XMLTools.NAME_OF));
- } else {
- System.out.println("ERROR : Name switch and Indexer name \
required");
- }
- } else
- System.out.println("ERROR : Collection and switch required");
+ // Get a Collection reference to the collection
+ String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL)); + col = \
DatabaseManager.getCollection(colstring); + if (col == null) {
+ System.out.println("ERROR : Collection not found!");
+ return false;
+ }
+
+ // Create a collection manager instance for the collection
+ CollectionManager colman = (CollectionManager) \
col.getService("CollectionManager", XMLDBAPIVERSION);
+ colman.dropIndexer(table.getString(XMLTools.NAME_OF));
+ System.out.println("DELETED: " + table.getString(XMLTools.NAME_OF));
} finally {
if (col != null) {
col.close();
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ExportTree.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ExportTree.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ExportTree.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ExportTree.java Sun \
Sep 23 13:33:31 2007 @@ -28,7 +28,6 @@
import java.io.File;
import java.io.FileOutputStream;
-import java.util.Hashtable;
/**
* ExportTree is designed to take a Collection tree and create a Directory
@@ -44,33 +43,28 @@
* @param table Description of Parameter
* @return Description of the Returned Value
*/
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
- Collection col = null;
-
- if (table.get(XMLTools.FILE_PATH).equals("")) {
- System.out.println("ERROR: Directory name and switch required");
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection name and switch required");
return false;
}
- if (table.get(XMLTools.COLLECTION) == null) {
- System.out.println("ERROR : Collection name and switch required");
+ if (table.getString(XMLTools.FILE_PATH).equals("")) {
+ System.out.println("ERROR: Directory name and switch required");
return false;
}
- File fp = new File((String) table.get(XMLTools.FILE_PATH));
-
+ File fp = new File(table.getString(XMLTools.FILE_PATH));
System.out.println();
- if (table.get(XMLTools.COLLECTION) != null) {
- String parent = parentDir((String) table.get(XMLTools.COLLECTION));
- File dir = new File(fp, parent);
+ String parent = parentDir(table.getString(XMLTools.COLLECTION));
+ File dir = new File(fp, parent);
- System.out.println("Creating directory " + dir.getPath());
- dir.mkdir();
+ System.out.println("Creating directory " + dir.getPath());
+ dir.mkdir();
- process(dir, table, col);
- }
+ process(dir, table);
return true;
}
@@ -87,14 +81,14 @@
/**
* Export given collection to the directory
*/
- boolean process(File directory, Hashtable table, Collection col) throws \
Exception { + boolean process(File directory, XMLTools.Config table) throws \
Exception { + Collection col = null;
try {
- String[] list = null;
- String collection = (String) table.get(XMLTools.COLLECTION);
+ String collection = table.getString(XMLTools.COLLECTION);
// Get a Collection reference to the collection
- String colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL)); + String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL)); col = DatabaseManager.getCollection(colstring);
if (col == null) {
System.out.println("ERROR : Collection not found!");
@@ -112,7 +106,7 @@
}
if (files != null) {
- System.out.println("Extracting " + files.length + " files from " + \
table.get(XMLTools.COLLECTION)); + System.out.println("Extracting " + \
files.length + " files from " + table.getString(XMLTools.COLLECTION)); for (int j = \
0; j < files.length; j++) { Resource res = col.getResource(files[j]);
Object content = res.getContent();
@@ -131,16 +125,16 @@
}
}
- list = col.listChildCollections();
+ String[] list = col.listChildCollections();
for (int i = 0; i < list.length; i++) {
File file = new File(directory, list[i]);
System.out.println("Creating directory " + file.getPath());
file.mkdirs();
- table.put(XMLTools.COLLECTION, (collection + "/" + file.getName()));
+ table.setString(XMLTools.COLLECTION, collection + "/" + \
file.getName());
- process(new File(directory + "//" + file.getName()), table, col);
+ process(new File(directory + "//" + file.getName()), table);
}
} finally {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/HelpCommand.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/HelpCommand.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/HelpCommand.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/HelpCommand.java Sun \
Sep 23 13:33:31 2007 @@ -18,14 +18,12 @@
*/
package org.apache.xindice.tools.command;
-import java.util.Hashtable;
-
import org.apache.xindice.server.Xindice;
import org.apache.xindice.util.StringUtilities;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
import org.apache.xindice.tools.XMLTools;
+import java.util.List;
+
/**
*
* @author <a href="mailto:byrne@apache.org">Todd Byrne</a>
@@ -33,8 +31,8 @@
*/
public class HelpCommand extends Command {
- public boolean execute(Hashtable table) throws Exception {
- NodeList list = (NodeList) table.get(XMLTools.COMMAND_LIST);
+ public boolean execute(XMLTools.Config table) throws Exception {
+ List list = table.getActions();
// This method relies on XML file Commands.xml attribute "helpclass" -
// used to order output
@@ -63,29 +61,25 @@
System.out.println("Actions:");
String helpClass; // Holds the helpclass for the current <command> node
- String desc; // Holds the description for the current <command> node
- String cmdswitch; // Holds the switch for the current <command> node
- // Show all elements with helpclass=document
+ // Show all elements with helpclass=document
// Loop over the commands, printing test from description attribute
- for (int i = 0; i < list.getLength(); i++) {
- helpClass = ((Element) list.item(i)).getAttribute("helpclass");
+ for (int i = 0; i < list.size(); i++) {
+ XMLTools.Action action = (XMLTools.Action) list.get(i);
+ helpClass = action.helpclass;
if (helpClass.equals("document")) {
- desc = ((Element) list.item(i)).getAttribute("description");
- cmdswitch = ((Element) list.item(i)).getAttribute("switch");
- System.out.println(" " + StringUtilities.leftJustify(cmdswitch, 13) + desc);
+ System.out.println(" " + StringUtilities.leftJustify(action.switchName, 13) + \
action.description); }
}
// Loop over the commands, printing text from description attribute
- for (int i = 0; i < list.getLength(); i++) {
- helpClass = ((Element) list.item(i)).getAttribute("helpclass");
+ for (int i = 0; i < list.size(); i++) {
+ XMLTools.Action action = (XMLTools.Action) list.get(i);
+ helpClass = action.helpclass;
if (helpClass.equals("security")) {
- desc = ((Element) list.item(i)).getAttribute("description");
- cmdswitch = ((Element) list.item(i)).getAttribute("switch");
- System.out.println(" " + StringUtilities.leftJustify(cmdswitch, 13) + desc);
+ System.out.println(" " + \
StringUtilities.leftJustify(action.switchName, 13) + action.description); }
}
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ImportTree.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ImportTree.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ImportTree.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ImportTree.java Sun \
Sep 23 13:33:31 2007 @@ -26,7 +26,6 @@
import java.io.File;
import java.io.FileFilter;
-import java.util.Hashtable;
/**
* ImportTree.java is designed to take a directory/file path and create a Collection
@@ -42,7 +41,18 @@
Command addDocument = null;
Command addCollection = null;
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
+
+ // Verify that the correct command line parameters were passed in
+ if (table.getString(XMLTools.FILE_PATH) == null) {
+ System.out.println("ERROR : Directory name and switch required");
+ return false;
+ }
+
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection name and switch required");
+ return false;
+ }
Collection col = null;
try {
@@ -54,29 +64,16 @@
addCollection =
(Command) \
Class.forName("org.apache.xindice.tools.command.AddCollection").newInstance();
- String startcollection = null;
-
- // Verify that the correct command line parameters were passed in
- if (table.get(XMLTools.FILE_PATH) == null) {
- System.out.println("ERROR : Directory name and switch required");
- return false;
- }
- if (table.get(XMLTools.COLLECTION) == null) {
- System.out.println("ERROR : Collection name and switch required");
- return false;
- }
-
- startcollection = (String) table.get(XMLTools.COLLECTION);
+ String startcollection = table.getString(XMLTools.COLLECTION);
// Make sure the root collection exists
- String colstring = normalizeCollectionURI(startcollection,
- (String) \
table.get(XMLTools.LOCAL)); + String colstring = \
normalizeCollectionURI(startcollection, \
table.getBoolean(XMLTools.LOCAL));
if ((col = DatabaseManager.getCollection(colstring)) == null) {
System.out.println("ERROR : Collection not found!");
return false;
}
- File startdir = new File((String) table.get(XMLTools.FILE_PATH));
+ File startdir = new File(table.getString(XMLTools.FILE_PATH));
// Make call to process, this is called recursively!
process(startdir, colstring, table);
@@ -92,10 +89,10 @@
}
// Recursive function to create collections/documents
- void process(File directory, String baseCollection, Hashtable table) {
+ void process(File directory, String baseCollection, XMLTools.Config table) {
try {
// The file extension to use for reading in files
- final String ext = (String) table.get(XMLTools.EXTENSION);
+ final String ext = table.getString(XMLTools.EXTENSION);
// Make sure we received a directory so we don't create a collection
// named after a file.
@@ -117,26 +114,24 @@
process(subdirs[i], baseCollection, table);
} else {
// Otherwise we have a file so import it.
- importFile(baseCollection, subdirs[i].getAbsolutePath(),
- subdirs[i].getName());
+ importFile(baseCollection, subdirs[i].getAbsolutePath(), \
subdirs[i].getName()); }
}
} catch (Exception e) {
System.out.println("ERROR : " + e.getMessage());
- if (table.get(XMLTools.VERBOSE).equals("true")) {
+ if (table.getBoolean(XMLTools.VERBOSE)) {
e.printStackTrace(System.err);
}
- return;
}
}
protected void importFile(String baseCollection, String path, String name)
throws Exception {
- Hashtable table = new Hashtable();
+ XMLTools.Config table = new XMLTools.Config();
// Use functionality from AddDocument to add this document
- table.put(XMLTools.COLLECTION, baseCollection);
- table.put(XMLTools.FILE_PATH, path);
- table.put(XMLTools.NAME_OF, name);
+ table.setString(XMLTools.COLLECTION, baseCollection);
+ table.setString(XMLTools.FILE_PATH, path);
+ table.setString(XMLTools.NAME_OF, name);
addDocument.execute(table);
}
@@ -144,9 +139,9 @@
protected String createCollection(String baseCollection, String newCollection)
throws Exception {
if (!newCollection.equals(".")) {
- Hashtable table = new Hashtable();
- table.put(XMLTools.COLLECTION, baseCollection);
- table.put(XMLTools.NAME_OF, newCollection);
+ XMLTools.Config table = new XMLTools.Config();
+ table.setString(XMLTools.COLLECTION, baseCollection);
+ table.setString(XMLTools.NAME_OF, newCollection);
addCollection.execute(table);
} else {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollectionDocuments.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollectionDocuments.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollectionDocuments.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollectionDocuments.java \
Sun Sep 23 13:33:31 2007 @@ -24,8 +24,6 @@
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
-import java.util.Hashtable;
-
/**
* ListCollectionDocumets.java is designed to let the user list all documents in a \
specific collection.
*
@@ -35,36 +33,33 @@
*/
public class ListCollectionDocuments extends Command {
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
+
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection and switch required");
+ return false;
+ }
Collection col = null;
- String colstring = null;
- String[] documentarray = null;
try {
+ // Create a collection instance
+ String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL)); +
+ col = DatabaseManager.getCollection(colstring);
+ if (col == null) {
+ System.out.println("ERROR : Collection not found!");
+ return false;
+ }
+
+ String[] documentarray = col.listResources();
+ System.out.println();
+
+ for (int i = 0; i < documentarray.length; i++) {
+ System.out.println("\t" + documentarray[i]);
+ }
- if (table.get(XMLTools.COLLECTION) != null) {
-
- // Create a collection instance
- colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL));
-
- col = DatabaseManager.getCollection(colstring);
- if (col == null) {
- System.out.println("ERROR : Collection not found!");
- return false;
- }
- documentarray = col.listResources();
-
- System.out.println();
-
- for (int i = 0; i < documentarray.length; i++) {
- System.out.println("\t" + documentarray[i]);
- }
-
- System.out.println("\nTotal documents: " + documentarray.length);
- } else
- System.out.println("ERROR : Collection and switch required");
-
+ System.out.println("\nTotal documents: " + documentarray.length);
} finally {
// Release the collection object
if (col != null) {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollections.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollections.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollections.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListCollections.java \
Sun Sep 23 13:33:31 2007 @@ -20,14 +20,10 @@
package org.apache.xindice.tools.command;
import org.apache.xindice.tools.XMLTools;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.logging.Log;
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
-import java.util.Hashtable;
-
/**
* ListCollections.java is designed to let the user list all Collections from
* a parent Collection or a nested Collection.
@@ -38,44 +34,34 @@
*/
public class ListCollections extends Command {
- private static final Log log = LogFactory.getLog(ListCollections.class);
+ public boolean execute(XMLTools.Config table) throws Exception {
- public boolean execute(Hashtable table) throws Exception {
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection context required");
+ return false;
+ }
- String[] colarray = null;
- String colstring = null;
Collection col = null;
try {
-
- if (table.get(XMLTools.COLLECTION) == null) {
- System.out.println("ERROR : Collection context required");
- return false;
- }
-
// list the COLLECTIONURI + The collection passed in
- colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) table.get(XMLTools.LOCAL));
-
-
+ String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL));
// Get a Collection reference
col = DatabaseManager.getCollection(colstring);
if (col == null) {
- // log a debug message
- log.debug("Error fetching collection '" + colstring + "'");
System.out.println("ERROR : Collection not found!");
return false;
- } else {
- colarray = col.listChildCollections();
-
- System.out.println();
+ }
- for (int i = 0; i < colarray.length; i++) {
- System.out.println("\t" + colarray[i]);
- }
+ String[] colarray = col.listChildCollections();
+ System.out.println();
- System.out.println("\nTotal collections: " + colarray.length);
+ for (int i = 0; i < colarray.length; i++) {
+ System.out.println("\t" + colarray[i]);
}
+
+ System.out.println("\nTotal collections: " + colarray.length);
} finally {
// Close collection objects and release
if (col != null) {
Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListIndexers.java
URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListIndexers.java?rev=578602&r1=578601&r2=578602&view=diff
==============================================================================
--- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListIndexers.java \
(original)
+++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/ListIndexers.java Sun \
Sep 23 13:33:31 2007 @@ -25,8 +25,6 @@
import org.xmldb.api.DatabaseManager;
import org.xmldb.api.base.Collection;
-import java.util.Hashtable;
-
/**
* ListIndexers.java is designed to let the user recall a list
* of Indexers from a specific Collection.
@@ -35,20 +33,19 @@
*/
public class ListIndexers extends Command {
- public boolean execute(Hashtable table) throws Exception {
+ public boolean execute(XMLTools.Config table) throws Exception {
+
+ if (table.getString(XMLTools.COLLECTION) == null) {
+ System.out.println("ERROR : Collection and switch required");
+ return false;
+ }
Collection col = null;
- String colstring = null;
try {
- // Check to see if a collection was passed in, if not set to root
- if (table.get(XMLTools.COLLECTION) == null) {
- colstring = normalizeCollectionURI("/", (String) \
table.get(XMLTools.LOCAL));
- } else {
- // Get a Collection reference to the collection
- colstring = normalizeCollectionURI((String) \
table.get(XMLTools.COLLECTION),
- (String) \
table.get(XMLTools.LOCAL));
- }
+ // Get a Collection reference to the collection
+ String colstring = \
normalizeCollectionURI(table.getString(XMLTools.COLLECTION), + \
table.getBoolean(XMLTools.LOCAL));
col = DatabaseManager.getCollection(colstring);
if (col == null) {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic