use of de.ipbhalle.exception.CouldNotFetchResultsException in project MetFragRelaunched by ipb-halle.
the class MetFragRestController method fetch.
/**
* get the result back (as CSV)
*
* @param processid
* @return
* @throws InterruptedException
* @throws ExecutionException
* @throws IOException
*/
@RequestMapping(method = RequestMethod.GET, value = "/result/{processid}", produces = { MediaType.TEXT_PLAIN_VALUE })
public String fetch(@PathVariable String processid) throws InterruptedException, ExecutionException, IOException {
File resultFile = new File(this.getResultFileName(processid));
if (!resultFile.exists() || !resultFile.isFile() || !resultFile.canRead())
new CouldNotFetchResultsException(processid);
StringBuilder builder = new StringBuilder();
BufferedReader breader = new BufferedReader(new FileReader(resultFile));
String line = "";
while ((line = breader.readLine()) != null) {
builder.append(line + "\r\n");
}
breader.close();
return builder.toString();
}
Aggregations