Search in sources :

Example 1 with ProjectRoleResponse

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

the class ProjectRoleCmd method setupProjectRoleResponse.

protected void setupProjectRoleResponse(final ProjectRole role) {
    final ProjectRoleResponse response = new ProjectRoleResponse();
    response.setId(role.getUuid());
    response.setProjectId(_projectService.getProject(role.getProjectId()).getUuid());
    response.setRoleName(role.getName());
    response.setDescription(role.getDescription());
    response.setResponseName(getCommandName());
    response.setObjectName("projectrole");
    setResponseObject(response);
}
Also used : ProjectRoleResponse(org.apache.cloudstack.api.response.ProjectRoleResponse)

Example 2 with ProjectRoleResponse

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

the class ListProjectRolesCmd method setupProjectRoleResponse.

private ProjectRoleResponse setupProjectRoleResponse(final ProjectRole role) {
    final ProjectRoleResponse response = new ProjectRoleResponse();
    response.setId(role.getUuid());
    response.setProjectId(_projectService.getProject(role.getProjectId()).getUuid());
    response.setRoleName(role.getName());
    response.setDescription(role.getDescription());
    response.setObjectName("projectrole");
    return response;
}
Also used : ProjectRoleResponse(org.apache.cloudstack.api.response.ProjectRoleResponse)

Example 3 with ProjectRoleResponse

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

the class ListProjectRolesCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    List<ProjectRole> projectRoles;
    if (getProjectId() != null && getProjectRoleId() != null) {
        projectRoles = Collections.singletonList(projRoleService.findProjectRole(getProjectRoleId(), getProjectId()));
    } else if (StringUtils.isNotBlank(getRoleName())) {
        projectRoles = projRoleService.findProjectRolesByName(getProjectId(), getRoleName());
    } else {
        projectRoles = projRoleService.findProjectRoles(getProjectId());
    }
    final ListResponse<ProjectRoleResponse> response = new ListResponse<>();
    final List<ProjectRoleResponse> roleResponses = new ArrayList<>();
    for (ProjectRole role : projectRoles) {
        if (role == null) {
            continue;
        }
        roleResponses.add(setupProjectRoleResponse(role));
    }
    response.setResponses(roleResponses);
    response.setResponseName(getCommandName());
    setResponseObject(response);
}
Also used : ProjectRoleResponse(org.apache.cloudstack.api.response.ProjectRoleResponse) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) ProjectRole(org.apache.cloudstack.acl.ProjectRole)

Aggregations

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