Search in sources :

Example 1 with BasicManagedRepository

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

the class DuplicateArtifactsConsumerTest method setUp.

@Before
@Override
public void setUp() throws Exception {
    super.setUp();
    assertNotNull(consumer);
    config = new BasicManagedRepository(TEST_REPO, TEST_REPO, Paths.get("target"));
    config.setLocation(Paths.get("target/test-repository").toAbsolutePath().toUri());
    metadataRepository = mock(MetadataRepository.class);
    RepositorySession session = mock(RepositorySession.class);
    when(session.getRepository()).thenReturn(metadataRepository);
    RepositorySessionFactory factory = applicationContext.getBean(RepositorySessionFactory.class);
    // (RepositorySessionFactory) lookup( RepositorySessionFactory.class );
    when(factory.createSession()).thenReturn(session);
    when(pathTranslator.getArtifactForPath(TEST_REPO, TEST_FILE)).thenReturn(TEST_METADATA);
}
Also used : MetadataRepository(org.apache.archiva.metadata.repository.MetadataRepository) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) RepositorySessionFactory(org.apache.archiva.metadata.repository.RepositorySessionFactory) RepositorySession(org.apache.archiva.metadata.repository.RepositorySession) Before(org.junit.Before)

Example 2 with BasicManagedRepository

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

the class RepositoryProviderMock method createStagingInstance.

@Override
public ManagedRepository createStagingInstance(ManagedRepositoryConfiguration configuration) throws RepositoryException {
    String id = configuration.getId() + StagingRepositoryFeature.STAGING_REPO_POSTFIX;
    BasicManagedRepository managedRepository = new BasicManagedRepository(id, configuration.getName(), Paths.get("target/repositories"));
    updateManagedInstance(managedRepository, configuration);
    return managedRepository;
}
Also used : BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository)

Example 3 with BasicManagedRepository

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

the class RepositoryProviderMock method createManagedInstance.

@Override
public ManagedRepository createManagedInstance(ManagedRepositoryConfiguration configuration) throws RepositoryException {
    BasicManagedRepository managedRepository = new BasicManagedRepository(configuration.getId(), configuration.getName(), Paths.get("target/repositories"));
    updateManagedInstance(managedRepository, configuration);
    return managedRepository;
}
Also used : BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository)

Example 4 with BasicManagedRepository

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

the class AbstractRepositoryPurgeTest method getRepoConfiguration.

public org.apache.archiva.repository.ManagedRepository getRepoConfiguration(String repoId, String repoName) throws URISyntaxException {
    Path basePath = Paths.get("target/test-" + getName()).toAbsolutePath();
    config = new BasicManagedRepository(repoId, repoName, basePath);
    config.addActiveReleaseScheme(ReleaseScheme.RELEASE);
    config.addActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
    ArtifactCleanupFeature atf = config.getFeature(ArtifactCleanupFeature.class).get();
    atf.setRetentionPeriod(Period.ofDays(TEST_DAYS_OLDER));
    String path = AbstractRepositoryPurgeTest.fixPath(basePath.resolve(repoId).toAbsolutePath().toString());
    config.setLocation(new URI(path));
    atf.setDeleteReleasedSnapshots(true);
    atf.setRetentionCount(TEST_RETENTION_COUNT);
    return config;
}
Also used : Path(java.nio.file.Path) BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) ArtifactCleanupFeature(org.apache.archiva.repository.features.ArtifactCleanupFeature) URI(java.net.URI)

Example 5 with BasicManagedRepository

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

the class DefaultLegacyRepositoryConverter method convertLegacyRepository.

@Override
public void convertLegacyRepository(Path legacyRepositoryDirectory, Path repositoryDirectory, List<String> fileExclusionPatterns) throws RepositoryConversionException {
    try {
        String defaultRepositoryUrl = PathUtil.toUrl(repositoryDirectory);
        BasicManagedRepository legacyRepository = new BasicManagedRepository("legacy", "Legacy Repository", repositoryDirectory.getParent());
        legacyRepository.setLocation(legacyRepositoryDirectory.toAbsolutePath().toUri());
        legacyRepository.setLayout("legacy");
        ArtifactRepository repository = artifactRepositoryFactory.createArtifactRepository("default", defaultRepositoryUrl, defaultLayout, null, null);
        legacyConverterConsumer.setExcludes(fileExclusionPatterns);
        legacyConverterConsumer.setDestinationRepository(repository);
        List<KnownRepositoryContentConsumer> knownConsumers = new ArrayList<>(1);
        knownConsumers.add(legacyConverterConsumer);
        List<InvalidRepositoryContentConsumer> invalidConsumers = Collections.emptyList();
        List<String> ignoredContent = new ArrayList<String>(Arrays.asList(RepositoryScanner.IGNORABLE_CONTENT));
        repoScanner.scan(legacyRepository, knownConsumers, invalidConsumers, ignoredContent, RepositoryScanner.FRESH_SCAN);
    } catch (RepositoryScannerException e) {
        throw new RepositoryConversionException("Error convering legacy repository.", e);
    }
}
Also used : BasicManagedRepository(org.apache.archiva.repository.BasicManagedRepository) KnownRepositoryContentConsumer(org.apache.archiva.consumers.KnownRepositoryContentConsumer) ArrayList(java.util.ArrayList) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) RepositoryScannerException(org.apache.archiva.repository.scanner.RepositoryScannerException) RepositoryConversionException(org.apache.archiva.converter.RepositoryConversionException) InvalidRepositoryContentConsumer(org.apache.archiva.consumers.InvalidRepositoryContentConsumer)

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