dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #38452
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19586: update UserRoleController to use WebMessage
------------------------------------------------------------
revno: 19586
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-07-08 15:31:17 +0700
message:
update UserRoleController to use WebMessage
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitLocationController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.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/organisationunit/OrganisationUnitLocationController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitLocationController.java 2015-06-16 10:36:25 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/organisationunit/OrganisationUnitLocationController.java 2015-07-08 08:31:17 +0000
@@ -30,13 +30,13 @@
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.AttributeValue;
+import org.hisp.dhis.commons.filter.FilterUtils;
import org.hisp.dhis.dxf2.common.JacksonUtils;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitGroup;
import org.hisp.dhis.organisationunit.OrganisationUnitGroupSet;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.system.filter.OrganisationUnitPolygonCoveringCoordinateFilter;
-import org.hisp.dhis.commons.filter.FilterUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java 2015-02-20 09:14:02 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/user/UserRoleController.java 2015-07-08 08:31:17 +0000
@@ -28,6 +28,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.dxf2.webmessage.WebMessageException;
import org.hisp.dhis.hibernate.exception.DeleteAccessDeniedException;
import org.hisp.dhis.hibernate.exception.UpdateAccessDeniedException;
import org.hisp.dhis.query.Order;
@@ -36,7 +37,7 @@
import org.hisp.dhis.user.UserAuthorityGroup;
import org.hisp.dhis.user.UserService;
import org.hisp.dhis.webapi.controller.AbstractCrudController;
-import org.hisp.dhis.webapi.utils.ContextUtils;
+import org.hisp.dhis.webapi.utils.WebMessageUtils;
import org.hisp.dhis.webapi.webdomain.WebMetaData;
import org.hisp.dhis.webapi.webdomain.WebOptions;
import org.springframework.beans.factory.annotation.Autowired;
@@ -73,22 +74,20 @@
}
@RequestMapping( value = "/{id}/users/{userId}", method = { RequestMethod.POST, RequestMethod.PUT } )
- public void addUserToRole( @PathVariable( value = "id" ) String pvId, @PathVariable( "userId" ) String pvUserId, HttpServletResponse response )
+ public void addUserToRole( @PathVariable( value = "id" ) String pvId, @PathVariable( "userId" ) String pvUserId, HttpServletResponse response ) throws WebMessageException
{
UserAuthorityGroup userAuthorityGroup = userService.getUserAuthorityGroup( pvId );
if ( userAuthorityGroup == null )
{
- ContextUtils.notFoundResponse( response, "UserRole does not exist: " + pvId );
- return;
+ throw new WebMessageException( WebMessageUtils.notFound( "UserRole does not exist: " + pvId ) );
}
User user = userService.getUser( pvUserId );
if ( user == null )
{
- ContextUtils.notFoundResponse( response, "User does not exist: " + pvId );
- return;
+ throw new WebMessageException( WebMessageUtils.notFound( "User does not exist: " + pvId ) );
}
if ( !aclService.canUpdate( currentUserService.getCurrentUser(), userAuthorityGroup ) )
@@ -106,22 +105,20 @@
}
@RequestMapping( value = "/{id}/users/{userId}", method = RequestMethod.DELETE )
- public void removeUserFromRole( @PathVariable( value = "id" ) String pvId, @PathVariable( "userId" ) String pvUserId, HttpServletResponse response )
+ public void removeUserFromRole( @PathVariable( value = "id" ) String pvId, @PathVariable( "userId" ) String pvUserId, HttpServletResponse response ) throws WebMessageException
{
UserAuthorityGroup userAuthorityGroup = userService.getUserAuthorityGroup( pvId );
if ( userAuthorityGroup == null )
{
- ContextUtils.notFoundResponse( response, "UserRole does not exist: " + pvId );
- return;
+ throw new WebMessageException( WebMessageUtils.notFound( "UserRole does not exist: " + pvId ) );
}
User user = userService.getUser( pvUserId );
if ( user == null || user.getUserCredentials() == null )
{
- ContextUtils.notFoundResponse( response, "User does not exist: " + pvId );
- return;
+ throw new WebMessageException( WebMessageUtils.notFound( "User does not exist: " + pvId ) );
}
if ( !aclService.canUpdate( currentUserService.getCurrentUser(), userAuthorityGroup ) )