@Override public Privilege findPrivilege(String id) { return identityService.createPrivilegeQuery().privilegeId(id).singleResult(); }
protected Privilege getPrivilegeById(String privilegeId) { Privilege privilege = identityService.createPrivilegeQuery().privilegeId(privilegeId).singleResult(); if (privilege == null) { throw new FlowableObjectNotFoundException("Could not find privilege with id " + privilegeId, Privilege.class); } return privilege; } }
@ApiOperation(value = "Get a single privilege", tags = { "Privileges" }) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the privilege exists and is returned."), @ApiResponse(code = 404, message = "Indicates the requested privilege does not exist.") }) @GetMapping(value = "/privileges/{privilegeId}", produces = "application/json") public PrivilegeResponse getUser(@ApiParam(name = "privilegeId") @PathVariable String privilegeId, HttpServletRequest request) { Privilege privilege = identityService.createPrivilegeQuery().privilegeId(privilegeId).singleResult(); if (privilege == null) { throw new FlowableObjectNotFoundException("Could not find privilege with id " + privilegeId, Privilege.class); } if (restApiInterceptor != null) { restApiInterceptor.accessPrivilegeInfoById(privilege); } List<User> users = identityService.getUsersWithPrivilege(privilege.getId()); List<Group> groups = identityService.getGroupsWithPrivilege(privilege.getId()); return restResponseFactory.createPrivilegeResponse(privilege, users, groups); }
query.privilegeId(allRequestParams.get("id"));
protected boolean isUserPrivilege(String privilegeId, String userId) { User user = identityService.createUserQuery().userId(userId).singleResult(); if (user == null) { throw new IllegalArgumentException("Invalid user id"); } return identityService.createPrivilegeQuery().privilegeId(privilegeId).userId(userId).count() > 0; }
protected boolean isGroupPrivilege(String privilegeId, String groupId) { Group group = identityService.createGroupQuery().groupId(groupId).singleResult(); if (group == null) { throw new IllegalArgumentException("Invalid group id"); } return identityService.createPrivilegeQuery().privilegeId(privilegeId).groupId(groupId).count() > 0; }