use of org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException in project dhis2-core by dhis2.
the class CurrentUserController method getDashboards.
@RequestMapping(value = "/dashboards", produces = { "application/json", "text/*" })
public void getDashboards(HttpServletResponse response) throws NotAuthenticatedException, IOException {
User user = currentUserService.getCurrentUser();
if (user == null) {
throw new NotAuthenticatedException();
}
List<org.hisp.dhis.dashboard.Dashboard> dashboards = Lists.newArrayList(manager.getAll(org.hisp.dhis.dashboard.Dashboard.class));
for (org.hisp.dhis.dashboard.Dashboard dashboard : dashboards) {
dashboard.setAccess(aclService.getAccess(dashboard, user));
for (DashboardItem dashboardItem : dashboard.getItems()) {
dashboardItem.setAccess(aclService.getAccess(dashboardItem, user));
}
}
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
renderService.toJson(response.getOutputStream(), dashboards);
}
Aggregations