List of usage examples for org.springframework.web.bind.annotation RequestMethod PATCH
RequestMethod PATCH
To view the source code for org.springframework.web.bind.annotation RequestMethod PATCH.
Click Source Link
From source file:org.cloudfoundry.identity.uaa.scim.endpoints.ScimGroupEndpoints.java
@RequestMapping(value = { "/Group/{groupId}", "/Groups/{groupId}" }, method = RequestMethod.PATCH) @ResponseBody// w w w . j ava2 s . c o m public ScimGroup patchGroup(@RequestBody ScimGroup patch, @PathVariable String groupId, @RequestHeader(value = "If-Match", required = false) String etag, HttpServletResponse httpServletResponse) { if (etag == null) { throw new ScimException("Missing If-Match for PATCH", HttpStatus.BAD_REQUEST); } logger.debug("patching group: " + groupId); int version = getVersion(groupId, etag); patch.setVersion(version); ScimGroup current = getGroup(groupId, httpServletResponse); current.patch(patch); return updateGroup(current, groupId, etag, httpServletResponse); }
From source file:org.cloudfoundry.identity.uaa.scim.endpoints.ScimUserEndpoints.java
@RequestMapping(value = "/Users/{userId}", method = RequestMethod.PATCH) @ResponseBody/*w w w . ja va2s. c o m*/ public ScimUser patchUser(@RequestBody ScimUser patch, @PathVariable String userId, @RequestHeader(value = "If-Match", required = false, defaultValue = "NaN") String etag, HttpServletRequest request, HttpServletResponse response) { if (etag.equals("NaN")) { throw new ScimException("Missing If-Match for PUT", HttpStatus.BAD_REQUEST); } int version = getVersion(userId, etag); ScimUser existing = dao.retrieve(userId); try { existing.patch(patch); existing.setVersion(version); if (existing.getEmails() != null && existing.getEmails().size() > 1) { String primary = existing.getPrimaryEmail(); existing.setEmails(new ArrayList<>()); existing.setPrimaryEmail(primary); } return updateUser(existing, userId, etag, request, response); } catch (IllegalArgumentException x) { throw new InvalidScimResourceException(x.getMessage()); } }
From source file:org.cloudfoundry.identity.uaa.scim.endpoints.ScimUserEndpoints.java
@RequestMapping(value = "/Users/{userId}/status", method = RequestMethod.PATCH) public UserAccountStatus updateAccountStatus(@RequestBody UserAccountStatus status, @PathVariable String userId) { ScimUser user = dao.retrieve(userId); if (!user.getOrigin().equals(OriginKeys.UAA)) { throw new IllegalArgumentException("Can only manage users from the internal user store."); }//from w w w. jav a 2s . co m if (status.getLocked() != null && status.getLocked()) { throw new IllegalArgumentException( "Cannot set user account to locked. User accounts only become locked through exceeding the allowed failed login attempts."); } if (status.isPasswordChangeRequired() != null && !status.isPasswordChangeRequired()) { throw new IllegalArgumentException( "The requirement that this user change their password cannot be removed via API."); } if (status.getLocked() != null && !status.getLocked()) { publish(new UserAccountUnlockedEvent(user)); } if (status.isPasswordChangeRequired() != null && status.isPasswordChangeRequired()) { dao.updatePasswordChangeRequired(userId, true); } return status; }
From source file:org.opentestsystem.delivery.testadmin.rest.ScheduleController.java
/** * Patches Schedule with new ScheduleDay object containing updated TimeSlot. * //from www .j a v a 2 s . c om * @param schedule * to be saved. * @param response * HttpServletResponse. * @return Schedule updated schedule object. */ @ResponseStatus(HttpStatus.OK) @RequestMapping(value = "/schedule/{scheduleId}", method = RequestMethod.PATCH, consumes = MediaType.APPLICATION_JSON_VALUE, produces = { MediaType.APPLICATION_JSON_VALUE }) @Secured({ "ROLE_Schedule Modify" }) @ResponseBody public Schedule patchSchedule(@PathVariable final String scheduleId, @RequestBody @Valid final ScheduledDay scheduleDay, final HttpServletResponse response) { return scheduleService.updateScheduleDay(scheduleId, scheduleDay); }
From source file:su.vistar.drivers.web.api.DriversController.java
@RequestMapping(value = "/{id}/", method = RequestMethod.PATCH) public @ResponseBody DriverDTO updateDriver(@PathVariable("id") int id, @RequestBody DriverDTO updatedDTO) { logger.info(String.format("? ? ? id %d", id)); Driver updated = new Driver(); updated.setSurname(updatedDTO.surname); updated.setName(updatedDTO.name);//ww w. ja v a 2s .c o m updated.setPatronimyc(updatedDTO.patronimyc); updated.setBirthdate(updatedDTO.birthdate); Gender.Variant gender = Gender.Variant.valueOf(updatedDTO.genderId); if (gender != null) { updated.setGender(gender.getGender()); } if (updatedDTO.categoryId != null) { Category category = categoriesService.getCategoryById(updatedDTO.categoryId); updated.setCategory(category); } // Driver returned = driversService.updateDriver(id, updated); return new DriverDTO(returned); }