Skip to content

Commit 7e43a3e

Browse files
fix resource type and id search
1 parent 3581806 commit 7e43a3e

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

server/src/main/java/com/cloud/api/query/QueryManagerImpl.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3191,14 +3191,18 @@ private Pair<List<AsyncJobJoinVO>, Integer> searchForAsyncJobsInternal(ListAsync
31913191
sc.setParameters("executingMsid", msHost.getMsid());
31923192
}
31933193

3194-
ApiCommandResourceType resourceType = getResourceType(cmd.getResourceType());
3195-
if (resourceType != null) {
3196-
sc.setParameters("instanceType", resourceType.toString());
3197-
}
3194+
if (cmd.getResourceType() != null) {
3195+
ApiCommandResourceType resourceType = getResourceType(cmd.getResourceType());
3196+
sc.addAnd("instanceType", SearchCriteria.Op.EQ, resourceType.toString());
31983197

3199-
final String resourceId = getResourceUuid(cmd.getResourceId());
3200-
if (resourceId != null) {
3201-
sc.setParameters("instanceUuid", resourceId);
3198+
final String resourceId = getResourceUuid(cmd.getResourceId());
3199+
if (resourceId == null) {
3200+
throw new InvalidParameterValueException("Invalid resource id for the resource type " + resourceType);
3201+
}
3202+
3203+
sc.addAnd("instanceUuid", SearchCriteria.Op.EQ, resourceId);
3204+
} else if (cmd.getResourceId() != null) {
3205+
throw new InvalidParameterValueException("Resource type must be specified for the resource id");
32023206
}
32033207

32043208
return _jobJoinDao.searchAndCount(sc, searchFilter);

0 commit comments

Comments
 (0)