public CreateResult create(final XMLNode node, final boolean onStartup) {
return create(node, Collections.EMPTY_MAP, onStartup);
}
public CreateResult create(final XMLNode node, final Map attributes, final boolean onStartup) {
final CreateResult result = new CreateResult();
HibernateTxFragment txFragment = new HibernateTxFragment() {
protected void txFragment(Session session) throws Exception {
if (ExportVisitor.WORKSPACE.equals(node.getObjectName())) {
createWorkspace(result, node, attributes, onStartup);
} else if (ExportVisitor.RESOURCE.equals(node.getObjectName())) {
createResource(result, null, null, null, node, attributes, onStartup);
} else {
throw new IllegalArgumentException("Invalid workspace node.");
}
}
};
try {
txFragment.execute();
} catch (Exception e) {
log.error("Error:", e);
return new CreateResult(e);
}
return result;
}