kevinross 2003/07/14 14:24:44
Modified: java/examples/guide/src/org/apache/xindice/examples
CreateCollection.java
Log:
added inline drop for repeated runs
Revision Changes Path
1.5 +17 -7
xml-xindice/java/examples/guide/src/org/apache/xindice/examples/CreateCollection.java
Index: CreateCollection.java
===================================================================
RCS file:
/home/cvs/xml-xindice/java/examples/guide/src/org/apache/xindice/examples/CreateCollection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- CreateCollection.java 10 Jul 2003 21:36:18 -0000 1.4
+++ CreateCollection.java 14 Jul 2003 21:24:43 -0000 1.5
@@ -67,28 +67,38 @@
* Simple XML:DB API example to create a collection.
*/
public class CreateCollection extends AbstractExample {
+
+ private static final String COLLECTION_NAME = "mycollection";
+
public static void main(String[] args) throws Exception {
Collection collection = null;
try {
- collection = getCollection("xmldb:xindice:///db/");
-// collection =
getCollection("xmldb:xindice://localhost:8888/db/");
+// collection = getCollection("xmldb:xindice:///db/");
+ collection =
getCollection("xmldb:xindice://localhost:8888/db/");
// collection =
getCollection("xmldb:xindice-embed:///db/");
- String collectionName = "mycollection";
CollectionManager service = (CollectionManager)
collection.getService("CollectionManager", "1.0");
+ try{
+ service.dropCollection(COLLECTION_NAME);
+ System.out.println("Dropped existing collection
with name: " + COLLECTION_NAME);
+ }
+ catch (Exception e) {
+ ; // nothing, this may be the first pass.
+ }
+
// Build up the Collection XML configuration.
String collectionConfig =
"<collection compressed=\"true\" name=\""
- + collectionName
+ + COLLECTION_NAME
+ "\">"
+ " <filer
class=\"org.apache.xindice.core.filer.BTreeFiler\" gzip=\"true\"/>"
+ "</collection>";
- service.createCollection(collectionName,
DOMParser.toDocument(collectionConfig));
+ service.createCollection(COLLECTION_NAME,
DOMParser.toDocument(collectionConfig));
- System.out.println("Collection " + collectionName + "
created.");
+ System.out.println("Collection " + COLLECTION_NAME + "
created.");
}
catch (XMLDBException e) {
System.err.println("XML:DB Exception occured " +
e.errorCode + " " + e.getMessage());