}
}
searcher.close();
} catch (CorruptIndexException e) {
logger.error(e.getMessage(), e);
throw new SpagoBIException("Index corrupted", e);
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new SpagoBIException("Unable to read index", e);
} // only searching, so
catch (ParseException e) {
logger.error(e.getMessage(), e);
throw new SpagoBIException("Wrong query syntax", e);
}
JSONArray documentsJSON = (JSONArray)SerializerFactory.getSerializer("application/json").serialize( objects, null);
for(int i=0; i<documentsJSON.length();i++){
JSONObject jsonobj = documentsJSON.getJSONObject(i);
String biobjid = jsonobj.getString("id");
String summary = (String)returned.get(biobjid);
jsonobj.put("summary", summary);
String views = (String)returned.get(biobjid+"-views");
jsonobj.put("views", views);
}
Collection func = profile.getFunctionalities();
if(func.contains("SeeMetadataFunctionality")){
JSONObject showmetadataAction = new JSONObject();
showmetadataAction.put("name", "showmetadata");
showmetadataAction.put("description", "Show Metadata");
for(int i = 0; i < documentsJSON.length(); i++) {
JSONObject documentJSON = documentsJSON.getJSONObject(i);
documentJSON.getJSONArray("actions").put(showmetadataAction);
}
}
JSONObject documentsResponseJSON = createJSONResponseDocuments(documentsJSON);
try {
writeBackToClient( new JSONSuccess( createJSONResponse(documentsResponseJSON) ) );
} catch (IOException e) {
logger.error(e.getMessage(), e);
throw new SpagoBIException("Impossible to write back the responce to the client", e);
}
} catch (Exception e) {
logger.error("Excepiton",e);
} finally {