Search in sources :

Example 11 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class ArchivaCli method doScan.

private void doScan(String path, String[] consumers) throws ConsumerException, IOException {
    BasicManagedRepository repo = BasicManagedRepository.newFilesystemInstance(Paths.get(path).getFileName().toString(), "Archiva CLI Provided Repo", Paths.get(path));
    repo.setLocation(Paths.get(path).toUri());
    List<KnownRepositoryContentConsumer> knownConsumerList = new ArrayList<>();
    knownConsumerList.addAll(getConsumerList(consumers));
    List<InvalidRepositoryContentConsumer> invalidConsumerList = Collections.emptyList();
    List<String> ignoredContent = new ArrayList<>();
    ignoredContent.addAll(Arrays.asList(RepositoryScanner.IGNORABLE_CONTENT));
    RepositoryScanner scanner = applicationContext.getBean(RepositoryScanner.class);
    try {
        RepositoryScanStatistics stats = scanner.scan(repo, knownConsumerList, invalidConsumerList, ignoredContent, RepositoryScanner.FRESH_SCAN);
        LOGGER.info(stats.toDump(repo));
    } catch (RepositoryScannerException e) {
        LOGGER.error(e.getMessage(), e);
    }
}
Also used : BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) RepositoryScanner(org.apache.archiva.repository.scanner.RepositoryScanner) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) RepositoryScanStatistics(org.apache.archiva.repository.scanner.RepositoryScanStatistics) ArrayList(java.util.ArrayList) RepositoryScannerException(org.apache.archiva.repository.scanner.RepositoryScannerException) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer)

Example 12 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class ArchivaRepositoryRegistryTest method putManagedRepository.

@Test
public void putManagedRepository() throws Exception {
    BasicManagedRepository managedRepository = BasicManagedRepository.newFilesystemInstance("test001", "Test repo", archivaConfiguration.getRepositoryBaseDir().resolve("test001"));
    managedRepository.setDescription(managedRepository.getPrimaryLocale(), "This is just a test");
    repositoryRegistry.putRepository(managedRepository);
    assertNotNull(managedRepository.getContent());
    assertEquals(6, repositoryRegistry.getRepositories().size());
    managedRepository = BasicManagedRepository.newFilesystemInstance("central", "Test repo", archivaConfiguration.getRepositoryBaseDir().resolve("central"));
    managedRepository.setDescription(managedRepository.getPrimaryLocale(), "This is just a test");
    ManagedRepository updatedRepo;
    try {
        repositoryRegistry.putRepository(managedRepository);
        throw new RuntimeException("Repository exception should be thrown, if there exists a remote repository already with that id");
    } catch (RepositoryException e) {
    // OK
    }
    managedRepository = BasicManagedRepository.newFilesystemInstance("internal", "Test repo", archivaConfiguration.getRepositoryBaseDir().resolve("internal"));
    managedRepository.setDescription(managedRepository.getPrimaryLocale(), "This is just a test");
    updatedRepo = repositoryRegistry.putRepository(managedRepository);
    assertSame(updatedRepo, managedRepository);
    assertNotNull(managedRepository.getContent());
    assertEquals(6, repositoryRegistry.getRepositories().size());
    ManagedRepository managedRepository1 = repositoryRegistry.getManagedRepository("internal");
    assertEquals("Test repo", managedRepository1.getName());
    assertSame(managedRepository1, managedRepository);
}
Also used : BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) ManagedRepository(org.apache.archiva.repository.ManagedRepository) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) RepositoryException(org.apache.archiva.repository.RepositoryException) Test(org.junit.jupiter.api.Test)

Example 13 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class RepositoryGroupHandlerTest method getManaged.

protected ManagedRepository getManaged(String id, String name) throws IOException {
    Path path = getRepoBaseDir().resolve("../managed");
    FileLockManager lockManager = new DefaultFileLockManager();
    FilesystemStorage storage = new FilesystemStorage(path.toAbsolutePath(), lockManager);
    return new BasicManagedRepository(id, name, storage);
}
Also used : Path(java.nio.file.Path) FileLockManager(org.apache.archiva.common.filelock.FileLockManager) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager)

Example 14 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class RepositoryScannerTest method createRepository.

protected EditableManagedRepository createRepository(String id, String name, Path location) throws IOException {
    FileLockManager lockManager = new DefaultFileLockManager();
    FilesystemStorage storage = new FilesystemStorage(location.toAbsolutePath(), lockManager);
    BasicManagedRepository repo = new BasicManagedRepository(id, name, storage);
    repo.setLocation(location.toAbsolutePath().toUri());
    repo.setContent(new ManagedRepositoryContentMock(repo));
    return repo;
}
Also used : FileLockManager(org.apache.archiva.common.filelock.FileLockManager) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) FilesystemStorage(org.apache.archiva.repository.storage.fs.FilesystemStorage) DefaultFileLockManager(org.apache.archiva.common.filelock.DefaultFileLockManager) ManagedRepositoryContentMock(org.apache.archiva.repository.scanner.mock.ManagedRepositoryContentMock)

Example 15 with BasicManagedRepository

use of org.apache.archiva.repository.base.managed.BasicManagedRepository in project archiva by apache.

the class MavenRepositoryProvider method getManagedConfiguration.

@Override
public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException {
    if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository)) {
        log.error("Wrong remote repository type " + managedRepository.getClass().getName());
        throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName());
    }
    ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration();
    cfg.setType(managedRepository.getType().toString());
    cfg.setId(managedRepository.getId());
    cfg.setName(managedRepository.getName());
    cfg.setDescription(managedRepository.getDescription());
    cfg.setLocation(convertUriToPath(managedRepository.getLocation()));
    cfg.setLayout(managedRepository.getLayout());
    cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition());
    cfg.setScanned(managedRepository.isScanned());
    cfg.setBlockRedeployments(managedRepository.blocksRedeployments());
    StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class);
    cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded());
    IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class);
    cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath()));
    cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath()));
    cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation());
    ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class);
    cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount());
    cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays());
    cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots());
    cfg.setReleases(managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE));
    cfg.setSnapshots(managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT));
    return cfg;
}
Also used : BasicManagedRepository(org.apache.archiva.repository.base.managed.BasicManagedRepository) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) RepositoryException(org.apache.archiva.repository.RepositoryException) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) StagingRepositoryFeature(org.apache.archiva.repository.features.StagingRepositoryFeature)

Aggregations

BasicManagedRepository (org.apache.archiva.repository.base.managed.BasicManagedRepository)20 IOException (java.io.IOException)8 RepositoryException (org.apache.archiva.repository.RepositoryException)8 DefaultFileLockManager (org.apache.archiva.common.filelock.DefaultFileLockManager)6 FilesystemStorage (org.apache.archiva.repository.storage.fs.FilesystemStorage)6 Path (java.nio.file.Path)4 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)4 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)3 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)3 Before (org.junit.Before)3 Test (org.junit.jupiter.api.Test)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 FileLockManager (org.apache.archiva.common.filelock.FileLockManager)2 EditableManagedRepository (org.apache.archiva.repository.EditableManagedRepository)2 MavenManagedRepository (org.apache.archiva.rest.api.v2.model.MavenManagedRepository)2 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)1 InvalidRepositoryContentConsumer (org.apache.archiva.consumers.InvalidRepositoryContentConsumer)1 KnownRepositoryContentConsumer (org.apache.archiva.consumers.KnownRepositoryContentConsumer)1 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)1