=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java 2014-11-05 23:28:41 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/MessageConversationController.java 2014-11-05 23:33:26 +0000 @@ -109,9 +109,9 @@ public RootNode getObject( @PathVariable String uid, Map parameters, HttpServletRequest request, HttpServletResponse response ) throws Exception { - org.hisp.dhis.message.MessageConversation messageConversationConversation = messageService.getMessageConversation( uid ); + org.hisp.dhis.message.MessageConversation messageConversation = messageService.getMessageConversation( uid ); - if( messageConversationConversation == null ) + if( messageConversation == null ) { response.setStatus( HttpServletResponse.SC_NOT_FOUND ); RootNode responseNode = new RootNode( "reply" ); @@ -119,7 +119,7 @@ return responseNode; } - if( !canReadMessageConversation( currentUserService.getCurrentUser(), messageConversationConversation ) ) + if( !canReadMessageConversation( currentUserService.getCurrentUser(), messageConversation ) ) { throw new AccessDeniedException( "Not authorized to access this conversation." ); } @@ -294,9 +294,9 @@ throw new UpdateAccessDeniedException( "Not authorized to modify this object." ); } - Collection messageConversationConversations = messageService.getMessageConversations( uids ); + Collection messageConversations = messageService.getMessageConversations( uids ); - if ( messageConversationConversations.isEmpty() ) + if ( messageConversations.isEmpty() ) { response.setStatus( HttpServletResponse.SC_NOT_FOUND ); responseNode.addChild( new SimpleNode( "message", "No MessageConversations found for the given UIDs." ) ); @@ -306,7 +306,7 @@ CollectionNode marked = responseNode.addChild( new CollectionNode( "markedRead" ) ); marked.setWrapping( false ); - for( org.hisp.dhis.message.MessageConversation conversation : messageConversationConversations ) + for( org.hisp.dhis.message.MessageConversation conversation : messageConversations ) { if( conversation.markRead( user ) ) { @@ -345,9 +345,9 @@ throw new UpdateAccessDeniedException( "Not authorized to modify this object." ); } - Collection messageConversationConversations = messageService.getMessageConversations( uids ); + Collection messageConversations = messageService.getMessageConversations( uids ); - if ( messageConversationConversations.isEmpty() ) + if ( messageConversations.isEmpty() ) { response.setStatus( HttpServletResponse.SC_NOT_FOUND ); responseNode.addChild( new SimpleNode( "message", "No MessageConversations found for the given UIDs." ) ); @@ -357,7 +357,7 @@ CollectionNode marked = responseNode.addChild( new CollectionNode( "markedUnread" ) ); marked.setWrapping( false ); - for( org.hisp.dhis.message.MessageConversation conversation : messageConversationConversations ) + for( org.hisp.dhis.message.MessageConversation conversation : messageConversations ) { if( conversation.markUnread( user ) ) { @@ -416,9 +416,9 @@ throw new DeleteAccessDeniedException( "Not authorized to modify user: " + user.getUid() ); } - org.hisp.dhis.message.MessageConversation messageConversationConversation = messageService.getMessageConversation( mcUid ); + org.hisp.dhis.message.MessageConversation messageConversation = messageService.getMessageConversation( mcUid ); - if( messageConversationConversation == null ) + if( messageConversation == null ) { responseNode.addChild( new SimpleNode( "message", "No messageConversation with uid: " + mcUid ) ); response.setStatus( HttpServletResponse.SC_NOT_FOUND ); @@ -427,10 +427,10 @@ CollectionNode removed = responseNode.addChild( new CollectionNode( "removed" ) ); - if( messageConversationConversation.remove( user ) ) + if( messageConversation.remove( user ) ) { - messageService.updateMessageConversation( messageConversationConversation ); - removed.addChild( new SimpleNode( "uid", messageConversationConversation.getUid() ) ); + messageService.updateMessageConversation( messageConversation ); + removed.addChild( new SimpleNode( "uid", messageConversation.getUid() ) ); } response.setStatus( HttpServletResponse.SC_OK ); @@ -465,9 +465,9 @@ throw new DeleteAccessDeniedException( "Not authorized to modify user: " + user.getUid() ); } - Collection messageConversationConversations = messageService.getMessageConversations( mcUids ); + Collection messageConversations = messageService.getMessageConversations( mcUids ); - if( messageConversationConversations.isEmpty() ) + if( messageConversations.isEmpty() ) { response.setStatus( HttpServletResponse.SC_NOT_FOUND ); responseNode.addChild( new SimpleNode( "message", "No MessageConversations found for the given UIDs." ) ); @@ -476,7 +476,7 @@ CollectionNode removed = responseNode.addChild( new CollectionNode( "removed" ) ); - for( org.hisp.dhis.message.MessageConversation mc : messageConversationConversations ) + for( org.hisp.dhis.message.MessageConversation mc : messageConversations ) { if( mc.remove( user ) ) { @@ -515,11 +515,11 @@ * Determines whether the given user has permission to read the MessageConversation. * * @param user the user to check permission for. - * @param messageConversationConversation the MessageConversation to access. + * @param messageConversation the MessageConversation to access. * @return true if the user can read the MessageConversation, false otherwise. */ - private boolean canReadMessageConversation( User user, org.hisp.dhis.message.MessageConversation messageConversationConversation ) + private boolean canReadMessageConversation( User user, org.hisp.dhis.message.MessageConversation messageConversation ) { - return messageConversationConversation.getUsers().contains( user ) || user.getUserCredentials().hasAnyAuthority( AclService.ACL_OVERRIDE_AUTHORITIES ); + return messageConversation.getUsers().contains( user ) || user.getUserCredentials().hasAnyAuthority( AclService.ACL_OVERRIDE_AUTHORITIES ); } }