@Test void testOptionsLdpr() { when(mockIoService.supportedWriteSyntaxes()).thenReturn(asList(TURTLE, JSONLD, NTRIPLES)); final OptionsHandler optionsHandler = new OptionsHandler(mockTrellisRequest, mockBundler, extensions); try (final Response res = optionsHandler.ldpOptions().build()) { assertEquals(NO_CONTENT, res.getStatusInfo(), ERR_RESPONSE_CODE); assertEquals(APPLICATION_SPARQL_UPDATE, res.getHeaderString(ACCEPT_PATCH), ERR_ACCEPT_PATCH); final String acceptPost = res.getHeaderString(ACCEPT_POST); assertNotNull(acceptPost, "Missing Accept-Post header!"); assertTrue(acceptPost.contains(APPLICATION_LD_JSON), "JSON-LD missing from acceptable POST formats!"); assertTrue(acceptPost.contains(APPLICATION_N_TRIPLES), "N-Triples missing from acceptable POST formats!"); assertTrue(acceptPost.contains(TEXT_TURTLE.split(";")[0]), "Turtle missing from acceptable POST formats!"); assertAll(CHECK_ALLOW, checkAllowHeader(res, asList(GET, HEAD, OPTIONS, PUT, DELETE, PATCH, POST))); } }
public ResponseBuilder ldpOptions() { LOGGER.debug("OPTIONS request for {}", getIdentifier()); final List<RDFSyntax> rdfSyntaxes = getServices().getIOService().supportedWriteSyntaxes(); final Stream<String> allSyntaxes = concat(rdfSyntaxes.stream().map(RDFSyntax::mediaType), of(WILDCARD)); return status(NO_CONTENT) .header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE, POST)) .header(ACCEPT_PATCH, APPLICATION_SPARQL_UPDATE) .header(ACCEPT_POST, allSyntaxes.collect(joining(","))); }
OptionsHandler extends BaseLdpHandler { public ResponseBuilder ldpOptions() { LOGGER.debug("OPTIONS request for {}", getIdentifier()); final List<RDFSyntax> rdfSyntaxes = getServices().getIOService().supportedWriteSyntaxes(); final Stream<String> allSyntaxes = concat(rdfSyntaxes.stream().map(RDFSyntax::mediaType), of(WILDCARD)); return status(NO_CONTENT) .header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE, POST)) .header(ACCEPT_PATCH, APPLICATION_SPARQL_UPDATE) .header(ACCEPT_POST, allSyntaxes.collect(joining(","))); } }
OptionsHandler extends BaseLdpHandler { public ResponseBuilder ldpOptions() { LOGGER.debug("OPTIONS request for {}", getIdentifier()); final List<RDFSyntax> rdfSyntaxes = getServices().getIOService().supportedWriteSyntaxes(); final Stream<String> allSyntaxes = concat(rdfSyntaxes.stream().map(RDFSyntax::mediaType), of(WILDCARD)); return status(NO_CONTENT) .header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE, POST)) .header(ACCEPT_PATCH, APPLICATION_SPARQL_UPDATE) .header(ACCEPT_POST, allSyntaxes.collect(joining(","))); } OptionsHandler(final TrellisRequest req, final ServiceBundler trellis, final Map<String, IRI> extensions); }
OptionsHandler extends BaseLdpHandler { public ResponseBuilder ldpOptions() { LOGGER.debug("OPTIONS request for {}", getIdentifier()); final List<RDFSyntax> rdfSyntaxes = getServices().getIOService().supportedWriteSyntaxes(); final Stream<String> allSyntaxes = concat(rdfSyntaxes.stream().map(RDFSyntax::mediaType), of(WILDCARD)); return status(NO_CONTENT) .header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE, POST)) .header(ACCEPT_PATCH, APPLICATION_SPARQL_UPDATE) .header(ACCEPT_POST, allSyntaxes.collect(joining(","))); } OptionsHandler(final TrellisRequest req, final ServiceBundler trellis, final Map<String, IRI> extensions); ResponseBuilder ldpOptions(); }
OptionsHandler extends BaseLdpHandler { public ResponseBuilder ldpOptions() { LOGGER.debug("OPTIONS request for {}", getIdentifier()); final List<RDFSyntax> rdfSyntaxes = getServices().getIOService().supportedWriteSyntaxes(); final Stream<String> allSyntaxes = concat(rdfSyntaxes.stream().map(RDFSyntax::mediaType), of(WILDCARD)); return status(NO_CONTENT) .header(ALLOW, join(",", GET, HEAD, OPTIONS, PATCH, PUT, DELETE, POST)) .header(ACCEPT_PATCH, APPLICATION_SPARQL_UPDATE) .header(ACCEPT_POST, allSyntaxes.collect(joining(","))); } OptionsHandler(final TrellisRequest req, final ServiceBundler trellis, final Map<String, IRI> extensions); ResponseBuilder ldpOptions();  }