Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Collections;
import java.util.List;

import com.cloud.exception.InvalidParameterValueException;
import org.apache.cloudstack.acl.ProjectRole;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
Expand Down Expand Up @@ -55,7 +56,6 @@ public class ListProjectRolesCmd extends BaseListCmd {
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////


public Long getProjectRoleId() { return projectRoleId; }

public Long getProjectId() {
Expand All @@ -72,7 +72,10 @@ public String getRoleName() {

@Override
public void execute() {
List<ProjectRole> projectRoles = new ArrayList<>();
if (getProjectId() != null && _projectService.getProject(getProjectId()) == null) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the special case projectId = -1 is neglected this way. It looks like it is not applicable for ListProjectRoles, but in general that value is allowed. Can you check how to handle it?

throw new InvalidParameterValueException("Failed to find project by ID.");
}
Comment on lines +75 to +77
Comment on lines +75 to +77
List<ProjectRole> projectRoles;
if (getProjectId() != null && getProjectRoleId() != null) {
projectRoles = Collections.singletonList(projRoleService.findProjectRole(getProjectRoleId(), getProjectId()));
} else if (StringUtils.isNotBlank(getRoleName())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ public ProjectRole findProjectRole(Long roleId, Long projectId) {

@Override
public List<ProjectRole> findProjectRoles(Long projectId, String keyword) {
if (projectId == null || projectId < 1L || projectDao.findById(projectId) == null) {
logger.warn("Invalid project ID provided");
return null;
if (projectId == null) {
logger.warn("Invalid project ID provided; thus, an empty list is being returned.");
return Collections.emptyList();
}
return ListUtils.toListOfInterface(projRoleDao.findAllRoles(projectId, keyword));
}
Expand Down
Loading