Package org.sonatype.nexus.proxy.repository

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


    // flush all potential changes
    eventBus().post(new ConfigurationPrepareForSaveEvent(getApplicationConfiguration()));
    eventBus().post(new ConfigurationCommitEvent(getApplicationConfiguration()));

    // get hold on all registered reposes
    Repository repo1 = getRepositoryRegistry().getRepository("repo1");
    Repository repo2 = getRepositoryRegistry().getRepository("repo2");
    Repository repo3 = getRepositoryRegistry().getRepository("repo3");
    Repository inhouse = getRepositoryRegistry().getRepository("inhouse");
    Repository inhouseSnapshot = getRepositoryRegistry().getRepository("inhouse-snapshot");
    MavenGroupRepository test = getRepositoryRegistry().getRepositoryWithFacet("test", MavenGroupRepository.class);

    // now change some of them
    repo1.setLocalStatus(LocalStatus.OUT_OF_SERVICE);
    repo3.setName("kuku");
View Full Code Here


  {
    if (uidStr.indexOf(":") > -1) {
      String[] parts = uidStr.split(":");

      if (parts.length == 2) {
        Repository repository = repositoryRegistry.getRepository(parts[0]);

        return createUid(repository, parts[1]);
      }
      else {
        throw new IllegalArgumentException(uidStr
View Full Code Here

  @Test
  public void testHosted2Proxy()
      throws Exception
  {
    Repository patient = getRepositoryRegistry().getRepositoryWithFacet("inhouse", MavenHostedRepository.class);

    assertTrue("This repo should not be READ only!", RepositoryWritePolicy.READ_ONLY != patient.getWritePolicy());

    convertHosted2Proxy((MavenHostedRepository) patient);

    assertTrue("Partient should be proxy", patient.getRepositoryKind()
        .isFacetAvailable(MavenProxyRepository.class));

    assertTrue("This repo should be READ only!", RepositoryWritePolicy.READ_ONLY == patient.getWritePolicy());
  }
View Full Code Here

  @Test
  public void testProxy2Hosted()
      throws Exception
  {
    Repository patient = getRepositoryRegistry().getRepositoryWithFacet("repo1", MavenProxyRepository.class);

    assertTrue("This repo should be READ only!", RepositoryWritePolicy.READ_ONLY == patient.getWritePolicy());

    convertProxy2Hosted((MavenProxyRepository) patient);

    assertTrue("Partient should be hosted", patient.getRepositoryKind()
        .isFacetAvailable(MavenHostedRepository.class));
  }
View Full Code Here

  @Test
  public void testHosted2Proxy2Hosted()
      throws Exception
  {
    Repository patient = getRepositoryRegistry().getRepositoryWithFacet("inhouse", MavenHostedRepository.class);

    convertHosted2Proxy((MavenHostedRepository) patient);

    convertProxy2Hosted((MavenProxyRepository) patient);

    assertTrue("Partient should be hosted", patient.getRepositoryKind()
        .isFacetAvailable(MavenHostedRepository.class));
  }
View Full Code Here

  @Test
  public void testProxy2Hosted2Proxy()
      throws Exception
  {
    Repository patient = getRepositoryRegistry().getRepositoryWithFacet("repo1", MavenProxyRepository.class);

    convertProxy2Hosted((MavenProxyRepository) patient);

    convertHosted2Proxy((MavenHostedRepository) patient);

    assertTrue("Partient should be proxy", patient.getRepositoryKind()
        .isFacetAvailable(MavenProxyRepository.class));
  }
View Full Code Here

      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.
View Full Code Here

   */
  @Test
  public void testNXCM4852()
      throws Exception
  {
    final Repository repository = getRepositoryRegistry().getRepository("inhouse");
    final ResourceStoreRequest request =
        new ResourceStoreRequest("/activemq/activemq-core/1.2/activemq-core-1.2.jar", true);

    try {
      repository.storeItem(request, new FilterInputStream(new ByteArrayInputStream(
          "123456789012345678901234567890".getBytes()))
      {
        @Override
        public int read()
            throws IOException
        {
          int result = super.read();
          if (result == -1) {
            throw new EOFException("Foo");
          }
          else {
            return result;
          }
        }

        @Override
        public int read(final byte[] b, final int off, final int len)
            throws IOException
        {
          int result = super.read(b, off, len);
          if (result == -1) {
            throw new EOFException("Foo");
          }
          return result;
        }
      }, null);

      fail("We expected a LocalStorageEofException to be thrown");
    }
    catch (LocalStorageEOFException e) {
      // good, we expected this
    }
    finally {
      // now we have to ensure no remnant files exists
      assertThat(repository.getLocalStorage().containsItem(repository, request), is(false));
      // no tmp files should exists either
      assertThat(
          repository.getLocalStorage().listItems(repository, new ResourceStoreRequest("/.nexus/tmp")),
          is(empty()));
    }
  }
View Full Code Here

    environmentBuilder().stopService();

    final Server server = Server.withPort(port);
    server.serve("/*").withBehaviours(new DropConnection()).start();
    try {
      final Repository repository = getRepositoryRegistry().getRepository("repo1");
      final ResourceStoreRequest request =
          new ResourceStoreRequest("/activemq/activemq-core/1.2/activemq-core-1.2.jar");

      try {
        final StorageItem item = repository.retrieveItem(request);
        fail("We expected a LocalStorageEofException to be thrown");
      }
      catch (LocalStorageEOFException e) {
        // good, we expected this
      }
      finally {
        // now we have to ensure no remnant files exists
        assertThat(repository.getLocalStorage().containsItem(repository, request), is(false));
        // no tmp files should exists either
        assertThat(
            repository.getLocalStorage().listItems(repository, new ResourceStoreRequest("/.nexus/tmp")),
            is(empty()));
      }
    }
    finally {
      server.stop();
View Full Code Here

  @Override
  public <T> T getRepositoryWithFacet(final String repoId, final Class<T> f)
      throws NoSuchRepositoryException
  {
    final Repository r = getRepository(repoId);

    if (r.getRepositoryKind().isFacetAvailable(f)) {
      return r.adaptToFacet(f);
    }
    else {
      throw new NoSuchRepositoryException(repoId);
    }
  }
View Full Code Here

TOP

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

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.