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);
}
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;
}
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);
}
Aggregations