Merge branch 'master' into 'master'

Fix HTTP Error 500 issue on the role edit page

See merge request entgra/carbon-device-mgt!387
feature/appm-store/pbac
Dharmakeerthi Lasantha 5 years ago
commit 8ddd50f1ed

@ -253,23 +253,37 @@ public class RoleManagementServiceImpl implements RoleManagementService {
roleInfo.setPermissionList(rolePermissions); roleInfo.setPermissionList(rolePermissions);
String[] permListAr = new String[permList.size()]; String[] permListAr = new String[permList.size()];
roleInfo.setPermissions(permList.toArray(permListAr)); roleInfo.setPermissions(permList.toArray(permListAr));
return Response.status(Response.Status.OK).entity(roleInfo).build(); return Response.status(Response.Status.OK).entity(roleInfo).build();
} catch (UserStoreException | UserAdminException e) { } catch (UserAdminException e) {
String msg = "Error occurred while retrieving the user role '" + roleName + "'"; String msg = "Error occurred due to Unable to retrieve user role'" + roleName + "'";
log.error(msg, e); log.error(msg, e);
return Response.serverError().entity( return Response.serverError()
new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); .entity(new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build())
.build();
} catch (UserStoreException e) {
String msg = "Error occurred while retrieving the UserStoreManager of the user role '"
+ roleName + "'";
log.error(msg, e);
return Response.serverError()
.entity(new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build())
.build();
} }
} }
private List<String> iteratePermissions(UIPermissionNode uiPermissionNode, List<String> list) { private List<String> iteratePermissions(UIPermissionNode uiPermissionNode, List<String> list) {
//To prevent NullPointer exceptions
if (uiPermissionNode == null) {
return list;
}
for (UIPermissionNode permissionNode : uiPermissionNode.getNodeList()) { for (UIPermissionNode permissionNode : uiPermissionNode.getNodeList()) {
if (permissionNode != null) {
list.add(permissionNode.getResourcePath()); list.add(permissionNode.getResourcePath());
if (permissionNode.getNodeList() != null && permissionNode.getNodeList().length > 0) { if (permissionNode.getNodeList() != null
&& permissionNode.getNodeList().length > 0) {
iteratePermissions(permissionNode, list); iteratePermissions(permissionNode, list);
} }
} }
}
return list; return list;
} }

Loading…
Cancel
Save