dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32060
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16385: add new endpoint for inbox, now can use /me/inbox, /me/inbox/messageConversations, /me/inbox/inte...
------------------------------------------------------------
revno: 16385
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-08-12 12:33:41 +0700
message:
add new endpoint for inbox, now can use /me/inbox, /me/inbox/messageConversations, /me/inbox/interpretations
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-09 14:36:38 +0000
+++ 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
@@ -29,21 +29,8 @@
*/
import org.apache.commons.collections.CollectionUtils;
+import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.dataelement.DataElement;
-import org.hisp.dhis.webapi.controller.exception.FilterTooShortException;
-import org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException;
-import org.hisp.dhis.webapi.utils.ContextUtils;
-import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
-import org.hisp.dhis.webapi.utils.FormUtils;
-import org.hisp.dhis.webapi.webdomain.FormDataSet;
-import org.hisp.dhis.webapi.webdomain.FormOrganisationUnit;
-import org.hisp.dhis.webapi.webdomain.FormProgram;
-import org.hisp.dhis.webapi.webdomain.Forms;
-import org.hisp.dhis.webapi.webdomain.user.Dashboard;
-import org.hisp.dhis.webapi.webdomain.user.Inbox;
-import org.hisp.dhis.webapi.webdomain.user.Recipients;
-import org.hisp.dhis.webapi.webdomain.user.UserAccount;
-import org.hisp.dhis.common.view.DetailedView;
import org.hisp.dhis.dataset.DataSet;
import org.hisp.dhis.dataset.DataSetService;
import org.hisp.dhis.dxf2.utils.JacksonUtils;
@@ -63,6 +50,19 @@
import org.hisp.dhis.user.UserGroupService;
import org.hisp.dhis.user.UserService;
import org.hisp.dhis.user.UserSettingService;
+import org.hisp.dhis.webapi.controller.exception.FilterTooShortException;
+import org.hisp.dhis.webapi.controller.exception.NotAuthenticatedException;
+import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.ContextUtils.CacheStrategy;
+import org.hisp.dhis.webapi.utils.FormUtils;
+import org.hisp.dhis.webapi.webdomain.FormDataSet;
+import org.hisp.dhis.webapi.webdomain.FormOrganisationUnit;
+import org.hisp.dhis.webapi.webdomain.FormProgram;
+import org.hisp.dhis.webapi.webdomain.Forms;
+import org.hisp.dhis.webapi.webdomain.user.Dashboard;
+import org.hisp.dhis.webapi.webdomain.user.Inbox;
+import org.hisp.dhis.webapi.webdomain.user.Recipients;
+import org.hisp.dhis.webapi.webdomain.user.UserAccount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
@@ -155,13 +155,41 @@
}
Inbox inbox = new Inbox();
- inbox.setMessageConversations( new ArrayList<MessageConversation>( messageService.getMessageConversations( 0, MAX_OBJECTS ) ) );
- inbox.setInterpretations( new ArrayList<Interpretation>( interpretationService.getInterpretations( 0, MAX_OBJECTS ) ) );
+ inbox.setMessageConversations( new ArrayList<>( messageService.getMessageConversations( 0, MAX_OBJECTS ) ) );
+ inbox.setInterpretations( new ArrayList<>( interpretationService.getInterpretations( 0, MAX_OBJECTS ) ) );
response.setContentType( MediaType.APPLICATION_JSON_VALUE );
JacksonUtils.toJson( response.getOutputStream(), inbox );
}
+ @RequestMapping( value = "/inbox/messageConversations", produces = { "application/json", "text/*" } )
+ public void getInboxMessageConversations( HttpServletResponse response ) throws Exception
+ {
+ User currentUser = currentUserService.getCurrentUser();
+
+ if ( currentUser == null )
+ {
+ throw new NotAuthenticatedException();
+ }
+
+ response.setContentType( MediaType.APPLICATION_JSON_VALUE );
+ JacksonUtils.toJson( response.getOutputStream(), new ArrayList<>( messageService.getMessageConversations( 0, MAX_OBJECTS ) ) );
+ }
+
+ @RequestMapping( value = "/inbox/interpretations", produces = { "application/json", "text/*" } )
+ public void getInboxInterpretations( HttpServletResponse response ) throws Exception
+ {
+ User currentUser = currentUserService.getCurrentUser();
+
+ if ( currentUser == null )
+ {
+ throw new NotAuthenticatedException();
+ }
+
+ response.setContentType( MediaType.APPLICATION_JSON_VALUE );
+ JacksonUtils.toJson( response.getOutputStream(), new ArrayList<>( interpretationService.getInterpretations( 0, MAX_OBJECTS ) ) );
+ }
+
@RequestMapping( value = "/dashboard", produces = { "application/json", "text/*" } )
public void getDashboard( HttpServletResponse response ) throws Exception
{