Guest User

Untitled

a guest
Jan 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. @RequestMapping(params = "action=get_role_permissions")
  2. @PreAuthorize("hasRole('ROLE_USER_READER')")
  3. public
  4. @ResponseBody
  5. JsonResponse getUserRolePermissions(@RequestParam("id") Long userRoleId,
  6. @RequestParam String language)
  7. throws InvalidBusinessOperationException {
  8.  
  9. try {
  10. //get user role view
  11. UserRoleView role = userRoleService.getViewById(userRoleId, language);
  12. boolean isAdmin = UserRoleService.userAdminID.equals(userRoleId);
  13.  
  14. //get role permission rules
  15. Map<Long, UserPermissionRuleView> rules = role.getRules();
  16.  
  17. //build form json from view
  18. List<UserPermissionRuleJson> data = settingsAssembler.buildUserPermissionRuleJson(rules.values(), !isAdmin);
  19.  
  20. return new SuccessResponse(data);
  21. } catch (EntityNotFoundException e) {
  22. throw new InvalidBusinessOperationException(getErrorMessage("error.business.notfound.role"), e);
  23. }
  24. }
Add Comment
Please, Sign In to add comment