------------------------------------------------------------ revno: 16386 committer: Morten Olav Hansen <morte...@gmail.com> branch nick: dhis2 timestamp: Tue 2014-08-12 13:42:44 +0700 message: add new me endpoint, /api/me/dashboards defaults to viewClass = detailed (so clients can get full info in one request) modified: dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java
-- lp:dhis2 https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk Your team DHIS 2 developers is subscribed to branch lp:dhis2. To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java 2014-08-12 05:33:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/CurrentUserController.java 2014-08-12 06:42:44 +0000 @@ -28,16 +28,17 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +import com.google.common.collect.Lists; +import com.google.common.collect.Maps; import org.apache.commons.collections.CollectionUtils; +import org.hisp.dhis.common.IdentifiableObjectManager; import org.hisp.dhis.common.view.DetailedView; import org.hisp.dhis.dataelement.DataElement; import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.DataSetService; import org.hisp.dhis.dxf2.utils.JacksonUtils; import org.hisp.dhis.i18n.I18nService; -import org.hisp.dhis.interpretation.Interpretation; import org.hisp.dhis.interpretation.InterpretationService; -import org.hisp.dhis.message.MessageConversation; import org.hisp.dhis.message.MessageService; import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; @@ -128,6 +129,9 @@ private ContextUtils contextUtils; @Autowired + private IdentifiableObjectManager manager; + + @Autowired private I18nService i18nService; @RequestMapping( produces = { "application/json", "text/*" } ) @@ -144,6 +148,24 @@ JacksonUtils.toJsonWithView( response.getOutputStream(), currentUser, DetailedView.class ); } + @RequestMapping( value = "/dashboards", produces = { "application/json", "text/*" } ) + public void getDashboards( HttpServletResponse response ) throws NotAuthenticatedException, IOException + { + User currentUser = currentUserService.getCurrentUser(); + + if ( currentUser == null ) + { + throw new NotAuthenticatedException(); + } + + Map<String, List<?>> output = Maps.newHashMap(); + List<org.hisp.dhis.dashboard.Dashboard> dashboards = Lists.newArrayList( manager.getAll( org.hisp.dhis.dashboard.Dashboard.class ) ); + output.put( "dashboards", dashboards ); + + response.setContentType( MediaType.APPLICATION_JSON_VALUE ); + JacksonUtils.toJsonWithView( response.getOutputStream(), output, DetailedView.class ); + } + @RequestMapping( value = "/inbox", produces = { "application/json", "text/*" } ) public void getInbox( HttpServletResponse response ) throws Exception {
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp