Interface Searches


  • public interface Searches
    Public API for executing searches
    Author:
    Yoav Landman
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void aql​(java.lang.String aqlQuery, AqlResultHandler handler)
      Perform a search using Artifactory Query Language (AQL).
      java.util.List<RepoPath> archiveEntriesByName​(java.lang.String query, java.lang.String... repositories)
      Search the content of jar/zip archives
      java.util.List<RepoPath> artifactsByGavc​(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, java.lang.String classifier, java.lang.String... repositories)  
      java.util.List<RepoPath> artifactsByName​(java.lang.String query, java.lang.String... repositories)
      Find artifacts by name
      java.util.Set<RepoPath> artifactsBySha1​(java.lang.String sha1, java.lang.String... repositories)
      Find artifacts by their checksum values
      java.util.Set<RepoPath> artifactsBySha256​(java.lang.String sha256, java.lang.String... repositories)
      Find artifacts by their checksum values
      java.util.List<RepoPath> artifactsCreatedOrModifiedInRange​(java.util.Calendar from, java.util.Calendar to, java.lang.String... repositories)
      Find artifacts created or modified within a date range
      java.util.List<RepoPath> artifactsNotDownloadedSince​(java.util.Calendar since, java.util.Calendar createdBefore, java.lang.String... repositories)
      Find artifacts not downloaded since the specified date, searches for both locally and remotely downloaded stats, using smart remote repository stats where applicable.
      java.util.Set<BuildRun> buildsByArtifactSha1​(java.lang.String sha1)
      Find all build runs that produced the artifact with the provided sha1 checksum
      java.util.Set<BuildRun> buildsByDependencySha1​(java.lang.String sha1)
      Find all build runs that used a dependency with the provided sha1 checksum
      java.util.List<RepoPath> itemsByProperties​(com.google.common.collect.SetMultimap<java.lang.String,​java.lang.String> properties, java.lang.String... repositories)
      Find artifacts by properties
    • Method Detail

      • artifactsByName

        java.util.List<RepoPath> artifactsByName​(java.lang.String query,
                                                 java.lang.String... repositories)
        Find artifacts by name
        Parameters:
        query - The search query term for the artifact name
        repositories - A list of repositories to search in. Can be null to search all repositories
        Returns:
        Artifacts found by the search, empty list if nothing was found
      • itemsByProperties

        java.util.List<RepoPath> itemsByProperties​(com.google.common.collect.SetMultimap<java.lang.String,​java.lang.String> properties,
                                                   java.lang.String... repositories)
        Find artifacts by properties
        Parameters:
        properties - A set of key-value properties to search for on artifacts or folders. All specified properties need to exist on found items. If multiple values are used a contains() semantic is applied
        repositories - A list of repositories to search in. Can be null to search all repositories.
        Returns:
        Artifacts matching the criteria
      • archiveEntriesByName

        java.util.List<RepoPath> archiveEntriesByName​(java.lang.String query,
                                                      java.lang.String... repositories)
        Search the content of jar/zip archives
        Parameters:
        query - The search term for the archive of the entry
        repositories - A list of repositories to search in. Can be null to search all repositories.
        Returns:
        List of zip resources repo path matching the criteria
      • artifactsByGavc

        java.util.List<RepoPath> artifactsByGavc​(@Nullable
                                                 java.lang.String groupId,
                                                 @Nullable
                                                 java.lang.String artifactId,
                                                 @Nullable
                                                 java.lang.String version,
                                                 @Nullable
                                                 java.lang.String classifier,
                                                 java.lang.String... repositories)
      • artifactsBySha1

        java.util.Set<RepoPath> artifactsBySha1​(java.lang.String sha1,
                                                java.lang.String... repositories)
        Find artifacts by their checksum values
        Parameters:
        sha1 - The sha1 checksum of the artifact
        repositories - A list of repositories to search in. Can be null to search all repositories
        Returns:
        Set of repo paths that comply with the given checksums
      • artifactsBySha256

        java.util.Set<RepoPath> artifactsBySha256​(java.lang.String sha256,
                                                  java.lang.String... repositories)
        Find artifacts by their checksum values
        Parameters:
        sha256 - The sha256 checksum of the artifact
        repositories - A list of repositories to search in. Can be null to search all repositories
        Returns:
        Set of repo paths that comply with the given checksums
      • artifactsCreatedOrModifiedInRange

        java.util.List<RepoPath> artifactsCreatedOrModifiedInRange​(@Nullable
                                                                   java.util.Calendar from,
                                                                   @Nullable
                                                                   java.util.Calendar to,
                                                                   java.lang.String... repositories)
        Find artifacts created or modified within a date range
        Parameters:
        from - The time to start the search exclusive (eg, >). If empty will start from 1st Jan 1970
        to - The time to end search inclusive (eg, <=), If null, will not use current time as the limit
        repositories - A list of repositories to search in. Can be null to search all repositories.
        Returns:
        List of file repo paths that were created or modified between the input time range and the date the file was modified.
      • artifactsNotDownloadedSince

        java.util.List<RepoPath> artifactsNotDownloadedSince​(@Nullable
                                                             java.util.Calendar since,
                                                             @Nullable
                                                             java.util.Calendar createdBefore,
                                                             java.lang.String... repositories)
        Find artifacts not downloaded since the specified date, searches for both locally and remotely downloaded stats, using smart remote repository stats where applicable.
        Parameters:
        since - The time to start the search exclusive (eg, >). If null will start from 1st Jan 1970
        createdBefore - Only include artifacts created before the specified time. If null will default to the value of since.
        repositories - A list of repositories to search in. Can be null to search all repositories
        Returns:
        List of file repo paths that were not downloaded since the specified date
      • buildsByArtifactSha1

        java.util.Set<BuildRun> buildsByArtifactSha1​(java.lang.String sha1)
        Find all build runs that produced the artifact with the provided sha1 checksum
        Parameters:
        sha1 - The sha1 checksum of the build dependency to search
        Returns:
        A list of BuildRuns (may be empty)
      • buildsByDependencySha1

        java.util.Set<BuildRun> buildsByDependencySha1​(java.lang.String sha1)
        Find all build runs that used a dependency with the provided sha1 checksum
        Parameters:
        sha1 - The sha1 cheksum of the build dependency to search
        Returns:
        A list of BuildRuns (may be empty)
      • aql

        void aql​(java.lang.String aqlQuery,
                 AqlResultHandler handler)
        Perform a search using Artifactory Query Language (AQL). This can be used to stream AQL results from Artifactory as map objects. This method accepts a String param with the AQL query, and an AqlResultHandler object (can be a closure).

        Usage example 1:

        
         String aqlQuery = "items.find..."
         searches.aql(aqlQuery) { AqlResult result ->
              result.each { Map item ->
                  String itemPath = item.path + "/" + item.name
                  //do something
              }
         }
          
        Usage example 2:
         
         AqlResultHandler handler = new AqlResultHandler() {
              void handle(AqlResult result) {
                  for (Map<String, Object> item : result) {
                      String name = item.name
                      //do something
                  }
              }
         }
         searches.aql(aqlQuery, handler)
          

        Parameters:
        aqlQuery - The AQL query to perform
        handler - The handler (can be a closure)