//Database database = (Database) c.newInstance();
System.out.println("collectionURI is " + collectionURI);
Collection col = DatabaseManager.getCollection(collectionURI);
//Collection col = database.getCollection(collectionURI);
Document doc = parseDocument();
XMLResource resource = (XMLResource)col.getResource(resourceName);
if (resource == null) {
OzoneProxy o = db.objectForName(resourceName);
if (o != null) {
System.out.println("Object found as db oject, deleting it..");
db.deleteObject(o);
}
System.out.println("resource is null, create the resource with name " + resourceName);
resource = (XMLResource) col.createResource(resourceName, XMLResource.RESOURCE_TYPE);
}
else {
System.out.println("deleting resource" + resourceName);
col.removeResource(resource);
resource = (XMLResource) col.createResource(resourceName, XMLResource.RESOURCE_TYPE);
}
System.out.println("Created resource " + resourceName + " with id " + resource.getId());
// double check to see if it actually works
resource = (XMLResource)col.getResource(resourceName);
System.out.println("Resource found with name " + resource.getId());
resource.setContentAsDOM(doc);
System.out.println("Updated content: " + resource.getContent());
col.storeResource(resource);
//System.out.println("Stored the following Document:\n" + toString(doc));
System.out.println("Stored the following Document:\n" + doc.getDocumentElement().getTagName());
col.close();
db.close();