Response validateScopeResponse = validateScope(request, Collections.singletonList(AbstractResource.SCOPE_WRITE));
if (validateScopeResponse != null) {
return validateScopeResponse;
}
ResourceServer persistedResourceServer = getResourceServer(request, id);
if (persistedResourceServer == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
// Copy over read-only fields
resourceServer.setSecret(persistedResourceServer.getSecret());
resourceServer.setKey(persistedResourceServer.getKey());
resourceServer.setOwner(getUserId(request));
pruneClientScopes(resourceServer.getScopes(), persistedResourceServer.getScopes(),
persistedResourceServer.getClients());
LOG.debug("About to update existing resourceServer {} with new properties: {}", persistedResourceServer,
resourceServer);
ResourceServer savedInstance;
try {
//we run transactional modus, so any constraint violations only occur after the commit of the transaction (to late...)
validate(resourceServer);
savedInstance = resourceServerRepository.save(resourceServer);
} catch (Exception e) {