Skip to content

Commit

Permalink
Fixed query and count methods in order to stop traversal of parents i…
Browse files Browse the repository at this point in the history
…f endpoints are found
  • Loading branch information
angelo.andreussi authored and Coduz committed May 22, 2023
1 parent 1eb7762 commit e2cac00
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,17 +234,16 @@ public EndpointInfoListResult query(KapuaQuery query, String section)
return entityManagerSession.doAction(em -> {
EndpointInfoListResult endpointInfoListResult = EndpointInfoDAO.query(em, query);

if (endpointInfoListResult.isEmpty() && query.getScopeId() != null) {

// First check if there are any endpoint specified at all
if (countAllEndpointsInScope(em, query.getScopeId(), section)) {
// if there are endpoints (even not matching the query), return the empty list
return endpointInfoListResult;
}
if (endpointInfoListResult.isEmpty() && query.getScopeId() != null) { //query did not find results

KapuaId originalScopeId = query.getScopeId();

do {
// First check if there are any endpoint AT ALL specified in this scope
if (countAllEndpointsInScope(em, query.getScopeId(), section)) {
// There are endpoints (even not matching the query), exit because I found the "nearest usable" endpoints which don't have what I'm searching
break;
}
Account account = KapuaSecurityUtils.doPrivileged(() -> ACCOUNT_SERVICE.find(query.getScopeId()));

if (account == null) {
Expand Down Expand Up @@ -291,15 +290,14 @@ public long count(KapuaQuery query, String section)

if (endpointInfoCount == 0 && query.getScopeId() != null) {

// First check if there are any endpoint specified at all
if (countAllEndpointsInScope(em, query.getScopeId(), section)) {
// if there are endpoints (even not matching the query), return 0
return endpointInfoCount;
}

KapuaId originalScopeId = query.getScopeId();

do {
// First check if there are any endpoint AT ALL specified in this scope
if (countAllEndpointsInScope(em, query.getScopeId(), section)) {
// There are endpoints (even not matching the query), exit because I found the "nearest usable" endpoints which don't have what I'm searching
break;
}
Account account = KapuaSecurityUtils.doPrivileged(() -> ACCOUNT_SERVICE.find(query.getScopeId()));

if (account == null) {
Expand Down

0 comments on commit e2cac00

Please sign in to comment.