use of javax.ws.rs.core.HttpHeaders.ALLOW in project trellis by trellis-ldp.
the class MementoResource method getTimeMapBuilder.
/**
* Create a response builder for a TimeMap response.
*
* @param mementos the mementos
* @param baseUrl the base URL
* @param req the LDP request
* @return a response builder object
*/
public ResponseBuilder getTimeMapBuilder(final SortedSet<Instant> mementos, final TrellisRequest req, final String baseUrl) {
final List<MediaType> acceptableTypes = req.getAcceptableMediaTypes();
final String identifier = HttpUtils.buildResourceUrl(req, baseUrl);
final List<Link> allLinks = getMementoLinks(identifier, mementos).collect(toList());
final ResponseBuilder builder = ok().link(identifier, ORIGINAL + " " + TIMEGATE);
builder.links(getMementoHeaders(identifier, mementos).map(this::filterLinkParams).toArray(Link[]::new)).link(Resource.getIRIString(), TYPE).link(RDFSource.getIRIString(), TYPE).header(ALLOW, join(",", GET, HEAD, OPTIONS));
final RDFSyntax syntax = getSyntax(trellis.getIOService(), acceptableTypes, APPLICATION_LINK_FORMAT);
if (syntax != null) {
final IRI profile = getProfile(acceptableTypes, syntax);
final IRI jsonldProfile = profile != null ? profile : compacted;
return builder.type(syntax.mediaType()).entity((StreamingOutput) out -> trellis.getIOService().write(trellis.getTimemapGenerator().asRdf(identifier, allLinks), out, syntax, baseUrl, jsonldProfile));
}
return builder.type(APPLICATION_LINK_FORMAT).entity(allLinks.stream().map(this::filterLinkParams).map(Link::toString).collect(joining(",\n")) + "\n");
}
Aggregations