@Test void testNotAcceptableLdprs() { when(mockTrellisRequest.getAcceptableMediaTypes()).thenReturn(singletonList(APPLICATION_JSON_TYPE)); final GetConfiguration config = new GetConfiguration(false, true, true, null, baseUrl); final GetHandler handler = new GetHandler(mockTrellisRequest, mockBundler, extensions, config); try (final Response res = assertThrows(NotAcceptableException.class, () -> handler.initialize(mockResource), "No error thrown when given an unaccepable media type!").getResponse()) { assertEquals(NOT_ACCEPTABLE, res.getStatusInfo(), ERR_RESPONSE_CODE); } }
public ResponseBuilder initialize(final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } handleTrailingSlashRedirection(resource); LOGGER.debug("Acceptable media types: {}", getRequest().getAcceptableMediaTypes()); this.syntax = getSyntax(getServices().getIOService(), getRequest().getAcceptableMediaTypes(), resource.getBinaryMetadata() .filter(b -> !DESCRIPTION.equals(getRequest().getExt())) .map(b -> b.getMimeType().orElse(APPLICATION_OCTET_STREAM)).orElse(null)); final IRI ext = getExtensionGraphName(); if (ext != null && !resource.stream(ext).findAny().isPresent()) { LOGGER.trace("No stream for extention: {}", ext); throw new NotFoundException(); } setResource(resource); return ok(); }
GetHandler extends BaseLdpHandler { public ResponseBuilder initialize(final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } handleTrailingSlashRedirection(resource); LOGGER.debug("Acceptable media types: {}", getRequest().getAcceptableMediaTypes()); this.syntax = getSyntax(getServices().getIOService(), getRequest().getAcceptableMediaTypes(), resource.getBinaryMetadata() .filter(b -> !DESCRIPTION.equals(getRequest().getExt())) .map(b -> b.getMimeType().orElse(APPLICATION_OCTET_STREAM)).orElse(null)); final IRI ext = getExtensionGraphName(); if (ext != null && !resource.stream(ext).findAny().isPresent()) { LOGGER.trace("No stream for extention: {}", ext); throw new NotFoundException(); } setResource(resource); return ok(); } }
GetHandler extends BaseLdpHandler { public ResponseBuilder initialize(final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } handleTrailingSlashRedirection(resource); LOGGER.debug("Acceptable media types: {}", getRequest().getAcceptableMediaTypes()); this.syntax = getSyntax(getServices().getIOService(), getRequest().getAcceptableMediaTypes(), resource.getBinaryMetadata() .filter(b -> !DESCRIPTION.equals(getRequest().getExt())) .map(b -> b.getMimeType().orElse(APPLICATION_OCTET_STREAM)).orElse(null)); final IRI ext = getExtensionGraphName(); if (ext != null && !resource.stream(ext).findAny().isPresent()) { LOGGER.trace("No stream for extention: {}", ext); throw new NotFoundException(); } setResource(resource); return ok(); } GetHandler(final TrellisRequest req, final ServiceBundler trellis, final Map<String, IRI> extensions,
            final GetConfiguration config); }
GetHandler extends BaseLdpHandler { public ResponseBuilder initialize(final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } handleTrailingSlashRedirection(resource); LOGGER.debug("Acceptable media types: {}", getRequest().getAcceptableMediaTypes()); this.syntax = getSyntax(getServices().getIOService(), getRequest().getAcceptableMediaTypes(), resource.getBinaryMetadata() .filter(b -> !DESCRIPTION.equals(getRequest().getExt())) .map(b -> b.getMimeType().orElse(APPLICATION_OCTET_STREAM)).orElse(null)); final IRI ext = getExtensionGraphName(); if (ext != null && !resource.stream(ext).findAny().isPresent()) { LOGGER.trace("No stream for extention: {}", ext); throw new NotFoundException(); } setResource(resource); return ok(); } GetHandler(final TrellisRequest req, final ServiceBundler trellis, final Map<String, IRI> extensions,
            final GetConfiguration config); ResponseBuilder initialize(final Resource resource); ResponseBuilder standardHeaders(final ResponseBuilder builder); CompletionStage<ResponseBuilder> getRepresentation(final ResponseBuilder builder); ResponseBuilder addMementoHeaders(final ResponseBuilder builder, final SortedSet<Instant> mementos); }
GetHandler extends BaseLdpHandler { public ResponseBuilder initialize(final Resource resource) { if (MISSING_RESOURCE.equals(resource)) { throw new NotFoundException(); } else if (DELETED_RESOURCE.equals(resource)) { throw new ClientErrorException(GONE); } handleTrailingSlashRedirection(resource); LOGGER.debug("Acceptable media types: {}", getRequest().getAcceptableMediaTypes()); this.syntax = getSyntax(getServices().getIOService(), getRequest().getAcceptableMediaTypes(), resource.getBinaryMetadata() .filter(b -> !DESCRIPTION.equals(getRequest().getExt())) .map(b -> b.getMimeType().orElse(APPLICATION_OCTET_STREAM)).orElse(null)); final IRI ext = getExtensionGraphName(); if (ext != null && !resource.stream(ext).findAny().isPresent()) { LOGGER.trace("No stream for extention: {}", ext); throw new NotFoundException(); } setResource(resource); return ok(); } GetHandler(final TrellisRequest req, final ServiceBundler trellis, final Map<String, IRI> extensions,
            final GetConfiguration config); ResponseBuilder initialize(final Resource resource); ResponseBuilder standardHeaders(final ResponseBuilder builder); CompletionStage<ResponseBuilder> getRepresentation(final ResponseBuilder builder); ResponseBuilder addMementoHeaders(final ResponseBuilder builder, final SortedSet<Instant> mementos);  }