use of org.alfresco.repo.solr.AlfrescoModelDiff in project alfresco-remote-api by Alfresco.
the class AlfrescoModelsDiff method buildModel.
private Map<String, Object> buildModel(WebScriptRequest req) throws JSONException, IOException {
Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
Content content = req.getContent();
if (content == null) {
throw new WebScriptException("Failed to convert request to String");
}
JSONObject o = new JSONObject(content.getContent());
JSONArray jsonModels = o.getJSONArray("models");
Map<QName, Long> models = new HashMap<QName, Long>(jsonModels.length());
for (int i = 0; i < jsonModels.length(); i++) {
JSONObject jsonModel = jsonModels.getJSONObject(i);
models.put(QName.createQName(jsonModel.getString("name")), jsonModel.getLong("checksum"));
}
List<AlfrescoModelDiff> diffs = solrTrackingComponent.getModelDiffs(models);
model.put("diffs", diffs);
if (logger.isDebugEnabled()) {
logger.debug("Result: \n\tRequest: " + req + "\n\tModel: " + model);
}
return model;
}
Aggregations