Package org.sonatype.nexus.configuration.model

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


    }

    // 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


  {
    // 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

  {
    List<String> reposes = new ArrayList<String>();
    for (String remoteRepoId : repoIds()) {
      // create proxy for remote
      M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
      CRepository repoConf = new DefaultCRepository();
      repoConf.setProviderRole(Repository.class.getName());
      repoConf.setProviderHint("maven2");
      repoConf.setId(remoteRepoId);
      repoConf.setName(remoteRepoId);
      repoConf.setNotFoundCacheActive(true);

      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);
      M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
      if (remoteRepoId.endsWith("-snapshot")) {
        exConf.setRepositoryPolicy(RepositoryPolicy.SNAPSHOT);
      }
      else {
        exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
      }
      exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
      exConf.setRoutingDiscoveryEnabled(false);

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

      repo.configure(repoConf);

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

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

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

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

    CRepository repoConf = new DefaultCRepository();

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

    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);
    M2RepositoryConfiguration exRepoConf = new M2RepositoryConfiguration(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
    M2Repository repoSnapshot = (M2Repository) env.lookup(Repository.class, "maven2");

    CRepository repoSnapshotConf = new DefaultCRepository();

    repoSnapshotConf.setProviderRole(Repository.class.getName());
    repoSnapshotConf.setProviderHint("maven2");
    repoSnapshotConf.setId("inhouse-snapshot");

    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);
    M2RepositoryConfiguration exSnapRepoConf = new M2RepositoryConfiguration(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
    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);
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

          throws Exception
      {
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY_REPO_ID);
          repoConf.setName(PROXY_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY_REPO_ID).toURI().toURL()
                  .toString()
          );
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server.getPort() + "/");
          repo.configure(repoConf);
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
      }
View Full Code Here

          final List<String> reposes = new ArrayList<String>();
          {
            // adding one proxy
            final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
            CRepository repoConf = new DefaultCRepository();
            repoConf.setProviderRole(Repository.class.getName());
            repoConf.setProviderHint("maven2");
            repoConf.setId(PROXY_REPO_ID);
            repoConf.setName(PROXY_REPO_ID);
            repoConf.setNotFoundCacheActive(true);
            repoConf.setLocalStorage(new CLocalStorage());
            repoConf.getLocalStorage().setProvider("file");
            repoConf.getLocalStorage().setUrl(
                env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY_REPO_ID).toURI().toURL()
                    .toString());
            Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
            repoConf.setExternalConfiguration(ex);
            M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
            exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
            exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
            repoConf.setRemoteStorage(new CRemoteStorage());
            repoConf.getRemoteStorage().setProvider(
                env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
            repoConf.getRemoteStorage().setUrl("http://localhost:" + server.getPort() + "/");
            repo.configure(repoConf);
            // repo.setCacheManager( env.getCacheManager() );
            reposes.add(repo.getId());
            env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
            env.getRepositoryRegistry().addRepository(repo);
View Full Code Here

   * @return app model, merged or created
   */
  public CRepository getRepositoryAppModel(RepositoryBaseResource resource, CRepository target)
      throws ResourceException
  {
    CRepository appModel = new DefaultCRepository();

    Xpp3Dom ex = null;

    appModel.setLocalStatus(LocalStatus.IN_SERVICE.name());
    if (target != null) {
      appModel.setLocalStatus(target.getLocalStatus());

      ex = (Xpp3Dom) target.getExternalConfiguration();
    }
    else {
      ex = new Xpp3Dom(DefaultCRepository.EXTERNAL_CONFIGURATION_NODE_NAME);
    }

    appModel.setId(resource.getId());

    appModel.setName(resource.getName());

    appModel.setExposed(resource.isExposed());

    appModel.setProviderRole(resource.getProviderRole());

    if (RepositoryBaseResourceConverter.REPO_TYPE_VIRTUAL.equals(resource.getRepoType())) {
      appModel.setExternalConfiguration(ex);

      // indexer is unaware of the m2 layout conversion
      appModel.setIndexable(false);

      RepositoryShadowResource repoResource = (RepositoryShadowResource) resource;

      M2LayoutedM1ShadowRepositoryConfiguration exConf = new M2LayoutedM1ShadowRepositoryConfiguration(ex);

      exConf.setMasterRepositoryId(repoResource.getShadowOf());

      exConf.setSynchronizeAtStartup(repoResource.isSyncAtStartup());

    }
    else if (!RepositoryBaseResourceConverter.REPO_TYPE_GROUP.equals(resource.getRepoType())) {
      RepositoryResource repoResource = (RepositoryResource) resource;

      // we can use the default if the value is empty
      if (StringUtils.isNotEmpty(repoResource.getWritePolicy())) {
        appModel.setWritePolicy(repoResource.getWritePolicy());
      }

      appModel.setBrowseable(repoResource.isBrowseable());

      appModel.setIndexable(repoResource.isIndexable());
      appModel.setSearchable(repoResource.isIndexable());

      appModel.setNotFoundCacheTTL(repoResource.getNotFoundCacheTTL());

      appModel.setExternalConfiguration(ex);

      M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);

      exConf.setRepositoryPolicy(EnumUtil.valueOf(repoResource.getRepoPolicy(), RepositoryPolicy.class));

      if (repoResource.getOverrideLocalStorageUrl() != null) {
        appModel.setLocalStorage(new CLocalStorage());

        appModel.getLocalStorage().setUrl(repoResource.getOverrideLocalStorageUrl());

        appModel.getLocalStorage().setProvider("file");
      }
      else {
        appModel.setLocalStorage(null);
      }

      RepositoryResourceRemoteStorage remoteStorage = repoResource.getRemoteStorage();
      if (remoteStorage != null) {
        appModel.setNotFoundCacheActive(true);

        appModel.setRemoteStorage(new CRemoteStorage());

        appModel.getRemoteStorage().setUrl(remoteStorage.getRemoteStorageUrl());

        appModel.getRemoteStorage().setProvider(
            remoteProviderHintFactory.getDefaultRoleHint(remoteStorage.getRemoteStorageUrl()));
      }
    }

    appModel.setProviderHint(resource.getProvider());

    if (RepositoryProxyResource.class.isAssignableFrom(resource.getClass())) {
      appModel = getRepositoryProxyAppModel((RepositoryProxyResource) resource, appModel);
    }

View Full Code Here

      {
        final List<String> reposes = new ArrayList<String>();
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY1_REPO_ID);
          repoConf.setName(PROXY1_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY1_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server1.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY2_REPO_ID);
          repoConf.setName(PROXY2_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY2_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server2.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY3_REPO_ID);
          repoConf.setName(PROXY3_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY3_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server3.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          // reposes.add( repo.getId() );
          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);
View Full Code Here

      {
        final List<String> reposes = new ArrayList<String>();
        {
          // adding one proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY_REPO_ID);
          repoConf.setName(PROXY_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + remoteServerPort + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          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);
View Full Code Here

      {
        final List<String> reposes = new ArrayList<String>();
        {
          // adding 1st proxy, that is out of service
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY1_REPO_ID);
          repoConf.setName(PROXY1_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStatus(LocalStatus.OUT_OF_SERVICE.name()); // THIS REPO IS OUT OF SERVICE
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY1_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // adding 2nd proxy
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(PROXY2_REPO_ID);
          repoConf.setName(PROXY2_REPO_ID);
          repoConf.setNotFoundCacheActive(true);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + PROXY2_REPO_ID).toURI().toURL()
                  .toString());
          Xpp3Dom ex = new Xpp3Dom("externalConfiguration");
          repoConf.setExternalConfiguration(ex);
          M2RepositoryConfiguration exConf = new M2RepositoryConfiguration(ex);
          exConf.setRepositoryPolicy(RepositoryPolicy.RELEASE);
          exConf.setChecksumPolicy(ChecksumPolicy.STRICT_IF_EXISTS);
          repoConf.setRemoteStorage(new CRemoteStorage());
          repoConf.getRemoteStorage().setProvider(
              env.getRemoteProviderHintFactory().getDefaultHttpRoleHint());
          repoConf.getRemoteStorage().setUrl("http://localhost:" + server.getPort() + "/");
          repo.configure(repoConf);
          // repo.setCacheManager( env.getCacheManager() );
          reposes.add(repo.getId());
          env.getApplicationConfiguration().getConfigurationModel().addRepository(repoConf);
          env.getRepositoryRegistry().addRepository(repo);
        }
        {
          // adding one hosted
          final M2Repository repo = (M2Repository) env.lookup(Repository.class, "maven2");
          CRepository repoConf = new DefaultCRepository();
          repoConf.setProviderRole(Repository.class.getName());
          repoConf.setProviderHint("maven2");
          repoConf.setId(HOSTED_REPO_ID);
          repoConf.setName(HOSTED_REPO_ID);
          repoConf.setLocalStorage(new CLocalStorage());
          repoConf.getLocalStorage().setProvider("file");
          repoConf.getLocalStorage().setUrl(
              env.getApplicationConfiguration().getWorkingDirectory("proxy/store/" + HOSTED_REPO_ID).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);
          reposes.add(repo.getId());
          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);
View Full Code Here

TOP

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

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.