Package org.sonatype.nexus.proxy.repository

Examples of org.sonatype.nexus.proxy.repository.GroupRepository


    } catch (final Exception e) {
      return list;
    }

    if (combo instanceof GroupRepository) {
      final GroupRepository group = (GroupRepository) combo;
      final List<Repository> repoList = group.getMemberRepositories();
      for (final Repository repo : repoList) {
        list.add(repo.getId());
      }
    } else {
      list.add(combo.getId());
View Full Code Here


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

    final ArrayList<GroupRepository> result = new ArrayList<GroupRepository>();

    for (Repository repo : getRepositories()) {
      if (!repo.getId().equals(repository.getId())
          && repo.getRepositoryKind().isFacetAvailable(GroupRepository.class)) {
        final GroupRepository group = repo.adaptToFacet(GroupRepository.class);

        members:
        for (Repository member : group.getMemberRepositories()) {
          if (repository.getId().equals(member.getId())) {
            result.add(group);
            break members;
          }
        }
View Full Code Here

  public RepositoryGroupResourceResponse get(Context context, Request request, Response response, Variant variant)
      throws ResourceException
  {
    RepositoryGroupResourceResponse result = new RepositoryGroupResourceResponse();

    GroupRepository groupRepo = null;

    try {
      groupRepo = getRepositoryRegistry().getRepositoryWithFacet(getGroupId(request), GroupRepository.class);
      result.setData(buildGroupResource(request, groupRepo));
    }
View Full Code Here

  protected void updateRepositoryGroup(RepositoryGroupResource model)
      throws ResourceException
  {
    try {
      GroupRepository group =
          getRepositoryRegistry().getRepositoryWithFacet(model.getId(), GroupRepository.class);

      group.setName(model.getName());

      group.setExposed(model.isExposed());

      ArrayList<String> members = new ArrayList<String>();

      for (RepositoryGroupMemberRepository member : (List<RepositoryGroupMemberRepository>) model
          .getRepositories()) {
        members.add(member.getId());
      }

      group.setMemberRepositoryIds(members);

      getNexusConfiguration().saveConfiguration();
    }
    catch (NoSuchRepositoryAccessException e) {
      // access denied 403
View Full Code Here

      template.getConfigurableRepository().setExposed(model.isExposed());

      template.getConfigurableRepository().setLocalStatus(LocalStatus.IN_SERVICE);

      // we create an empty group
      GroupRepository groupRepository = (GroupRepository) template.create();

      ArrayList<String> memberIds = new ArrayList<String>(model.getRepositories().size());

      for (RepositoryGroupMemberRepository member : (List<RepositoryGroupMemberRepository>) model
          .getRepositories()) {
        memberIds.add(member.getId());
      }

      groupRepository.setMemberRepositoryIds(memberIds);

      getNexusConfiguration().saveConfiguration();
    }
    // FIXME: cstamas or toby?
        /*
 
View Full Code Here

  public void testGroupReindex()
      throws Exception
  {
    fillInRepo();

    GroupRepository group = (GroupRepository) repositoryRegistry.getRepository("public");

    File groupRoot = new File(new URL(group.getLocalUrl()).toURI());
    File index = new File(groupRoot, ".index");

    File indexFile = new File(index, "nexus-maven-repository-index.gz");
    File incrementalIndexFile = new File(index, "nexus-maven-repository-index.1.gz");

    assertFalse("No index .gz file should exist.", indexFile.exists());
    assertFalse("No incremental chunk should exists.", incrementalIndexFile.exists());

    indexerManager.reindexRepository(null, group.getId(), true);

    assertTrue("Index .gz file should exist.", indexFile.exists());
    assertFalse("No incremental chunk should exists.", incrementalIndexFile.exists());

    // copy some _new_ stuff, not found in any of the members
    File sourceApacheSnapshotsRoot = new File(getBasedir(), "src/test/resources/reposes/apache-snapshots-2");
    File snapshotsRoot = new File(new URL(snapshots.getLocalUrl()).toURI());
    copyDirectory(sourceApacheSnapshotsRoot, snapshotsRoot);
    indexerManager.reindexRepository(null, group.getId(), false);

    assertTrue("Index .gz file should exist.", indexFile.exists());
    assertTrue("Incremental chunk should exists.", incrementalIndexFile.exists());

    assertTrue("We expected less than 300 bytes but got " + incrementalIndexFile.length(),
View Full Code Here

    // add repo content
    fillInRepo();

    // our patient
    final GroupRepository group = (GroupRepository) repositoryRegistry.getRepository("public");

    // reindex
    indexerManager.reindexAllRepositories(null, true);

    // Note: public by default contains snapshots repository as member
    // Snapshots repository is the only one that contains GroupID "org.sonatype.plexus".
    // Meaning, the presence of this search (is in result set or not) is used
    // to validate the group member changes.
    // Similarly, Apache Snapshots repository by default is NOT member of
    // Public, and it is the only one having artifact with groupID "org.sonatype.test-evict".

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));

    // do searches
    searchFor("org.sonatype.plexus", 1, "snapshots"); // is in this repo
    searchFor("org.sonatype.plexus", 1, group.getId()); // snapshots is member of public
    searchFor("org.sonatype.test-evict", 1, "apache-snapshots"); // is in this repo
    searchFor("org.sonatype.test-evict", 0, group.getId()); // apache-snapshots not a member

    // reconfigure group: remove snapshots
    group.removeMemberRepositoryId(snapshots.getId());
    nexusConfiguration().saveConfiguration();
    waitForTasksToStop();
    wairForAsyncEventsToCalmDown();

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));

    // do searches
    searchFor("org.sonatype.plexus", 1, "snapshots"); // is in this repo
    searchFor("org.sonatype.plexus", 0, group.getId()); // snapshots is not member of public
    searchFor("org.sonatype.test-evict", 1, "apache-snapshots"); // is in this repo
    searchFor("org.sonatype.test-evict", 0, group.getId()); // apache-snapshots not a member

    // reconfigure group: add apache-snapshots
    group.addMemberRepositoryId(apacheSnapshots.getId());
    nexusConfiguration().saveConfiguration();
    waitForTasksToStop();
    wairForAsyncEventsToCalmDown();

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));

    // do searches
    searchFor("org.sonatype.plexus", 1, "snapshots"); // is in this repo
    searchFor("org.sonatype.plexus", 0, group.getId()); // snapshots is not member of public
    searchFor("org.sonatype.test-evict", 1, "apache-snapshots"); // is in this repo
    searchFor("org.sonatype.test-evict", 1, group.getId()); // apache-snapshots is a member of public
  }
View Full Code Here

  {
    // add repo content
    fillInRepo();

    // our patients, group and one member
    final GroupRepository group = (GroupRepository) repositoryRegistry.getRepository("public");
    final Repository member = repositoryRegistry.getRepository("snapshots");

    // reindex
    indexerManager.reindexAllRepositories(null, true);

    // Note: public by default contains snapshots repository as member
    // Snapshots repository is the only one that contains GroupID "org.sonatype.plexus".
    // Meaning, the presence of this search (is in result set or not) is used
    // to validate the group member changes.

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(member));

    // do searches
    searchFor("org.sonatype.plexus", 1, member.getId()); // is in this repo
    searchFor("org.sonatype.plexus", 1, group.getId()); // snapshots is member of public

    // reconfigure group member: make it non-indexable
    member.setSearchable(false);
    member.setIndexable(false);
    nexusConfiguration().saveConfiguration();
    waitForTasksToStop();
    wairForAsyncEventsToCalmDown();

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));
    Assert.assertNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(member));

    // do searches
    searchFor("org.sonatype.plexus", 0, member.getId()); // is in this repo
    searchFor("org.sonatype.plexus", 0, group.getId()); // snapshots is not member of public

    // reconfigure group: add apache-snapshots
    member.setSearchable(true);
    member.setIndexable(true);
    nexusConfiguration().saveConfiguration();
    waitForTasksToStop();
    wairForAsyncEventsToCalmDown();

    // assure context does exists (if Igor comments out few lines or so, as MI will plainly swallow targeted search
    // against nonexistent context!)
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(group));
    Assert.assertNotNull(((DefaultIndexerManager) indexerManager).getRepositoryIndexContext(member));

    // do searches
    searchFor("org.sonatype.plexus", 1, member.getId()); // is in this repo
    searchFor("org.sonatype.plexus", 1, group.getId()); // snapshots is not member of public
  }
View Full Code Here

  @Override
  public void onHandle(final Repository repository, final ResourceStoreRequest request, final Action action)
      throws ItemNotFoundException
  {
    GroupRepository groupRepository = repository.adaptToFacet(GroupRepository.class);
    final String requestPath = request.getRequestPath();
    if (Action.read.equals(action) && requestPath.endsWith(PATH_OF_REPOMD_XML) && groupRepository != null) {
      Yum yum = yumRegistry.get(groupRepository.getId());
      if (yum != null && yum instanceof YumGroup) {
        for (Repository member : groupRepository.getMemberRepositories()) {
          if (member.getRepositoryKind().isFacetAvailable(ProxyRepository.class)) {
            try {
              log.debug("Fetching {}:{} member of {}", member.getId(), PATH_OF_REPOMD_XML, groupRepository.getId());
              member.retrieveItem(new ResourceStoreRequest(PATH_OF_REPOMD_XML));
            }
            catch (ItemNotFoundException e) {
              // proxy repo is not a yum repository, go on
            }
            catch (Exception e) {
              log.debug(
                  "Could not retrieve {} from {}, member of yum enabled group {}. Ignoring.",
                  PATH_OF_REPOMD_XML, member.getId(), groupRepository.getId(), e
              );
            }
          }
        }
        try {
View Full Code Here

TOP

Related Classes of org.sonatype.nexus.proxy.repository.GroupRepository

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.