/**
  * @param snapshotDirectoryPath Path to a repository snapshot directory (eg, /a/path/1.0-SNAPSHOT)
  * @param buildNumber The file with build number to search for or 0 if doesn't matter
  * @param timestamp The file with timestamp to search for or null if doesn't matter
  * @param fileExtension The file type to search for. Use null for any type
  * @return The path of the first unique snapshot file with the input build number.
  */
 private String findSnapshotFile(
     RepoPath snapshotDirectoryPath, int buildNumber, String timestamp, String fileExtension) {
   log.debug(
       "Searching for unique snapshot file in {} with build number {} and timestamp {}",
       new Object[] {snapshotDirectoryPath, buildNumber, timestamp});
   RepositoryService repoService = ContextHelper.get().getRepositoryService();
   if (repoService.exists(snapshotDirectoryPath)) {
     List<String> children = repoService.getChildrenNames(snapshotDirectoryPath);
     for (String child : children) {
       if (MavenNaming.isUniqueSnapshotFileName(child)) {
         // now match against all the conditions
         boolean buildNumberMatches =
             buildNumber == 0
                 || buildNumber == MavenNaming.getUniqueSnapshotVersionBuildNumber(child);
         boolean timestampMatches =
             timestamp == null
                 || timestamp.equals(MavenNaming.getUniqueSnapshotVersionTimestamp(child));
         boolean typeMatches =
             fileExtension == null || fileExtension.equals(PathUtils.getExtension(child));
         if (buildNumberMatches && timestampMatches && typeMatches) {
           // passed all the search requirements...
           log.debug("Found unique snapshot: {}", child);
           return child;
         }
       }
     }
   }
   log.debug(
       "Unique snapshot file not found in {} for build number {}",
       snapshotDirectoryPath,
       buildNumber);
   return null;
 }