Package org.sonatype.nexus.proxy.walker

Examples of org.sonatype.nexus.proxy.walker.ParentOMatic


  // ==

  protected Node<Payload> buildRoot(final List<String> entries, final int maxDepth) {
    // no rule B!
    final ParentOMatic parentOMatic = new ParentOMatic(true, true, false);
    for (String entry : entries) {
      parentOMatic.addAndMarkPath(entry);
    }
    if (maxDepth != Integer.MAX_VALUE) {
      // cut the tree to maxDepth
      parentOMatic.cutNodesDeeperThan(maxDepth);
    }
    return parentOMatic.getRoot();
  }
View Full Code Here


    final PrefixCollectorProcessor prefixCollectorProcessor = new PrefixCollectorProcessor();
    context.getProcessors().add(prefixCollectorProcessor);

    try {
      walker.walk(context);
      final ParentOMatic parentOMatic = prefixCollectorProcessor.getParentOMatic();
      if (parentOMatic.getRoot().isLeaf()) {
        // tree is basically empty, so make the list too
        discoveryResult.recordSuccess(ID, "Repository crawled successfully (is empty)",
            new ArrayListPrefixSource(Collections.<String>emptyList()));
      }
      else {
View Full Code Here

      extends AbstractWalkerProcessor
  {
    private final ParentOMatic parentOMatic;

    public PrefixCollectorProcessor() {
      this.parentOMatic = new ParentOMatic();
    }
View Full Code Here

          cacheAltered = altered1 || altered2;
        }
      }
    }
    else {
      final ParentOMatic parentOMatic = new ParentOMatic(false);
      final DefaultWalkerContext context = new DefaultWalkerContext(this, request);
      final Collection<String> nfcPaths = getNotFoundCache().listKeysInCache();

      for (String nfcPath : nfcPaths) {
        final DefaultStorageNotFoundItem nfcItem =
            new DefaultStorageNotFoundItem(this, new ResourceStoreRequest(nfcPath));

        if (filter.shouldProcess(context, nfcItem)) {
          parentOMatic.addAndMarkPath(nfcPath);
        }
      }

      for (String path : parentOMatic.getMarkedPaths()) {
        boolean removed = getNotFoundCache().remove(path);
        cacheAltered = cacheAltered || removed;
      }
    }
View Full Code Here

  @Override
  protected List<String> diveIn(final ScrapeContext context, final Page page)
      throws IOException
  {
    // we use the great and all-mighty ParentOMatic
    final ParentOMatic parentOMatic = new ParentOMatic();
    diveIn(context, page, 0, parentOMatic, parentOMatic.getRoot());
    // Special case: scraped with 0 entry, we consider this as an error
    // Remote repo empty? Why are you proxying it? Or worse, some scrape
    // exotic index page and we end up with 0 entries by mistake?
    if (parentOMatic.getRoot().isLeaf()) {
      context.stop("Remote recognized as " + getTargetedServer()
          + ", but scraped 0 entries. This is considered a failure.");
      return null;
    }
    final List<String> entries = parentOMatic.getAllLeafPaths();
    return entries;
  }
View Full Code Here

          "Collecting deletable snapshots on repository " + repository.getId() + " from storage directory "
              + repository.getLocalUrl()
      );
    }

    final ParentOMatic parentOMatic = new ParentOMatic();

    // create a walker to collect deletables and let it loose on collections only
    final SnapshotRemoverWalkerProcessor snapshotRemoveProcessor =
        new SnapshotRemoverWalkerProcessor(repository, request, parentOMatic);

    final DefaultWalkerContext ctxMain =
        new DefaultWalkerContext(repository,
            new ResourceStoreRequest("/"),
            new DottedStoreWalkerFilter(),
            TraversalType.BREADTH_FIRST,
            false);
    ctxMain.getContext().put(DeleteOperation.DELETE_OPERATION_CTX_KEY, getDeleteOperation(request));
    ctxMain.getProcessors().add(snapshotRemoveProcessor);
    walker.walk(ctxMain);

    if (ctxMain.getStopCause() != null) {
      result.setSuccessful(false);
    }

    // and collect results
    result.setDeletedSnapshots(snapshotRemoveProcessor.getDeletedSnapshots());
    result.setDeletedFiles(snapshotRemoveProcessor.getDeletedFiles());

    if (log.isDebugEnabled()) {
      log.debug(
          "Collected and deleted " + snapshotRemoveProcessor.getDeletedSnapshots()
              + " snapshots with alltogether " + snapshotRemoveProcessor.getDeletedFiles()
              + " files on repository " + repository.getId()
      );
    }

    // if we are processing a hosted-snapshot repository, we need to rebuild maven metadata
    // without this if below, the walk would happen against proxy repositories too, but doing nothing!
    if (repository.getRepositoryKind().isFacetAvailable(HostedRepository.class)) {
      // expire NFC since we might create new maven metadata files
      repository.expireNotFoundCaches(new ResourceStoreRequest(RepositoryItemUid.PATH_ROOT));

      RecreateMavenMetadataWalkerProcessor metadataRebuildProcessor =
          new RecreateMavenMetadataWalkerProcessor(log, getDeleteOperation(request));

      for (String path : parentOMatic.getMarkedPaths()) {
        TaskUtil.checkInterruption();

        DefaultWalkerContext ctxMd =
            new DefaultWalkerContext(repository, new ResourceStoreRequest(path),
                new DottedStoreWalkerFilter());
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.walker.ParentOMatic

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.