Examples of MavenProxyRepository


Examples of org.sonatype.nexus.client.core.subsystem.repository.maven.MavenProxyRepository

    final MavenHostedRepository remoteRepository = remoteRepositories().get(MavenHostedRepository.class,
        REMOTE_REPOSITORY_ID);
    remoteRepository.disableBrowsing().save();

    // create local/central proxying remote/central
    final MavenProxyRepository localRepository = localRepositories()
        .create(MavenProxyRepository.class, LOCAL_REPOSITORY_ID).asProxyOf(remoteRepository.contentUri())
        .doNotDownloadRemoteIndexes().withRepoPolicy("RELEASE").save();
    waitForRemoteToSettleDown();
    waitForLocalToSettleDown();

    assertThat(LOCAL_REPOSITORY_ID + " should not be autoblocked",
        !localRepositories().get(MavenProxyRepository.class, LOCAL_REPOSITORY_ID).status().isAutoBlocked());

    localRepository.refresh();

    assertThat(LOCAL_REPOSITORY_ID + " should not be autoblocked",
        !localRepositories().get(MavenProxyRepository.class, LOCAL_REPOSITORY_ID).status().isAutoBlocked());
  }
View Full Code Here

Examples of org.sonatype.nexus.client.core.subsystem.repository.maven.MavenProxyRepository

  public void createMaven2RepoWithDefaultValues() {
    final String id = uniqueName("nxcm5131-m2");

    doCreateMaven2Repo(id);

    MavenProxyRepository repository = repositories().get(id);

    assertThat(repository.id(), is(id));
    assertThat(repository.name(), is(id));

    assertThat(repository.itemMaxAge(), is(1440));
    assertThat(repository.artifactMaxAge(), is(0));
    assertThat(repository.metadataMaxAge(), is(0));

    assertThat(repository.isExposed(), is(false));
    assertThat(repository.isBrowsable(), is(false));
    assertThat(repository.isAutoBlocking(), is(true));
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.maven.MavenProxyRepository

  /**
   * Handler for {@link PrefixFilePublishedRepositoryEvent} event.
   */
  @Subscribe
  public void onPrefixFilePublishedRepositoryEvent(final PrefixFilePublishedRepositoryEvent evt) {
    final MavenProxyRepository mavenProxyRepository = evt.getRepository().adaptToFacet(MavenProxyRepository.class);
    if (isRepositoryHandled(mavenProxyRepository)) {
      buildPathMatcherFor(mavenProxyRepository);
    }
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.maven.MavenProxyRepository

  /**
   * Handler for {@link PrefixFileUnpublishedRepositoryEvent} event.
   */
  @Subscribe
  public void onPrefixFileUnpublishedRepositoryEvent(final PrefixFileUnpublishedRepositoryEvent evt) {
    final MavenProxyRepository mavenProxyRepository = evt.getRepository().adaptToFacet(MavenProxyRepository.class);
    if (isRepositoryHandled(mavenProxyRepository)) {
      dropPathMatcherFor(mavenProxyRepository);
    }
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.maven.MavenProxyRepository

  @Test
  public void testNEXUS4943RepositoryMetadataManager_expireNotFoundMetadataCaches()
      throws Exception
  {
    // hosted reposes has NFC shut down (see NEXUS-4798)
    MavenProxyRepository m2Repo =
        getRepositoryRegistry().getRepositoryWithFacet("repo1", MavenProxyRepository.class);
    m2Repo.addToNotFoundCache(new ResourceStoreRequest("/some/path/file.jar"));
    m2Repo.addToNotFoundCache(new ResourceStoreRequest("/some/path/maven-metadata.xml"));

    // note: above, that is the "standard" way to write item paths! (starting with slash)
    // below, we tamper directly with NFC, so the lack of starting slash should not confuse you!

    // we have two known entries in NFC
    assertThat(m2Repo.getNotFoundCache().listKeysInCache().size(), equalTo(2));
    assertThat(m2Repo.getNotFoundCache().listKeysInCache(),
        contains("some/path/file.jar", "some/path/maven-metadata.xml"));

    m2Repo.getRepositoryMetadataManager().expireNotFoundMetadataCaches(new ResourceStoreRequest("/"));

    // M2 metadata should be removed, so we have one known entry in NFC
    assertThat(m2Repo.getNotFoundCache().listKeysInCache().size(), equalTo(1));
    assertThat(m2Repo.getNotFoundCache().listKeysInCache(), contains("some/path/file.jar"));
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.maven.MavenProxyRepository

  @Test
  public void testNEXUS4943RepositoryMetadataManager_expireMetadataCaches()
      throws Exception
  {
    // hosted reposes has NFC shut down (see NEXUS-4798)
    MavenProxyRepository m2Repo =
        getRepositoryRegistry().getRepositoryWithFacet("repo1", MavenProxyRepository.class);

    // put some proxied content
    // we need GavBuilder-like class, this below is hilarious!
    final Gav gav =
        new Gav("org.slf4j", "slf4j-api", "1.4.3", null, "jar", null, null, null, false, null, false, null);
    m2Repo.getArtifactStoreHelper().retrieveArtifact(new ArtifactStoreRequest(m2Repo, gav, false));
    // get GAV metadata (is present)
    m2Repo.retrieveItem(new ResourceStoreRequest("/org/slf4j/slf4j-api/1.4.3/maven-metadata.xml"));
    // get GA metadat (not present, will go into NFC
    try {
      m2Repo.retrieveItem(new ResourceStoreRequest("/org/slf4j/slf4j-api/maven-metadata.xml"));
    }
    catch (ItemNotFoundException e) {
      // good, we expected this
    }

    // expire sub-tree to use walking method to update all item attributes to expired=true
    m2Repo.getRepositoryMetadataManager().expireMetadataCaches(new ResourceStoreRequest("/org/"));

    // the GA metadata should be removed from NFC, so we have no known entry in NFC
    assertThat(m2Repo.getNotFoundCache().listKeysInCache().size(), equalTo(0));

    // the GAV metadata should be expired
    assertThat(
        m2Repo.retrieveItem(new ResourceStoreRequest("/org/slf4j/slf4j-api/1.4.3/maven-metadata.xml")).isExpired(),
        is(true));
    // but the JAR should not be expired
    assertThat(
        m2Repo.retrieveItem(new ResourceStoreRequest("/org/slf4j/slf4j-api/1.4.3/slf4j-api-1.4.3.jar")).isExpired(),
        is(false));
  }
View Full Code Here

Examples of org.sonatype.nexus.proxy.maven.MavenProxyRepository

          if (!prefixSource.exists()) {
            // automatic routing has not been initialized for this repository yet, for initialization.
            doUpdatePrefixFileAsync(true, mavenRepository);
          }
          else {
            MavenProxyRepository mavenProxyRepository =
                mavenRepository.adaptToFacet(MavenProxyRepository.class);
            if (mavenProxyRepository != null) {
              mayUpdateProxyPrefixFile(mavenProxyRepository);
            }
          }
View Full Code Here

Examples of org.sonatype.nexus.proxy.maven.MavenProxyRepository

  // ==

  @Override
  public RoutingStatus getStatusFor(final MavenRepository mavenRepository) {
    final MavenProxyRepository mavenProxyRepository = mavenRepository.adaptToFacet(MavenProxyRepository.class);
    final boolean remoteDiscoveryEnabled;
    if (mavenProxyRepository != null) {
      final DiscoveryConfig discoveryConfig = getRemoteDiscoveryConfig(mavenProxyRepository);
      remoteDiscoveryEnabled = discoveryConfig.isEnabled();
    }
    else {
      remoteDiscoveryEnabled = false;
    }

    PublishingStatus publishingStatus = null;
    DiscoveryStatus discoveryStatus = null;

    // publish status
    final FilePrefixSource publishedEntrySource = getPrefixSourceFor(mavenRepository);
    if (!publishedEntrySource.supported()) {
      final String message;
      if (isMavenRepositorySupported(mavenRepository)) {
        if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenGroupRepository.class)) {
          final MavenGroupRepository mavenGroupRepository =
              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 =
              "Publishing not possible, following members have no published prefix file: "
                  + Joiner.on(", ").join(membersWithoutPrefixFiles);
        }
        else if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class)) {
          if (remoteDiscoveryEnabled) {
            message = "Discovery in progress or unable to discover remote content (see discovery status).";
          }
          else {
            message = "Remote discovery not enabled.";
          }
        }
        else if (mavenRepository.getRepositoryKind().isFacetAvailable(MavenHostedRepository.class)) {
          message = "Check Nexus logs for more details."; // hosted reposes must be discovered always
        }
        else if (mavenRepository.getRepositoryKind().isFacetAvailable(ShadowRepository.class)) {
          message = "Unsupported repository type (only hosted, proxy and groups are supported).";
        }
        else {
          message = "Check Nexus logs for more details.";
        }
      }
      else {
        message = "Unsupported repository format (only Maven2 format is supported).";
      }
      publishingStatus = new PublishingStatus(PStatus.NOT_PUBLISHED, message, -1, null);
    }
    else {
      publishingStatus =
          new PublishingStatus(PStatus.PUBLISHED, "Prefix file published successfully.",
              publishedEntrySource.getLostModifiedTimestamp(), publishedEntrySource.getFilePath());
    }

    if (mavenProxyRepository == null) {
      discoveryStatus = new DiscoveryStatus(DStatus.NOT_A_PROXY);
    }
    else {
      if (!remoteDiscoveryEnabled) {
        discoveryStatus = new DiscoveryStatus(DStatus.DISABLED);
      }
      else if (constrainedExecutor.hasRunningWithKey(mavenProxyRepository.getId())) {
        // still running or never run yet
        discoveryStatus = new DiscoveryStatus(DStatus.ENABLED_IN_PROGRESS);
      }
      else {
        final PropfileDiscoveryStatusSource discoveryStatusSource =
            new PropfileDiscoveryStatusSource(mavenProxyRepository);
        if (!discoveryStatusSource.exists()) {
          if (!mavenProxyRepository.getLocalStatus().shouldServiceRequest()) {
            // should run but not yet scheduled, or never run yet
            // out of service prevents us to persist ending states, so this
            // is the only place where we actually "calculate" it
            discoveryStatus =
                new DiscoveryStatus(DStatus.ENABLED_NOT_POSSIBLE, "none",
View Full Code Here

Examples of org.sonatype.nexus.proxy.maven.MavenProxyRepository

  @Test
  public void proxyPrefixFileIsUnchanged()
      throws Exception
  {
    // all is settled now, proxy should have prefix file pulled from remote AND merged with cache content
    final MavenProxyRepository proxyRepository =
        getRepositoryRegistry().getRepositoryWithFacet(PROXY_REPO_ID, MavenProxyRepository.class);

    final Manager routingManager = lookup(Manager.class);
    final PrefixSource proxyPrefixSource = routingManager.getPrefixSourceFor(proxyRepository);
View Full Code Here

Examples of org.sonatype.nexus.proxy.maven.MavenProxyRepository

              if (repository.getRepositoryKind().isFacetAvailable(MavenProxyRepository.class)) {
                ChecksumPolicy checksum =
                    EnumUtil.valueOf(model.getChecksumPolicy(), ChecksumPolicy.class);

                MavenProxyRepository pRepository = repository.adaptToFacet(MavenProxyRepository.class);
                pRepository.setChecksumPolicy(checksum);

                pRepository.setDownloadRemoteIndexes(model.isDownloadRemoteIndexes());

                pRepository.setChecksumPolicy(EnumUtil.valueOf(model.getChecksumPolicy(),
                    ChecksumPolicy.class));

                pRepository.setDownloadRemoteIndexes(model.isDownloadRemoteIndexes());

                RepositoryProxyResource proxyModel = (RepositoryProxyResource) model;

                pRepository.setArtifactMaxAge(proxyModel.getArtifactMaxAge());

                pRepository.setMetadataMaxAge(proxyModel.getMetadataMaxAge());

                if (proxyModel.getItemMaxAge() != null) {
                  pRepository.setItemMaxAge(proxyModel.getItemMaxAge());
                }
              }
            }
            else {
              // This is a total hack to be able to retrieve this data from a non core repo if available
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.