Package org.sonatype.nexus.proxy.maven.routing

Examples of org.sonatype.nexus.proxy.maven.routing.PrefixSource


    return pathMatchers.remove(mavenProxyRepository.getId()) != null;
  }

  protected void buildPathMatcherFor(final MavenProxyRepository mavenProxyRepository) {
    try {
      final PrefixSource prefixSource = manager.getPrefixSourceFor(mavenProxyRepository);
      if (prefixSource.supported()) {
        final PathMatcher pathMatcher = new PathMatcher(prefixSource.readEntries(), Integer.MAX_VALUE);
        pathMatchers.put(mavenProxyRepository.getId(), pathMatcher);
      }
      else {
        dropPathMatcherFor(mavenProxyRepository);
      }
View Full Code Here


  }

  protected void handlePrefixFileUpdate(final RepositoryItemEvent evt) {
    final MavenRepository mavenRepository = (MavenRepository) evt.getRepository();
    try {
      final PrefixSource prefixSource = manager.getPrefixSourceFor(mavenRepository);
      manager.publish(mavenRepository, prefixSource);
    }
    catch (IOException e) {
      getLogger().warn("Problem while publishing prefix file for repository {}",
          RepositoryStringUtils.getHumanizedNameString(mavenRepository), e);
View Full Code Here

  {
    checkUpdateConditions(mavenProxyRepository);
    try {
      log.debug("Quick updating prefix file of {}", mavenProxyRepository);
      constrainedExecutor.cancelRunningWithKey(mavenProxyRepository.getId());
      final PrefixSource prefixSource =
          updateProxyPrefixFile(mavenProxyRepository, Collections.singletonList(quickRemoteStrategy));

      // this is never null
      final PrefixSource oldPrefixSource = getPrefixSourceFor(mavenProxyRepository);
      // does repo goes from unpublished to published or other way around?
      final boolean stateChanged =
          (oldPrefixSource.supported()) != (prefixSource != null && prefixSource.supported());
      if (prefixSource != null && prefixSource.supported()) {
        if (stateChanged) {
          log.info("Updated and published prefix file of {}",
              RepositoryStringUtils.getHumanizedNameString(mavenProxyRepository));
        }
View Full Code Here

  protected void updateAndPublishPrefixFile(final MavenRepository mavenRepository)
      throws IOException
  {
    log.debug("Updating prefix file of {}", mavenRepository);
    try {
      final PrefixSource prefixSource;
      if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenGroupRepository.class)) {
        prefixSource = updateGroupPrefixFile(mavenRepository.adaptToFacet(MavenGroupRepository.class));
      }
      else if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class)) {
        prefixSource = updateProxyPrefixFile(mavenRepository.adaptToFacet(MavenProxyRepository.class), null);
      }
      else if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenHostedRepository.class)) {
        prefixSource = updateHostedPrefixFile(mavenRepository.adaptToFacet(MavenHostedRepository.class));
      }
      else {
        // we should not get here
        log.info("Repository {} unsupported by automatic routing feature",
            RepositoryStringUtils.getFullHumanizedNameString(mavenRepository));
        return;
      }

      // this is never null
      final PrefixSource oldPrefixSource = getPrefixSourceFor(mavenRepository);
      // does repo goes from unpublished to published or other way around?
      final boolean stateChanged =
          (oldPrefixSource.supported()) != (prefixSource != null && prefixSource.supported());

      if (prefixSource != null && prefixSource.supported()) {
        if (stateChanged) {
          log.info("Updated and published prefix file of {}",
              RepositoryStringUtils.getHumanizedNameString(mavenRepository));
View Full Code Here

      throw new IllegalStateException("Maven repository "
          + RepositoryStringUtils.getHumanizedNameString(mavenProxyRepository)
          + " not in state to be updated (is blocked).");
    }

    PrefixSource prefixSource = null;
    final DiscoveryConfig config = getRemoteDiscoveryConfig(mavenProxyRepository);
    if (config.isEnabled()) {
      final DiscoveryResult<MavenProxyRepository> discoveryResult;
      if (null == remoteStrategies) {
        discoveryResult = remoteContentDiscoverer.discoverRemoteContent(mavenProxyRepository);
      }
      else {
        discoveryResult =
            remoteContentDiscoverer.discoverRemoteContent(mavenProxyRepository, remoteStrategies);
      }

      log.debug("Results of {} remote discovery: {}", mavenProxyRepository,
          discoveryResult.getAllResults());

      if (discoveryResult.isSuccessful()) {
        final PrefixSource remotePrefixSource = discoveryResult.getPrefixSource();
        if (remotePrefixSource.supported()) {
          // grab local too and merge them
          final DiscoveryResult<MavenRepository> localDiscoveryResult =
              localContentDiscoverer.discoverLocalContent(mavenProxyRepository);
          if (localDiscoveryResult.isSuccessful()) {
            final HashSet<String> mergedEntries = Sets.newHashSet();
            mergedEntries.addAll(remotePrefixSource.readEntries());
            mergedEntries.addAll(localDiscoveryResult.getPrefixSource().readEntries());
            final ArrayListPrefixSource mergedPrefixSource =
                new ArrayListPrefixSource(Lists.newArrayList(mergedEntries),
                    remotePrefixSource.getLostModifiedTimestamp());
            prefixSource = mergedPrefixSource;
          }
          else {
            log.debug("{} local discovery unsuccessful", mavenProxyRepository);
          }
View Full Code Here

  protected PrefixSource updateHostedPrefixFile(final MavenHostedRepository mavenHostedRepository)
      throws IllegalStateException, IOException
  {
    checkUpdateConditions(mavenHostedRepository);
    PrefixSource prefixSource = null;
    final DiscoveryResult<MavenRepository> discoveryResult =
        localContentDiscoverer.discoverLocalContent(mavenHostedRepository);
    if (discoveryResult.isSuccessful()) {
      prefixSource = discoveryResult.getPrefixSource();
    }
View Full Code Here

  protected PrefixSource updateGroupPrefixFile(final MavenGroupRepository mavenGroupRepository)
      throws IllegalStateException, IOException
  {
    checkUpdateConditions(mavenGroupRepository);
    PrefixSource prefixSource = null;
    // save merged prefix list into group's local storage (if all members has prefix list)
    boolean allMembersHavePublished = true;
    final LinkedHashSet<String> entries = new LinkedHashSet<String>();
    for (Repository member : mavenGroupRepository.getMemberRepositories()) {
      if (member.getRepositoryKind().isFacetAvailable(MavenRepository.class)) {
View Full Code Here

              mavenRepository.adaptToFacet(MavenGroupRepository.class);
          final List<String> membersWithoutPrefixFiles = new ArrayList<String>();
          for (Repository member : mavenGroupRepository.getMemberRepositories()) {
            final MavenRepository memberMavenRepository = member.adaptToFacet(MavenRepository.class);
            if (null != memberMavenRepository) {
              final PrefixSource ps = getPrefixSourceFor(memberMavenRepository);
              if (!ps.supported()) {
                membersWithoutPrefixFiles.add(memberMavenRepository.getName());
              }
            }
          }
          message =
View Full Code Here

        }
        if (unmarshalled.entries().isEmpty()) {
          return new StrategyResult("Remote publishes empty prefix file", UNSUPPORTED_PREFIXSOURCE, false);
        }

        final PrefixSource prefixSource = new FilePrefixSource(mavenProxyRepository, path, config);
        if (prefixFileAgeInDays < 1) {
          return new StrategyResult("Remote publishes prefix file (is less than a day old), using it.", prefixSource,
              true);
        }
        else {
View Full Code Here

    final Manager wm = lookup(Manager.class);
    waitForRoutingBackgroundUpdates();

    // after member removal, group1 should have proxy1 WL in group
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID,
              MavenRepository.class));

      assertThat("Group1 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
      assertThat(groupEntries, hasSize(1));
      assertThat(groupEntries, hasItem("/org/apache"));
    }
    // after member addition and removal (from member group1), group2 should have proxy1 and proxt3 WL in group
    {
      final PrefixSource groupPrefixSource =
          wm.getPrefixSourceFor(getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID,
              MavenRepository.class));

      assertThat("Group2 should have WL", groupPrefixSource.supported());

      final List<String> groupEntries = groupPrefixSource.readEntries();
      assertThat(groupEntries, hasSize(2));
      assertThat(groupEntries, hasItem("/org/apache"));
      assertThat(groupEntries, hasItem("/eu/flatwhite"));
    }
  }
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.maven.routing.PrefixSource

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.