Fix HTTP Error 500 issue on the role edit page

4.x.x
Ruwan Liyanage 5 years ago committed by Dharmakeerthi Lasantha
parent 369a6def21
commit d5976deed8

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

Loading…
Cancel
Save