private void saveResults(
      TnrsJob job,
      JSONObject results,
      Vector<String> ids,
      Vector<String> original_names,
      String session_id)
      throws Exception {

    if (job.getType() == TnrsJob.PARSING_JOB) {
      ParsingResultsFile csv = new ParsingResultsFile(job, baseFolder);
      csv.writeJsonData(results.getJSONArray("parsedNames"), ids);

    } else {
      MatchingResultsFile csv = new MatchingResultsFile(job, baseFolder, session_id, false);
      TNRSResultsTransformer transformer = new TNRSResultsTransformer();
      JSONArray results_array = transformer.transform(results, job, ids, original_names);
      csv.writeJsonData(results_array, ids);
      csv.close();
    }
  }
    @Override
    public void handle(HttpExchange arg0) throws IOException {
      try {

        JSONObject json =
            (JSONObject) JSONSerializer.toJSON(IOUtils.toString(arg0.getRequestBody()));

        String email = json.getString("email");
        String key = json.getString("key");
        String session_id = json.getString("session_id");

        TnrsJob job = JobHelper.readJobInfo(baseFolder, email, key);

        if (job.getType() == TnrsJob.PARSING_JOB) {

          ParsingResultsFile results = new ParsingResultsFile(job, baseFolder);
          results.createFileForDownload(properties.getProperty("org.iplantc.folder.tmp"));

        } else {

          MatchingResultsFile results = new MatchingResultsFile(job, baseFolder, session_id, false);

          results.createFileForDownload(
              properties.getProperty("org.iplantc.tnrs.folder.tmp"), json);

          results.close();
        }

        String url = servicesUrl + "getcsv?id=" + key;

        HandlerHelper.writeResponseRequest(arg0, 200, url, null);
      } catch (Exception ex) {
        log.error(ExceptionUtils.getFullStackTrace(ex));
        ex.printStackTrace();
      }
    }