1- package org .codejive .jpm .util ;
1+ package org .codejive .jpm .search ;
22
33import java .io .IOException ;
44import java .io .InputStream ;
1010import org .apache .http .client .methods .HttpGet ;
1111import org .apache .http .impl .client .CloseableHttpClient ;
1212import org .apache .http .impl .client .HttpClients ;
13+ import org .codejive .jpm .util .Version ;
1314import org .eclipse .aether .artifact .DefaultArtifact ;
1415import org .yaml .snakeyaml .DumperOptions ;
1516import org .yaml .snakeyaml .LoaderOptions ;
1819import org .yaml .snakeyaml .representer .Representer ;
1920
2021/** Utility class for searching Maven artifacts. */
21- public class SearchUtils {
22+ public class SearchSmoRestImpl implements Search {
2223
2324 /**
2425 * Find artifacts matching the given pattern. This will return the first page of results. If the
@@ -30,31 +31,33 @@ public class SearchUtils {
3031 *
3132 * @param artifactPattern The pattern to search for.
3233 * @param count The maximum number of results to return.
33- * @return The search result as an instance of {@link SearchResult}.
34+ * @return The search result as an instance of {@link Search. SearchResult}.
3435 * @throws IOException If an error occurred during the search.
3536 */
36- public static SearchResult findArtifacts (String artifactPattern , int count ) throws IOException {
37+ public Search . SearchResult findArtifacts (String artifactPattern , int count ) throws IOException {
3738 return select (artifactPattern , 0 , count );
3839 }
3940
4041 /**
41- * Find the next page of artifacts. This takes a {@link SearchResult} returned by a previous
42- * call to {@link #findArtifacts(String, int)} and returns the next page of results.
42+ * Find the next page of artifacts. This takes a {@link Search. SearchResult} returned by a
43+ * previous call to {@link #findArtifacts(String, int)} and returns the next page of results.
4344 *
4445 * @param prevResult The previous search result.
45- * @return The next search result as an instance of {@link SearchResult}.
46+ * @return The next search result as an instance of {@link Search. SearchResult}.
4647 * @throws IOException If an error occurred during the search.
4748 */
48- public static SearchResult findNextArtifacts (SearchResult prevResult ) throws IOException {
49+ public Search .SearchResult findNextArtifacts (Search .SearchResult prevResult )
50+ throws IOException {
4951 if (prevResult .start + prevResult .count >= prevResult .total ) {
5052 return null ;
5153 }
52- SearchResult result =
54+ Search . SearchResult result =
5355 select (prevResult .query , prevResult .start + prevResult .count , prevResult .count );
5456 return result .artifacts .isEmpty () ? null : result ;
5557 }
5658
57- private static SearchResult select (String query , int start , int count ) throws IOException {
59+ private static Search .SearchResult select (String query , int start , int count )
60+ throws IOException {
5861 String [] parts = query .split (":" , -1 );
5962 String finalQuery ;
6063 if (parts .length >= 3 ) {
@@ -106,9 +109,10 @@ private static SearchResult select(String query, int start, int count) throws IO
106109 List <DefaultArtifact > artifacts =
107110 result .response .docs .stream ()
108111 .filter (d -> acceptDoc (d , parts ))
109- .map (SearchUtils ::toArtifact )
112+ .map (SearchSmoRestImpl ::toArtifact )
110113 .collect (Collectors .toList ());
111- return new SearchResult (artifacts , query , start , count , result .response .numFound );
114+ return new Search .SearchResult (
115+ artifacts , query , start , count , result .response .numFound );
112116 }
113117 }
114118 }
0 commit comments