try {
if (key == null) {
key = collection.createId();
}
// Support of binary objects can be added. Content can be obtained using Source.
Resource resource = collection.createResource(key, "XMLResource");
resource.setContent(document);
collection.storeResource(resource);
result = "success";
key = resource.getId();
} catch (XMLDBException e) {
message = "Failed to create resource " + key + ": " + e.errorCode;
getLogger().debug(message, e);
}
}
} else if ("delete".equals(operation)) {
try {
Resource resource = collection.getResource(this.key);
if (resource == null) {
message = "Resource " + this.key + " does not exist";
getLogger().debug(message);
} else {
collection.removeResource(resource);