Response validateScopeResponse = validateScope(request, Collections.singletonList(AbstractResource.SCOPE_WRITE));
if (validateScopeResponse != null) {
return validateScopeResponse;
}
ResourceOwner resourceOwnerSaved;
try {
//we run transactional modus, so any constraint violations only occur after the commit of the transaction (to late...)
validate(newOne);
resourceOwnerSaved = resourceOwnerRepository.save(newOne);
} catch (Exception e) {
return buildErrorResponse(e);
}
LOG.debug("New resourceOwner has been saved: {}. ", resourceOwnerSaved);
final URI uri = UriBuilder.fromPath("{resourceServerId}.json").build(resourceOwnerSaved.getId());
return Response.created(uri).entity(resourceOwnerSaved).build();
}