@GET @Path("/" + WsUriConstants.MAPPING_SET + WsUriConstants.RDF) @Produces({MediaType.TEXT_PLAIN, "text/turtle", "application/rdf+xml", "application/n-triples", "application/ld+json", "application/trig" }) public Response getMappingSetRdfText(@QueryParam(WsConstants.ID) String idString, @QueryParam(WsUriConstants.BASE_URI) String baseUri, @QueryParam(WsUriConstants.RDF_FORMAT) String formatName, @Context Request request, @Context HttpServletRequest httpServletRequest) throws BridgeDBException{ baseUri = checkBaseUri(baseUri, httpServletRequest); String context = checkContext(baseUri, httpServletRequest); Set<Statement> statements = getMappingSetStatements(idString, baseUri, context); if (noContentOnEmpty & statements.isEmpty()){ return Response.noContent().build(); } List<MediaType> types = new ArrayList<MediaType>(); for (RDFFormat f :RDFFormat.values() ) { types.add(MediaType.valueOf(f.getDefaultMIMEType())); types.addAll(MediaTypes.createMediaTypes(f.getMIMETypes().toArray(new String[]{}))); } List<Variant> variants = VariantListBuilder.newInstance().mediaTypes(types.toArray(new MediaType[]{})).build(); Variant variant = request.selectVariant(variants); if (formatName == null || formatName.isEmpty()) { RDFFormat format = RDFFormat.forMIMEType(variant.getMediaType().toString(), RDFFormat.NTRIPLES); formatName = format.getName(); } String rdfInfo = BridgeDbRdfTools.writeRDF(statements, formatName); return Response.ok(rdfInfo, MediaType.TEXT_PLAIN_TYPE).build(); }
/** * Retrieve the node profile * * @param rangeValue the range value * @return a binary or the triples for the specified node * @throws IOException if IO exception occurred * @throws UnsupportedAlgorithmException if unsupported digest algorithm occurred * @throws UnsupportedAccessTypeException if unsupported access-type occurred */ @GET @Produces({TURTLE_WITH_CHARSET + ";qs=1.0", JSON_LD + ";qs=0.8", N3_WITH_CHARSET, N3_ALT2_WITH_CHARSET, RDF_XML, NTRIPLES, TEXT_PLAIN_WITH_CHARSET, TURTLE_X, TEXT_HTML_WITH_CHARSET}) public Response getResource(@HeaderParam("Range") final String rangeValue) throws IOException, UnsupportedAlgorithmException, UnsupportedAccessTypeException { checkCacheControlHeaders(request, servletResponse, resource(), session); LOGGER.info("GET resource '{}'", externalPath); final AcquiredLock readLock = lockManager.lockForRead(resource().getPath()); try (final RdfStream rdfStream = new DefaultRdfStream(asNode(resource()))) { // If requesting a binary, check the mime-type if "Accept:" header is present. // (This needs to be done before setting up response headers, as getContent // returns a response - so changing headers after that won't work so nicely.) final ImmutableList<MediaType> acceptableMediaTypes = ImmutableList.copyOf(headers .getAcceptableMediaTypes()); if (resource() instanceof FedoraBinary && acceptableMediaTypes.size() > 0) { final MediaType mediaType = getBinaryResourceMediaType(); // Respect the Want-Digest header for fixity check final String wantDigest = headers.getHeaderString(WANT_DIGEST); if (!isNullOrEmpty(wantDigest)) { servletResponse.addHeader(DIGEST, handleWantDigestHeader((FedoraBinary)resource(), wantDigest)); } if (!acceptableMediaTypes.stream().anyMatch(t -> t.isCompatible(mediaType))) { return notAcceptable(VariantListBuilder.newInstance().mediaTypes(mediaType).build()).build(); } } addResourceHttpHeaders(resource()); return getContent(rangeValue, getChildrenLimit(), rdfStream); } finally { readLock.release(); } }
@Override public VariantListBuilder createVariantListBuilder() { throw new UnsupportedOperationException(); }
@Override public VariantListBuilder createVariantListBuilder() { // TODO return null; }