public Short getAccountType() { return RoleType.getAccountTypeByRole(roleService.findRole(roleId), accountType); }
@Override public void execute() { List<Role> roles; if (getId() != null && getId() > 0L) { roles = Collections.singletonList(roleService.findRole(getId())); } else if (StringUtils.isNotBlank(getName())) { roles = roleService.findRolesByName(getName()); } else if (getRoleType() != null) { roles = roleService.findRolesByType(getRoleType()); } else { roles = roleService.listRoles(); } setupResponse(roles); } }
@Override public void execute() { final Role role = roleService.findRole(getRoleId()); boolean result = false; if (role == null) {
public Short getAccountType() { return RoleType.getAccountTypeByRole(roleService.findRole(roleId), accountType); }
public Short getAccountType() { return RoleType.getAccountTypeByRole(roleService.findRole(roleId), accountType); }
@Test public void testUpdateSuccess() { when(roleService.findRole(updateRoleCmd.getRoleId())).thenReturn(role); when(role.getId()).thenReturn(1L); when(role.getUuid()).thenReturn("12345-abcgdkajd"); when(role.getDescription()).thenReturn("Defualt user"); when(role.getName()).thenReturn("User"); when(role.getRoleType()).thenReturn(RoleType.User); when(roleService.updateRole(role,updateRoleCmd.getRoleName(),updateRoleCmd.getRoleType(),updateRoleCmd.getRoleDescription())).thenReturn(role); when(role.getId()).thenReturn(1L); when(role.getDescription()).thenReturn("Description Initial"); when(role.getName()).thenReturn("User"); updateRoleCmd.execute(); RoleResponse response = (RoleResponse) updateRoleCmd.getResponseObject(); assertEquals((String)ReflectionTestUtils.getField(response, "roleName"),role.getName()); assertEquals((String)ReflectionTestUtils.getField(response, "roleDescription"),role.getDescription()); } }
private void setupResponse(final List<RolePermission> rolePermissions, final Long roleId) { final Role roleProvided = roleService.findRole(roleId); final ListResponse<RolePermissionResponse> response = new ListResponse<>(); final List<RolePermissionResponse> rolePermissionResponses = new ArrayList<>(); for (final RolePermission rolePermission : rolePermissions) { final RolePermissionResponse rolePermissionResponse = new RolePermissionResponse(); Role role = roleProvided; if (role == null) { role = roleService.findRole(rolePermission.getRoleId()); } rolePermissionResponse.setRoleId(role.getUuid()); rolePermissionResponse.setRoleName(role.getName()); rolePermissionResponse.setId(rolePermission.getUuid()); rolePermissionResponse.setRule(rolePermission.getRule()); rolePermissionResponse.setRulePermission(rolePermission.getPermission()); rolePermissionResponse.setDescription(rolePermission.getDescription()); rolePermissionResponse.setObjectName("rolepermission"); rolePermissionResponses.add(rolePermissionResponse); } response.setResponses(rolePermissionResponses); response.setResponseName(getCommandName()); setResponseObject(response); }
public static AccountResponse newAccountResponse(ResponseView view, AccountJoinVO ve) { AccountResponse response = s_accountJoinDao.newAccountResponse(view, ve); // Populate account role information if (ve.getRoleId() != null) { Role role = s_roleService.findRole(ve.getRoleId()); if (role != null) { response.setRoleId(role.getUuid()); response.setRoleType(role.getRoleType()); response.setRoleName(role.getName()); } } return response; }
@Override public void execute() { Role role = roleService.findRole(getRoleId()); if (role == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Cannot find the role with provided id"); } CallContext.current().setEventDetails("Role id: " + role.getId()); boolean result = roleService.deleteRole(role); SuccessResponse response = new SuccessResponse(getCommandName()); response.setSuccess(result); setResponseObject(response); } }
@Override public void execute() { Role role = roleService.findRole(getRoleId()); if (role == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided"); } CallContext.current().setEventDetails("Role: " + getRoleName() + ", type:" + getRoleType() + ", description: " + getRoleDescription()); role = roleService.updateRole(role, getRoleName(), getRoleType(), getRoleDescription()); setupResponse(role); } }
@Override public void execute() { final Role role = roleService.findRole(getRoleId()); if (role == null) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Invalid role id provided"); } CallContext.current().setEventDetails("Role id: " + role.getId() + ", rule:" + getRule() + ", permission: " + getPermission() + ", description: " + getDescription()); final RolePermission rolePermission = roleService.createRolePermission(role, getRule(), getPermission(), getDescription()); if (rolePermission == null) { throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create role permission"); } setupResponse(rolePermission, role); } }
final Role accountRole = roleService.findRole(account.getRoleId()); if (accountRole == null || accountRole.getId() < 1L) { denyApiAccess(commandName);
public static UserResponse newUserResponse(UserAccountJoinVO usr, Long domainId) { UserResponse response = s_userAccountJoinDao.newUserResponse(usr); if(!AccountManager.UseSecretKeyInResponse.value()){ response.setSecretKey(null); } // Populate user account role information if (usr.getAccountRoleId() != null) { Role role = s_roleService.findRole( usr.getAccountRoleId()); if (role != null) { response.setRoleId(role.getUuid()); response.setRoleType(role.getRoleType()); response.setRoleName(role.getName()); } } if (domainId != null && usr.getDomainId() != domainId) response.setIsCallerChildDomain(true); else response.setIsCallerChildDomain(false); return response; }