Search in sources :

Example 1 with ProjectRolePermissionResponse

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

the class ListProjectRolePermissionsCmd method setupResponse.

private ProjectRolePermissionResponse setupResponse(ProjectRole role, ProjectRolePermission rolePermission) {
    final ProjectRolePermissionResponse rolePermissionResponse = new ProjectRolePermissionResponse();
    rolePermissionResponse.setProjectId(_projectService.getProject(rolePermission.getProjectId()).getUuid());
    rolePermissionResponse.setProjectRoleId(role.getUuid());
    rolePermissionResponse.setProjectRoleName(role.getName());
    rolePermissionResponse.setId(rolePermission.getUuid());
    rolePermissionResponse.setRule(rolePermission.getRule());
    rolePermissionResponse.setRulePermission(rolePermission.getPermission());
    rolePermissionResponse.setDescription(rolePermission.getDescription());
    rolePermissionResponse.setObjectName("projectrolepermission");
    return rolePermissionResponse;
}
Also used : ProjectRolePermissionResponse(org.apache.cloudstack.api.response.ProjectRolePermissionResponse)

Example 2 with ProjectRolePermissionResponse

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

the class ListProjectRolePermissionsCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    List<ProjectRolePermission> projectRolePermissions = projRoleService.findAllProjectRolePermissions(getProjectId(), getProjectRoleId());
    final ProjectRole projectRole = projRoleService.findProjectRole(getProjectRoleId(), getProjectId());
    final ListResponse<ProjectRolePermissionResponse> response = new ListResponse<>();
    final List<ProjectRolePermissionResponse> rolePermissionResponses = new ArrayList<>();
    for (final ProjectRolePermission rolePermission : projectRolePermissions) {
        ProjectRole role = projectRole;
        if (role == null) {
            role = projRoleService.findProjectRole(rolePermission.getProjectRoleId(), rolePermission.getProjectId());
        }
        rolePermissionResponses.add(setupResponse(role, rolePermission));
    }
    response.setResponses(rolePermissionResponses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ProjectRolePermission(org.apache.cloudstack.acl.ProjectRolePermission) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ProjectRolePermissionResponse(org.apache.cloudstack.api.response.ProjectRolePermissionResponse) ProjectRole(org.apache.cloudstack.acl.ProjectRole)

Example 3 with ProjectRolePermissionResponse

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

the class CreateProjectRolePermissionCmd method setupResponse.

private void setupResponse(final ProjectRolePermission rolePermission, final ProjectRole role) {
    final ProjectRolePermissionResponse response = new ProjectRolePermissionResponse();
    response.setId(rolePermission.getUuid());
    response.setProjectId(_projectService.getProject(rolePermission.getProjectId()).getUuid());
    response.setProjectRoleId(role.getUuid());
    response.setRule(rolePermission.getRule());
    response.setRulePermission(rolePermission.getPermission());
    response.setDescription(rolePermission.getDescription());
    response.setResponseName(getCommandName());
    response.setObjectName("projectrolepermission");
    setResponseObject(response);
}
Also used : ProjectRolePermissionResponse(org.apache.cloudstack.api.response.ProjectRolePermissionResponse)

Aggregations

ProjectRolePermissionResponse (org.apache.cloudstack.api.response.ProjectRolePermissionResponse)3 ArrayList (java.util.ArrayList)1 ProjectRole (org.apache.cloudstack.acl.ProjectRole)1 ProjectRolePermission (org.apache.cloudstack.acl.ProjectRolePermission)1 ListResponse (org.apache.cloudstack.api.response.ListResponse)1