Search in sources :

Example 1 with RolePermissionResponse

use of org.apache.cloudstack.api.response.RolePermissionResponse in project cloudstack by apache.

the class CreateRolePermissionCmd method setupResponse.

private void setupResponse(final RolePermission rolePermission, final Role role) {
    final RolePermissionResponse response = new RolePermissionResponse();
    response.setId(rolePermission.getUuid());
    response.setRoleId(role.getUuid());
    response.setRule(rolePermission.getRule());
    response.setRulePermission(rolePermission.getPermission());
    response.setDescription(rolePermission.getDescription());
    response.setResponseName(getCommandName());
    response.setObjectName("rolepermission");
    setResponseObject(response);
}
Also used : RolePermissionResponse(org.apache.cloudstack.api.response.RolePermissionResponse)

Example 2 with RolePermissionResponse

use of org.apache.cloudstack.api.response.RolePermissionResponse 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)

Aggregations

RolePermissionResponse (org.apache.cloudstack.api.response.RolePermissionResponse)2 ArrayList (java.util.ArrayList)1 Role (org.apache.cloudstack.acl.Role)1 RolePermission (org.apache.cloudstack.acl.RolePermission)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1