Search in sources :

Example 16 with NotAuthenticatedException

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);
}
Also used : User(org.hisp.dhis.user.User) NotAuthenticatedException(org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException) Dashboard(org.hisp.dhis.webapi.webdomain.user.Dashboard) DashboardItem(org.hisp.dhis.dashboard.DashboardItem) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

NotAuthenticatedException (org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException)16 User (org.hisp.dhis.user.User)12 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)3 CollectionNode (org.hisp.dhis.node.types.CollectionNode)3 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)3 FormOrganisationUnit (org.hisp.dhis.webapi.webdomain.FormOrganisationUnit)3 Dashboard (org.hisp.dhis.webapi.webdomain.user.Dashboard)3 List (java.util.List)2 Interpretation (org.hisp.dhis.interpretation.Interpretation)2 MessageConversation (org.hisp.dhis.message.MessageConversation)2 RootNode (org.hisp.dhis.node.types.RootNode)2 Forms (org.hisp.dhis.webapi.webdomain.Forms)2 UserAccount (org.hisp.dhis.webapi.webdomain.user.UserAccount)2 Serializable (java.io.Serializable)1 HashMap (java.util.HashMap)1 DashboardItem (org.hisp.dhis.dashboard.DashboardItem)1 DataElement (org.hisp.dhis.dataelement.DataElement)1 DataSet (org.hisp.dhis.dataset.DataSet)1