This is an automated email from the ASF dual-hosted git repository.
dahn pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/master by this push:
new 7f408ec Fix: Listing projects comprising of only the user's on
listAll=true (#4469)
7f408ec is described below
commit 7f408ec967327a152d903dcc55260ccff9bad0fd
Author: Pearl Dsilva <[email protected]>
AuthorDate: Mon Nov 16 18:07:11 2020 +0530
Fix: Listing projects comprising of only the user's on listAll=true (#4469)
Co-authored-by: Pearl Dsilva <[email protected]>
---
.../api/command/user/project/CreateProjectCmd.java | 2 +-
.../main/java/com/cloud/api/query/QueryManagerImpl.java | 15 ++++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git
a/api/src/main/java/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java
b/api/src/main/java/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java
index 40db387..64de9a7 100644
---
a/api/src/main/java/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java
+++
b/api/src/main/java/org/apache/cloudstack/api/command/user/project/CreateProjectCmd.java
@@ -116,7 +116,7 @@ public class CreateProjectCmd extends BaseAsyncCreateCmd {
throw new InvalidParameterValueException("Account name and domain
id must be specified together");
}
- if (userId != null && (accountId == null && domainId == null)) {
+ if (userId != null && (accountId == null || domainId == null)) {
throw new InvalidParameterValueException("Account ID and Domain ID
must be specified with userID");
}
if (accountName != null) {
diff --git a/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
b/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
index e8161bc..ac97519 100644
--- a/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
@@ -1517,15 +1517,19 @@ public class QueryManagerImpl extends
MutualExclusiveIdsManagerBase implements Q
}
if (accountId != null) {
- sb.and("accountId", sb.entity().getAccountId(),
SearchCriteria.Op.EQ);
+ if (userId == null) {
+ sb.and().op("accountId", sb.entity().getAccountId(),
SearchCriteria.Op.EQ);
+ sb.and("userIdNull", sb.entity().getUserId(), Op.NULL);
+ sb.cp();
+ } else {
+ sb.and("accountId", sb.entity().getAccountId(),
SearchCriteria.Op.EQ);
+ }
}
if (userId != null) {
sb.and().op("userId", sb.entity().getUserId(), Op.EQ);
sb.or("userIdNull", sb.entity().getUserId(), Op.NULL);
sb.cp();
- } else {
- sb.and("userIdNull", sb.entity().getUserId(), Op.NULL);
}
SearchCriteria<ProjectJoinVO> sc = sb.create();
@@ -2585,6 +2589,7 @@ public class QueryManagerImpl extends
MutualExclusiveIdsManagerBase implements Q
Object keyword = cmd.getKeyword();
Long startIndex = cmd.getStartIndex();
Long pageSize = cmd.getPageSizeVal();
+ Boolean readonly = cmd.getReadonly();
Filter searchFilter = new Filter(ImageStoreJoinVO.class, "id",
Boolean.TRUE, startIndex, pageSize);
@@ -2597,6 +2602,7 @@ public class QueryManagerImpl extends
MutualExclusiveIdsManagerBase implements Q
sb.and("protocol", sb.entity().getProtocol(), SearchCriteria.Op.EQ);
sb.and("provider", sb.entity().getProviderName(),
SearchCriteria.Op.EQ);
sb.and("role", sb.entity().getRole(), SearchCriteria.Op.EQ);
+ sb.and("readonly", sb.entity().isReadonly(), Op.EQ);
SearchCriteria<ImageStoreJoinVO> sc = sb.create();
sc.setParameters("role", DataStoreRole.Image);
@@ -2625,6 +2631,9 @@ public class QueryManagerImpl extends
MutualExclusiveIdsManagerBase implements Q
if (protocol != null) {
sc.setParameters("protocol", protocol);
}
+ if (readonly != null) {
+ sc.setParameters("readonly", readonly);
+ }
// search Store details by ids
Pair<List<ImageStoreJoinVO>, Integer> uniqueStorePair =
_imageStoreJoinDao.searchAndCount(sc, searchFilter);