try {
final Date date = MementoUtils.MEMENTO_DATE_FORMAT.parse(date_string);
final URI resource = ResourceUtils.getUriResource(conn, resource_string);
final ContentType type = getContentType(types_string);
//get serializer
final RDFFormat serializer = lmfIOService.getSerializer(type.getMime());
//create response serialisation
StreamingOutput entity = new StreamingOutput() {
@Override
public void write(OutputStream output) throws IOException, WebApplicationException {
RDFWriter writer = Rio.createWriter(serializer, output);
try {
RepositoryConnection con = versioningService.getSnapshot(date);
URI subject = con.getValueFactory().createURI(resource.stringValue());
try {
con.exportStatements(subject,null,null,true,writer);
} catch (RepositoryException e) {
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
} catch (RDFHandlerException e) {
throw new IOException("error while writing RDF data to stream");
} finally {
con.commit();
con.close();
}
} catch (RepositoryException e) {
throw new WebApplicationException(e, Response.Status.INTERNAL_SERVER_ERROR);
}
}
};
//get versions
MementoVersionSet versions = mementoService.getVersionSet(resource, date);
//build version links
Set<String> links = versions.buildLinks(configurationService.getBaseUri());
//add timegate link
links.add("<" + MementoUtils.timegateURI(resource_string, configurationService.getBaseUri()) + ">;rel=timegate");
//add timemap link
links.add("<" + MementoUtils.timemapURI(resource_string, configurationService.getBaseUri()) + ">;rel=timemap");
//create response
return Response
.ok()
.header("Link", CollectionUtils.fold(links," ,"))
.header("Content-Type", type.toString())
.header("Memento-Datetime", versions.getCurrent().getCommitTime().toString())
.entity(entity)
.build();
} catch (ParseException e) {