use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class ConfigurationRegistryReader method readConfiguration.
private Configuration readConfiguration(String prefix, Registry registry) {
Configuration value = new Configuration();
// String version = registry.getString( prefix + "version", value.getVersion() );
List<String> versionList = registry.getList(prefix + "version");
String version = value.getVersion();
if (versionList != null && !versionList.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (int i = 0, size = versionList.size(); i < size; i++) {
sb.append(versionList.get(i));
if (i < size - 1) {
sb.append(',');
}
}
version = sb.toString();
}
value.setVersion(version);
// String metadataStore = registry.getString( prefix + "metadataStore", value.getMetadataStore() );
List<String> metadataStoreList = registry.getList(prefix + "metadataStore");
String metadataStore = value.getMetadataStore();
if (metadataStoreList != null && !metadataStoreList.isEmpty()) {
StringBuilder sb = new StringBuilder();
for (int i = 0, size = metadataStoreList.size(); i < size; i++) {
sb.append(metadataStoreList.get(i));
if (i < size - 1) {
sb.append(',');
}
}
metadataStore = sb.toString();
}
value.setMetadataStore(metadataStore);
java.util.List repositoryGroups = new java.util.ArrayList();
List repositoryGroupsSubsets = registry.getSubsetList(prefix + "repositoryGroups.repositoryGroup");
for (Iterator i = repositoryGroupsSubsets.iterator(); i.hasNext(); ) {
RepositoryGroupConfiguration v = readRepositoryGroupConfiguration("", (Registry) i.next());
repositoryGroups.add(v);
}
value.setRepositoryGroups(repositoryGroups);
java.util.List managedRepositories = new java.util.ArrayList();
List managedRepositoriesSubsets = registry.getSubsetList(prefix + "managedRepositories.managedRepository");
for (Iterator i = managedRepositoriesSubsets.iterator(); i.hasNext(); ) {
ManagedRepositoryConfiguration v = readManagedRepositoryConfiguration("", (Registry) i.next());
managedRepositories.add(v);
}
value.setManagedRepositories(managedRepositories);
java.util.List remoteRepositories = new java.util.ArrayList();
List remoteRepositoriesSubsets = registry.getSubsetList(prefix + "remoteRepositories.remoteRepository");
for (Iterator i = remoteRepositoriesSubsets.iterator(); i.hasNext(); ) {
RemoteRepositoryConfiguration v = readRemoteRepositoryConfiguration("", (Registry) i.next());
remoteRepositories.add(v);
}
value.setRemoteRepositories(remoteRepositories);
java.util.List proxyConnectors = new java.util.ArrayList();
List proxyConnectorsSubsets = registry.getSubsetList(prefix + "proxyConnectors.proxyConnector");
for (Iterator i = proxyConnectorsSubsets.iterator(); i.hasNext(); ) {
ProxyConnectorConfiguration v = readProxyConnectorConfiguration("", (Registry) i.next());
proxyConnectors.add(v);
}
value.setProxyConnectors(proxyConnectors);
java.util.List networkProxies = new java.util.ArrayList();
List networkProxiesSubsets = registry.getSubsetList(prefix + "networkProxies.networkProxy");
for (Iterator i = networkProxiesSubsets.iterator(); i.hasNext(); ) {
NetworkProxyConfiguration v = readNetworkProxyConfiguration("", (Registry) i.next());
networkProxies.add(v);
}
value.setNetworkProxies(networkProxies);
java.util.List legacyArtifactPaths = new java.util.ArrayList();
List legacyArtifactPathsSubsets = registry.getSubsetList(prefix + "legacyArtifactPaths.legacyArtifactPath");
for (Iterator i = legacyArtifactPathsSubsets.iterator(); i.hasNext(); ) {
LegacyArtifactPath v = readLegacyArtifactPath("", (Registry) i.next());
legacyArtifactPaths.add(v);
}
value.setLegacyArtifactPaths(legacyArtifactPaths);
RepositoryScanningConfiguration repositoryScanning = readRepositoryScanningConfiguration(prefix + "repositoryScanning.", registry);
value.setRepositoryScanning(repositoryScanning);
WebappConfiguration webapp = readWebappConfiguration(prefix + "webapp.", registry);
value.setWebapp(webapp);
OrganisationInformation organisationInfo = readOrganisationInformation(prefix + "organisationInfo.", registry);
value.setOrganisationInfo(organisationInfo);
NetworkConfiguration networkConfiguration = readNetworkConfiguration(prefix + "networkConfiguration.", registry);
value.setNetworkConfiguration(networkConfiguration);
RedbackRuntimeConfiguration redbackRuntimeConfiguration = readRedbackRuntimeConfiguration(prefix + "redbackRuntimeConfiguration.", registry);
value.setRedbackRuntimeConfiguration(redbackRuntimeConfiguration);
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = readArchivaRuntimeConfiguration(prefix + "archivaRuntimeConfiguration.", registry);
value.setArchivaRuntimeConfiguration(archivaRuntimeConfiguration);
java.util.List proxyConnectorRuleConfigurations = new java.util.ArrayList();
List proxyConnectorRuleConfigurationsSubsets = registry.getSubsetList(prefix + "proxyConnectorRuleConfigurations.proxyConnectorRuleConfiguration");
for (Iterator i = proxyConnectorRuleConfigurationsSubsets.iterator(); i.hasNext(); ) {
ProxyConnectorRuleConfiguration v = readProxyConnectorRuleConfiguration("", (Registry) i.next());
proxyConnectorRuleConfigurations.add(v);
}
value.setProxyConnectorRuleConfigurations(proxyConnectorRuleConfigurations);
ArchivaDefaultConfiguration archivaDefaultConfiguration = readArchivaDefaultConfiguration(prefix + "archivaDefaultConfiguration.", registry);
value.setArchivaDefaultConfiguration(archivaDefaultConfiguration);
return value;
}
use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class ArchivaConfigurationMRM789Test method assertConfiguration.
/**
* Ensures that the provided configuration matches the details present in the archiva-default.xml file.
*/
private void assertConfiguration(Configuration configuration, int managedExpected, int remoteExpected, int proxyConnectorExpected) throws Exception {
assertEquals("check managed repositories: " + configuration.getManagedRepositories(), managedExpected, configuration.getManagedRepositories().size());
assertEquals("check remote repositories: " + configuration.getRemoteRepositories(), remoteExpected, configuration.getRemoteRepositories().size());
assertEquals("check proxy connectors:" + configuration.getProxyConnectors(), proxyConnectorExpected, configuration.getProxyConnectors().size());
RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning();
assertNotNull("check repository scanning", repoScanning);
assertEquals("check file types", 4, repoScanning.getFileTypes().size());
assertEquals("check known consumers", 9, repoScanning.getKnownContentConsumers().size());
assertEquals("check invalid consumers", 1, repoScanning.getInvalidContentConsumers().size());
List<String> patterns = filetypes.getFileTypePatterns("artifacts");
assertNotNull("check 'artifacts' file type", patterns);
assertEquals("check 'artifacts' patterns", 13, patterns.size());
WebappConfiguration webapp = configuration.getWebapp();
assertNotNull("check webapp", webapp);
UserInterfaceOptions ui = webapp.getUi();
assertNotNull("check webapp ui", ui);
assertTrue("check showFindArtifacts", ui.isShowFindArtifacts());
assertTrue("check appletFindEnabled", ui.isAppletFindEnabled());
}
use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class ArchivaConfigurationTest method assertConfiguration.
/**
* Ensures that the provided configuration matches the details present in the archiva-default.xml file.
*/
private void assertConfiguration(Configuration configuration, int managedExpected, int remoteExpected, int proxyConnectorExpected) throws Exception {
assertEquals("check managed repositories: " + configuration.getManagedRepositories(), managedExpected, configuration.getManagedRepositories().size());
assertEquals("check remote repositories: " + configuration.getRemoteRepositories(), remoteExpected, configuration.getRemoteRepositories().size());
assertEquals("check proxy connectors:" + configuration.getProxyConnectors(), proxyConnectorExpected, configuration.getProxyConnectors().size());
RepositoryScanningConfiguration repoScanning = configuration.getRepositoryScanning();
assertNotNull("check repository scanning", repoScanning);
assertEquals("check file types", 4, repoScanning.getFileTypes().size());
assertEquals("check known consumers", 9, repoScanning.getKnownContentConsumers().size());
assertEquals("check invalid consumers", 1, repoScanning.getInvalidContentConsumers().size());
List<String> patterns = filetypes.getFileTypePatterns("artifacts");
assertNotNull("check 'artifacts' file type", patterns);
assertEquals("check 'artifacts' patterns", 13, patterns.size());
WebappConfiguration webapp = configuration.getWebapp();
assertNotNull("check webapp", webapp);
UserInterfaceOptions ui = webapp.getUi();
assertNotNull("check webapp ui", ui);
assertTrue("check showFindArtifacts", ui.isShowFindArtifacts());
assertTrue("check appletFindEnabled", ui.isAppletFindEnabled());
}
use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class FileTypes method getFileTypePatterns.
/**
* Get the list of patterns for a specified filetype.
* You will always get a list. In this order.
* <ul>
* <li>The Configured List</li>
* <li>The Default List</li>
* <li>A single item list of <code>"**/*"</code></li>
* </ul>
*
* @param id the id to lookup.
* @return the list of patterns.
*/
public List<String> getFileTypePatterns(String id) {
Configuration config = archivaConfiguration.getConfiguration();
Predicate selectedFiletype = new FiletypeSelectionPredicate(id);
RepositoryScanningConfiguration repositoryScanningConfiguration = config.getRepositoryScanning();
if (repositoryScanningConfiguration != null) {
FileType filetype = IterableUtils.find(config.getRepositoryScanning().getFileTypes(), selectedFiletype);
if ((filetype != null) && CollectionUtils.isNotEmpty(filetype.getPatterns())) {
return filetype.getPatterns();
}
}
List<String> defaultPatterns = defaultTypeMap.get(id);
if (CollectionUtils.isEmpty(defaultPatterns)) {
return Collections.singletonList("**/*");
}
return defaultPatterns;
}
use of org.apache.archiva.configuration.model.RepositoryScanningConfiguration in project archiva by apache.
the class Maven2RepositoryMetadataResolverTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
c = new Configuration();
c.setVersion("2.0");
testRepo = new ManagedRepositoryConfiguration();
testRepo.setId(TEST_REPO_ID);
testRepo.setLocation(Paths.get("target/test-repository").toAbsolutePath().toString());
testRepo.setReleases(true);
testRepo.setSnapshots(true);
c.addManagedRepository(testRepo);
RemoteRepositoryConfiguration testRemoteRepo = new RemoteRepositoryConfiguration();
testRemoteRepo.setId(TEST_REMOTE_REPO_ID);
testRemoteRepo.setLayout("default");
testRemoteRepo.setName("Central Repository");
testRemoteRepo.setUrl("http://central.repo.com/maven2");
testRemoteRepo.setTimeout(10);
c.addRemoteRepository(testRemoteRepo);
ProxyConnectorConfiguration proxyConnector = new ProxyConnectorConfiguration();
proxyConnector.setSourceRepoId(TEST_REPO_ID);
proxyConnector.setTargetRepoId(TEST_REMOTE_REPO_ID);
proxyConnector.setDisabled(false);
c.addProxyConnector(proxyConnector);
RepositoryScanningConfiguration scCfg = new RepositoryScanningConfiguration();
c.setRepositoryScanning(scCfg);
configuration.save(c);
assertFalse(configuration.isDefaulted());
repositoryRegistry.reload();
assertTrue(c.getManagedRepositories().get(0).isSnapshots());
assertTrue(c.getManagedRepositories().get(0).isReleases());
wagonFactory = mock(WagonFactory.class);
storage.setWagonFactory(wagonFactory);
Wagon wagon = new MockWagon();
when(wagonFactory.getWagon(new WagonFactoryRequest().protocol("wagon#http"))).thenReturn(wagon);
}
Aggregations