Search in sources :

Example 1 with CouldNotFetchResultsException

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();
}
Also used : CouldNotFetchResultsException(de.ipbhalle.exception.CouldNotFetchResultsException) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CouldNotFetchResultsException (de.ipbhalle.exception.CouldNotFetchResultsException)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1