Package org.sonatype.nexus.configuration.model

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


    }

    // ading one hosted only
    M2Repository repo = (M2Repository) lookup(Repository.class, "maven2");

    CRepository repoConf = new DefaultCRepository();

    repoConf.setProviderRole(Repository.class.getName());
    repoConf.setProviderHint("maven2");
    repoConf.setId(id);

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

    repoConf.getLocalStorage().setUrl(repoRoot.toURI().toURL().toString());

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

    repo.configure(repoConf);
View Full Code Here


      throws IOException
  {
    List<CRepository> repos = getNexusConfig().getRepositories();

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

      // check id
      if (cRepo.getId().equals(repoId)) {
        return cRepo;
      }
    }
    return null;
  }
View Full Code Here

      throws IOException
  {
    List<CRepository> repos = getNexusConfig().getRepositories();

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

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

        return exRepoConf;
      }
    }
View Full Code Here

      throws IOException
  {
    List<CRepository> repos = getNexusConfig().getRepositories();

    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

      throws IOException
  {
    List<CRepository> repos = getNexusConfig().getRepositories();

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

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

        return exRepoConf;
      }
    }
View Full Code Here

    // getId() would NPE!
    String repoId = "not-configured-yet";
    final CRepositoryCoreConfiguration currentCoreConfiguration =
        (CRepositoryCoreConfiguration) getCurrentCoreConfiguration();
    if (currentCoreConfiguration != null) {
      final CRepository crepository = currentCoreConfiguration.getConfiguration(false);
      if (crepository != null && crepository.getId() != null && crepository.getId().trim().length() > 0) {
        repoId = crepository.getId();
      }
    }
    return String.format("%s(id=%s)", getClass().getSimpleName(), repoId);
  }
View Full Code Here

      throws ConfigurationException
  {
    // Setting common things on a repository

    // FIXME: hm, we are called when we are dirty, so....
    CRepository repo = coreConfiguration.getConfiguration(true);

    // NX-198: filling up the default variable to store the "default" local URL
    File defaultStorageFile = new File(new File(configuration.getWorkingDirectory(), "storage"), repo.getId());

    try {
      repo.defaultLocalStorageUrl = defaultStorageFile.toURI().toURL().toString();
    }
    catch (MalformedURLException e) {
      // will not happen, not user settable
      throw new InvalidConfigurationException("Malformed URL for LocalRepositoryStorage!", e);
    }

    String localUrl;
    boolean usingDefaultLocalUrl;

    if (repo.getLocalStorage() != null && !Strings.isNullOrEmpty(repo.getLocalStorage().getUrl())) {
      localUrl = repo.getLocalStorage().getUrl();
      usingDefaultLocalUrl = false;
    }
    else {
      localUrl = repo.defaultLocalStorageUrl;
      usingDefaultLocalUrl = true;
    }

    if (repo.getLocalStorage() == null) {
      repo.setLocalStorage(new CLocalStorage());

      repo.getLocalStorage().setProvider("file");
    }

    LocalRepositoryStorage ls = getLocalRepositoryStorage(repo.getId(), repo.getLocalStorage().getProvider());

    try {
      ls.validateStorageUrl(localUrl);

      if (!usingDefaultLocalUrl) {
        repo.getLocalStorage().setUrl(localUrl);
      }

      repository.setLocalStorage(ls);
      // mark local storage context dirty, if applicable
      final LocalStorageContext ctx = repository.getLocalStorageContext();
View Full Code Here

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

        Assert.assertEquals(effectiveLocalStorage, storageURL);
      }

      // now check all agaist the the cRepo
      CRepository cRepo = getNexusConfigUtil().getRepo(listRepo.getId());

      if (cRepo != null) {
        M2RepositoryConfiguration cM2Repo = getNexusConfigUtil().getM2Repo(listRepo.getId());
        Assert.assertEquals(listRepo.getId(), cRepo.getId());
        Assert.assertEquals(listRepo.getName(), cRepo.getName());
        // Assert.assertEquals( cM2Repo.getType(), listRepo.getFormat() );
        Assert.assertEquals(listRepo.getRepoPolicy(), cM2Repo.getRepositoryPolicy().name());

        log.debug("cRepo.getRemoteStorage(): " + cRepo.getRemoteStorage());
        log.debug("listRepo.getRemoteUri(): " + listRepo.getRemoteUri());

        Assert.assertTrue((cRepo.getRemoteStorage() == null && listRepo.getRemoteUri() == null)
            || (cRepo.getRemoteStorage().getUrl().equals(listRepo.getRemoteUri())));
      }
      else {
        M2LayoutedM1ShadowRepositoryConfiguration cShadow =
            getNexusConfigUtil().getRepoShadow(listRepo.getId());

        Assert.assertEquals(listRepo.getId(), cRepo.getId());
        Assert.assertEquals(listRepo.getName(), cRepo.getName());
        // Assert.assertEquals( cShadow.getType(), this.formatToType( listRepo.getFormat() ) );
        Assert.assertEquals(listRepo.getRepoType(), RepositoryBaseResourceConverter.REPO_TYPE_VIRTUAL);
      }

    }
View Full Code Here

  {
    for (ProxyRepository master : getRepositoryRegistry().getRepositoriesWithFacet(ProxyRepository.class)) {
      M1LayoutedM2ShadowRepository shadow =
          (M1LayoutedM2ShadowRepository) getContainer().lookup(ShadowRepository.class, "m2-m1-shadow");

      CRepository repoConf = new DefaultCRepository();

      repoConf.setProviderRole(ShadowRepository.class.getName());
      repoConf.setProviderHint("m2-m1-shadow");
      repoConf.setId(master.getId() + "-m1");
      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(master.getId());

      shadow.configure(repoConf);
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.configuration.model.CRepository

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.