contentsFile = XmldbURI.create("contents.xml");
} else {
try{
contentsFile = XmldbURI.xmldbUriFor(contentsName);
} catch(URISyntaxException e) {
throw new TriggerException(e);
}
}
// try to retrieve the contents file
try {
this.doc = parent.getDocument(broker, contentsFile);
if(this.doc == null)
// doesn't exist yet: create it
LOG.debug("creating new file for collection contents");
// IMPORTANT: temporarily disable triggers on the collection.
// We would end up in infinite recursion if we don't do that
parent.setTriggersEnabled(false);
IndexInfo info = parent.validateXMLResource(null, broker, contentsFile, "<?xml version=\"1.0\"?><contents></contents>");
//TODO : unlock the collection here ?
parent.store(null, broker, info, "<?xml version=\"1.0\"?><contents></contents>", false);
this.doc = info.getDocument();
} catch (Exception e) {
throw new TriggerException(e.getMessage(), e);
} finally {
parent.setTriggersEnabled(true);
}
}