Fixed issues in RoleManagementService

revert-70aa11f8
mharindu 9 years ago
parent d65174d026
commit ce557266ec

@ -170,6 +170,10 @@ public class RoleManagementServiceImpl implements RoleManagementService {
@POST @POST
@Override @Override
public Response addRole(RoleWrapper roleWrapper) { public Response addRole(RoleWrapper roleWrapper) {
if (roleWrapper == null) {
log.error("Request body is incorrect or empty");
return Response.status(Response.Status.BAD_REQUEST).build();
}
try { try {
UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -197,6 +201,10 @@ public class RoleManagementServiceImpl implements RoleManagementService {
@Path("/{roleName}") @Path("/{roleName}")
@Override @Override
public Response updateRole(@PathParam("roleName") String roleName, RoleWrapper roleWrapper) { public Response updateRole(@PathParam("roleName") String roleName, RoleWrapper roleWrapper) {
if (roleWrapper == null) {
log.error("Request body is incorrect or empty");
return Response.status(Response.Status.BAD_REQUEST).build();
}
String newRoleName = roleWrapper.getRoleName(); String newRoleName = roleWrapper.getRoleName();
try { try {
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
@ -256,10 +264,14 @@ public class RoleManagementServiceImpl implements RoleManagementService {
return Response.status(Response.Status.OK).build(); return Response.status(Response.Status.OK).build();
} }
@POST @PUT
@Path("/{roleName}/users") @Path("/{roleName}/users")
@Override @Override
public Response updateUsersOfRole(@PathParam("roleName") String roleName, List<String> users) { public Response updateUsersOfRole(@PathParam("roleName") String roleName, List<String> users) {
if (users == null || users.size() == 0) {
log.error("No users are found");
return Response.status(Response.Status.BAD_REQUEST).build();
}
try { try {
final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager(); final UserStoreManager userStoreManager = DeviceMgtAPIUtils.getUserStoreManager();
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {

@ -460,7 +460,7 @@
<Permission> <Permission>
<name>List roles</name> <name>List roles</name>
<path>/device-mgt/admin/roles/list</path> <path>/device-mgt/admin/roles/list</path>
<url>/roles/permissions</url> <url>/roles/*/permissions</url>
<method>GET</method> <method>GET</method>
</Permission> </Permission>
@ -481,22 +481,14 @@
<Permission> <Permission>
<name>Update role</name> <name>Update role</name>
<path>/device-mgt/admin/roles/update</path> <path>/device-mgt/admin/roles/update</path>
<url>/roles</url> <url>/roles/*</url>
<method>PUT</method> <method>PUT</method>
</Permission> </Permission>
<!--<Permission>-->
<!--<name>Update a specific role</name>-->
<!--<path>/device-mgt/roles/update</path>-->
<!--<url>/roles/*</url>-->
<!--<method>PUT</method>-->
<!---->
<!--</Permission>-->
<Permission> <Permission>
<name>Update role</name> <name>Update role</name>
<path>/device-mgt/admin/roles/update</path> <path>/device-mgt/admin/roles/update</path>
<url>/roles/users</url> <url>/roles/*/users</url>
<method>PUT</method> <method>PUT</method>
</Permission> </Permission>
@ -510,7 +502,7 @@
<Permission> <Permission>
<name>Remove role</name> <name>Remove role</name>
<path>/device-mgt/admin/roles/remove</path> <path>/device-mgt/admin/roles/remove</path>
<url>/roles</url> <url>/roles/*</url>
<method>DELETE</method> <method>DELETE</method>
</Permission> </Permission>

Loading…
Cancel
Save