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);
}
}
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);
}
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);
}
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;
}
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;
}
Aggregations