Search in sources :

Example 6 with RepositoryScanningConfiguration

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;
}
Also used : RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) LdapConfiguration(org.apache.archiva.configuration.model.LdapConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) NetworkConfiguration(org.apache.archiva.configuration.model.NetworkConfiguration) RedbackRuntimeConfiguration(org.apache.archiva.configuration.model.RedbackRuntimeConfiguration) AbstractRepositoryConfiguration(org.apache.archiva.configuration.model.AbstractRepositoryConfiguration) ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) AbstractRepositoryConnectorConfiguration(org.apache.archiva.configuration.model.AbstractRepositoryConnectorConfiguration) FileLockConfiguration(org.apache.archiva.configuration.model.FileLockConfiguration) RepositoryGroupConfiguration(org.apache.archiva.configuration.model.RepositoryGroupConfiguration) CacheConfiguration(org.apache.archiva.configuration.model.CacheConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) SyncConnectorConfiguration(org.apache.archiva.configuration.model.SyncConnectorConfiguration) ArchivaDefaultConfiguration(org.apache.archiva.configuration.model.ArchivaDefaultConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) ProxyConnectorRuleConfiguration(org.apache.archiva.configuration.model.ProxyConnectorRuleConfiguration) Iterator(java.util.Iterator) NetworkProxyConfiguration(org.apache.archiva.configuration.model.NetworkProxyConfiguration) List(java.util.List) NetworkConfiguration(org.apache.archiva.configuration.model.NetworkConfiguration) ArchivaDefaultConfiguration(org.apache.archiva.configuration.model.ArchivaDefaultConfiguration) ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) List(java.util.List) LegacyArtifactPath(org.apache.archiva.configuration.model.LegacyArtifactPath) OrganisationInformation(org.apache.archiva.configuration.model.OrganisationInformation) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RedbackRuntimeConfiguration(org.apache.archiva.configuration.model.RedbackRuntimeConfiguration)

Example 7 with RepositoryScanningConfiguration

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());
}
Also used : WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) UserInterfaceOptions(org.apache.archiva.configuration.model.UserInterfaceOptions) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration)

Example 8 with RepositoryScanningConfiguration

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());
}
Also used : WebappConfiguration(org.apache.archiva.configuration.model.WebappConfiguration) UserInterfaceOptions(org.apache.archiva.configuration.model.UserInterfaceOptions) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration)

Example 9 with RepositoryScanningConfiguration

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>&quot;**&#47;*&quot;</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;
}
Also used : RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) FileType(org.apache.archiva.configuration.model.FileType) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) Predicate(org.apache.commons.collections4.Predicate) FiletypeSelectionPredicate(org.apache.archiva.configuration.model.functors.FiletypeSelectionPredicate) FiletypeSelectionPredicate(org.apache.archiva.configuration.model.functors.FiletypeSelectionPredicate)

Example 10 with RepositoryScanningConfiguration

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);
}
Also used : WagonFactoryRequest(org.apache.archiva.maven.common.proxy.WagonFactoryRequest) ArchivaConfiguration(org.apache.archiva.configuration.provider.ArchivaConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) Configuration(org.apache.archiva.configuration.model.Configuration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) ContextConfiguration(org.springframework.test.context.ContextConfiguration) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) WagonFactory(org.apache.archiva.maven.common.proxy.WagonFactory) Wagon(org.apache.maven.wagon.Wagon) Before(org.junit.Before)

Aggregations

RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)10 Configuration (org.apache.archiva.configuration.model.Configuration)6 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)5 WebappConfiguration (org.apache.archiva.configuration.model.WebappConfiguration)4 ContextConfiguration (org.springframework.test.context.ContextConfiguration)4 Path (java.nio.file.Path)3 FileType (org.apache.archiva.configuration.model.FileType)3 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)3 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)3 ArchivaConfiguration (org.apache.archiva.configuration.provider.ArchivaConfiguration)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Iterator (java.util.Iterator)2 List (java.util.List)2 ArchivaRuntimeConfiguration (org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration)2 LegacyArtifactPath (org.apache.archiva.configuration.model.LegacyArtifactPath)2 NetworkProxyConfiguration (org.apache.archiva.configuration.model.NetworkProxyConfiguration)2 RepositoryGroupConfiguration (org.apache.archiva.configuration.model.RepositoryGroupConfiguration)2 UserInterfaceOptions (org.apache.archiva.configuration.model.UserInterfaceOptions)2 PostConstruct (javax.annotation.PostConstruct)1