use of org.openrefine.wikidata.operations.SaveWikibaseSchemaOperation in project OpenRefine by OpenRefine.
the class SaveWikibaseSchemaCommand method doPost.
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (!hasValidCSRFToken(request)) {
respondCSRFError(response);
return;
}
try {
Project project = getProject(request);
String jsonString = request.getParameter("schema");
if (jsonString == null) {
respondError(response, "No Wikibase schema provided.");
return;
}
WikibaseSchema schema = ParsingUtilities.mapper.readValue(jsonString, WikibaseSchema.class);
AbstractOperation op = new SaveWikibaseSchemaOperation(schema);
Process process = op.createProcess(project, new Properties());
performProcessAndRespond(request, response, project, process);
} catch (IOException e) {
// We do not use respondException here because this is an expected
// exception which happens every time a user tries to save an incomplete
// schema - the exception should not be logged.
respondError(response, String.format("Wikibase schema could not be parsed: ", e.getMessage()));
} catch (Exception e) {
// This is an unexpected exception, so we log it.
respondException(response, e);
}
}
Aggregations