@RequestMapping(value = BASE_MAPPING, method = DELETE) public ResponseEntity<? extends ResourceSupport> deletePropertyReference(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property) throws Exception { Function<ReferencedProperty, ResourceSupport> handler = prop -> prop.mapValue(it -> { if (prop.property.isCollectionLike() || prop.property.isMap()) { throw HttpRequestMethodNotSupportedException.forRejectedMethod(HttpMethod.DELETE) .withAllowedMethods(HttpMethod.GET, HttpMethod.HEAD); } else { prop.wipeValue(); } publisher.publishEvent(new BeforeLinkDeleteEvent(prop.accessor.getBean(), prop.propertyValue)); Object result = repoRequest.getInvoker().invokeSave(prop.accessor.getBean()); publisher.publishEvent(new AfterLinkDeleteEvent(result, prop.propertyValue)); return (ResourceSupport) null; }).orElse(null); doWithReferencedProperty(repoRequest, id, property, handler, HttpMethod.DELETE); return ControllerUtils.toEmptyResponse(HttpStatus.NO_CONTENT); }
throw HttpRequestMethodNotSupportedException.forRejectedMethod(HttpMethod.PATCH)//
@RequestMapping(value = BASE_MAPPING, method = DELETE) public ResponseEntity<? extends ResourceSupport> deletePropertyReference(RootResourceInformation repoRequest, @BackendId Serializable id, @PathVariable String property) throws Exception { Function<ReferencedProperty, ResourceSupport> handler = prop -> prop.mapValue(it -> { if (prop.property.isCollectionLike() || prop.property.isMap()) { throw HttpRequestMethodNotSupportedException.forRejectedMethod(HttpMethod.DELETE) .withAllowedMethods(HttpMethod.GET, HttpMethod.HEAD); } else { prop.wipeValue(); } publisher.publishEvent(new BeforeLinkDeleteEvent(prop.accessor.getBean(), prop.propertyValue)); Object result = repoRequest.getInvoker().invokeSave(prop.accessor.getBean()); publisher.publishEvent(new AfterLinkDeleteEvent(result, prop.propertyValue)); return (ResourceSupport) null; }).orElse(null); doWithReferencedProperty(repoRequest, id, property, handler, HttpMethod.DELETE); return ControllerUtils.toEmptyResponse(HttpStatus.NO_CONTENT); }
throw HttpRequestMethodNotSupportedException.forRejectedMethod(HttpMethod.PATCH)//