@RequestMapping(value = "/Users/{userId}", method = RequestMethod.PUT) @ResponseBody public ScimUser updateUser(@RequestBody ScimUser user, @PathVariable String userId, @RequestHeader(value = "If-Match", required = false, defaultValue = "NaN") String etag, HttpServletRequest request, HttpServletResponse httpServletResponse) { throwWhenUserManagementIsDisallowed(user.getOrigin(), request); throwWhenInvalidSelfEdit(user, userId, request); if (etag.equals("NaN")) { throw new ScimException("Missing If-Match for PUT", HttpStatus.BAD_REQUEST); } int version = getVersion(userId, etag); user.setVersion(version); try { ScimUser updated = scimUserProvisioning.update(userId, user, IdentityZoneHolder.get().getId()); scimUpdates.incrementAndGet(); ScimUser scimUser = syncApprovals(syncGroups(updated)); addETagHeader(httpServletResponse, scimUser); return scimUser; } catch (OptimisticLockingFailureException e) { throw new ScimResourceConflictException(e.getMessage()); } }
@Override public Response toResponse(final OptimisticLockingFailureException e) { logger.info("Mapping error " + e.getMessage()); return Response.status(Status.CONFLICT) .entity(e.getMessage()) .type(MediaType.TEXT_PLAIN_TYPE) .build(); } }
/** 楽観的排他(Hibernateのバージョンチェック)の例外 */ @ExceptionHandler(OptimisticLockingFailureException.class) public ResponseEntity<Map<String, String[]>> handleOptimisticLockingFailureException( OptimisticLockingFailureException e) { log.warn(e.getMessage(), e); return new ErrorHolder(msg, locale(), "error.OptimisticLockingFailure").result(HttpStatus.BAD_REQUEST); }
LOG.error("exception encountered on store of document " + e.getMessage()); throw e;
@RequestMapping(value = "/Users/{userId}", method = RequestMethod.PUT) @ResponseBody public ScimUser updateUser(@RequestBody ScimUser user, @PathVariable String userId, @RequestHeader(value = "If-Match", required = false, defaultValue = "NaN") String etag, HttpServletResponse httpServletResponse) { if (etag.equals("NaN")) { throw new ScimException("Missing If-Match for PUT", HttpStatus.BAD_REQUEST); } int version = getVersion(userId, etag); user.setVersion(version); try { ScimUser updated = dao.update(userId, user); scimUpdates.incrementAndGet(); ScimUser scimUser = syncApprovals(syncGroups(updated)); addETagHeader(httpServletResponse, scimUser); return scimUser; } catch (OptimisticLockingFailureException e) { throw new ScimResourceConflictException(e.getMessage()); } }
} else if ( subcause instanceof OptimisticLockingFailureException ) { OptimisticLockingFailureException ole = (OptimisticLockingFailureException) subcause; sourceObject = ole.getMessage(); optLockException = true; } else {