Package org.sonatype.nexus.proxy.repository

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


  protected Repository getRepositoryForPathPrefixOrId(String pathPrefixOrId, Class<? extends Repository> kind)
      throws NoSuchRepositoryException
  {
    List<? extends Repository> repositories = repositoryRegistry.getRepositoriesWithFacet(kind);

    Repository idMatched = null;

    Repository pathPrefixMatched = null;

    for (Repository repository : repositories) {
      if (StringUtils.equals(repository.getId(), pathPrefixOrId)) {
        idMatched = repository;
      }
View Full Code Here


  {
    if (isVirtual()) {
      return getStore().list(getResourceStoreRequest());
    }
    else {
      Repository repo = getRepositoryItemUid().getRepository();
      Collection<StorageItem> result = repo.list(false, this);
      correctPaths(result);
      return result;
    }
  }
View Full Code Here

    // create this new repo type
    final RepositoryTemplate template =
        (RepositoryTemplate) templateManager.getTemplates().getTemplateById("nexus4807");
    template.getConfigurableRepository().setId("peter");
    template.getConfigurableRepository().setName("We all love Peter!");
    final Repository repository = template.create();

    // do some simple assertion
    assertThat(repository.getId(), equalTo("peter"));
    assertThat(repository.getName(), equalTo("We all love Peter!"));
    // assert peter is here simply, by having this below not throw any exception and returning non-null
    // note: by interface contract, this method never returns null: either returns value or throws exception
    assertThat(repositoryRegistry.getRepository("peter"), notNullValue());

    // now drop it
    nexusConfiguration.deleteRepository(repository.getId());

    // assert peter left the building
    try {
      repositoryRegistry.getRepository("peter");
      Assert.fail("Peter should not be present, he just left!");
    }
    catch (NoSuchRepositoryException e) {
      // good, he left of main entrance
    }

    // and assert that we really do love Peter
    Nexus4807Repository nexus4807Repository = repository.adaptToFacet(Nexus4807Repository.class);
    assertThat(nexus4807Repository.isDisposeInvoked(), is(true));
  }
View Full Code Here

  }

  @Subscribe
  @AllowConcurrentEvents
  public void inspect(final RepositoryRegistryEventPostRemove evt) {
    Repository repository = evt.getRepository();

    try {
      // remove the storage folders for the repository
      DeleteRepositoryFoldersTask task = nexusScheduler.createTaskInstance(DeleteRepositoryFoldersTask.class);

      task.setRepository(repository);

      nexusScheduler.submit("Deleting repository folder for repository \"" + repository.getName() + "\" (id="
          + repository.getId() + ").", task);
    }
    catch (Exception e) {
      log.warn("Could not remove repository folders for repository {}", repository, e);
    }
  }
View Full Code Here

  }

  @Before
  public void prepare() throws Exception {
    final String contentString = "SOME_CONTENT";
    Repository inhouse = getRepositoryRegistry().getRepository("inhouse");
    DefaultStorageFileItem file = new DefaultStorageFileItem(
        inhouse,
        new ResourceStoreRequest("/a.txt"),
        true,
        true,
        new StringContentLocator(contentString));
    inhouse.storeItem(false, file);
    DefaultStorageLinkItem link = new DefaultStorageLinkItem(inhouse, new ResourceStoreRequest("/b.txt"), true, true,
        file.getRepositoryItemUid());
    inhouse.storeItem(false, link);
  }
View Full Code Here

          break;
        }

        for (String repositoryId : mapping.getMappedRepositories()) {
          Repository mappedRepository = repositoryRegistry.getRepository(repositoryId);

          // but only if is user managed
          if (mappedRepository.isUserManaged()) {
            reposIdSet.remove(mappedRepository.getId());
          }
        }
      }
    }
View Full Code Here

      throws ConfigurationException
  {
    checkRepositoryMaxInstanceCountForCreation(klazz, name, repositoryModel);

    // create it, will do runtime validation
    Repository repository = runtimeConfigurationBuilder.createRepository(klazz, name);
    if (repository instanceof Configurable) {
      ((Configurable) repository).configure(repositoryModel);
    }

    // register with repoRegistry
View Full Code Here

      throws ConfigurationException, IOException
  {
    validateRepository(settings, true);

    // create it, will do runtime validation
    Repository repository = instantiateRepository(getConfigurationModel(), settings);

    // now add it to config, since it is validated and successfully created
    getConfigurationModel().addRepository(settings);

    // save
View Full Code Here

  @Override
  public synchronized void deleteRepository(String id, boolean force)
      throws NoSuchRepositoryException, IOException, ConfigurationException, AccessDeniedException
  {
    Repository repository = repositoryRegistry.getRepository(id);

    if (!force && !repository.isUserManaged()) {
      throw new AccessDeniedException("Not allowed to delete non-user-managed repository '" + id + "'.");
    }

    // put out of service so wont be accessed any longer
    repository.setLocalStatus(LocalStatus.OUT_OF_SERVICE);
    // disable indexing for same purpose
    repository.setIndexable(false);
    repository.setSearchable(false);

    // remove dependants too

    // =======
    // shadows
    // (fail if any repo references the currently processing one)
    List<ShadowRepository> shadows = repositoryRegistry.getRepositoriesWithFacet(ShadowRepository.class);

    for (Iterator<ShadowRepository> i = shadows.iterator(); i.hasNext(); ) {
      ShadowRepository shadow = i.next();

      if (repository.getId().equals(shadow.getMasterRepository().getId())) {
        throw new RepositoryDependentException(repository, shadow);
      }
    }

    // ======
View Full Code Here

    when(fsPeer
        .listItems(Mockito.any(Repository.class), Mockito.any(File.class), Mockito.any(ResourceStoreRequest.class),
            eq(new File(repoLocation, "invalid/")))).thenReturn(invalidFileCollection);

    // create Repository Mock
    Repository repository = mock(Repository.class);
    when(repository.getId()).thenReturn("mock");
    when(repository.getRepositoryKind()).thenReturn(new DefaultRepositoryKind(HostedRepository.class, null));
    when(repository.getLocalUrl()).thenReturn(repoLocation.toURI().toURL().toString());
    AttributesHandler attributesHandler = mock(AttributesHandler.class);
    when(repository.getAttributesHandler()).thenReturn(attributesHandler);
    when(repository.getLocalStorageContext()).thenReturn(new DefaultLocalStorageContext(null));
    RepositoryItemUid uid = mock(RepositoryItemUid.class);
    when(repository.createUid(anyString())).thenReturn(uid);


    DefaultFSLocalRepositoryStorage localRepositoryStorageUnderTest = new DefaultFSLocalRepositoryStorage(wastebasket,
        linkPersister, mimeUtil, fsPeer);
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.