Search in sources :

Example 1 with AlfrescoModelDiff

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;
}
Also used : HashMap(java.util.HashMap) QName(org.alfresco.service.namespace.QName) JSONArray(org.json.JSONArray) AlfrescoModelDiff(org.alfresco.repo.solr.AlfrescoModelDiff) WebScriptException(org.springframework.extensions.webscripts.WebScriptException) JSONObject(org.json.JSONObject) Content(org.springframework.extensions.surf.util.Content) JSONObject(org.json.JSONObject)

Aggregations

HashMap (java.util.HashMap)1 AlfrescoModelDiff (org.alfresco.repo.solr.AlfrescoModelDiff)1 QName (org.alfresco.service.namespace.QName)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 Content (org.springframework.extensions.surf.util.Content)1 WebScriptException (org.springframework.extensions.webscripts.WebScriptException)1