Search in sources :

Example 1 with RepositoryConversionException

use of org.apache.archiva.converter.RepositoryConversionException 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

ArrayList (java.util.ArrayList)1 InvalidRepositoryContentConsumer (org.apache.archiva.consumers.InvalidRepositoryContentConsumer)1 KnownRepositoryContentConsumer (org.apache.archiva.consumers.KnownRepositoryContentConsumer)1 RepositoryConversionException (org.apache.archiva.converter.RepositoryConversionException)1 BasicManagedRepository (org.apache.archiva.repository.BasicManagedRepository)1 RepositoryScannerException (org.apache.archiva.repository.scanner.RepositoryScannerException)1 ArtifactRepository (org.apache.maven.artifact.repository.ArtifactRepository)1