From 5b96e1b849e44a4712679385ca7e77ad9e930456 Mon Sep 17 00:00:00 2001 From: Megala Date: Wed, 12 Oct 2016 09:38:11 +0530 Subject: [PATCH 1/3] Fixing EMM-1333 --- .../service/impl/RoleManagementServiceImpl.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index 6cae3ad776..22499f79ce 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -135,7 +135,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { final UserRealmProxy userRealmProxy = new UserRealmProxy(userRealmCore); final UIPermissionNode rolePermissions = userRealmProxy.getRolePermissions(roleName, MultitenantConstants.SUPER_TENANT_ID); - UIPermissionNode[] deviceMgtPermissions = new UIPermissionNode[2]; + UIPermissionNode[] deviceMgtPermissions = new UIPermissionNode[4]; for (UIPermissionNode permissionNode : rolePermissions.getNodeList()) { if (permissionNode.getResourcePath().equals("/permission/admin")) { @@ -144,6 +144,16 @@ public class RoleManagementServiceImpl implements RoleManagementService { deviceMgtPermissions[0] = node; } else if (node.getResourcePath().equals("/permission/admin/login")) { deviceMgtPermissions[1] = node; + } else if (node.getResourcePath().equals("/permission/admin/manage")) { + // Adding permissions related to app-store in emm-console + for (UIPermissionNode subNode : node.getNodeList()) { + if (subNode.getResourcePath().equals("/permission/admin/manage/mobileapp")) { + deviceMgtPermissions[2] = subNode; + } + if (subNode.getResourcePath().equals("/permission/admin/manage/webapp")) { + deviceMgtPermissions[3] = subNode; + } + } } } } From 4999b841691d1f6e0b5c47952c5859ac78eeea78 Mon Sep 17 00:00:00 2001 From: Megala Date: Wed, 12 Oct 2016 09:41:43 +0530 Subject: [PATCH 2/3] Reformatting code --- .../mgt/jaxrs/service/impl/RoleManagementServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java index 22499f79ce..bfc767b8cd 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/RoleManagementServiceImpl.java @@ -149,8 +149,7 @@ public class RoleManagementServiceImpl implements RoleManagementService { for (UIPermissionNode subNode : node.getNodeList()) { if (subNode.getResourcePath().equals("/permission/admin/manage/mobileapp")) { deviceMgtPermissions[2] = subNode; - } - if (subNode.getResourcePath().equals("/permission/admin/manage/webapp")) { + } else if (subNode.getResourcePath().equals("/permission/admin/manage/webapp")) { deviceMgtPermissions[3] = subNode; } } From 0498c68ca56e948ca03ebff2fa613409018fc62e Mon Sep 17 00:00:00 2001 From: charitha Date: Wed, 12 Oct 2016 12:55:59 +0530 Subject: [PATCH 3/3] Add validation to maximum limit value (cherry picked from commit 4ed757f) --- .../mgt/jaxrs/service/impl/util/RequestValidationUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java index 603cbe2005..00c7a503e2 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.api/src/main/java/org/wso2/carbon/device/mgt/jaxrs/service/impl/util/RequestValidationUtil.java @@ -337,10 +337,10 @@ public class RequestValidationUtil { new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter limit is a " + "negative value.").build()); } - if (limit - offset > 100) { + if (limit > 100) { throw new InputValidationException( - new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request results list should" + - " be less than or equal 100 values.").build()); + new ErrorResponse.ErrorResponseBuilder().setCode(400l).setMessage("Request parameter limit should" + + " be less than or equal to 100.").build()); } }