Package org.sonatype.nexus.proxy.maven.maven2

Examples of org.sonatype.nexus.proxy.maven.maven2.M2Repository


  public void testNexus4985GroupsShouldNotSwallowMemberExceptions()
      throws Exception
  {
    // add another group to make things a bit hairier
    {
      M2GroupRepository group = (M2GroupRepository) lookup(GroupRepository.class, "maven2");

      CRepository repoGroupConf = new DefaultCRepository();

      repoGroupConf.setProviderRole(GroupRepository.class.getName());
      repoGroupConf.setProviderHint("maven2");
      repoGroupConf.setId("another-test");

      repoGroupConf.setLocalStorage(new CLocalStorage());
      repoGroupConf.getLocalStorage().setProvider("file");
      repoGroupConf.getLocalStorage().setUrl(
          getApplicationConfiguration().getWorkingDirectory("proxy/store/another-test").toURI().toURL().toString());

      Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
      repoGroupConf.setExternalConfiguration(exGroupRepo);
      M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
      // members are "test" (an existing group, to have group of group) and repo1 that is already member via
      // "test"
      exGroupRepoConf.setMemberRepositoryIds(Arrays.asList("test", "repo1"));
      exGroupRepoConf.setMergeMetadata(true);
      group.configure(repoGroupConf);
      getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
      getRepositoryRegistry().addRepository(group);
    }

    // now put a hosted repository "inhouse-snapshot" out of service to make output nicer
    final Repository inhouseSnapshot = getRepositoryRegistry().getRepository("inhouse-snapshot");
    inhouseSnapshot.setLocalStatus(LocalStatus.OUT_OF_SERVICE);
    ((AbstractMavenRepository) inhouseSnapshot).commitChanges();

    // so far, what we did: we had few reposes and a group called "test" (that had all the reposes as members).
    // now, we added test and repo1 reposes ta a newly created group, to have groups of groups.
    // we also put a member repo "inhouse-snapshot" out of service.

    // now we ask for something that IS KNOWN TO NOT EXISTS, hence, request will arrive to all members
    // and members of members (recursively), and the response will form a nice tree

    final GroupRepository group =
        getRepositoryRegistry().getRepositoryWithFacet("another-test", GroupRepository.class);

    try {
      group.retrieveItem(new ResourceStoreRequest("/some/path/that/we/know/is/not/existing/123456/12.foo"));
      // anything else should fail
      fail("We expected an exception here!");
    }
    catch (GroupItemNotFoundException e) {
      final String dumpStr = dumpNotFoundReasoning(e, 0);
View Full Code Here


    env.getApplicationConfiguration().getConfigurationModel().addRepository(repoSnapshotConf);

    env.getRepositoryRegistry().addRepository(repoSnapshot);

    // add a group
    M2GroupRepository group = (M2GroupRepository) env.lookup(GroupRepository.class, "maven2");

    CRepository repoGroupConf = new DefaultCRepository();

    repoGroupConf.setProviderRole(GroupRepository.class.getName());
    repoGroupConf.setProviderHint("maven2");
    repoGroupConf.setId("test");

    repoGroupConf.setLocalStorage(new CLocalStorage());
    repoGroupConf.getLocalStorage().setProvider("file");
    repoGroupConf.getLocalStorage().setUrl(
        env.getApplicationConfiguration().getWorkingDirectory("proxy/store/test").toURI().toURL().toString());

    Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
    repoGroupConf.setExternalConfiguration(exGroupRepo);
    M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
    exGroupRepoConf.setMemberRepositoryIds(reposes);
    exGroupRepoConf.setMergeMetadata(true);

    group.configure(repoGroupConf);

    env.getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);

    env.getRepositoryRegistry().addRepository(group);
  }
View Full Code Here

          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // add a group
          final M2GroupRepository group =
              (M2GroupRepository) env.lookup(GroupRepository.class, "maven2");
          CRepository repoGroupConf = new DefaultCRepository();
          repoGroupConf.setProviderRole(GroupRepository.class.getName());
          repoGroupConf.setProviderHint("maven2");
          repoGroupConf.setId(GROUP1_REPO_ID);
          repoGroupConf.setName(GROUP1_REPO_ID);
          repoGroupConf.setLocalStorage(new CLocalStorage());
          repoGroupConf.getLocalStorage().setProvider("file");
          repoGroupConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + GROUP1_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
          repoGroupConf.setExternalConfiguration(exGroupRepo);
          M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
          exGroupRepoConf.setMemberRepositoryIds(reposes);
          exGroupRepoConf.setMergeMetadata(true);
          group.configure(repoGroupConf);
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
          env.getRepositoryRegistry().addRepository(group);
        }
        {
          // add 2nd group
          final M2GroupRepository group =
              (M2GroupRepository) env.lookup(GroupRepository.class, "maven2");
          CRepository repoGroupConf = new DefaultCRepository();
          repoGroupConf.setProviderRole(GroupRepository.class.getName());
          repoGroupConf.setProviderHint("maven2");
          repoGroupConf.setId(GROUP2_REPO_ID);
          repoGroupConf.setName(GROUP2_REPO_ID);
          repoGroupConf.setLocalStorage(new CLocalStorage());
          repoGroupConf.getLocalStorage().setProvider("file");
          repoGroupConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + GROUP2_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
          repoGroupConf.setExternalConfiguration(exGroupRepo);
          M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
          exGroupRepoConf.setMemberRepositoryIds(Collections.singletonList(GROUP1_REPO_ID));
          exGroupRepoConf.setMergeMetadata(true);
          group.configure(repoGroupConf);
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
          env.getRepositoryRegistry().addRepository(group);
        }
      }
    };
View Full Code Here

          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // add a group
          final M2GroupRepository group =
              (M2GroupRepository) env.lookup(GroupRepository.class, "maven2");
          CRepository repoGroupConf = new DefaultCRepository();
          repoGroupConf.setProviderRole(GroupRepository.class.getName());
          repoGroupConf.setProviderHint("maven2");
          repoGroupConf.setId(GROUP_REPO_ID);
          repoGroupConf.setName(GROUP_REPO_ID);
          repoGroupConf.setLocalStorage(new CLocalStorage());
          repoGroupConf.getLocalStorage().setProvider("file");
          repoGroupConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/test").toURI().toURL().toString());
          Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
          repoGroupConf.setExternalConfiguration(exGroupRepo);
          M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
          exGroupRepoConf.setMemberRepositoryIds(reposes);
          exGroupRepoConf.setMergeMetadata(true);
          group.configure(repoGroupConf);
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
          env.getRepositoryRegistry().addRepository(group);
        }
      }
    };
View Full Code Here

          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // add a group
          final M2GroupRepository group =
              (M2GroupRepository) env.lookup(GroupRepository.class, "maven2");
          CRepository repoGroupConf = new DefaultCRepository();
          repoGroupConf.setProviderRole(GroupRepository.class.getName());
          repoGroupConf.setProviderHint("maven2");
          repoGroupConf.setId(GROUP_REPO_ID);
          repoGroupConf.setName(GROUP_REPO_ID);
          repoGroupConf.setLocalStorage(new CLocalStorage());
          repoGroupConf.getLocalStorage().setProvider("file");
          repoGroupConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/test").toURI().toURL().toString());
          Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
          repoGroupConf.setExternalConfiguration(exGroupRepo);
          M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
          exGroupRepoConf.setMemberRepositoryIds(reposes);
          exGroupRepoConf.setMergeMetadata(true);
          group.configure(repoGroupConf);
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
          env.getRepositoryRegistry().addRepository(group);
        }
      }
    };
View Full Code Here

          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // add a group
          final M2GroupRepository group =
              (M2GroupRepository) env.lookup(GroupRepository.class, "maven2");
          CRepository repoGroupConf = new DefaultCRepository();
          repoGroupConf.setProviderRole(GroupRepository.class.getName());
          repoGroupConf.setProviderHint("maven2");
          repoGroupConf.setId(GROUP_REPO_ID);
          repoGroupConf.setName(GROUP_REPO_ID);
          repoGroupConf.setLocalStorage(new CLocalStorage());
          repoGroupConf.getLocalStorage().setProvider("file");
          repoGroupConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/test").toURI().toURL().toString());
          Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
          repoGroupConf.setExternalConfiguration(exGroupRepo);
          M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
          exGroupRepoConf.setMemberRepositoryIds(reposes);
          exGroupRepoConf.setMergeMetadata(true);
          group.configure(repoGroupConf);
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
          env.getRepositoryRegistry().addRepository(group);
        }
      }
    };
View Full Code Here

  }

  private Repository buildGroupRepository(String repoId, boolean exposed)
      throws Exception
  {
    M2GroupRepository repo = (M2GroupRepository) this.lookup(GroupRepository.class, "maven2");
    CRepository repoConfig = new DefaultCRepository();
    repoConfig.setId(repoId);
    repoConfig.setExposed(exposed);
    repoConfig.setProviderRole(GroupRepository.class.getName());
    repoConfig.setProviderHint("maven2");
    repo.configure(repoConfig);
    this.repositoryRegistry.addRepository(repo);
    this.applicationConfiguration.getConfigurationModel().addRepository(repoConfig);

    return repo;
  }
View Full Code Here

    for (Iterator<CRepository> iter = repos.iterator(); iter.hasNext(); ) {
      CRepository cRepo = iter.next();

      // check id
      if (cRepo.getId().equals(groupId)) {
        M2GroupRepositoryConfiguration exRepoConf =
            new M2GroupRepositoryConfiguration((Xpp3Dom) cRepo.getExternalConfiguration());

        return exRepoConf;
      }
    }
View Full Code Here

      repoGroupConf.getLocalStorage().setUrl(
          getApplicationConfiguration().getWorkingDirectory("proxy/store/another-test").toURI().toURL().toString());

      Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
      repoGroupConf.setExternalConfiguration(exGroupRepo);
      M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
      // members are "test" (an existing group, to have group of group) and repo1 that is already member via
      // "test"
      exGroupRepoConf.setMemberRepositoryIds(Arrays.asList("test", "repo1"));
      exGroupRepoConf.setMergeMetadata(true);
      group.configure(repoGroupConf);
      getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
      getRepositoryRegistry().addRepository(group);
    }
View Full Code Here

    repoGroupConf.getLocalStorage().setUrl(
        env.getApplicationConfiguration().getWorkingDirectory("proxy/store/test").toURI().toURL().toString());

    Xpp3Dom exGroupRepo = new Xpp3Dom("externalConfiguration");
    repoGroupConf.setExternalConfiguration(exGroupRepo);
    M2GroupRepositoryConfiguration exGroupRepoConf = new M2GroupRepositoryConfiguration(exGroupRepo);
    exGroupRepoConf.setMemberRepositoryIds(reposes);
    exGroupRepoConf.setMergeMetadata(true);

    group.configure(repoGroupConf);

    env.getApplicationConfiguration().getConfigurationModel().addRepository(repoGroupConf);
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.maven.maven2.M2Repository

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.