コード例 #1
0
  protected Node fromRepository(
      CmrRepository repository, ArtifactContext context, boolean addLeaf) {
    log.debug(" Trying repository " + repository.getDisplayString());
    Node node = repository.findParent(context);
    if (node != null) {
      if (addLeaf) {
        Node parent = node;
        context.toNode(parent);
        NodeUtils.keepRepository(parent, repository);
        try {
          String[] names = repository.getArtifactNames(context);
          for (String name : names) {
            node = parent.getChild(name);
            if (node != null) {
              break;
            }
          }
        } finally {
          ArtifactContext.removeNode(parent);
        }
      }

      if (node != null) {
        NodeUtils.keepRepository(node, repository);
        log.debug("  -> Found at " + NodeUtils.getFullPath(node));
      }
    }
    return node;
  }
コード例 #2
0
 // Check if the source file and destination node point to the same file
 @Override
 public boolean isSameFile(ArtifactContext context, File srcFile) throws RepositoryException {
   boolean same = false;
   if (!cache.getRoot().isRemote()) {
     Node dstParent = getOrCreateParent(context);
     Node newChild = dstParent.getChild(srcFile.getName());
     if (newChild != null) {
       try {
         File existing = newChild.getContent(File.class);
         same = FileUtil.sameFile(srcFile, existing);
       } catch (IOException e) {
         throw new RepositoryException(e);
       }
     }
   }
   return same;
 }
コード例 #3
0
 public ArtifactResult getArtifactResult(ArtifactContext context) throws RepositoryException {
   context = applyOverrides(context);
   final Node node = getLeafNode(context);
   if (node != null) {
     String foundSuffix = ArtifactContext.getSuffixFromNode(node);
     // First handle all the artifact we didn't find
     ArtifactResult result = handleNotFound(context, foundSuffix);
     if (result != null) {
       // Seems we were able to find this artifact anyway, so lets return it
       return result;
     } else {
       // Now return the artifact we found
       context.setSuffixes(foundSuffix); // Make sure we'll have only one suffix
       if (ArtifactContext.isDirectoryName(node.getLabel())) {
         return getFolder(context, node);
       } else {
         return getArtifactResult(context, node);
       }
     }
   } else {
     return handleNotFound(context, null);
   }
 }