Search in sources :

Example 1 with AqlSearchResult

use of org.jfrog.build.api.search.AqlSearchResult in project build-info by JFrogDev.

the class ArtifactoryDependenciesClient method searchArtifactsByAql.

public AqlSearchResult searchArtifactsByAql(String aql) throws IOException {
    PreemptiveHttpClient client = httpClient.getHttpClient();
    String url = artifactoryUrl + "/api/search/aql";
    HttpPost httpPost = new HttpPost(url);
    StringEntity entity = new StringEntity(aql);
    httpPost.setEntity(entity);
    AqlSearchResult result = readResponse(client.execute(httpPost), new TypeReference<AqlSearchResult>() {
    }, "Failed to search artifact by the aql '" + aql + "'", true);
    return result;
}
Also used : PreemptiveHttpClient(org.jfrog.build.client.PreemptiveHttpClient) HttpPost(org.apache.http.client.methods.HttpPost) StringEntity(org.apache.http.entity.StringEntity) AqlSearchResult(org.jfrog.build.api.search.AqlSearchResult)

Example 2 with AqlSearchResult

use of org.jfrog.build.api.search.AqlSearchResult in project build-info by JFrogDev.

the class AqlDependenciesHelper method collectArtifactsToDownload.

public Set<DownloadableArtifact> collectArtifactsToDownload(String aql, boolean explode) throws IOException {
    Set<DownloadableArtifact> downloadableArtifacts = Sets.newHashSet();
    if (StringUtils.isNotBlank(buildName)) {
        aql = addBuildToQuery(aql);
    }
    aql = "items.find(" + aql + ")";
    AqlSearchResult aqlSearchResult = downloader.getClient().searchArtifactsByAql(aql);
    List<AqlSearchResult.SearchEntry> searchResults = aqlSearchResult.getResults();
    for (AqlSearchResult.SearchEntry searchEntry : searchResults) {
        String path = searchEntry.getPath().equals(".") ? "" : searchEntry.getPath() + "/";
        DownloadableArtifact downloadableArtifact = new DownloadableArtifact(StringUtils.stripEnd(artifactoryUrl, "/") + "/" + searchEntry.getRepo(), target, path + searchEntry.getName(), "", "", PatternType.NORMAL);
        downloadableArtifact.setExplode(explode);
        downloadableArtifacts.add(downloadableArtifact);
    }
    return downloadableArtifacts;
}
Also used : AqlSearchResult(org.jfrog.build.api.search.AqlSearchResult) DownloadableArtifact(org.jfrog.build.api.dependency.DownloadableArtifact)

Aggregations

AqlSearchResult (org.jfrog.build.api.search.AqlSearchResult)2 HttpPost (org.apache.http.client.methods.HttpPost)1 StringEntity (org.apache.http.entity.StringEntity)1 DownloadableArtifact (org.jfrog.build.api.dependency.DownloadableArtifact)1 PreemptiveHttpClient (org.jfrog.build.client.PreemptiveHttpClient)1