Search in sources :

Example 11 with BasicManagedRepository

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

the class ArchivaCli method doScan.

private void doScan(String path, String[] consumers) throws ConsumerException, MalformedURLException {
    BasicManagedRepository repo = new BasicManagedRepository(Paths.get(path).getFileName().toString(), "Archiva CLI Provided Repo", Paths.get(path).getParent());
    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.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.BasicManagedRepository in project archiva by apache.

the class ArtifactMissingChecksumsConsumerTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    Path basePath = Paths.get("target/test-classes");
    repoConfig = new BasicManagedRepository("test-repo", "Test Repository", basePath);
    repoConfig.setLayout("default");
    repoConfig.setLocation(basePath.resolve("test-repo/").toUri());
    consumer = applicationContext.getBean("knownRepositoryContentConsumer#create-missing-checksums", KnownRepositoryContentConsumer.class);
}
Also used : Path(java.nio.file.Path) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) Before(org.junit.Before)

Example 13 with BasicManagedRepository

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

the class SimpleArtifactConsumerTest method setUpMockRepository.

private void setUpMockRepository() throws RepositoryAdminException, IOException, RepositoryException {
    Path repoDir = Paths.get("target/test-consumer-repo");
    Files.createDirectories(repoDir);
    repoDir.toFile().deleteOnExit();
    testRepository = new BasicManagedRepository("test-consumer-repository", "Test-Consumer-Repository", Paths.get("target/repositories"));
    testRepository.setLocation(repoDir.toAbsolutePath().toUri());
    repositoryRegistry.putRepository(testRepository);
// when( repositoryRegistry.getManagedRepository( testRepository.getId() ) ).thenReturn( testRepository );
}
Also used : Path(java.nio.file.Path) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository)

Example 14 with BasicManagedRepository

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

the class RepositoryScannerTest method createRepository.

protected EditableManagedRepository createRepository(String id, String name, Path location) {
    BasicManagedRepository repo = new BasicManagedRepository(id, name, location.getParent());
    repo.setLocation(location.toAbsolutePath().toUri());
    return repo;
}
Also used : BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository)

Example 15 with BasicManagedRepository

use of org.apache.archiva.repository.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).get();
    cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded());
    IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get();
    cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath()));
    cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath()));
    cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation());
    ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get();
    cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount());
    cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays());
    cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots());
    if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE)) {
        cfg.setReleases(true);
    } else {
        cfg.setReleases(false);
    }
    if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT)) {
        cfg.setSnapshots(true);
    } else {
        cfg.setSnapshots(false);
    }
    return cfg;
}
Also used : BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) IndexCreationFeature(org.apache.archiva.repository.features.IndexCreationFeature) ManagedRepositoryConfiguration(org.apache.archiva.configuration.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.BasicManagedRepository)15 Path (java.nio.file.Path)4 Before (org.junit.Before)4 KnownRepositoryContentConsumer (org.apache.archiva.consumers.KnownRepositoryContentConsumer)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 InvalidRepositoryContentConsumer (org.apache.archiva.consumers.InvalidRepositoryContentConsumer)2 ArtifactCleanupFeature (org.apache.archiva.repository.features.ArtifactCleanupFeature)2 RepositoryScannerException (org.apache.archiva.repository.scanner.RepositoryScannerException)2 ArchivaConfiguration (org.apache.archiva.configuration.ArchivaConfiguration)1 FileTypes (org.apache.archiva.configuration.FileTypes)1 ManagedRepositoryConfiguration (org.apache.archiva.configuration.ManagedRepositoryConfiguration)1 RepositoryConversionException (org.apache.archiva.converter.RepositoryConversionException)1 MetadataRepository (org.apache.archiva.metadata.repository.MetadataRepository)1 RepositorySession (org.apache.archiva.metadata.repository.RepositorySession)1 RepositorySessionFactory (org.apache.archiva.metadata.repository.RepositorySessionFactory)1 RepositoryException (org.apache.archiva.repository.RepositoryException)1 IndexCreationFeature (org.apache.archiva.repository.features.IndexCreationFeature)1 StagingRepositoryFeature (org.apache.archiva.repository.features.StagingRepositoryFeature)1 RepositoryScanStatistics (org.apache.archiva.repository.scanner.RepositoryScanStatistics)1