public void setContentAsDOM( Node content ) throws XMLDBException {
ExternalTransaction tx = database.newTransaction();
try {
if (content == null) {
System.out.println("XMLResourceImpl.setContentAsDOM() - Content is null");
throw new XMLDBException(ErrorCodes.INVALID_RESOURCE);
}
if (content instanceof Document) {
Document doc = (Document)content;
tx.begin();
container.storeDOM(doc);
tx.commit();
}
else {
System.out.println("Cannot store Nodes right now, must be a Document");
}
}
catch (Exception e) {
e.printStackTrace();
try {
System.out.println("XMLResourceImpl.setContentAsDOM() - Transaction status is " + tx.getStatus());
if (tx.getStatus() == tx.STATUS_ACTIVE)
tx.rollback();
throw new XMLDBException( ErrorCodes.VENDOR_ERROR, e.getMessage());
}
catch (Exception rollbackException) {
throw new XMLDBException(ErrorCodes.VENDOR_ERROR, rollbackException.getMessage());
}
}
}