Fix HTTP Error 500 issue on the role edit page

feature/appm-store/pbac
Ruwan Liyanage 5 years ago committed by Dharmakeerthi Lasantha
parent 369a6def21
commit d5976deed8

@ -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