if (badGetDataRequest(request, jsonObject) || !authSucc(request, jsonObject)) {
return;
}
final String repositoryName = request.getParameter("repositoryName");
final Repository repository = Repositories.getRepository(repositoryName);
if (null == repository) {
jsonObject.put(Keys.STATUS_CODE, HttpServletResponse.SC_BAD_REQUEST);
jsonObject.put(Keys.MSG, "Not found repository[name=" + repositoryName + "]");
return;
}
final boolean cacheEnabled = repository.isCacheEnabled();
repository.setCacheEnabled(false);
final Query query = new Query().setCurrentPageNum(Integer.valueOf(request.getParameter("pageNum"))).
setPageSize(Integer.valueOf(request.getParameter("pageSize")));
try {
final JSONObject result = repository.get(query);
final JSONObject pagination = result.getJSONObject(Pagination.PAGINATION);
final JSONArray data = result.getJSONArray(Keys.RESULTS);
jsonObject.put(Pagination.PAGINATION, pagination);
jsonObject.put(Keys.RESULTS, data);
} catch (final Exception e) {
LOGGER.log(Level.SEVERE, "Gets data failed", e);
jsonObject.put(Keys.STATUS_CODE, HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
jsonObject.put(Keys.MSG, "Gets data failed[errorMsg=" + e.getMessage() + "]");
} finally {
repository.setCacheEnabled(cacheEnabled);
}
}