kstaken 2002/07/20 15:45:50
Modified: java/src/org/apache/xindice/tools XMLTools.java
java/src/org/apache/xindice/tools/command AddCollection.java
AddDocument.java AddIndexer.java
AddMultipleDocuments.java Command.java
DeleteCollection.java DeleteDocument.java
DeleteIndexer.java ExportTree.java ImportTree.java
ListCollectionDocuments.java ListCollections.java
ListIndexers.java RetrieveDocument.java
Shutdown.java XPathQuery.java
Log:
Adding local database support to the command line tools. The system can now be
run without any server process.
Revision Changes Path
1.7 +15 -20
xml-xindice/java/src/org/apache/xindice/tools/XMLTools.java
Index: XMLTools.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/XMLTools.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XMLTools.java 19 Jul 2002 03:24:27 -0000 1.6
+++ XMLTools.java 20 Jul 2002 22:45:49 -0000 1.7
@@ -94,14 +94,11 @@
public static final String EXTENSION = "extension";
public static final String FILE_PATH = "filePath";
public static final String ACTION = "action";
- public static final String IMPL_CLASS = "implClass";
public static final String NAME_OF = "nameOf";
- public static final String XML_OBJECT_URI = "xmlobjecturi";
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 FORCE = "force";
public static final String TYPE = "type";
public static final String PAGE_SIZE = "pagesize";
public static final String MAX_KEY_SIZE = "maxkeysize";
@@ -109,6 +106,8 @@
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";
@@ -121,7 +120,8 @@
public static void main(String[] args) {
try {
- new XMLTools().process(args);
+ new XMLTools().process(args);
+ System.exit(1);
}
catch (Exception e) {
System.out.println(e.getMessage());
@@ -140,7 +140,6 @@
table.put( EXTENSION, "" );
table.put( QUERY, "" );
table.put( AUTO_KEY, "" );
- table.put( FORCE, "" );
table.put( VERBOSE, "false" );
}
@@ -236,12 +235,8 @@
table.put( FILE_PATH, at.nextSwitchToken());
} else if ( token.equalsIgnoreCase("-h") ||
token.equalsIgnoreCase("--help") ) {
table.put( ACTION, "help");
- } else if ( token.equalsIgnoreCase("-i") ||
token.equalsIgnoreCase("--implementclass") ) {
- table.put( IMPL_CLASS, at.nextSwitchToken());
} else if ( token.equalsIgnoreCase("-n") ||
token.equalsIgnoreCase("--nameOf") ) {
table.put( NAME_OF, at.nextSwitchToken());
- } else if ( token.equalsIgnoreCase("-o") ||
token.equalsIgnoreCase("--xmlobjecturi") ) {
- table.put( XML_OBJECT_URI, at.nextSwitchToken());
} else if ( token.equalsIgnoreCase("-p") ||
token.equalsIgnoreCase("--pattern") ) {
table.put( PATTERN, at.nextSwitchToken());
} else if ( token.equalsIgnoreCase("-q") ||
token.equalsIgnoreCase("--query") ) {
@@ -250,6 +245,10 @@
table.put( URI, at.nextSwitchToken());
} else if ( token.equalsIgnoreCase("-v") ||
token.equalsIgnoreCase("--verbose") ) {
table.put( VERBOSE, "true");
+ } else if ( token.equalsIgnoreCase("-l") ||
token.equalsIgnoreCase("--localdb") ) {
+ table.put( LOCAL, "true");
+ } else if ( token.equalsIgnoreCase("-d") ||
token.equalsIgnoreCase("--dbconfig") ) {
+ table.put( DB_CONFIG, at.nextSwitchToken());
} else if ( token.equalsIgnoreCase("-s") ||
token.equalsIgnoreCase("--namespaces") ) {
table.put(NAMESPACES, at.nextSwitchToken());
// Index specific options
@@ -315,12 +314,6 @@
// register Xindice Database with xml:db
Database db = new DatabaseImpl();
- // If a naming service URI is specified setup the driver to use
- // it.
- if ( table.containsKey( URI ) ) {
- String dbURI = (String) table.get( URI );
- db.setProperty( "xindice.naming.ior", dbURI);
- }
DatabaseManager.registerDatabase( db );
// execute command class
@@ -629,13 +622,15 @@
System.out.println(" -c " + "Collection context (must
always be specified)");
System.out.println(" -e " + "File extension for multiple
documents");
System.out.println(" -f " + "File path for document
retrieval and storage");
- System.out.println(" -i " + "Implementing Class for
XMLObjects");
System.out.println(" -n " + "Name");
- System.out.println(" -o " + "URI String for invocation of
XMLObject");
System.out.println(" -p " + "Index pattern");
System.out.println(" -q " + "Query string");
- System.out.println(" -u " + "Database URI");
- System.out.println(" -s " + "Semi-colon delimited list of
namespaces for query in the form prefix=namespace-uri");
+ 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(" --pagesize " + "Page size for file pages
(default: 4096)");
System.out.println(" --maxkeysize " + "The maximum size for file
keys (default: 0=none)");
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/AddCollection.java
Index: AddCollection.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddCollection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AddCollection.java 19 Jul 2002 03:24:27 -0000 1.2
+++ AddCollection.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -96,7 +96,8 @@
if (table.get("collection") != null && table.get("nameOf") != null)
{
// Get a Collection reference to pass on to individual commands
- String colstring = normalizeCollectionURI((String)
table.get("collection"));
+ String colstring = normalizeCollectionURI((String)
table.get("collection"),
+ (String)
table.get("local"));
col = DatabaseManager.getCollection(colstring);
1.5 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/AddDocument.java
Index: AddDocument.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddDocument.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- AddDocument.java 19 Jul 2002 03:24:27 -0000 1.4
+++ AddDocument.java 20 Jul 2002 22:45:49 -0000 1.5
@@ -109,7 +109,8 @@
try {
// Create a collection instance
- String colstring = normalizeCollectionURI((String)
table.get("collection"));
+ String colstring = normalizeCollectionURI((String)
table.get("collection"),
+ (String)
table.get("local"));
col = DatabaseManager.getCollection(colstring);
if (col == null) {
System.out.println("ERROR : Collection not found!");
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/AddIndexer.java
Index: AddIndexer.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddIndexer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AddIndexer.java 19 Jul 2002 03:24:27 -0000 1.2
+++ AddIndexer.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -89,7 +89,8 @@
if (table.get("collection") != null) {
// Get a Collection reference to the collection
- String colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ String colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
col = DatabaseManager.getCollection( colstring );
if ( col == null ) {
System.out.println("ERROR : Collection not found!");
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java
Index: AddMultipleDocuments.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/AddMultipleDocuments.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- AddMultipleDocuments.java 19 Jul 2002 03:24:27 -0000 1.2
+++ AddMultipleDocuments.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -96,7 +96,8 @@
}
// Get a Collection reference to the collection
- String colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ String colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
col = DatabaseManager.getCollection( colstring );
if ( col == null ) {
System.out.println("ERROR : Collection not found!");
1.2 +13 -22
xml-xindice/java/src/org/apache/xindice/tools/command/Command.java
Index: Command.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/Command.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Command.java 6 Dec 2001 19:33:57 -0000 1.1
+++ Command.java 20 Jul 2002 22:45:49 -0000 1.2
@@ -71,7 +71,8 @@
// Collection manager path to instantiate
public static final String XINDICEURI="xindice://";
- public static final String COLLECTIONURI="xmldb:" + XINDICEURI;
+ public static final String XINDICELOCALURI="xindice-embed://";
+ public static final String XMLDBURI="xmldb:";
// Version of the XML:DB API that we are using
public static final String XMLDBAPIVERSION="1.0";
@@ -84,34 +85,24 @@
public abstract boolean execute(Hashtable table) throws Exception;
// public class to return normalized CollectionURI for creation of a
Collection object
- public String normalizeCollectionURI(String uri) {
+ public String normalizeCollectionURI(String uri, String local) {
// Check to see if this uri starts with "xmldb:" , if so treat as
absolute
if ( uri.startsWith("xmldb:") ) {
// URI is absolute, leave alone
return uri;
}
- else if ( uri.startsWith("xindice:") ) {
- return ( "xmldb:" + uri );
+ else if ( uri.startsWith("xindice:") ||
uri.startsWith("xindice-embed:") ) {
+ return ( XMLDBURI + uri );
}
else {
- // URI passed in is not absoulte, prepend COLLECTIONURI to it
- return ( COLLECTIONURI + uri );
+ if ( ( local != null ) && local.equals("true") ) {
+ return ( XMLDBURI + XINDICELOCALURI + uri );
+ }
+ else {
+ // URI passed in is not absoulte, build the full URI
+ return ( XMLDBURI + XINDICEURI + uri );
+ }
}
}
-
- // public class to return normalized CollectionURI for creation of a
Collection object
- public String normalizeXindiceURI(String uri) throws XindiceException {
-
- // Check to see if this uri starts with "xmldb:" , if so treat as
absolute
- if ( uri.startsWith("xindice:") ) {
- // URI is absolute, leave alone
- return uri;
- }
- else {
- return ( XINDICEURI + uri.substring(1) );
- }
- }
-
-
} //interface Command
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/DeleteCollection.java
Index: DeleteCollection.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/DeleteCollection.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DeleteCollection.java 19 Jul 2002 03:24:27 -0000 1.2
+++ DeleteCollection.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -88,7 +88,8 @@
if (table.get("collection") != null && table.get("nameOf") !=
null ) {
// Get a Collection reference to the collection to be deleted
- String colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ String colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
col = DatabaseManager.getCollection( colstring );
if ( col == null ) {
System.out.println("ERROR : Collection not found!");
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/DeleteDocument.java
Index: DeleteDocument.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/DeleteDocument.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DeleteDocument.java 19 Jul 2002 03:24:27 -0000 1.2
+++ DeleteDocument.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -84,7 +84,8 @@
try {
if (table.get("collection") != null) {
// Get a Collection reference to the collection to be deleted
- String colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ String colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
col = DatabaseManager.getCollection( colstring );
if ( col == null ) {
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/DeleteIndexer.java
Index: DeleteIndexer.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/DeleteIndexer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DeleteIndexer.java 19 Jul 2002 03:24:27 -0000 1.2
+++ DeleteIndexer.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -83,7 +83,8 @@
try {
if (table.get("collection") != null) {
// Get a Collection reference to the collection
- String colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ String colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
col = DatabaseManager.getCollection( colstring );
if ( col == null ) {
System.out.println("ERROR : Collection not found!");
1.4 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/ExportTree.java
Index: ExportTree.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/ExportTree.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ExportTree.java 19 Jul 2002 03:24:27 -0000 1.3
+++ ExportTree.java 20 Jul 2002 22:45:49 -0000 1.4
@@ -148,7 +148,8 @@
String collection = (String) table.get("collection");
// Get a Collection reference to the collection
- String colstring = normalizeCollectionURI((String)
table.get("collection"));
+ String colstring = normalizeCollectionURI((String)
table.get("collection"),
+ (String)
table.get("local"));
col = DatabaseManager.getCollection(colstring);
if (col == null) {
System.out.println("ERROR : Collection not found!");
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/ImportTree.java
Index: ImportTree.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/ImportTree.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ImportTree.java 19 Jul 2002 03:24:27 -0000 1.2
+++ ImportTree.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -106,7 +106,8 @@
startcollection = (String) table.get("collection");
// Make sure the root collection exists
- String colstring = normalizeCollectionURI(startcollection);
+ String colstring = normalizeCollectionURI(startcollection,
+ (String)
table.get("local"));
if ((col = DatabaseManager.getCollection(colstring)) == null) {
System.out.println("ERROR : Collection not found!");
return false;
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/ListCollectionDocuments.java
Index: ListCollectionDocuments.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/ListCollectionDocuments.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ListCollectionDocuments.java 19 Jul 2002 03:24:27 -0000 1.2
+++ ListCollectionDocuments.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -83,7 +83,8 @@
if (table.get("collection") != null) {
// Create a collection instance
- colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
col = DatabaseManager.getCollection( colstring );
if ( col == null ) {
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/ListCollections.java
Index: ListCollections.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/ListCollections.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ListCollections.java 19 Jul 2002 03:24:27 -0000 1.2
+++ ListCollections.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -85,7 +85,8 @@
}
// list the COLLECTIONURI + The collection passed in
- colstring = normalizeCollectionURI( (String)table.get("collection")
);
+ colstring = normalizeCollectionURI( (String)table.get("collection"),
+ (String) table.get("local") );
// Get a Collection reference
1.3 +4 -3
xml-xindice/java/src/org/apache/xindice/tools/command/ListIndexers.java
Index: ListIndexers.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/ListIndexers.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ListIndexers.java 19 Jul 2002 03:24:27 -0000 1.2
+++ ListIndexers.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -83,11 +83,12 @@
// Check to see if a collection was passed in, if not set to root
if ( table.get("collection") == null ) {
- colstring = normalizeCollectionURI( "/" );
+ colstring = normalizeCollectionURI( "/", (String)
table.get("local") );
}
else {
// Get a Collection reference to the collection
- colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String) table.get("local")
);
}
col = DatabaseManager.getCollection( colstring );
1.4 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/RetrieveDocument.java
Index: RetrieveDocument.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/RetrieveDocument.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- RetrieveDocument.java 19 Jul 2002 03:24:27 -0000 1.3
+++ RetrieveDocument.java 20 Jul 2002 22:45:49 -0000 1.4
@@ -84,7 +84,8 @@
if (table.get("collection") != null) {
// Create a collection instance
- String colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ String colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
String docname = (String)table.get("nameOf");
col = DatabaseManager.getCollection( colstring );
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/Shutdown.java
Index: Shutdown.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/Shutdown.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Shutdown.java 19 Jul 2002 03:24:27 -0000 1.2
+++ Shutdown.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -91,7 +91,8 @@
try {
// Get a Collection reference to pass on to individual commands
- String colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ String colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
col = DatabaseManager.getCollection( colstring );
DatabaseInstanceManager man =
(DatabaseInstanceManager)col.getService("DatabaseInstanceManager",XMLDBAPIVERSION);
1.3 +3 -2
xml-xindice/java/src/org/apache/xindice/tools/command/XPathQuery.java
Index: XPathQuery.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/src/org/apache/xindice/tools/command/XPathQuery.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XPathQuery.java 2 Jul 2002 08:03:07 -0000 1.2
+++ XPathQuery.java 20 Jul 2002 22:45:49 -0000 1.3
@@ -95,7 +95,8 @@
}
- String colstring = normalizeCollectionURI(
(String)table.get("collection") );
+ String colstring = normalizeCollectionURI(
(String)table.get("collection"),
+ (String)
table.get("local") );
String querystring = (String)table.get("query");
XPathQueryService service = null;
ResourceIterator results = null;