String msg =
"Updates are only accepted if the schemeElement is available. " +
"So no updates will be done. " + "schema id: " + schema.getId() +
", schema path: " + schema.getPath() + ".";
log.error(msg);
throw new GovernanceException(msg);
}
boolean succeeded = false;
try {
registry.beginTransaction();
// getting the old schema.
Schema oldSchema = getSchema(schema.getId());
if (oldSchema == null) {
addSchema(schema);
return;
}
// we are expecting only the OMElement to be different.
Resource schemaResource = registry.newResource();
schemaResource.setMediaType(GovernanceConstants.SCHEMA_MEDIA_TYPE);
// setting the schema content
setContent(schema, schemaResource);
registry.put(oldSchema.getPath(), schemaResource);
schema.updatePath();
schema.loadSchemaDetails();
succeeded = true;
} catch (RegistryException e) {
String msg =
"Error in updating the schema, schema id: " + schema.getId() +
", schema path: " + schema.getPath() + ".";
log.error(msg, e);
throw new GovernanceException(msg, e);
} finally {
if (succeeded) {
try {
registry.commitTransaction();
} catch (RegistryException e) {