*
* @param content The new content value
*/
public void setContent( Object value ) throws XMLDBException {
if (value instanceof String) {
ExternalTransaction tx = database.newTransaction();
// we assume it's a valid XML doc and parse it
try {
StringReader in = new StringReader((String)value);
InputSource source = new InputSource(in);
SAXParser parser = parserFactory.newSAXParser();
ParserAdapter adapter = new ParserAdapter( parser.getParser() );
tx.begin();
adapter.setContentHandler( container.storeSAX() );
adapter.parse( source );
tx.commit();
}
catch (SAXException e) {
try {
if (tx.getStatus() == tx.STATUS_ACTIVE)
tx.rollback();
throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, e.getMessage());
}
catch (Exception rollbackException) {
throw new XMLDBException(ErrorCodes.VENDOR_ERROR, rollbackException.toString());
}
}
catch (Exception e) {
try {
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.toString());
}