@Override public void invokeDeleteById(Object id) { delegate.invokeDeleteById(id); }
/** * <code>DELETE /{repository}/{id}</code> - Deletes the entity backing the item resource. * * @param resourceInformation * @param id * @param eTag * @return * @throws ResourceNotFoundException * @throws HttpRequestMethodNotSupportedException * @throws ETagDoesntMatchException */ @RequestMapping(value = BASE_MAPPING + "/{id}", method = RequestMethod.DELETE) public ResponseEntity<?> deleteItemResource(RootResourceInformation resourceInformation, @BackendId Serializable id, ETag eTag) throws ResourceNotFoundException, HttpRequestMethodNotSupportedException { resourceInformation.verifySupportedMethod(HttpMethod.DELETE, ResourceType.ITEM); RepositoryInvoker invoker = resourceInformation.getInvoker(); Optional<Object> domainObj = invoker.invokeFindById(id); return domainObj.map(it -> { PersistentEntity<?, ?> entity = resourceInformation.getPersistentEntity(); eTag.verify(entity, it); publisher.publishEvent(new BeforeDeleteEvent(it)); invoker.invokeDeleteById(entity.getIdentifierAccessor(it).getIdentifier()); publisher.publishEvent(new AfterDeleteEvent(it)); return new ResponseEntity<Object>(HttpStatus.NO_CONTENT); }).orElseThrow(() -> new ResourceNotFoundException()); }
@Override public void invokeDeleteById(Object id) { delegate.invokeDeleteById(id); }
/** * <code>DELETE /{repository}/{id}</code> - Deletes the entity backing the item resource. * * @param resourceInformation * @param id * @param eTag * @return * @throws ResourceNotFoundException * @throws HttpRequestMethodNotSupportedException * @throws ETagDoesntMatchException */ @RequestMapping(value = BASE_MAPPING + "/{id}", method = RequestMethod.DELETE) public ResponseEntity<?> deleteItemResource(RootResourceInformation resourceInformation, @BackendId Serializable id, ETag eTag) throws ResourceNotFoundException, HttpRequestMethodNotSupportedException { resourceInformation.verifySupportedMethod(HttpMethod.DELETE, ResourceType.ITEM); RepositoryInvoker invoker = resourceInformation.getInvoker(); Optional<Object> domainObj = invoker.invokeFindById(id); return domainObj.map(it -> { PersistentEntity<?, ?> entity = resourceInformation.getPersistentEntity(); eTag.verify(entity, it); publisher.publishEvent(new BeforeDeleteEvent(it)); invoker.invokeDeleteById(entity.getIdentifierAccessor(it).getIdentifier()); publisher.publishEvent(new AfterDeleteEvent(it)); return new ResponseEntity<Object>(HttpStatus.NO_CONTENT); }).orElseThrow(() -> new ResourceNotFoundException()); }