@Test void testPatchMissing() { final PatchHandler patchHandler = new PatchHandler(mockTrellisRequest, null, mockBundler, extensions, false, null, null); try (final Response res = assertThrows(NotFoundException.class, () -> patchHandler.initialize(mockParent, MISSING_RESOURCE)).getResponse()) { assertEquals(NOT_FOUND, res.getStatusInfo(), ERR_RESPONSE_CODE); } }
public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (!supportsCreate && MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (!supportsCreate && DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (updateBody == null) { throw new BadRequestException("Missing body for update"); } else if (!supportsInteractionModel(LDP.RDFSource)) { throw new BadRequestException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } else if (syntax == null) { LOGGER.debug("Content-Type: {} not supported", getRequest().getContentType()); throw new NotSupportedException(); } if (exists(resource)) { checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); } else { setResource(null); setParent(parent); } return ok(); }
PatchHandler extends MutatingLdpHandler { public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (!supportsCreate && MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (!supportsCreate && DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (updateBody == null) { throw new BadRequestException("Missing body for update"); } else if (!supportsInteractionModel(LDP.RDFSource)) { throw new BadRequestException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } else if (syntax == null) { LOGGER.debug("Content-Type: {} not supported", getRequest().getContentType()); throw new NotSupportedException(); } if (exists(resource)) { checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); } else { setResource(null); setParent(parent); } return ok(); } }
PatchHandler extends MutatingLdpHandler { public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (!supportsCreate && MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (!supportsCreate && DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (updateBody == null) { throw new BadRequestException("Missing body for update"); } else if (!supportsInteractionModel(LDP.RDFSource)) { throw new BadRequestException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } else if (syntax == null) { LOGGER.debug("Content-Type: {} not supported", getRequest().getContentType()); throw new NotSupportedException(); } if (exists(resource)) { checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); } else { setResource(null); setParent(parent); } return ok(); } PatchHandler(final TrellisRequest req, final String updateBody, final ServiceBundler trellis,
            final Map<String, IRI> extensions, final boolean supportsCreate, final String defaultJsonLdProfile,
            final String baseUrl); }
PatchHandler extends MutatingLdpHandler { public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (!supportsCreate && MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (!supportsCreate && DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (updateBody == null) { throw new BadRequestException("Missing body for update"); } else if (!supportsInteractionModel(LDP.RDFSource)) { throw new BadRequestException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } else if (syntax == null) { LOGGER.debug("Content-Type: {} not supported", getRequest().getContentType()); throw new NotSupportedException(); } if (exists(resource)) { checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); } else { setResource(null); setParent(parent); } return ok(); } PatchHandler(final TrellisRequest req, final String updateBody, final ServiceBundler trellis,
            final Map<String, IRI> extensions, final boolean supportsCreate, final String defaultJsonLdProfile,
            final String baseUrl); ResponseBuilder initialize(final Resource parent, final Resource resource); CompletionStage<ResponseBuilder> updateResource(final ResponseBuilder builder); }
PatchHandler extends MutatingLdpHandler { public ResponseBuilder initialize(final Resource parent, final Resource resource) { if (!supportsCreate && MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (!supportsCreate && DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } else if (updateBody == null) { throw new BadRequestException("Missing body for update"); } else if (!supportsInteractionModel(LDP.RDFSource)) { throw new BadRequestException(status(BAD_REQUEST) .link(UnsupportedInteractionModel.getIRIString(), LDP.constrainedBy.getIRIString()) .entity("Unsupported interaction model provided").type(TEXT_PLAIN_TYPE).build()); } else if (syntax == null) { LOGGER.debug("Content-Type: {} not supported", getRequest().getContentType()); throw new NotSupportedException(); } if (exists(resource)) { checkCache(resource.getModified(), generateEtag(resource)); setResource(resource); resource.getContainer().ifPresent(p -> setParent(parent)); } else { setResource(null); setParent(parent); } return ok(); } PatchHandler(final TrellisRequest req, final String updateBody, final ServiceBundler trellis,
            final Map<String, IRI> extensions, final boolean supportsCreate, final String defaultJsonLdProfile,
            final String baseUrl); ResponseBuilder initialize(final Resource parent, final Resource resource); CompletionStage<ResponseBuilder> updateResource(final ResponseBuilder builder);  }