@Test void testDeletePersistenceSupport() { when(mockResourceService.supportedInteractionModels()).thenReturn(emptySet()); final DeleteHandler handler = new DeleteHandler(mockTrellisRequest, mockBundler, extensions, baseUrl); try (final Response res = assertThrows(WebApplicationException.class, () -> handler.initialize(mockParent, mockResource)).getResponse()) { assertTrue(res.getLinks().stream().anyMatch(link -> link.getUri().toString().equals(UnsupportedInteractionModel.getIRIString()) && link.getRel().equals(LDP.constrainedBy.getIRIString())), "Missing Link headers"); assertEquals(TEXT_PLAIN_TYPE, res.getMediaType(), "Incorrect media type"); } }
public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (!supportsInteractionModel(LDP.Resource)) { throw new ClientErrorException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); return noContent(); }
DeleteHandler extends MutatingLdpHandler { public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (!supportsInteractionModel(LDP.Resource)) { throw new ClientErrorException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); return noContent(); } }
DeleteHandler extends MutatingLdpHandler { public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (!supportsInteractionModel(LDP.Resource)) { throw new ClientErrorException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); return noContent(); } DeleteHandler(final TrellisRequest req, final ServiceBundler trellis,
            final Map<String, IRI> extensions, final String baseUrl); }
DeleteHandler extends MutatingLdpHandler { public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (!supportsInteractionModel(LDP.Resource)) { throw new ClientErrorException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); return noContent(); } DeleteHandler(final TrellisRequest req, final ServiceBundler trellis,
            final Map<String, IRI> extensions, final String baseUrl); ResponseBuilder initialize(final Resource parent, final Resource resource); CompletionStage<ResponseBuilder> deleteResource(final ResponseBuilder builder); }
DeleteHandler extends MutatingLdpHandler { public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (!supportsInteractionModel(LDP.Resource)) { throw new ClientErrorException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); return noContent(); } DeleteHandler(final TrellisRequest req, final ServiceBundler trellis,
            final Map<String, IRI> extensions, final String baseUrl); ResponseBuilder initialize(final Resource parent, final Resource resource); CompletionStage<ResponseBuilder> deleteResource(final ResponseBuilder builder);  }