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:com.nagarro.core.v2.controller.UsersController.java
/** * Updates the address. Only attributes provided in the request body will be changed. * * @param address//from w ww . j a va 2 s . c om * address object * @bodyparams * firstName,lastName,titleCode,line1,line2,town,postalCode,region(isocode),country(isocode),defaultAddress * @throws WebserviceValidationException */ @Secured({ "ROLE_CUSTOMERGROUP", "ROLE_GUEST", "ROLE_TRUSTED_CLIENT", "ROLE_CUSTOMERMANAGERGROUP" }) @RequestMapping(value = "/{userId}/addresses/{addressId}", method = RequestMethod.PATCH, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) @ResponseStatus(HttpStatus.OK) public void patchAddress(@PathVariable final String addressId, @RequestBody final AddressWsDTO address) throws WebserviceValidationException { final AddressData addressData = userFacade.getAddressForCode(addressId); if (addressData == null) { throw new RequestParameterException( "Address with given id: '" + sanitize(addressId) + "' doesn't exist or belong to another user", RequestParameterException.INVALID, "addressId"); } final boolean isAlreadyDefaultAddress = addressData.isDefaultAddress(); addressData.setFormattedAddress(null); dataMapper.map(address, addressData, "firstName,lastName,titleCode,line1,line2,town,postalCode,region(isocode),country(isocode),defaultAddress", false); validate(addressData, "address", addressValidator); if (addressData.getId().equals(userFacade.getDefaultAddress().getId())) { addressData.setDefaultAddress(true); addressData.setVisibleInAddressBook(true); } if (!isAlreadyDefaultAddress && addressData.isDefaultAddress()) { userFacade.setDefaultAddress(addressData); } userFacade.editAddress(addressData); }
From source file:de.hybris.platform.ycommercewebservices.v2.controller.UsersController.java
/** * Update address. Only attributes given in request body will be changed. * /*from w w w. j a v a 2 s.c o m*/ * @param address * address object * @bodyparams * firstName,lastName,titleCode,line1,line2,town,postalCode,region(isocode),country(isocode),defaultAddress * @throws WebserviceValidationException */ @Secured({ "ROLE_CUSTOMERGROUP", "ROLE_GUEST", "ROLE_TRUSTED_CLIENT", "ROLE_CUSTOMERMANAGERGROUP" }) @RequestMapping(value = "/{userId}/addresses/{addressId}", method = RequestMethod.PATCH, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) @ResponseStatus(HttpStatus.OK) public void patchAddress(@PathVariable final String addressId, @RequestBody final AddressWsDTO address) throws WebserviceValidationException { final AddressData addressData = userFacade.getAddressForCode(addressId); if (addressData == null) { throw new RequestParameterException( "Address with given id: '" + addressId + "' doesn't exist or belong to another user", RequestParameterException.INVALID, "addressId"); } final boolean isAlreadyDefaultAddress = addressData.isDefaultAddress(); addressData.setFormattedAddress(null); dataMapper.map(address, addressData, "firstName,lastName,titleCode,line1,line2,town,postalCode,region(isocode),country(isocode),defaultAddress", false); validate(addressData, "address", addressValidator); if (addressData.getId().equals(userFacade.getDefaultAddress().getId())) { addressData.setDefaultAddress(true); addressData.setVisibleInAddressBook(true); } if (!isAlreadyDefaultAddress && addressData.isDefaultAddress()) { userFacade.setDefaultAddress(addressData); } userFacade.editAddress(addressData); }
From source file:de.hybris.platform.ycommercewebservices.v2.controller.UsersController.java
/** * Updates existing customer's credit card payment details by it's ID. Only attributes given in request will be * changed.//from ww w .ja va2 s.c o m * * @formparam accountHolderName Name on card. This parameter is required. * @formparam cardNumber Card number. This parameter is required. * @formparam cardType Card type. This parameter is required. Call GET /{baseSiteId}/cardtypes beforehand to see what * card types are supported * @formparam expiryMonth Month of expiry date. This parameter is required. * @formparam expiryYear Year of expiry date. This parameter is required. * @formparam issueNumber * @formparam startMonth * @formparam startYear * @formparam subscriptionId * @formparam saved Parameter defines if the payment details should be saved for the customer and than could be * reused for future orders. * @formparam defaultPaymentInfo Parameter defines if the payment details should be used as default for customer. * @formparam billingAddress.firstName Customer's first name. This parameter is required. * @formparam billingAddress.lastName Customer's last name. This parameter is required. * @formparam billingAddress.titleCode Customer's title code. This parameter is required. For a list of codes, see * /{baseSiteId}/titles resource * @formparam billingAddress.country.isocode Country isocode. This parameter is required and have influence on how * rest of address parameters are validated (e.g. if parameters are required : * line1,line2,town,postalCode,region.isocode) * @formparam billingAddress.line1 First part of address. If this parameter is required depends on country (usually * it is required). * @formparam billingAddress.line2 Second part of address. If this parameter is required depends on country (usually * it is not required) * @formparam billingAddress.town Town name. If this parameter is required depends on country (usually it is * required) * @formparam billingAddress.postalCode Postal code. If this parameter is required depends on country (usually it is * required) * @formparam billingAddress.region.isocode Isocode for region. If this parameter is required depends on country. * @throws RequestParameterException */ @Secured({ "ROLE_CUSTOMERGROUP", "ROLE_TRUSTED_CLIENT", "ROLE_CUSTOMERMANAGERGROUP" }) @RequestMapping(value = "/{userId}/paymentdetails/{paymentDetailsId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) public void updatePaymentInfo(@PathVariable final String paymentDetailsId, final HttpServletRequest request) throws RequestParameterException { if (LOG.isDebugEnabled()) { LOG.debug("updatePaymentInfo: id = " + paymentDetailsId); } final CCPaymentInfoData paymentInfoData; try { paymentInfoData = userFacade.getCCPaymentInfoForCode(paymentDetailsId); } catch (final PK.PKException ex) { throw new RequestParameterException("Payment details [" + paymentDetailsId + "] not found.", RequestParameterException.UNKNOWN_IDENTIFIER, "paymentDetailsId", ex); } final boolean isAlreadyDefaultPaymentInfo = paymentInfoData.isDefaultPaymentInfo(); final Collection<PaymentInfoOption> options = new ArrayList<PaymentInfoOption>(); options.add(PaymentInfoOption.BASIC); options.add(PaymentInfoOption.BILLING_ADDRESS); httpRequestPaymentInfoPopulator.populate(request, paymentInfoData, options); validate(paymentInfoData, "paymentDetails", ccPaymentInfoValidator); userFacade.updateCCPaymentInfo(paymentInfoData); if (paymentInfoData.isSaved() && !isAlreadyDefaultPaymentInfo && paymentInfoData.isDefaultPaymentInfo()) { userFacade.setDefaultPaymentInfo(paymentInfoData); } }
From source file:com.nagarro.core.v2.controller.UsersController.java
/** * Updates existing customer's credit card payment details based on its ID. Only attributes given in request will be * changed.//from ww w. j a v a 2 s.com * * @formparam accountHolderName Name on card. This parameter is required. * @formparam cardNumber Card number. This parameter is required. * @formparam cardType Card type. This parameter is required. Call GET /{baseSiteId}/cardtypes beforehand to see what * card types are supported * @formparam expiryMonth Month of expiry date. This parameter is required. * @formparam expiryYear Year of expiry date. This parameter is required. * @formparam issueNumber * @formparam startMonth * @formparam startYear * @formparam subscriptionId * @formparam saved Parameter defines if the payment details should be saved for the customer and than could be * reused for future orders. * @formparam defaultPaymentInfo Parameter defines if the payment details should be used as default for customer. * @formparam billingAddress.firstName Customer's first name. This parameter is required. * @formparam billingAddress.lastName Customer's last name. This parameter is required. * @formparam billingAddress.titleCode Customer's title code. This parameter is required. For a list of codes, see * /{baseSiteId}/titles resource * @formparam billingAddress.country.isocode Country isocode. This parameter is required and have influence on how * rest of address parameters are validated (e.g. if parameters are required : * line1,line2,town,postalCode,region.isocode) * @formparam billingAddress.line1 First part of address. If this parameter is required depends on country (usually * it is required). * @formparam billingAddress.line2 Second part of address. If this parameter is required depends on country (usually * it is not required) * @formparam billingAddress.town Town name. If this parameter is required depends on country (usually it is * required) * @formparam billingAddress.postalCode Postal code. If this parameter is required depends on country (usually it is * required) * @formparam billingAddress.region.isocode Isocode for region. If this parameter is required depends on country. * @throws RequestParameterException */ @Secured({ "ROLE_CUSTOMERGROUP", "ROLE_TRUSTED_CLIENT", "ROLE_CUSTOMERMANAGERGROUP" }) @RequestMapping(value = "/{userId}/paymentdetails/{paymentDetailsId}", method = RequestMethod.PATCH) @ResponseStatus(HttpStatus.OK) public void updatePaymentInfo(@PathVariable final String paymentDetailsId, final HttpServletRequest request) throws RequestParameterException { if (LOG.isDebugEnabled()) { LOG.debug("updatePaymentInfo: id = " + sanitize(paymentDetailsId)); } final CCPaymentInfoData paymentInfoData = getPaymentInfo(paymentDetailsId); final boolean isAlreadyDefaultPaymentInfo = paymentInfoData.isDefaultPaymentInfo(); final Collection<PaymentInfoOption> options = new ArrayList<PaymentInfoOption>(); options.add(PaymentInfoOption.BASIC); options.add(PaymentInfoOption.BILLING_ADDRESS); httpRequestPaymentInfoPopulator.populate(request, paymentInfoData, options); validate(paymentInfoData, "paymentDetails", ccPaymentInfoValidator); userFacade.updateCCPaymentInfo(paymentInfoData); if (paymentInfoData.isSaved() && !isAlreadyDefaultPaymentInfo && paymentInfoData.isDefaultPaymentInfo()) { userFacade.setDefaultPaymentInfo(paymentInfoData); } }
From source file:de.hybris.platform.ycommercewebservices.v2.controller.UsersController.java
/** * Updates existing customer's credit card payment details by it's ID. Only attributes given in request body will be * changed.// ww w . j av a 2 s . co m * * @param paymentDetails * payment details object * @bodyparams * accountHolderName,cardNumber,cardType,issueNumber,startMonth,expiryMonth,startYear,expiryYear,subscriptionId * ,defaultPaymentInfo,saved,billingAddress(firstName,lastName,titleCode,line1,line2,town,postalCode, * region(isocode),country(isocode),defaultAddress) * @throws RequestParameterException * @throws WebserviceValidationException */ @Secured({ "ROLE_CUSTOMERGROUP", "ROLE_TRUSTED_CLIENT", "ROLE_CUSTOMERMANAGERGROUP" }) @RequestMapping(value = "/{userId}/paymentdetails/{paymentDetailsId}", method = RequestMethod.PATCH, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) @ResponseStatus(HttpStatus.OK) public void updatePaymentInfo(@PathVariable final String paymentDetailsId, @RequestBody final PaymentDetailsWsDTO paymentDetails) throws RequestParameterException { final CCPaymentInfoData paymentInfoData; try { paymentInfoData = userFacade.getCCPaymentInfoForCode(paymentDetailsId); } catch (final PK.PKException ex) { throw new RequestParameterException("Payment details [" + paymentDetailsId + "] not found.", RequestParameterException.UNKNOWN_IDENTIFIER, "paymentDetailsId", ex); } final boolean isAlreadyDefaultPaymentInfo = paymentInfoData.isDefaultPaymentInfo(); dataMapper.map(paymentDetails, paymentInfoData, "accountHolderName,cardNumber,cardType,issueNumber,startMonth,expiryMonth,startYear,expiryYear,subscriptionId,defaultPaymentInfo,saved,billingAddress(firstName,lastName,titleCode,line1,line2,town,postalCode,region(isocode),country(isocode),defaultAddress)", false); validate(paymentInfoData, "paymentDetails", ccPaymentInfoValidator); userFacade.updateCCPaymentInfo(paymentInfoData); if (paymentInfoData.isSaved() && !isAlreadyDefaultPaymentInfo && paymentInfoData.isDefaultPaymentInfo()) { userFacade.setDefaultPaymentInfo(paymentInfoData); } }
From source file:com.nagarro.core.v2.controller.UsersController.java
/** * Updates existing customer's credit card payment details based on its ID. Only attributes given in request will be * changed./*from ww w. j ava2s . c o m*/ * * @param paymentDetails * payment details object * @bodyparams * accountHolderName,cardNumber,cardType,issueNumber,startMonth,expiryMonth,startYear,expiryYear,subscriptionId * ,defaultPaymentInfo,saved,billingAddress(firstName,lastName,titleCode,line1,line2,town,postalCode, * region(isocode),country(isocode),defaultAddress) * @throws RequestParameterException * @throws WebserviceValidationException */ @Secured({ "ROLE_CUSTOMERGROUP", "ROLE_TRUSTED_CLIENT", "ROLE_CUSTOMERMANAGERGROUP" }) @RequestMapping(value = "/{userId}/paymentdetails/{paymentDetailsId}", method = RequestMethod.PATCH, consumes = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE }) @ResponseStatus(HttpStatus.OK) public void updatePaymentInfo(@PathVariable final String paymentDetailsId, @RequestBody final PaymentDetailsWsDTO paymentDetails) throws RequestParameterException { final CCPaymentInfoData paymentInfoData = getPaymentInfo(paymentDetailsId); final boolean isAlreadyDefaultPaymentInfo = paymentInfoData.isDefaultPaymentInfo(); dataMapper.map(paymentDetails, paymentInfoData, "accountHolderName,cardNumber,cardType,issueNumber,startMonth,expiryMonth,startYear,expiryYear,subscriptionId,defaultPaymentInfo,saved,billingAddress(firstName,lastName,titleCode,line1,line2,town,postalCode,region(isocode),country(isocode),defaultAddress)", false); validate(paymentInfoData, "paymentDetails", ccPaymentInfoValidator); userFacade.updateCCPaymentInfo(paymentInfoData); if (paymentInfoData.isSaved() && !isAlreadyDefaultPaymentInfo && paymentInfoData.isDefaultPaymentInfo()) { userFacade.setDefaultPaymentInfo(paymentInfoData); } }
From source file:org.ambraproject.rhino.rest.controller.ArticleCrudController.java
@RequestMapping(value = "/articles/{doi}/revisions/{number}/syndications", method = RequestMethod.PATCH) @ApiImplicitParam(name = "body", paramType = "body", dataType = "SyndicationInputView", value = "example: {\"targetQueue\": \"activemq:plos.pmc\", \"status\": \"FAILURE\", \"errorMessage\": \"failed\"}") public ResponseEntity<?> patchSyndication(HttpServletRequest request, @PathVariable("doi") String doi, @PathVariable("number") int revisionNumber) throws IOException { ArticleRevisionIdentifier revisionId = ArticleRevisionIdentifier.create(DoiEscaping.unescape(doi), revisionNumber);//from w w w . j av a2 s .com SyndicationInputView input = readJsonFromRequest(request, SyndicationInputView.class); Syndication patched = syndicationCrudService.updateSyndication(revisionId, input.getTargetQueue(), input.getStatus(), input.getErrorMessage()); return ServiceResponse.serveView(new SyndicationView(patched)).asJsonResponse(entityGson); }
From source file:org.ambraproject.rhino.rest.controller.IssueCrudController.java
@Transactional(rollbackFor = { Throwable.class }) @RequestMapping(value = "/journals/{journalKey}/volumes/{volumeDoi}/issues/{issueDoi:.+}", method = RequestMethod.PATCH) @ApiImplicitParam(name = "body", paramType = "body", dataType = "IssueInputView", value = "example #1: {\"displayName\": \"July\"}<br>" + "example #2: {\"imageArticleDoi\": \"10.1371/image.pbio.v02.i07\"}<br>" + "example #3: {\"articleOrder\": [\"10.1371/journal.pbio.0020213\", \"10.1371/journal.pbio.0020214\", " + "\"10.1371/journal.pbio.0020228\"]}") public ResponseEntity<?> update(HttpServletRequest request, @RequestHeader(value = HttpHeaders.IF_MODIFIED_SINCE, required = false) Date ifModifiedSince, @PathVariable("journalKey") String journalKey, @PathVariable("volumeDoi") String volumeDoi, @PathVariable("issueDoi") String issueDoi) throws IOException { // TODO: Validate journalKey and volumeDoiObj IssueIdentifier issueId = getIssueId(issueDoi); IssueInputView input = readJsonFromRequest(request, IssueInputView.class); issueCrudService.update(issueId, input); return issueCrudService.serveIssue(issueId).getIfModified(ifModifiedSince).asJsonResponse(entityGson); }
From source file:org.ambraproject.rhino.rest.controller.VolumeCrudController.java
@Transactional(rollbackFor = { Throwable.class }) @RequestMapping(value = "/journals/{journalKey}/volumes/{volumeDoi:.+}", method = RequestMethod.PATCH) @ApiImplicitParam(name = "body", paramType = "body", dataType = "VolumeInputView", value = "example #1: {\"doi\": \"10.1371/volume.pmed.v01\"}<br>" + "example #2: {\"displayName\": \"2004\"}") public ResponseEntity<?> update(HttpServletRequest request, @PathVariable("journalKey") String journalKey, @PathVariable("volumeDoi") String volumeDoi) throws IOException { // TODO: Validate journalKey VolumeIdentifier volumeId = getVolumeId(volumeDoi); VolumeInputView input = readJsonFromRequest(request, VolumeInputView.class); Volume updated = volumeCrudService.update(volumeId, input); VolumeOutputView view = volumeOutputViewFactory.getView(updated); return ServiceResponse.serveView(view).asJsonResponse(entityGson); }
From source file:org.apache.servicecomb.demo.springmvc.server.CodeFirstSpringmvc.java
@ResponseHeaders({ @ResponseHeader(name = "h1", response = String.class), @ResponseHeader(name = "h2", response = String.class) }) @RequestMapping(path = "/responseEntity", method = RequestMethod.PATCH) public ResponseEntity<Date> responseEntityPATCH(InvocationContext c1, @RequestAttribute("date") Date date) { return responseEntity(c1, date); }