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));
}
colEle.appendChild(filEle);
tempcol = colman.createCollection(colPath, doc);
System.out.println("Created : " + table.get(XMLTools.COLLECTION) + "/" + colPath);
} else {
System.out.println("ERROR : Collection Context and New Collection name required");
}