Source:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Project project = getProject(request); response.setCharacterEncoding("UTF-8"); response.setHeader("Content-Type", "application/json"); String jsonString = request.getParameter("schema"); WikibaseSchema schema = null; if (jsonString != null) { try { JSONObject json = ParsingUtilities.evaluateJsonStringToObject(jsonString); schema = WikibaseSchema.reconstruct(json); } catch (JSONException e) { respond(response, "error", "Wikibase schema could not be parsed."); return; } } else { schema = (WikibaseSchema) project.overlayModels.get("wikibaseSchema"); } if (schema == null) { respond(response, "error", "No Wikibase schema provided."); return; } QAWarningStore warningStore = new QAWarningStore(); Engine engine = getEngine(request, project); List<ItemUpdate> editBatch = schema.evaluate(project, engine, warningStore); StringWriter sb = new StringWriter(2048); JSONWriter writer = new JSONWriter(sb); writer.object(); { StringWriter stringWriter = new StringWriter(); EditInspector inspector = new EditInspector(warningStore); inspector.inspect(editBatch); writer.key("warnings"); writer.array(); for (QAWarning warning : warningStore.getWarnings()) { warning.write(writer, new Properties()); } writer.endArray(); writer.key("max_severity"); writer.value(warningStore.getMaxSeverity().toString()); writer.key("nb_warnings"); writer.value(warningStore.getNbWarnings()); QuickStatementsExporter exporter = new QuickStatementsExporter(); exporter.translateItemList(editBatch, stringWriter); writer.key("quickstatements"); writer.value(FirstLinesExtractor.extractFirstLines(stringWriter.toString(), 50)); } writer.endObject(); respond(response, sb.toString()); } catch (Exception e) { respondException(response, e); } }

Target:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { Project project = getProject(request); response.setCharacterEncoding("UTF-8"); response.setHeader("Content-Type", "application/json"); String jsonString = request.getParameter("schema"); WikibaseSchema schema = null; if (jsonString != null) { try { schema = WikibaseSchema.reconstruct(jsonString); } catch (JSONException e) { respondError(response, "Wikibase schema could not be parsed."); return; } } else { schema = (WikibaseSchema) project.overlayModels.get("wikibaseSchema"); } if (schema == null) { respondError(response, "No Wikibase schema provided."); return; } QAWarningStore warningStore = new QAWarningStore(); Engine engine = getEngine(request, project); List<ItemUpdate> editBatch = schema.evaluate(project, engine, warningStore); StringWriter sb = new StringWriter(2048); JSONWriter writer = new JSONWriter(sb); writer.object(); { EditInspector inspector = new EditInspector(warningStore); inspector.inspect(editBatch); writer.key("warnings"); writer.array(); for (QAWarning warning : warningStore.getWarnings()) { warning.write(writer, new Properties()); } writer.endArray(); writer.key("max_severity"); writer.value(warningStore.getMaxSeverity().toString()); writer.key("nb_warnings"); writer.value(warningStore.getNbWarnings()); WikibaseAPIUpdateScheduler scheduler = new WikibaseAPIUpdateScheduler(); List<ItemUpdate> nonNullEdits = scheduler.schedule(editBatch).stream() .filter(e -> !e.isNull()) .collect(Collectors.toList()); writer.key("edit_count"); writer.value(nonNullEdits.size()); List<ItemUpdate> firstEdits = nonNullEdits.stream() .limit(10) .collect(Collectors.toList()); ObjectMapper mapper = new ObjectMapper(); String firstEditsJson = mapper.writeValueAsString(firstEdits); writer.key("edits_preview"); writer.value(new JSONArray(firstEditsJson)); } writer.endObject(); respond(response, sb.toString()); } catch (Exception e) { respondException(response, e); } }