diff --git a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ApplicationAPIImpl.java b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ApplicationAPIImpl.java index f109a78f67..57e92f22a3 100755 --- a/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ApplicationAPIImpl.java +++ b/bpm/bonita-core/bonita-process-engine/src/main/java/org/bonitasoft/engine/api/impl/ApplicationAPIImpl.java @@ -258,6 +258,17 @@ public SearchResult searchIApplications(final SearchOptions search protected SearchResult internalSearchIApplications(ServiceAccessor serviceAccessor, SearchApplicationDescriptor appSearchDescriptor, SearchOptions searchOptions) throws SearchException { + if(searchOptions.getFilters().size() == 1) { + // Avoid a search query for a search by token to benefit from the cache optimization + final SearchFilter searchFilter = searchOptions.getFilters().get(0); + if (TOKEN.equals(searchFilter.getField())) { + try { + return new SearchResultImpl<>(1, List.of(getIApplicationByToken((String) searchFilter.getValue()))); + } catch (ApplicationNotFoundException e) { + return new SearchResultImpl<>(0, List.of()); + } + } + } final ApplicationModelConverter converter = getApplicationModelConverter(serviceAccessor.getPageService()); final ApplicationService applicationService = serviceAccessor.getApplicationService(); final Optional filterOnUserId = searchOptions.getFilters().stream()