You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by ks...@apache.org on 2002/07/19 05:24:28 UTC
cvs commit: xml-xindice/java/src/org/apache/xindice/tools/command AddCollection.java AddDocument.java AddIndexer.java AddMultipleDocuments.java DeleteCollection.java DeleteDocument.java DeleteIndexer.java ExportTree.java ImportTree.java ListCollectionDocuments.java ListCollections.java ListIndexers.java RetrieveDocument.java Shutdown.java AddCollectionXMLObject.java DeleteCollectionXMLObject.java InvokeXmlObject.java ListCollectionXMLObjects.java
kstaken 2002/07/18 20:24:27
Modified: java/src/org/apache/xindice/tools XMLTools.java
java/src/org/apache/xindice/tools/command AddCollection.java
AddDocument.java AddIndexer.java
AddMultipleDocuments.java DeleteCollection.java
DeleteDocument.java DeleteIndexer.java
ExportTree.java ImportTree.java
ListCollectionDocuments.java ListCollections.java
ListIndexers.java RetrieveDocument.java
Shutdown.java
Removed: java/src/org/apache/xindice/tools/command
AddCollectionXMLObject.java
DeleteCollectionXMLObject.java InvokeXmlObject.java
ListCollectionXMLObjects.java
Log:
Code cleanups and removing XMLObject commands.
Revision Changes Path
1.6 +27 -42 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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- XMLTools.java 11 Jul 2002 04:37:03 -0000 1.5
+++ XMLTools.java 19 Jul 2002 03:24:27 -0000 1.6
@@ -250,8 +250,6 @@
table.put( URI, at.nextSwitchToken());
} else if ( token.equalsIgnoreCase("-v") || token.equalsIgnoreCase("--verbose") ) {
table.put( VERBOSE, "true");
- } else if ( token.equalsIgnoreCase("-y") || token.equalsIgnoreCase("--yes_force") ) {
- table.put( FORCE, "yes");
} else if ( token.equalsIgnoreCase("-s") || token.equalsIgnoreCase("--namespaces") ) {
table.put(NAMESPACES, at.nextSwitchToken());
// Index specific options
@@ -275,24 +273,7 @@
if ( !execute() ) {
printHelp();
return;
- }
-
- } catch (org.omg.CORBA.BAD_PARAM bp) {
- throw new org.omg.CORBA.BAD_PARAM(
- "ERROR : "+bp+" One or more parameters not found");
-
- } catch (org.omg.CORBA.COMM_FAILURE cf) {
- throw new org.omg.CORBA.COMM_FAILURE(
- "ERROR : "+cf+" Verify the Xindice server is running");
-
- } catch (org.omg.CORBA.UNKNOWN un) {
- throw new org.omg.CORBA.UNKNOWN(
- "ERROR : "+un+" Parameters were not entered correctly");
-
- } catch (org.omg.CORBA.MARSHAL m) {
- throw new org.omg.CORBA.MARSHAL(
- "ERROR : "+m+" One or more parameters not found");
-
+ }
} catch (NoSuchElementException ne) {
throw new NoSuchElementException(
"ERROR : "+ne+" Switch found. Parameter missing.");
@@ -329,26 +310,31 @@
}
}
- if ( commandClass != null ) {
- {
- // 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
- Command command = (Command)Class.forName( commandClass ).newInstance();
- command.execute( table );
- return true;
- }
+ if ( commandClass != null ) {
+ try {
+ // 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
+ Command command = (Command)Class.forName( commandClass ).newInstance();
+ command.execute( table );
+ return true;
+ } catch (Exception e) {
+ System.out.println("ERROR : " + e.getMessage() );
+
+ if (table.get(VERBOSE).equals("true")) {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
}
return false;
@@ -649,7 +635,6 @@
System.out.println(" -p " + "Index pattern");
System.out.println(" -q " + "Query string");
System.out.println(" -u " + "Database URI");
- System.out.println(" -y " + "Force Deletion process");
System.out.println(" -s " + "Semi-colon delimited list of namespaces for query in the form prefix=namespace-uri");
System.out.println(" -t " + "Specify the data type in collection index");
System.out.println(" --pagesize " + "Page size for file pages (default: 4096)");
1.2 +1 -9 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddCollection.java 6 Dec 2001 19:33:57 -0000 1.1
+++ AddCollection.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -163,14 +163,6 @@
System.out.println("ERROR : Collection Context and New Collection name required");
}
}
-
- catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage());
- if (table.get("verbose").equals("true")) {
- org.apache.xindice.Debug.printStackTrace(e);
- }
- return false;
- }
finally {
// Release the collection objects
if (col != null) {
1.4 +2 -10 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AddDocument.java 26 Feb 2002 17:32:53 -0000 1.3
+++ AddDocument.java 19 Jul 2002 03:24:27 -0000 1.4
@@ -144,15 +144,7 @@
System.out.println("Added document " + table.get("collection") + "/" +
resource.getId());
resource = null;
- }
- catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage());
- if (table.get("verbose").equals("true")) {
- System.out.println("Document name = " + (String) table.get("nameOf"));
- e.printStackTrace(System.out);
- }
- return false;
- }
+ }
finally {
if (col != null) {
col.close();
1.2 +1 -8 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddIndexer.java 6 Dec 2001 19:33:57 -0000 1.1
+++ AddIndexer.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -153,13 +153,6 @@
System.out.println("ERROR : Collection and switch required");
}
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- e.printStackTrace(System.out);
- }
- return false;
-
} finally {
if ( col != null ) {
col.close();
1.2 +1 -8 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AddMultipleDocuments.java 6 Dec 2001 19:33:57 -0000 1.1
+++ AddMultipleDocuments.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -166,13 +166,6 @@
} // for loop
}
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- e.printStackTrace(System.out);
- }
- return false;
-
} finally {
// Release all resources
if ( col != null ) {
1.2 +1 -28 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeleteCollection.java 6 Dec 2001 19:33:57 -0000 1.1
+++ DeleteCollection.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -84,8 +84,6 @@
Collection col = null;
try {
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-
// Verify that the collection passed in is not null
if (table.get("collection") != null && table.get("nameOf") != null ) {
@@ -97,23 +95,6 @@
return false;
}
- if (!table.get("force").equals("yes")) {
- System.out.println("Are you sure you want to delete the collection " + table.get("nameOf") + " ? (y/n)");
-
- try {
- final String ans = in.readLine();
-
- if (!ans.equalsIgnoreCase("y")) {
- System.out.println("Operation aborted.");
- return true;
- }
-
- } catch (IOException ie) {
- System.out.println(ie);
- return false;
- }
- }
-
// Create a collection manager instance for the parent of the collection
CollectionManager colman = (CollectionManager)col.getService("CollectionManager",XMLDBAPIVERSION);
@@ -125,14 +106,6 @@
else
System.out.println("Error : Collection Context and Name required");
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
-
- if (table.get("verbose").equals("true")) {
- e.printStackTrace(System.out);
- }
- return false;
-
} finally {
if ( col != null ) {
col.close();
1.2 +2 -34 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeleteDocument.java 6 Dec 2001 19:33:57 -0000 1.1
+++ DeleteDocument.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -78,16 +78,11 @@
public class DeleteDocument extends Command {
- public boolean execute(Hashtable table ) throws Exception {
-
+ public boolean execute(Hashtable table ) throws Exception {
Collection col = null;
try {
-
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-
if (table.get("collection") != null) {
-
// Get a Collection reference to the collection to be deleted
String colstring = normalizeCollectionURI( (String)table.get("collection") );
@@ -98,26 +93,6 @@
}
if (table.get("nameOf") != null) {
-
- // If the user didn't chools to force deletion, ASK
- if (!table.get("force").equals("yes")) {
- System.out.println("Continue deletion process? (y/n)");
-
- try {
- final String ans = in.readLine();
-
- if (!ans.equalsIgnoreCase("y")) {
- System.out.println("Operation aborted.");
- return true;
- }
-
- } catch (IOException ie) {
- System.out.println(ie);
- return false;
- }
-
- }
-
Resource colresource = col.getResource((String)table.get("nameOf"));
col.removeResource(colresource);
@@ -134,13 +109,6 @@
// User did not supply collection name
System.out.println("ERROR : Collection and switch required");
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- e.printStackTrace(System.out);
- }
- return false;
-
} finally {
if ( col != null ) {
col.close();
1.2 +23 -51 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeleteIndexer.java 6 Dec 2001 19:33:57 -0000 1.1
+++ DeleteIndexer.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -81,57 +81,29 @@
Collection col = null ;
try {
+ if (table.get("collection") != null) {
+ // Get a Collection reference to the collection
+ String colstring = normalizeCollectionURI( (String)table.get("collection") );
+ 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("nameOf") != null) {
+ colman.dropIndexer((String)table.get("nameOf"));
+ System.out.println("DELETED: " + (String)table.get("nameOf"));
+ }
+ else {
+ System.out.println("ERROR : Name switch and Indexer name required");
+ }
+ }
+ else
+ System.out.println("ERROR : Collection and switch required");
- BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
-
- if (table.get("collection") != null) {
- //CollectionManager manager = db.getCollection((String)table.get("collection")).getCollectionManager();
- // Get a Collection reference to the collection
- String colstring = normalizeCollectionURI( (String)table.get("collection") );
- 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("nameOf") != null) {
- if (!table.get("force").equals("yes")) {
- // Allow the user to abort the deletion process
- System.out.println("Continue deletion process? (y/n)");
- try {
- final String ans = in.readLine();
-
- if (!ans.equalsIgnoreCase("y")) {
- System.out.println("Operation aborted.");
- return true;
- }
-
- } catch (IOException ie) {
- System.out.println(ie);
- return false;
- }
- }
-
- colman.dropIndexer((String)table.get("nameOf"));
- System.out.println("DELETED: " + (String)table.get("nameOf"));
- }
- else {
- System.out.println("ERROR : Name switch and Indexer name required");
- }
- }
- else
- System.out.println("ERROR : Collection and switch required");
-
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- org.apache.xindice.Debug.printStackTrace(e);
- }
- return false;
-
} finally {
if ( col != null ) {
col.close();
1.3 +18 -34 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ExportTree.java 26 Mar 2002 16:53:03 -0000 1.2
+++ ExportTree.java 19 Jul 2002 03:24:27 -0000 1.3
@@ -84,39 +84,29 @@
Collection col = null;
- try {
-
- if (table.get("filePath").equals("")) {
- System.out.println("ERROR: Directory name and switch required");
- return false;
- }
-
- if (table.get("collection") == null) {
- System.out.println("ERROR : Collection name and switch required");
- return false;
- }
+ if (table.get("filePath").equals("")) {
+ System.out.println("ERROR: Directory name and switch required");
+ return false;
+ }
- File fp = new File((String) table.get("filePath"));
+ if (table.get("collection") == null) {
+ System.out.println("ERROR : Collection name and switch required");
+ return false;
+ }
- System.out.println();
+ File fp = new File((String) table.get("filePath"));
- if (table.get("collection") != null) {
- String parent = parentDir((String) table.get("collection"));
- File dir = new File(fp, parent);
+ System.out.println();
- System.out.println("Creating directory " + dir.getPath());
+ if (table.get("collection") != null) {
+ String parent = parentDir((String) table.get("collection"));
+ File dir = new File(fp, parent);
- dir.mkdir();
+ System.out.println("Creating directory " + dir.getPath());
- process(dir, table, col);
- }
+ dir.mkdir();
- }
- catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage());
- if (table.get("verbose").equals("true")) {
- org.apache.xindice.Debug.printStackTrace(e);
- }
+ process(dir, table, col);
}
return true;
@@ -206,13 +196,7 @@
process(new File(directory + "//" + file.getName()), table, col);
}
- }
- catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage());
- if (table.get("verbose").equals("true")) {
- org.apache.xindice.Debug.printStackTrace(e);
- }
- }
+ }
finally {
if (col != null) {
col.close();
1.2 +2 -10 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ImportTree.java 6 Dec 2001 19:33:57 -0000 1.1
+++ ImportTree.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -117,15 +117,7 @@
// Make call to process, this is called recursively!
process(startdir, startcollection, table);
- }
- catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage());
- if (table.get("verbose").equals("true")) {
- org.apache.xindice.Debug.printStackTrace(e);
- }
- return false;
- }
- finally {
+ } finally {
// Be sure to close collection objects
if (col != null) {
col.close();
1.2 +1 -8 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ListCollectionDocuments.java 6 Dec 2001 19:33:57 -0000 1.1
+++ ListCollectionDocuments.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -104,13 +104,6 @@
else
System.out.println("ERROR : Collection and switch required");
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- e.printStackTrace(System.out);
- }
- return false;
-
} finally {
// Release the collection object
if ( col != null ) {
1.2 +1 -8 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ListCollections.java 6 Dec 2001 19:33:57 -0000 1.1
+++ ListCollections.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -110,13 +110,6 @@
System.out.println("ERROR : Collection not found ");
}
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- org.apache.xindice.Debug.printStackTrace(e);
- }
- return false;
-
} finally {
// Close collection objects and release
if ( col != null ) {
1.2 +1 -8 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ListIndexers.java 6 Dec 2001 19:33:57 -0000 1.1
+++ ListIndexers.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -109,13 +109,6 @@
System.out.println("\nTotal Indexes: " + idx.length);
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- org.apache.xindice.Debug.printStackTrace(e);
- }
- return false;
-
} finally {
if ( col != null ) {
col.close();
1.3 +1 -9 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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RetrieveDocument.java 26 Feb 2002 07:17:02 -0000 1.2
+++ RetrieveDocument.java 19 Jul 2002 03:24:27 -0000 1.3
@@ -83,7 +83,6 @@
try {
if (table.get("collection") != null) {
- //col = db.getCollection((String)table.get("collection"));
// Create a collection instance
String colstring = normalizeCollectionURI( (String)table.get("collection") );
String docname = (String)table.get("nameOf");
@@ -146,13 +145,6 @@
System.out.println("ERROR : Collection context required");
}
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- e.printStackTrace(System.out);
- }
- return false;
-
} finally {
// Release the collection object
if ( col != null ) {
1.2 +1 -8 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.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Shutdown.java 6 Dec 2001 19:33:57 -0000 1.1
+++ Shutdown.java 19 Jul 2002 03:24:27 -0000 1.2
@@ -99,13 +99,6 @@
// Shutdown the server
man.shutdown();
- } catch (Exception e) {
- System.out.println("ERROR : " + e.getMessage() );
- if (table.get("verbose").equals("true")) {
- e.printStackTrace(System.out);
- }
- return false;
-
} finally {
if ( col != null ) {
col.close();