String newcol = (String) table.get(XMLTools.NAME_OF);
// Create an instance of the collection manager and create the collection
CollectionManager colman = (CollectionManager) col.getService("CollectionManager", XMLDBAPIVERSION);
String colName = "";
String parName = newcol;
int idx = parName.lastIndexOf("/");
if (idx != -1) {
colName = parName.substring(idx + 1);
parName = parName.substring(0, idx);
} else if (idx == -1) {
colName = parName;
}
if (colName.equals("")) {
System.out.println("Cannot create a NULL collection");
return false;
}
Document doc = new DocumentImpl();
Element colEle = doc.createElement("collection");
colEle.setAttribute("compressed", "true");
colEle.setAttribute("name", colName);
doc.appendChild(colEle);
Element filEle = doc.createElement("filer");
filEle.setAttribute("class", "org.apache.xindice.core.filer.BTreeFiler");
//filEle.setAttribute("gzip", "true");
if (table.containsKey(XMLTools.PAGE_SIZE)) {
filEle.setAttribute("pagesize", (String) table.get(XMLTools.PAGE_SIZE));
}
if (table.containsKey(XMLTools.MAX_KEY_SIZE)) {
filEle.setAttribute("maxkeysize", (String) table.get(XMLTools.MAX_KEY_SIZE));
}
colEle.appendChild(filEle);
tempcol = colman.createCollection(newcol, doc);
System.out.println("Created : " + table.get(XMLTools.COLLECTION) + "/" + newcol);
} else {
System.out.println("ERROR : Collection Context and New Collection name required");