Author: natalia Date: Thu Aug 30 18:57:36 2007 New Revision: 571355 URL: http://svn.apache.org/viewvc?rev=571355&view=rev Log: Add detailed help screen to commands. AddCollection can create new collections from configuration file
Modified: xml/xindice/trunk/config/commands.xml 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/config/commands.xml URL: http://svn.apache.org/viewvc/xml/xindice/trunk/config/commands.xml?rev=571355&r1=571354&r2=571355&view=diff ============================================================================== --- xml/xindice/trunk/config/commands.xml (original) +++ xml/xindice/trunk/config/commands.xml Thu Aug 30 18:57:36 2007 @@ -34,14 +34,14 @@ <commands> <user> <command switch="--help" - name="help screen" + name="help" class="org.apache.xindice.tools.command.HelpCommand" - helpclass="" + helpclass="hidden" description="Prints the help screen." /> <command switch="-h" - name="help screen" + name="help" class="org.apache.xindice.tools.command.HelpCommand" - helpclass="" + helpclass="hidden" description="Prints the help screen." /> <command switch="ac" name="add_collection" @@ -58,16 +58,16 @@ class="org.apache.xindice.tools.command.ImportTree" helpclass="document" description="Creates a collection/document from a directory tree" /> - <command switch="di" - name="delete_indexer" - class="org.apache.xindice.tools.command.DeleteIndexer" - helpclass="hidden" - description="" /> <command switch="ai" name="add_indexer" class="org.apache.xindice.tools.command.AddIndexer" - helpclass="hidden" - description="" /> + helpclass="document" + description="Creates a collection indexer" /> + <command switch="di" + name="delete_indexer" + class="org.apache.xindice.tools.command.DeleteIndexer" + helpclass="document" + description="Deletes a collection indexer" /> <command switch="li" name="list_indexers" class="org.apache.xindice.tools.command.ListIndexers" 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -55,6 +55,7 @@ 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"; @@ -68,7 +69,7 @@ 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 COMMAND_LIST = "__command_list__"; public static final String PAGE_COUNT = "pagecount"; private Hashtable table; @@ -194,7 +195,9 @@ while (at.hasMoreTokens()) { String token = at.nextToken(); - if (token.equalsIgnoreCase("-c") || token.equalsIgnoreCase("--collection")) { + if (token.equalsIgnoreCase("-h") || token.equalsIgnoreCase("--help")) { + table.put(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 '/'"); @@ -247,7 +250,7 @@ } } } - + /** * This method is to carry out execution, after instance variables being setup by process( args ) */ @@ -275,13 +278,18 @@ Command command; try { - // Register Xindice Database with XML:DB - DatabaseImpl db = new DatabaseImpl(); - DatabaseManager.registerDatabase(db); - - // Execute command class command = (Command) Class.forName(commandClass).newInstance(); - command.execute(table); + if ("true".equals(table.get(HELP))) { + // show command help + command.usage(); + } else { + // Register Xindice Database with XML:DB + DatabaseImpl db = new DatabaseImpl(); + DatabaseManager.registerDatabase(db); + + // Execute command class + command.execute(table); + } return true; } catch (XMLDBException e) { @@ -304,7 +312,7 @@ } } } - + public boolean handleOption(String option, ArgTokenizer at) { return false; } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -22,13 +22,20 @@ import org.apache.xindice.client.xmldb.services.CollectionManager; import org.apache.xindice.tools.XMLTools; import org.apache.xindice.xml.dom.DocumentImpl; +import org.apache.xindice.xml.dom.DOMParser; +import org.apache.xindice.xml.TextWriter; +import org.apache.xindice.util.XindiceException; import org.w3c.dom.Document; import org.w3c.dom.Element; +import org.w3c.dom.Attr; 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; /** * AddCollection.java is designed to let the user create @@ -43,84 +50,52 @@ */ public boolean execute(Hashtable table) throws Exception { - Collection col = null; - Collection tempcol = null; - try { + if (table.get(XMLTools.COLLECTION) == null) { + System.out.println("ERROR : Collection and switch required"); + return false; + } - // Verify that that collection passed in is not null - if (table.get(XMLTools.COLLECTION) != null && table.get(XMLTools.NAME_OF) != null) { + if ("".equals(table.get(XMLTools.FILE_PATH)) && table.get(XMLTools.NAME_OF) == null) { + System.out.println("ERROR : New Collection name required or File path required"); + return false; + } - // Get a Collection reference to pass on to individual commands - 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 an instance of the collection manager and create the collection - CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION); - - String colPath = (String) table.get(XMLTools.NAME_OF); - String colName = ""; - - int idx = colPath.lastIndexOf("/"); - if (idx != -1) { - colName = colPath.substring(idx + 1); - } else if (idx == -1) { - colName = colPath; - } - - if (colName.equals("")) { - System.out.println("Cannot create a NULL collection"); - return false; - } - - Document doc = new DocumentImpl(); - - Element colEle = doc.createElement("collection"); - colEle.setAttribute("name", colName); - // FIXME Make this configurable - colEle.setAttribute("compressed", "true"); - colEle.setAttribute("inline-metadata", "true"); - - doc.appendChild(colEle); - - 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 ("HashFiler".equals(filer)) { - filerClass = "org.apache.xindice.core.filer.HashFiler"; - } else if (!"BTreeFiler".equals(filer)) { - System.out.println("Unknown filer: " + filer); - return false; - } - } - - filEle.setAttribute("class", filerClass); - if (table.containsKey(XMLTools.PAGE_SIZE)) { - filEle.setAttribute(XMLTools.PAGE_SIZE, (String) table.get(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.containsKey(XMLTools.PAGE_COUNT)) { - filEle.setAttribute(XMLTools.PAGE_COUNT, (String) table.get(XMLTools.PAGE_COUNT)); - } + Document config; + if (!"".equals(table.get(XMLTools.FILE_PATH))) { + // configuration was passed in a file + config = readConfig(table); + } else { + // build configuration from parameters + config = buildConfig(table); + } - colEle.appendChild(filEle); - tempcol = colman.createCollection(colPath, doc); + Collection col = null; + 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)); + + col = DatabaseManager.getCollection(colstring); + if (col == null) { + System.out.println("ERROR : Collection not found!"); + return false; + } - System.out.println("Created : " + table.get(XMLTools.COLLECTION) + "/" + colPath); + // Create an instance of the collection manager and create the collection + CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION); + + String colPath; + if (!"".equals(table.get(XMLTools.FILE_PATH))) { + colPath = config.getDocumentElement().getAttributeNode("name").getNodeValue(); } else { - System.out.println("ERROR : Collection Context and New Collection name required"); + colPath = (String) table.get(XMLTools.NAME_OF); } + tempcol = colman.createCollection(colPath, config); + + System.out.println("Created : " + table.get(XMLTools.COLLECTION) + "/" + colPath); } finally { // Release the collection objects if (col != null) { @@ -132,5 +107,113 @@ } return true; + } + + private Document readConfig(Hashtable table) throws Exception { + InputStream fis = null; + try { + File file = new File((String) table.get(XMLTools.FILE_PATH)); + fis = new FileInputStream(file); + + // check if top element has necessary attribute 'name' + Document doc = DOMParser.toDocument(fis); + Attr attr = doc.getDocumentElement().getAttributeNode("name"); + if (attr == null || "".equals(attr.getNodeValue())) { + throw new Exception("Collection configuration top element must have attribute \"name\""); + } + + return doc; + } catch (XindiceException e) { + throw new Exception("Indexer configuration could not be parsed", e); + } finally { + if (fis != null) { + fis.close(); + } + } + } + + private Document buildConfig(Hashtable table) throws Exception { + String colPath = (String) table.get(XMLTools.NAME_OF); + + String colName; + // get the part after last /, any collection before / must already exist + int idx = colPath.lastIndexOf("/"); + if (idx != -1) { + colName = colPath.substring(idx + 1); + } else { + colName = colPath; + } + + if (colName.equals("")) { + throw new Exception("Cannot create a NULL collection"); + } + + Document doc = new DocumentImpl(); + + Element colEle = doc.createElement("collection"); + colEle.setAttribute("name", colName); + // FIXME Make this configurable + colEle.setAttribute("compressed", "true"); + colEle.setAttribute("inline-metadata", "true"); + + doc.appendChild(colEle); + + 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 ("HashFiler".equals(filer)) { + filerClass = "org.apache.xindice.core.filer.HashFiler"; + } else if (!"BTreeFiler".equals(filer)) { + throw new Exception("Unknown filer: " + filer); + } + } + + filEle.setAttribute("class", filerClass); + if (table.containsKey(XMLTools.PAGE_SIZE)) { + filEle.setAttribute(XMLTools.PAGE_SIZE, (String) table.get(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.containsKey(XMLTools.PAGE_COUNT)) { + filEle.setAttribute(XMLTools.PAGE_COUNT, (String) table.get(XMLTools.PAGE_COUNT)); + } + + colEle.appendChild(filEle); + + // If in verbose mode, show.... + if ("true".equals(table.get(XMLTools.VERBOSE))) { + String colstr = TextWriter.toString(doc); + System.out.println("Collection node element = "); + System.out.println("\t" + colstr + "\n"); + } + + return doc; + } + public void usage() { + System.out.println("Format: xindice ac -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Creates new collections and nested collections"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Name for the collection to be created, must be present"); + System.out.println(" unless collection configuration is specified"); + System.out.println(" -f|--filepath <file>"); + System.out.println(" Name of the file that holds collection configuration. If"); + System.out.println(" specified, the rest of command-specific parameters is"); + System.out.println(" ignored"); + System.out.println(" --pagesize <number>"); + System.out.println(" Page size for file pages (default: 4096)"); + System.out.println(" --maxkeysize <number>"); + System.out.println(" The maximum size for file keys (default: 0=none)"); + System.out.println(" --pagecount <nuymber>"); + System.out.println(" Number of pages in the primary storage (default: 1024)"); + System.out.println(" --filer <name>"); + System.out.println(" Collection filer, can be HashFiler or BTreeFiler (default:"); + System.out.println(" BTreeFiler)"); + System.out.println(); } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -100,4 +100,22 @@ return true; } + + public void usage() { + System.out.println("Format: xindice ad -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Adds a single document to an existing collection"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -f|--filepath <file>"); + System.out.println(" File path for the document being added to the collection"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Document key. If this parameter is omitted, database will"); + System.out.println(" generate an unique key"); + System.out.println(); + System.out.println("Examples:"); + System.out.println(" xindice ad -c /db/test -f /tmp/xmldocument -n myxmldocument"); + System.out.println(" xindice ad -c /db/test/nested -f /tmp/data.xml"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -176,4 +176,48 @@ idxEle.appendChild(pattern); } } + + public void usage() { + System.out.println("Format: xindice ai -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Creates an index for a collection based on given pattern"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Name for the indexer to be created, must be present"); + System.out.println(" unless indexer configuration is specified"); + System.out.println(" -p|--pattern <pattern>"); + System.out.println(" Index pattern, must be present unless indexer configuration"); + System.out.println(" is specified"); + System.out.println(" -f|--filepath <file>"); + System.out.println(" Name of the file that holds indexer configuration. If"); + System.out.println(" specified, the rest of command-specific parameters is"); + System.out.println(" ignored"); + System.out.println(" -t|--type <type>"); + System.out.println(" Specify the data type in collection index. Type can be"); + System.out.println(" one of the following:"); + System.out.println(" string (ValueIndexer)"); + System.out.println(" trimmed (ValueIndexer)"); + System.out.println(" short (ValueIndexer)"); + System.out.println(" int (ValueIndexer)"); + System.out.println(" long (ValueIndexer)"); + System.out.println(" float (ValueIndexer)"); + System.out.println(" double (ValueIndexer)"); + System.out.println(" byte (ValueIndexer)"); + System.out.println(" char (ValueIndexer)"); + System.out.println(" boolean (ValueIndexer)"); + System.out.println(" name (NameIndexer)"); + System.out.println(" text (LuceneIndexer)"); + System.out.println(" (default: string/trimmed)"); + System.out.println(" --pagesize <number>"); + System.out.println(" Page size for file pages (default: 4096). Does not apply to"); + System.out.println(" LuceneIndexer"); + System.out.println(" --maxkeysize <number>"); + System.out.println(" The maximum size for file keys (default: 0=none). Does not"); + System.out.println(" apply to LuceneIndexer"); + System.out.println(" --pagecount <nuymber>"); + System.out.println(" Number of pages in the primary storage (default: 1024). Does"); + System.out.println(" not apply to LuceneIndexer"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -25,7 +25,6 @@ import org.xmldb.api.base.Collection; import java.io.File; -import java.io.FileInputStream; import java.io.FilenameFilter; import java.util.Hashtable; @@ -130,5 +129,19 @@ } return true; + } + + public void usage() { + System.out.println("Format: xindice addmultiple -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Add several documents to an existing collection at one time. Documents are"); + System.out.println("added with an ID the same as the file name"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -f|--filepath <path>"); + System.out.println(" Directory name for the files being added to a collection"); + System.out.println(" -e|--extension <extention>"); + System.out.println(" File extension for documents to use in the filter"); + System.out.println(); } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -90,4 +90,18 @@ return true; } + + public void usage() { + System.out.println("Format: xindice ar -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Adds a single binary resourcet to an existing collection"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -f|--filepath <file>"); + System.out.println(" File path for the resource being added to the collection"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Resource key. If this parameter is omitted, database will"); + System.out.println(" generate an unique key"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -41,8 +41,9 @@ 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 boolean execute(Hashtable table, Database db) public abstract boolean execute(Hashtable 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) { 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -70,9 +70,15 @@ return true; } -} - - - - + public void usage() { + System.out.println("Format: xindice dc -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Drops a collection from the database or parent collection"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Name of the collection to be deleted"); + System.out.println(); + } +} 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -73,4 +73,19 @@ return true; } + + public void usage() { + System.out.println("Format: xindice dd -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Deletes a document/binary resource, referred by the key, from a specific"); + System.out.println("collection"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Key of the resource to be deleted"); + System.out.println(); + System.out.println("Examples:"); + System.out.println(" xindice dd -c /db/test -n myxmldocument"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -71,5 +71,15 @@ return true; } + public void usage() { + System.out.println("Format: xindice di -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Drops an index from a collection"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Name for the indexer to be dropped"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -150,5 +150,16 @@ } return true; } + + public void usage() { + System.out.println("Format: xindice export -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Takes a collection tree and creates a directory tree from it"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -f|--filepath <path>"); + System.out.println(" Directory name where tree will be created"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -34,48 +34,38 @@ public class HelpCommand extends Command { public boolean execute(Hashtable table) throws Exception { - NodeList list = (NodeList)table.get(XMLTools.COMMAND_LIST); + NodeList list = (NodeList) table.get(XMLTools.COMMAND_LIST); - // This method relies on two things to format the output for help - // Method isAdmin() - Tells us if this is an admin instance, used to hide certain output - // XML file Commands.xml attribute "helpclass" - used to order output - - 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 the header and switch commands - System.out.println(); - System.out.println("Xindice Command Tools v" + Xindice.Version); - System.out.println(); - System.out.println("Format: xindice action [switch] [parameter]"); - System.out.println(); - System.out.println("Switches:"); - System.out.println(" -c Collection context (must always be specified),"); - System.out.println(" can be either canonical name of the collection"); - System.out.println(" or complete xmldb URL"); - System.out.println(" -e File extension for multiple documents"); - System.out.println(" -f File path for document retrieval and storage"); - System.out.println(" -n Name"); - System.out.println(" -p Index pattern"); - System.out.println(" -q Query string"); - System.out.println(" -s Semi-colon delimited list of namespaces for query in "); - System.out.println(" the form prefix=namespace-uri"); - System.out.println(" -l Use a local database rather then going over the network."); - System.out.println(" Should be combined with -d to specify the configuration to use."); - System.out.println(" -d Path to the database configuration to use for the local "); - System.out.println(" database. Only applies if -l is specified."); - System.out.println(" -t Specify the data type in collection index"); - System.out.println(" -v Verbose"); - System.out.println(" --pagesize Page size for file pages (default: 4096)"); - System.out.println(" --maxkeysize The maximum size for file keys (default: 0=none)"); - System.out.println(" --pagecount Number of pages in the primary storage (default: 1024)"); - System.out.println(" --filer Collection filer, can be HashFiler or BTreeFiler (default: BTreeFiler)"); - System.out.println(); + // This method relies on XML file Commands.xml attribute "helpclass" - + // used to order output + // Show the header and general switches + System.out.println(); + System.out.println("Xindice Command Tools v" + Xindice.Version); + System.out.println(); + System.out.println("Format: xindice <action> [parameters]"); + System.out.println(); + System.out.println("General purpose switches:"); + System.out.println(" -c|--collection <context>"); + System.out.println(" Collection context (must always be specified), can be either"); + System.out.println(" canonical name of the collection or complete xmldb URL"); + System.out.println(" -l|--localdb"); + System.out.println(" Use a local database rather then going over the network."); + System.out.println(" Should be combined with -d to specify the configuration to use"); + System.out.println(" -d|--dbconfig <path>"); + System.out.println(" Path to the database configuration to use for the local "); + System.out.println(" database. Only applies if -l is specified."); + System.out.println(" -v|--verbose"); + System.out.println(" Verbose. Outputs additional information and exceptions"); + System.out.println(" -h|--help"); + System.out.println(" Print help screen for an action"); + System.out.println(); 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 // Loop over the commands, printing test from description attribute for (int i = 0; i < list.getLength(); i++) { @@ -99,18 +89,16 @@ } } - System.out.println(); - System.out.println("Examples:"); - System.out.println(" xindice ad -c /db/test -f /tmp/xmldocument -n myxmldocument"); - System.out.println(" xindice dd -c /db/test -n myxmldocument"); - System.out.println(" xindice rd -c /db/test/ocs -f a:\\file.xml -n file.xml"); - System.out.println(" xindice xpath -c /db/test/ocs -q test"); - System.out.println(" xindice xpath -c /db/test -s a=http://somedomain.com/schema.xsd -q /a:foo"); - System.out.println(" xindice xupdate -c /db/test -f /path/to/xupdate.xml"); - System.out.println(" xindice xupdate -c /db/test -n document-to-update.xml -f /path/to/xupdate.xml"); - System.out.println(); + System.out.println(); System.out.println("For more information, please read the Xindice - Tools Reference Guide"); System.out.println(); return true; } + + public void usage() { + System.out.println("Format: xindice help"); + System.out.println(); + System.out.println("Describes usage of Xindice Command Tools"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -190,4 +190,18 @@ } } + public void usage() { + System.out.println("Format: xindice import -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Takes a directory path and creates a collection from it's name. The files"); + System.out.println("within the directory are converted into documents and then stored into the"); + System.out.println("newly created collection with their filename as a document key."); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -f|--filepath <file>"); + System.out.println(" Directory tree"); + System.out.println(" -e|--extension <extention>"); + System.out.println(" File extension for documents to use in the filter"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -74,4 +74,12 @@ return true; } + + public void usage() { + System.out.println("Format: xindice ld -c <context> [-l [-d <path>]] [-v]"); + System.out.println(); + System.out.println("List all documents in a specific collection. Document names are"); + System.out.println("returned in no specific order"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -84,6 +84,13 @@ } return true; } + + public void usage() { + System.out.println("Format: xindice lc -c <context> [-l [-d <path>]] [-v]"); + System.out.println(); + System.out.println("Lists child collections in a specific collection"); + System.out.println(); + } } 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=571355&r1=571354&r2=571355&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 Thu Aug 30 18:57:36 2007 @@ -77,4 +77,11 @@ return true; } + + public void usage() { + System.out.println("Format: xindice li -c <context> [-l [-d <path>]] [-v]"); + System.out.println(); + System.out.println("Recalls a list of indexers from a specific collection"); + System.out.println(); + } } Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/RetrieveDocument.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/RetrieveDocument.java?rev=571355&r1=571354&r2=571355&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/RetrieveDocument.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/RetrieveDocument.java Thu Aug 30 18:57:36 2007 @@ -114,5 +114,21 @@ return true; } + public void usage() { + System.out.println("Format: xindice rd -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Retrieves a document from a specific collection"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -f|--filepath <file>"); + System.out.println(" File path where document will be stored, if omitted"); + System.out.println(" document will printed to standard output"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Document key"); + System.out.println(); + System.out.println("Examples:"); + System.out.println(" xindice rd -c /db/test/ocs -f a:\\file.xml -n file.xml"); + System.out.println(); + } } Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java?rev=571355&r1=571354&r2=571355&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/Shutdown.java Thu Aug 30 18:57:36 2007 @@ -73,4 +73,11 @@ return true; } + + public void usage() { + System.out.println("Format: xindice shutdown -c <context> [-l [-d <path>]] [-v]"); + System.out.println(); + System.out.println("Shuts down the database. Shutdown command only works with embedded driver"); + System.out.println(); + } } Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/TextQuery.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/TextQuery.java?rev=571355&r1=571354&r2=571355&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/TextQuery.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/TextQuery.java Thu Aug 30 18:57:36 2007 @@ -1,22 +1,3 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * $Id$ - */ - package org.apache.xindice.tools.command; import org.apache.xindice.tools.XMLTools; @@ -79,5 +60,16 @@ } return true; + } + + public void usage() { + System.out.println("Format: xindice text -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Searches collection for documents matching given text query"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -q|--query <query>"); + System.out.println(" Lucene text query"); + System.out.println(); } } Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XPathQuery.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XPathQuery.java?rev=571355&r1=571354&r2=571355&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XPathQuery.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XPathQuery.java Thu Aug 30 18:57:36 2007 @@ -111,4 +111,19 @@ } } } + + public void usage() { + System.out.println("Format: xindice xpath -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Searches collection for documents matching given XPath query"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -q|--query <query>"); + System.out.println(" XPath query"); + System.out.println(); + System.out.println("Examples:"); + System.out.println(" xindice xpath -c /db/test/ocs -q test"); + System.out.println(" xindice xpath -c /db/test -s a=http://somedomain.com/schema.xsd -q /a:foo"); + System.out.println(); + } } Modified: xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XUpdate.java URL: http://svn.apache.org/viewvc/xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XUpdate.java?rev=571355&r1=571354&r2=571355&view=diff ============================================================================== --- xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XUpdate.java (original) +++ xml/xindice/trunk/java/src/org/apache/xindice/tools/command/XUpdate.java Thu Aug 30 18:57:36 2007 @@ -119,4 +119,22 @@ return true; } + + public void usage() { + System.out.println("Format: xindice xupdate -c <context> [-l [-d <path>]] [-v] [parameters...]"); + System.out.println(); + System.out.println("Runs XUpdate query stored in a file against a specified collection or"); + System.out.println("document"); + System.out.println(); + System.out.println("Command-specific switches:"); + System.out.println(" -f|--filepath <file>"); + System.out.println(" Name of the file with that holds XUpdate query"); + System.out.println(" -n|--nameOf <name>"); + System.out.println(" Document name, if query to be run against single document"); + System.out.println(); + System.out.println("Examples:"); + System.out.println(" xindice xupdate -c /db/test -f /path/to/xupdate.xml"); + System.out.println(" xindice xupdate -c /db/test -n document-to-update.xml -f /path/to/xupdate.xml"); + System.out.println(); + } }