use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class ConfigurationRegistryReader method readRepositoryScanningConfiguration.
private RepositoryScanningConfiguration readRepositoryScanningConfiguration(String prefix, Registry registry) {
RepositoryScanningConfiguration value = new RepositoryScanningConfiguration();
java.util.List fileTypes = new java.util.ArrayList();
List fileTypesSubsets = registry.getSubsetList(prefix + "fileTypes.fileType");
for (Iterator i = fileTypesSubsets.iterator(); i.hasNext(); ) {
FileType v = readFileType("", (Registry) i.next());
fileTypes.add(v);
}
value.setFileTypes(fileTypes);
java.util.List knownContentConsumers = new java.util.ArrayList();
knownContentConsumers.addAll(registry.getList(prefix + "knownContentConsumers.knownContentConsumer"));
value.setKnownContentConsumers(knownContentConsumers);
java.util.List invalidContentConsumers = new java.util.ArrayList();
invalidContentConsumers.addAll(registry.getList(prefix + "invalidContentConsumers.invalidContentConsumer"));
value.setInvalidContentConsumers(invalidContentConsumers);
return value;
}
use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class Maven2RepositoryMergerTest method testMergeWithOutConflictArtifacts.
@Test
public void testMergeWithOutConflictArtifacts() throws Exception {
String sourceRepoId = "source-repo";
ArtifactMetadata artifact1 = new ArtifactMetadata();
artifact1.setNamespace("org.testng");
artifact1.setProject("testng");
artifact1.setVersion("5.8");
artifact1.setProjectVersion("5.8");
artifact1.setId("testng-5.8-jdk15.jar");
artifact1.setRepositoryId(sourceRepoId);
List<ArtifactMetadata> sourceRepoArtifactsList = getArtifacts();
sourceRepoArtifactsList.add(artifact1);
List<ArtifactMetadata> targetRepoArtifactsList = getArtifacts();
Configuration c = new Configuration();
ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation("target/test-repository");
String sourceRepo = "src/test/resources/test-repository-with-conflict-artifacts";
ManagedRepositoryConfiguration testRepoWithConflicts = new ManagedRepositoryConfiguration();
testRepoWithConflicts.setId(sourceRepoId);
testRepoWithConflicts.setLocation(sourceRepo);
RepositoryScanningConfiguration repoScanConfig = new RepositoryScanningConfiguration();
List<String> knownContentConsumers = new ArrayList<>();
knownContentConsumers.add("metadata-updater");
repoScanConfig.setKnownContentConsumers(knownContentConsumers);
c.setRepositoryScanning(repoScanConfig);
c.addManagedRepository(testRepo);
c.addManagedRepository(testRepoWithConflicts);
configuration.save(c);
Path targetRepoFile = Paths.get("/target/test-repository/com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.jar");
targetRepoFile.toFile().setReadOnly();
when(metadataRepository.getArtifacts(session, sourceRepoId)).thenReturn(sourceRepoArtifactsList);
when(metadataRepository.getArtifacts(session, TEST_REPO_ID)).thenReturn(targetRepoArtifactsList);
assertEquals(1, repositoryMerger.getConflictingArtifacts(metadataRepository, sourceRepoId, TEST_REPO_ID).size());
verify(metadataRepository).getArtifacts(session, TEST_REPO_ID);
}
use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class Maven2RepositoryMergerTest method testMerge.
@Test
public void testMerge() throws Exception {
String targetRepoPath = "target/test-repository-target";
Path mergedArtifact = Paths.get(targetRepoPath, "com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.jar");
Path mavenMetadata = Paths.get(targetRepoPath, "com/example/test/test-artifact/maven-metadata.xml");
Path pom = Paths.get(targetRepoPath, "com/example/test/test-artifact/1.0-SNAPSHOT/test-artifact-1.0-20100308.230825-1.pom");
for (Path testArtifact : new Path[] { mergedArtifact, mavenMetadata, pom }) {
Files.deleteIfExists(testArtifact);
}
assertFalse("Artifact file exists already", Files.exists(mergedArtifact));
assertFalse("Metadata file exists already", Files.exists(mavenMetadata));
assertFalse("Pom File exists already", Files.exists(pom));
Configuration c = new Configuration();
ManagedRepositoryConfiguration testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation("target/test-repository");
RepositoryScanningConfiguration repoScanConfig = new RepositoryScanningConfiguration();
List<String> knownContentConsumers = new ArrayList<>();
knownContentConsumers.add("metadata-updater12");
repoScanConfig.setKnownContentConsumers(knownContentConsumers);
c.setRepositoryScanning(repoScanConfig);
ManagedRepositoryConfiguration targetRepo = new ManagedRepositoryConfiguration();
targetRepo.setId("target-rep");
targetRepo.setLocation(targetRepoPath);
c.addManagedRepository(testRepo);
c.addManagedRepository(targetRepo);
configuration.save(c);
when(metadataRepository.getArtifacts(session, TEST_REPO_ID)).thenReturn(getArtifacts());
repositoryMerger.merge(metadataRepository, TEST_REPO_ID, "target-rep");
verify(metadataRepository).getArtifacts(session, TEST_REPO_ID);
assertTrue(Files.exists(mergedArtifact));
assertTrue(Files.exists(mavenMetadata));
assertTrue(Files.exists(pom));
}
use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class MockConfiguration method initialize.
@PostConstruct
public void initialize() throws Exception {
configuration.setRepositoryScanning(new RepositoryScanningConfiguration() {
@Override
public List<FileType> getFileTypes() {
FileType fileType = new FileType();
fileType.setId(FileTypes.ARTIFACTS);
fileType.setPatterns(Collections.singletonList("**/*"));
return Collections.singletonList(fileType);
}
});
ArchivaRuntimeConfiguration rt = new ArchivaRuntimeConfiguration();
List<String> checksums = new ArrayList<>();
checksums.add("MD5");
checksums.add("SHA1");
checksums.add("SHA256");
rt.setChecksumTypes(checksums);
configuration.setArchivaRuntimeConfiguration(rt);
}
use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class ArchivaConfigurationTest method testRemoveLastElements.
@Test
public void testRemoveLastElements() throws Exception {
Path baseFile = getTestFile("target/test/test-file.xml");
Files.deleteIfExists(baseFile);
assertFalse(Files.exists(baseFile));
Path userFile = getTestFile("target/test/test-file-user.xml");
Files.deleteIfExists(userFile);
assertFalse(Files.exists(userFile));
Files.createDirectories(baseFile.getParent());
FileUtils.copyFile(getTestFile("src/test/conf/conf-single-list-elements.xml").toFile(), baseFile.toFile());
Files.createDirectories(userFile.getParent());
FileUtils.writeStringToFile(userFile.toFile(), "<configuration/>", Charset.forName("UTF-8"));
ArchivaConfiguration archivaConfiguration = lookup(ArchivaConfiguration.class, "test-remove-central");
archivaConfiguration.reload();
Configuration configuration = archivaConfiguration.getConfiguration();
RepositoryGroupConfiguration repositoryGroup = configuration.getRepositoryGroups().get(0);
assertNotNull(repositoryGroup);
configuration.removeRepositoryGroup(repositoryGroup);
assertTrue(configuration.getRepositoryGroups().isEmpty());
RemoteRepositoryConfiguration repository = configuration.getRemoteRepositoriesAsMap().get("central");
assertNotNull(repository);
configuration.removeRemoteRepository(repository);
assertTrue(configuration.getRemoteRepositories().isEmpty());
ManagedRepositoryConfiguration managedRepository = configuration.getManagedRepositoriesAsMap().get("snapshots");
assertNotNull(managedRepository);
configuration.removeManagedRepository(managedRepository);
assertTrue(configuration.getManagedRepositories().isEmpty());
ProxyConnectorConfiguration proxyConnector = configuration.getProxyConnectors().get(0);
assertNotNull(proxyConnector);
configuration.removeProxyConnector(proxyConnector);
assertTrue(configuration.getProxyConnectors().isEmpty());
NetworkProxyConfiguration networkProxy = configuration.getNetworkProxiesAsMap().get("proxy");
assertNotNull(networkProxy);
configuration.removeNetworkProxy(networkProxy);
assertTrue(configuration.getNetworkProxies().isEmpty());
LegacyArtifactPath path = configuration.getLegacyArtifactPaths().get(0);
assertNotNull(path);
configuration.removeLegacyArtifactPath(path);
assertTrue(configuration.getLegacyArtifactPaths().isEmpty());
RepositoryScanningConfiguration scanning = configuration.getRepositoryScanning();
String consumer = scanning.getKnownContentConsumers().get(0);
assertNotNull(consumer);
scanning.removeKnownContentConsumer(consumer);
// default values
assertFalse(scanning.getKnownContentConsumers().isEmpty());
consumer = scanning.getInvalidContentConsumers().get(0);
assertNotNull(consumer);
scanning.removeInvalidContentConsumer(consumer);
assertTrue(scanning.getInvalidContentConsumers().isEmpty());
archivaConfiguration.save(configuration);
archivaConfiguration = lookup(ArchivaConfiguration.class, "test-read-saved");
configuration = archivaConfiguration.getConfiguration();
assertNull(configuration.getRemoteRepositoriesAsMap().get("central"));
assertTrue(configuration.getRepositoryGroups().isEmpty());
assertNull(configuration.getManagedRepositoriesAsMap().get("snapshots"));
assertTrue(configuration.getProxyConnectors().isEmpty());
assertNull(configuration.getNetworkProxiesAsMap().get("proxy"));
assertTrue(configuration.getLegacyArtifactPaths().isEmpty());
scanning = configuration.getRepositoryScanning();
assertFalse(scanning.getKnownContentConsumers().isEmpty());
assertTrue(scanning.getInvalidContentConsumers().isEmpty());
}
Aggregations