use of com.google.refine.importing.ImportingJob in project OpenRefine by OpenRefine.
the class GetImportingJobStatusCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
long jobID = Long.parseLong(request.getParameter("jobID"));
ImportingJob job = ImportingManager.getJob(jobID);
Writer w = response.getWriter();
JSONWriter writer = new JSONWriter(w);
try {
writer.object();
if (job == null) {
writer.key("code");
writer.value("error");
writer.key("message");
writer.value("No such import job");
} else {
writer.key("code");
writer.value("ok");
writer.key("job");
job.write(writer, new Properties());
}
writer.endObject();
} catch (JSONException e) {
throw new ServletException(e);
} finally {
w.flush();
w.close();
}
}
use of com.google.refine.importing.ImportingJob in project OpenRefine by OpenRefine.
the class CancelImportingJobCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
long jobID = Long.parseLong(request.getParameter("jobID"));
ImportingJob job = ImportingManager.getJob(jobID);
if (job == null) {
HttpUtilities.respond(response, "error", "No such import job");
} else {
job.canceled = true;
ImportingManager.disposeJob(jobID);
HttpUtilities.respond(response, "ok", "Job canceled");
}
}
Aggregations