Search in sources :

Example 1 with EntryPartWriter

use of org.nextprot.api.core.export.EntryPartWriter in project nextprot-api by calipho-sib.

the class ExportController method streamEntrySubPart.

@RequestMapping(value = "/export/entry/{entry}/{blockOrSubpart}", method = { RequestMethod.GET })
public void streamEntrySubPart(HttpServletRequest request, HttpServletResponse response, @PathVariable("entry") String entryName, @PathVariable("blockOrSubpart") String blockOrSubpart) {
    Entry entry = entryBuilderService.build(EntryConfig.newConfig(entryName).with(blockOrSubpart).withBed(true));
    try {
        EntryPartWriter writer = EntryPartWriter.valueOf(NextprotMediaType.valueOf(request), EntryPartExporterImpl.fromSubPart(blockOrSubpart), response.getOutputStream());
        writer.write(entry);
    } catch (IOException e) {
        throw new NextProtException("cannot export " + entryName + " " + blockOrSubpart + " in " + NextprotMediaType.valueOf(request) + " format", e);
    }
}
Also used : Entry(org.nextprot.api.core.domain.Entry) NextProtException(org.nextprot.api.commons.exception.NextProtException) EntryPartWriter(org.nextprot.api.core.export.EntryPartWriter) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 NextProtException (org.nextprot.api.commons.exception.NextProtException)1 Entry (org.nextprot.api.core.domain.Entry)1 EntryPartWriter (org.nextprot.api.core.export.EntryPartWriter)1