You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "lbownik (via GitHub)" <gi...@apache.org> on 2023/05/24 06:56:09 UTC

[GitHub] [netbeans] lbownik commented on a diff in pull request #5984: use SMO service for class name and SHA1 queries.

lbownik commented on code in PR #5984:
URL: https://github.com/apache/netbeans/pull/5984#discussion_r1203551404


##########
java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexerImpl.java:
##########
@@ -1196,12 +1206,38 @@ private ResultImplementation<NBVersionInfo> getVersions(final String groupId, fi
 
     @Override
     public ResultImplementation<NBVersionInfo> findVersionsByClass(final String className, List<RepositoryInfo> repos) {
-        ResultImpl<NBVersionInfo> result = new ResultImpl<>((ResultImpl<NBVersionInfo> result1) -> {
-            findVersionsByClass(className, result1, result1.getSkipped(), false);
-        });
-        return findVersionsByClass(className, result, repos, true);
+
+        Optional<RepositoryInfo> central = repos.stream()
+                .filter(repo -> repo.getId().equals(smo.getRepositoryId()))
+                .findFirst();
+
+        // remote index contains no class data -> use web service
+        if (central.isPresent()) {
+            List<RepositoryInfo> otherRepos = new ArrayList<>(repos);
+            otherRepos.remove(central.get());
+
+            SearchRequest request = new SearchRequest(new Paging(64), 
+                    FieldQuery.fieldQuery(className.contains(".") ?
+                            org.apache.maven.search.MAVEN.FQ_CLASS_NAME
+                          : org.apache.maven.search.MAVEN.CLASS_NAME, className));
+
+            return mergeResults(
+                () -> (ResultImpl) findVersionsByClass(className, otherRepos),
+                () -> {

Review Comment:
   IMHO making this lambda a method would make this code more readable



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists