Examples of CRepository


Examples of org.sonatype.nexus.configuration.model.CRepository

    repositoryRegistry.removeRepository(id);

    List<CRepository> reposes = getConfigurationModel().getRepositories();

    for (Iterator<CRepository> i = reposes.iterator(); i.hasNext(); ) {
      CRepository repo = i.next();

      if (repo.getId().equals(id)) {
        i.remove();

        saveConfiguration();

        releaseRepository(repository, getConfigurationModel(), repo);
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

    String masterId = "repo1-m1";

    M2LayoutedM1ShadowRepository shadow =
        (M2LayoutedM1ShadowRepository) getContainer().lookup(ShadowRepository.class, "m1-m2-shadow");

    CRepository repoConf = new DefaultCRepository();

    repoConf.setProviderRole(ShadowRepository.class.getName());
    repoConf.setProviderHint("m1-m2-shadow");
    repoConf.setId(masterId + "-m2");
    repoConf.setIndexable(false);

    repoConf.setLocalStorage(new CLocalStorage());
    repoConf.getLocalStorage().setProvider("file");

    Xpp3Dom exRepo = new Xpp3Dom("externalConfiguration");
    repoConf.setExternalConfiguration(exRepo);
    M1LayoutedM2ShadowRepositoryConfiguration exRepoConf = new M1LayoutedM2ShadowRepositoryConfiguration(exRepo);
    exRepoConf.setMasterRepositoryId(masterId);

    shadow.configure(repoConf);
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

    super(provider, id, description, new Maven1ContentClass(), MavenHostedRepository.class, repositoryPolicy);
  }

  @Override
  protected CRepositoryCoreConfiguration initCoreConfiguration() {
    CRepository repo = new DefaultCRepository();

    repo.setId("");
    repo.setName("");

    repo.setProviderRole(Repository.class.getName());
    repo.setProviderHint("maven1");

    Xpp3Dom ex = new Xpp3Dom(DefaultCRepository.EXTERNAL_CONFIGURATION_NODE_NAME);
    repo.setExternalConfiguration(ex);

    M1RepositoryConfiguration exConf = new M1RepositoryConfiguration(ex);
    // huh? see initConfig classes
    if (getRepositoryPolicy() != null) {
      exConf.setRepositoryPolicy(getRepositoryPolicy());
    }

    repo.externalConfigurationImple = exConf;

    repo.setWritePolicy(RepositoryWritePolicy.ALLOW_WRITE_ONCE.name());
    repo.setNotFoundCacheTTL(1440);

    CRepositoryCoreConfiguration result =
        new CRepositoryCoreConfiguration(
            getTemplateProvider().getApplicationConfiguration(),
            repo,
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

  public void testNEXUS2212SaveInvalidConfig()
      throws Exception
  {
    Configuration nexusConfig = nexusConfiguration.getConfigurationModel();

    CRepository centralCRepo = null;

    for (CRepository cRepo : nexusConfig.getRepositories()) {
      if (cRepo.getId().equals("central")) {
        centralCRepo = cRepo;
        break;
      }
    }

    assertNotNull(centralCRepo);

    centralCRepo.setLocalStatus(LocalStatus.OUT_OF_SERVICE.name());
    nexusConfiguration.saveConfiguration();
  }
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

  private Repository getDummyRepository()
      throws Exception
  {
    M2Repository repository = (M2Repository) lookup(Repository.class, "maven2");

    CRepository cRepo = new DefaultCRepository();
    cRepo.setId("test-repo");
    cRepo.setLocalStatus(LocalStatus.IN_SERVICE.toString());
    cRepo.setNotFoundCacheTTL(1);
    cRepo.setLocalStorage(new CLocalStorage());
    cRepo.getLocalStorage().setProvider("file");
    cRepo.setProviderRole(Repository.class.getName());
    cRepo.setProviderHint("maven2");

    Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
    cRepo.setExternalConfiguration(ex);
    M2RepositoryConfiguration extConf = new M2RepositoryConfiguration(ex);
    extConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);

    repository.configure(cRepo);
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

    //
    //        // anon username
    //        config.getSecurity().setAnonymousPassword( password );

    // repo auth pass
    CRepository central = this.getCentralRepo(config);
    central.getRemoteStorage().setAuthentication(new CRemoteAuthentication());
    central.getRemoteStorage().getAuthentication().setPassword(password);

    // now we need to make the file valid....
    config.getRemoteProxySettings().getHttpProxySettings().setProxyPort(1234);

    // save it
    source.storeConfiguration();

    XStream xs = new XStream();
    xs.processAnnotations(new Class[] { Xpp3Dom.class });
    Assert.assertTrue("Configuration is corroupt, passwords are encrypted (in memory). ",
        xs.toXML(config).contains(password));

    // now get the file and look for the "clear-text"
    String configString = FileUtils.readFileToString(new File(this.getNexusConfiguration()));

    Assert.assertFalse("Clear text password found in nexus.xml:\n" + configString, configString
        .contains(password));

    // make sure we do not have the default smtp password either
    Assert.assertFalse("Old SMTP password found in nexus.xml", configString.contains("smtp-password"));

    // now load it again and make sure the password is clear text
    Configuration newConfig = source.loadConfiguration();
    Assert.assertEquals(password, newConfig.getSmtpConfiguration().getPassword());
    Assert.assertEquals(
        password, newConfig.getRemoteProxySettings().getHttpProxySettings().getAuthentication().getPassword()
    );
    Assert.assertEquals(
        password, newConfig.getRemoteProxySettings().getHttpsProxySettings().getAuthentication().getPassword()
    );
    //        Assert.assertEquals( password, newConfig.getSecurity().getAnonymousPassword() );

    central = this.getCentralRepo(newConfig);
    Assert.assertEquals(password, central.getRemoteStorage().getAuthentication().getPassword());
  }
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

    super(provider, id, description, new Maven2ContentClass(), MavenProxyRepository.class, repositoryPolicy);
  }

  @Override
  protected CRepositoryCoreConfiguration initCoreConfiguration() {
    CRepository repo = new DefaultCRepository();

    repo.setId("");
    repo.setName("");

    repo.setProviderRole(Repository.class.getName());
    repo.setProviderHint("maven2");

    repo.setRemoteStorage(new CRemoteStorage());
    repo.getRemoteStorage().setProvider(
        getTemplateProvider().getRemoteProviderHintFactory().getDefaultHttpRoleHint());
    repo.getRemoteStorage().setUrl("http://some-remote-repository/repo-root");

    Xpp3Dom ex = new Xpp3Dom(DefaultCRepository.EXTERNAL_CONFIGURATION_NODE_NAME);
    repo.setExternalConfiguration(ex);

    M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
    // huh? see initConfig classes
    if (getRepositoryPolicy() != null) {
      exConf.setRepositoryPolicy(getRepositoryPolicy());
    }

    repo.externalConfigurationImple = exConf;

    repo.setWritePolicy(RepositoryWritePolicy.READ_ONLY.name());
    repo.setNotFoundCacheActive(true);
    repo.setNotFoundCacheTTL(1440);

    if (exConf.getRepositoryPolicy() != null && exConf.getRepositoryPolicy() == RepositoryPolicy.SNAPSHOT) {
      exConf.setArtifactMaxAge(1440);
    }
    else {
      exConf.setArtifactMaxAge(-1);
    }

    repo.setIndexable(true);
    repo.setSearchable(true);

    CRepositoryCoreConfiguration result =
        new CRepositoryCoreConfiguration(getTemplateProvider().getApplicationConfiguration(), repo,
            new CRepositoryExternalConfigurationHolderFactory<M2RepositoryConfiguration>()
            {
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

  @Test
  public void sameMemberMultipleTime() {
    final Xpp3Dom xpp3Dom = mock(Xpp3Dom.class);
    final ApplicationConfiguration applicationConfiguration = mock(ApplicationConfiguration.class);
    final Configuration configuration = mock(Configuration.class);
    final CRepository repo1 = new CRepository();
    repo1.setId("1");
    final CRepository repo2 = new CRepository();
    repo2.setId("2");

    when(applicationConfiguration.getConfigurationModel()).thenReturn(configuration);
    when(configuration.getRepositories()).thenReturn(Lists.newArrayList(repo1, repo2));

    final AbstractGroupRepositoryConfiguration underTest = new AbstractGroupRepositoryConfiguration(
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

        localStorageDirectory =
            env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + REPO_ID);

        // ading one hosted only
        final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
        CRepository repoConf = new DefaultCRepository();
        repoConf.setProviderRole(Repository.class.getName());
        repoConf.setProviderHint("maven2");
        repoConf.setId(REPO_ID);
        repoConf.setName(REPO_ID);
        repoConf.setLocalStorage(new CLocalStorage());
        repoConf.getLocalStorage().setProvider("file");
        repoConf.getLocalStorage().setUrl(localStorageDirectory.toURI().toURL().toString());
        Xpp3Dom exRepo = new Xpp3Dom("externalConfiguration");
        repoConf.setExternalConfiguration(exRepo);
        M2RepositoryConfiguration exRepoConf = new M2RepositoryConfiguration(exRepo);
        exRepoConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
        repo.configure(repoConf);
        env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
        env.getRepositoryRegistry().addRepository(repo);
View Full Code Here

Examples of org.sonatype.nexus.configuration.model.CRepository

    List<String> reposes = new ArrayList<String>();
    for (String remoteRepoId : repoIds()) {

      // create proxy for remote
      M1Repository repo = (M1Repository) env.lookup(Repository.class, "maven1");
      CRepository repoConf = new DefaultCRepository();
      repoConf.setProviderRole(Repository.class.getName());
      repoConf.setProviderHint("maven1");
      repoConf.setId(remoteRepoId);
      repoConf.setName(remoteRepoId);

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

      Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
      repoConf.setExternalConfiguration(ex);
      M1RepositoryConfiguration exConf = new M1RepositoryConfiguration(ex);
      exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
      exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);

      repoConf.setRemoteStorage(new CRemoteStorage());
      repoConf.getRemoteStorage().setProvider(env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
      repoConf.getRemoteStorage().setUrl(server().getUrl() + "/" + remoteRepoId);
      repoConf.setIndexable(false);

      repo.configure(repoConf);

      // repo.setCacheManager( env.getCacheManager() );
      reposes.add(repo.getId());

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

      env.getRepositoryRegistry().addRepository(repo);
    }

    // ading one hosted only
    M1Repository repo = (M1Repository) env.lookup(Repository.class, "maven1");

    CRepository repoConf = new DefaultCRepository();

    repoConf.setProviderRole(Repository.class.getName());
    repoConf.setProviderHint("maven1");
    repoConf.setId("inhouse");
    repoConf.setIndexable(false);

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

    Xpp3Dom exRepo = new Xpp3Dom("externalConfiguration");
    repoConf.setExternalConfiguration(exRepo);
    M1RepositoryConfiguration exRepoConf = new M1RepositoryConfiguration(exRepo);
    exRepoConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
    exRepoConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);

    repo.configure(repoConf);

    reposes.add(repo.getId());

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

    env.getRepositoryRegistry().addRepository(repo);

    // add a hosted snapshot repo
    M1Repository repoSnapshot = (M1Repository) env.lookup(Repository.class, "maven1");

    CRepository repoSnapshotConf = new DefaultCRepository();

    repoSnapshotConf.setProviderRole(Repository.class.getName());
    repoSnapshotConf.setProviderHint("maven1");
    repoSnapshotConf.setId("inhouse-snapshot");
    repoSnapshotConf.setIndexable(false);

    repoSnapshotConf.setLocalStorage(new CLocalStorage());
    repoSnapshotConf.getLocalStorage().setProvider("file");
    repoSnapshotConf.getLocalStorage().setUrl(
        env
            .getApplicationConfiguration().getWorkingDirectory("proxy/store/inhouse-snapshot").toURI().toURL()
            .toString()
    );

    Xpp3Dom exSnapRepo = new Xpp3Dom("externalConfiguration");
    repoSnapshotConf.setExternalConfiguration(exSnapRepo);
    M1RepositoryConfiguration exSnapRepoConf = new M1RepositoryConfiguration(exSnapRepo);
    exSnapRepoConf.setRepositoryPolicy(RepositoryPolicy.SNAPSHOT);
    exSnapRepoConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);

    repoSnapshot.configure(repoSnapshotConf);

    reposes.add(repoSnapshot.getId());

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

    env.getRepositoryRegistry().addRepository(repoSnapshot);

    // add a group
    M1GroupRepository group = (M1GroupRepository) env.lookup(GroupRepository.class, "maven1");

    CRepository repoGroupConf = new DefaultCRepository();

    repoGroupConf.setProviderRole(GroupRepository.class.getName());
    repoGroupConf.setProviderHint("maven1");
    repoGroupConf.setId("test");
    repoGroupConf.setIndexable(false);

    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);
    M1GroupRepositoryConfiguration exGroupRepoConf = new M1GroupRepositoryConfiguration(exGroupRepo);
    exGroupRepoConf.setMemberRepositoryIds(reposes);
    exGroupRepoConf.setMergeMetadata(true);

    group.configure(repoGroupConf);
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.