Skip to content
Merged
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 @@ -116,7 +116,7 @@ public long getEntityOwnerId() {
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)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why should they both be specified? user + either implies the other

Copy link
Contributor

Choose a reason for hiding this comment

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

discussed off-line with @Pearl1594 . no functional need but bugs may arise when not implemented this way

throw new InvalidParameterValueException("Account ID and Domain ID must be specified with userID");
Copy link
Contributor

Choose a reason for hiding this comment

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

@Pearl1594 update this msg to reflect the change in cond.

Copy link
Contributor

Choose a reason for hiding this comment

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

It already did, as far as I can tell, neither accountId nor domainId may be null so both must be specified.

Copy link
Contributor

Choose a reason for hiding this comment

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

am i missing anything here @DaanHoogland , the cond. is OR and the msg says both (account id and domain id).

Copy link
Contributor

Choose a reason for hiding this comment

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

throw an exception when either is null, would mean both may not be null. The message was already the (not yet implemented) new condition.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmmm , correct @DaanHoogland

}
if (accountName != null) {
Expand Down
15 changes: 12 additions & 3 deletions server/src/main/java/com/cloud/api/query/QueryManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1517,15 +1517,19 @@ private Pair<List<ProjectJoinVO>, Integer> listProjectsInternal(ListProjectsCmd
}

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();
Expand Down Expand Up @@ -2585,6 +2589,7 @@ private Pair<List<ImageStoreJoinVO>, Integer> searchForImageStoresInternal(ListI
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);

Expand All @@ -2597,6 +2602,7 @@ private Pair<List<ImageStoreJoinVO>, Integer> searchForImageStoresInternal(ListI
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);
Expand Down Expand Up @@ -2625,6 +2631,9 @@ private Pair<List<ImageStoreJoinVO>, Integer> searchForImageStoresInternal(ListI
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);
Expand Down