* @throws Exception exception
*/
@RequestProcessing(value = USERS_URI_PREFIX + Requests.PAGINATION_PATH_PATTERN, method = HTTPRequestMethod.GET)
public void getUsers(final HttpServletRequest request, final HttpServletResponse response, final HTTPRequestContext context)
throws Exception {
final JSONRenderer renderer = new JSONRenderer();
context.setRenderer(renderer);
if (!userUtils.isAdminLoggedIn(request)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN);
return;
}
try {
final String requestURI = request.getRequestURI();
final String path = requestURI.substring((Latkes.getContextPath() + USERS_URI_PREFIX).length());
final JSONObject requestJSONObject = Requests.buildPaginationRequest(path);
final JSONObject result = userQueryService.getUsers(requestJSONObject);
result.put(Keys.STATUS_CODE, true);
renderer.setJSONObject(result);
} catch (final ServiceException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
final JSONObject jsonObject = QueryResults.defaultResult();
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
}
}