Search in sources :

Example 6 with ImportingJob

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();
    }
}
Also used : JSONWriter(org.json.JSONWriter) ServletException(javax.servlet.ServletException) ImportingJob(com.google.refine.importing.ImportingJob) JSONException(org.json.JSONException) Properties(java.util.Properties) Writer(java.io.Writer) JSONWriter(org.json.JSONWriter)

Example 7 with ImportingJob

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");
    }
}
Also used : ImportingJob(com.google.refine.importing.ImportingJob)

Aggregations

ImportingJob (com.google.refine.importing.ImportingJob)7 ServletException (javax.servlet.ServletException)5 JSONException (org.json.JSONException)5 IOException (java.io.IOException)4 Properties (java.util.Properties)4 JSONObject (org.json.JSONObject)4 JSONWriter (org.json.JSONWriter)4 Project (com.google.refine.model.Project)3 LinkedList (java.util.LinkedList)3 AuthenticationException (com.google.gdata.util.AuthenticationException)2 ServiceException (com.google.gdata.util.ServiceException)2 Writer (java.io.Writer)2 ProjectMetadata (com.google.refine.ProjectMetadata)1 Engine (com.google.refine.browsing.Engine)1 FilteredRecords (com.google.refine.browsing.FilteredRecords)1 FilteredRows (com.google.refine.browsing.FilteredRows)1 RecordVisitor (com.google.refine.browsing.RecordVisitor)1 RowVisitor (com.google.refine.browsing.RowVisitor)1 LanguageInfo (com.google.refine.expr.MetaParser.LanguageInfo)1 Format (com.google.refine.importing.ImportingManager.Format)1