log.debugv("saveChanges", "source={0}", source);
Response response;
Session session = sessionFactory.openSession();
try {
ContextProvider context = new HibernateContext(session, metadata);
SaveResult sr = context.saveChanges(source);
String json = Json.toJson(sr);
log.debugv("saveChanges: SaveResult={0}", json);
if (sr.hasErrors()) {
response = Response.status(Response.Status.FORBIDDEN).entity(json).build();