Exemplo n.º 1
0
 /**
  * Returns true if the node that the path points to exists (Use with files only!)
  *
  * @param path repo path to check for existence
  */
 public static boolean exists(RepoPath path) {
   AqlSearchablePath aqlPath = new AqlSearchablePath(path);
   AqlApiItem aql =
       AqlApiItem.create()
           .filter(
               and(
                   AqlApiItem.repo().equal(aqlPath.getRepo()),
                   AqlApiItem.path().equal(aqlPath.getPath()),
                   AqlApiItem.name().equal(aqlPath.getFileName())));
   AqlEagerResult<AqlItem> results =
       ContextHelper.get().beanForType(AqlService.class).executeQueryEager(aql);
   return results != null && results.getResults() != null && results.getResults().size() > 0;
 }
Exemplo n.º 2
0
 /** Returns an AqlApiItem OR clause containing an AND for each of the searchable paths given */
 public static AqlBase.OrClause getSearchClauseForPaths(
     List<AqlSearchablePath> aqlSearchablePaths) {
   AqlBase.OrClause searchClause = AqlBase.or();
   for (AqlSearchablePath path : aqlSearchablePaths) {
     log.debug("Adding path '{}' to artifact search", path.toRepoPath().toString());
     searchClause.append(
         and(
             AqlApiItem.repo().matches(path.getRepo()),
             AqlApiItem.path().matches(path.getPath()),
             AqlApiItem.name().matches(path.getFileName())));
   }
   return searchClause;
 }
Exemplo n.º 3
0
 /**
  * Returns a list of {@link org.artifactory.aql.util.AqlSearchablePath} pointing to all files
  * contained in the current folder as well as all files under all subdirectories of that folder.
  *
  * <p>NOTE: use only with folders!
  *
  * @param path RepoPath of the folder to construct the search paths from
  */
 public static List<AqlSearchablePath> getSearchablePathForCurrentFolderAndSubfolders(
     RepoPath path) {
   List<AqlSearchablePath> artifactPaths = Lists.newArrayList();
   // Add *.* in filename for AqlSearchablePath creation - path is assumed to be a folder
   RepoPath searchPath = InternalRepoPathFactory.childRepoPath(path, "*.*");
   // All files in the folder containing the file
   AqlSearchablePath allFilesInCurrentFolder = new AqlSearchablePath(searchPath);
   // All files in all subfolders of folder containing the file
   AqlSearchablePath allFilesInSubFolders = new AqlSearchablePath(searchPath);
   if (".".equals(allFilesInSubFolders.getPath())) { // Special case for root folder
     allFilesInSubFolders.setPath("**");
   } else {
     allFilesInSubFolders.setPath(allFilesInSubFolders.getPath() + "/**");
   }
   // This will also find files without any extension (i.e. docker, lfs)
   allFilesInCurrentFolder.setFileName("*");
   allFilesInSubFolders.setFileName("*");
   artifactPaths.add(allFilesInCurrentFolder);
   artifactPaths.add(allFilesInSubFolders);
   return artifactPaths;
 }