Package org.sonatype.nexus.proxy.maven

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


    Repository repo1 = getRepositoryRegistry().getRepository("repo1");
    Repository repo2 = getRepositoryRegistry().getRepository("repo2");
    Repository repo3 = getRepositoryRegistry().getRepository("repo3");
    Repository inhouse = getRepositoryRegistry().getRepository("inhouse");
    Repository inhouseSnapshot = getRepositoryRegistry().getRepository("inhouse-snapshot");
    MavenGroupRepository test = getRepositoryRegistry().getRepositoryWithFacet("test", MavenGroupRepository.class);

    // now change some of them
    repo1.setLocalStatus(LocalStatus.OUT_OF_SERVICE);
    repo3.setName("kuku");
    test.setMergeMetadata(false);

    // changes are not applied yet!
    assertEquals("Should not be applied!", LocalStatus.IN_SERVICE, repo1.getLocalStatus());
    assertEquals("Should not be applied!", "repo3", repo3.getName());
    assertEquals("Should not be applied!", true, test.isMergeMetadata());

    // fire prepareForSave event
    ConfigurationPrepareForSaveEvent pevt = new ConfigurationPrepareForSaveEvent(getApplicationConfiguration());
    eventBus().post(pevt);
    assertFalse(pevt.isVetoed());

    eventBus().post(new ConfigurationCommitEvent(getApplicationConfiguration()));

    // changes are now applied!
    assertEquals("Should be applied!", LocalStatus.OUT_OF_SERVICE, repo1.getLocalStatus());
    assertEquals("Should be applied!", "kuku", repo3.getName());
    assertEquals("Should be applied!", false, test.isMergeMetadata());

    // changed reposes should be in event
    assertTrue("Is changed!", pevt.getChanges().contains(repo1));
    assertTrue("Is changed!", pevt.getChanges().contains(repo3));
    assertTrue("Is changed!", pevt.getChanges().contains(test));
View Full Code Here


    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());
View Full Code Here

    // propagate
    propagatePrefixFileUpdateOf(mavenRepository);
  }

  protected void propagatePrefixFileUpdateOf(final MavenRepository mavenRepository) {
    MavenGroupRepository containingGroupRepository = null;
    final List<GroupRepository> groups = repositoryRegistry.getGroupsOfRepository(mavenRepository);
    for (GroupRepository groupRepository : groups) {
      containingGroupRepository = groupRepository.adaptToFacet(MavenGroupRepository.class);
      if (mavenRepository != null) {
        // this method is invoked while holding write lock on mavenRepository prefix file
View Full Code Here

      // the above line should throw IOex
      Assert.fail("There should be exception thrown!");
    }
    catch (IOException e) {
      final MavenGroupRepository publicGroup = repositoryRegistry
          .getRepositoryWithFacet("public", MavenGroupRepository.class);
      // ensure we fetched from one we wanted (failingRepository)
      assertThat(fetchCountingInvocationHandler, new InvocationMatcher(indexedProxyRepositories));
      // ensure we scanned all the repositories (minus the one failed, as it failed _BEFORE_ scan invocation)
      Assert.assertEquals(publicGroup.getMemberRepositoryIds().size() - 1, scanInvocationCount);

      // ensure suppressed exception detail is present
      assertThat(e.getSuppressed(), notNullValue());
      assertThat(e.getSuppressed()[0], is((Throwable) ex));
    }
View Full Code Here

  public void testUpdateGroup()
      throws Exception
  {
    createM1HostedRepo("m1h");
    createM1ProxyRepo("m1p");
    MavenGroupRepository group = createM1Group("m1g", Arrays.asList("central-m1", "m1h", "m1p"));

    assertTrue(group.getMemberRepositoryIds().contains("m1h"));
    assertTrue(group.getMemberRepositoryIds().contains("m1p"));
    assertTrue(group.getMemberRepositoryIds().contains("central-m1"));
    assertTrue(group.getMemberRepositoryIds().size() == 3);

    // now delete the proxy
    nexusConfiguration().deleteRepository("m1p");

    assertTrue(group.getMemberRepositoryIds().contains("m1h"));
    assertTrue(group.getMemberRepositoryIds().contains("central-m1"));
    assertTrue(group.getMemberRepositoryIds().size() == 2);
  }
View Full Code Here

      // lookup nexus, this will do all sort of things, amongst them validate the config
      startNx();

      RepositoryRegistry repositoryRegistry = lookup(RepositoryRegistry.class);

      MavenGroupRepository publicGroup =
          repositoryRegistry.getRepositoryWithFacet("public", MavenGroupRepository.class);

      List<String> memberIds = new ArrayList<String>();
      for (Repository repo : publicGroup.getMemberRepositories()) {
        memberIds.add(repo.getId());
      }

      MatcherAssert.assertThat("Repo object list returned a different set of repos", memberIds,
          Matchers.equalTo(publicGroup.getMemberRepositoryIds()));

      MatcherAssert.assertThat(
          "The config should be 4 reposes, but ids found are: " + publicGroup.getMemberRepositoryIds(),
          publicGroup.getMemberRepositories().size(), Matchers.equalTo(4));
    }
    catch (Exception e) {
      Assert.fail("Should succeed!");
    }
  }
View Full Code Here

      saveItemToFile((StorageFileItem) item2, md2File);

      // get metadata from a gidr router but switch merging off (default is on), spoofing should happen, and the
      // highest ranked repo
      // in group (repo1) should provide the file
      MavenGroupRepository mgr =
          getRepositoryRegistry().getRepositoryWithFacet("test", MavenGroupRepository.class);
      mgr.setMergeMetadata(false);
      ((AbstractMavenGroupRepository)mgr).commitChanges();
      // mgr.getCurrentCoreConfiguration().commitChanges();
      eventBus().post(new ConfigurationChangeEvent(getApplicationConfiguration(), null, null));

      StorageItem item =
View Full Code Here

      assertEquals(1, md2.getVersioning().getVersions().size());
      assertEquals("20020202020202", md2.getVersioning().getLastUpdated());

      // get metadata from a gidr router but switch merging off (default is on), spoofing should happen, and the
      // highest ranked repo in group (repo1) should provide the file
      MavenGroupRepository mgr =
          getRepositoryRegistry().getRepositoryWithFacet("test", MavenGroupRepository.class);
      mgr.setMergeMetadata(false);
      ((AbstractMavenGroupRepository)mgr).commitChanges();
      // mgr.getCurrentCoreConfiguration().commitChanges();
      eventBus().post(new ConfigurationChangeEvent(getApplicationConfiguration(), null, null));

      item = getRootRouter().retrieveItem(new ResourceStoreRequest("/groups/test" + spoofedPath, false));
View Full Code Here

    // in case of group member changes, the "cascade" is sync, hence
    // we have no ordering problem as we have with async updates of proxy/hosted
    // reposes on boot
    prefixFileUpdateListener.reset();

    final MavenGroupRepository mgr =
        getRepositoryRegistry().getRepositoryWithFacet(GROUP1_REPO_ID, MavenGroupRepository.class);

    mgr.removeMemberRepositoryId(HOSTED1_REPO_ID);
    getApplicationConfiguration().saveConfiguration();
    waitForRoutingBackgroundUpdates();

    assertThat(prefixFileUpdateListener.getPublished(), contains(GROUP1_REPO_ID, GROUP2_REPO_ID));

    mgr.addMemberRepositoryId(HOSTED1_REPO_ID);
    getApplicationConfiguration().saveConfiguration();
    waitForRoutingBackgroundUpdates();

    assertThat(prefixFileUpdateListener.getPublished(),
        contains(GROUP1_REPO_ID, GROUP2_REPO_ID, GROUP1_REPO_ID, GROUP2_REPO_ID));
View Full Code Here

    // in case of group member changes, the "cascade" is sync, hence
    // we have no ordering problem as we have with async updates of proxy/hosted
    // reposes on boot
    prefixFileUpdateListener.reset();

    final MavenGroupRepository mgr =
        getRepositoryRegistry().getRepositoryWithFacet(GROUP2_REPO_ID, MavenGroupRepository.class);

    mgr.removeMemberRepositoryId(GROUP1_REPO_ID);
    mgr.addMemberRepositoryId(HOSTED1_REPO_ID);
    getApplicationConfiguration().saveConfiguration();
    waitForRoutingBackgroundUpdates();

    assertThat(prefixFileUpdateListener.getPublished(), contains(GROUP2_REPO_ID));

    mgr.addMemberRepositoryId(HOSTED2_REPO_ID);
    getApplicationConfiguration().saveConfiguration();
    waitForRoutingBackgroundUpdates();

    assertThat(prefixFileUpdateListener.getPublished(),
        contains(GROUP2_REPO_ID, GROUP2_REPO_ID));
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.maven.MavenGroupRepository

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.