Search in sources :

Example 6 with Role

use of org.apache.cloudstack.acl.Role in project cloudstack by apache.

the class ListRolePermissionsCmd method setupResponse.

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);
}
Also used : Role(org.apache.cloudstack.acl.Role) ListResponse(org.apache.cloudstack.api.response.ListResponse) RolePermissionResponse(org.apache.cloudstack.api.response.RolePermissionResponse) ArrayList(java.util.ArrayList) RolePermission(org.apache.cloudstack.acl.RolePermission)

Example 7 with Role

use of org.apache.cloudstack.acl.Role in project cloudstack by apache.

the class UpdateRoleCmd method execute.

@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());
    boolean result = roleService.updateRole(role, getRoleName(), getRoleType(), getRoleDescription());
    SuccessResponse response = new SuccessResponse(getCommandName());
    response.setSuccess(result);
    setResponseObject(response);
}
Also used : Role(org.apache.cloudstack.acl.Role) SuccessResponse(org.apache.cloudstack.api.response.SuccessResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException)

Example 8 with Role

use of org.apache.cloudstack.acl.Role in project cloudstack by apache.

the class ApiDBUtils method newUserResponse.

public static UserResponse newUserResponse(UserAccountJoinVO usr, Long domainId) {
    UserResponse response = s_userAccountJoinDao.newUserResponse(usr);
    // 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;
}
Also used : UserResponse(org.apache.cloudstack.api.response.UserResponse) Role(org.apache.cloudstack.acl.Role)

Example 9 with Role

use of org.apache.cloudstack.acl.Role in project cloudstack by apache.

the class ApiDBUtils method newAccountResponse.

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;
}
Also used : Role(org.apache.cloudstack.acl.Role) ProjectAccountResponse(org.apache.cloudstack.api.response.ProjectAccountResponse) AccountResponse(org.apache.cloudstack.api.response.AccountResponse)

Aggregations

Role (org.apache.cloudstack.acl.Role)9 ServerApiException (org.apache.cloudstack.api.ServerApiException)5 ArrayList (java.util.ArrayList)3 RolePermission (org.apache.cloudstack.acl.RolePermission)3 SuccessResponse (org.apache.cloudstack.api.response.SuccessResponse)3 ListResponse (org.apache.cloudstack.api.response.ListResponse)2 AccountResponse (org.apache.cloudstack.api.response.AccountResponse)1 ProjectAccountResponse (org.apache.cloudstack.api.response.ProjectAccountResponse)1 RolePermissionResponse (org.apache.cloudstack.api.response.RolePermissionResponse)1 RoleResponse (org.apache.cloudstack.api.response.RoleResponse)1 UserResponse (org.apache.cloudstack.api.response.UserResponse)1