Search in sources :

Example 1 with ArchivaRuntimeConfiguration

use of org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration 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);
}
Also used : ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) FileType(org.apache.archiva.configuration.model.FileType) RepositoryScanningConfiguration(org.apache.archiva.configuration.model.RepositoryScanningConfiguration) PostConstruct(javax.annotation.PostConstruct)

Example 2 with ArchivaRuntimeConfiguration

use of org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration in project archiva by apache.

the class MavenRepositoryProviderTest method setUp.

@Before
public void setUp() throws Exception {
    provider = new MavenRepositoryProvider();
    MockConfiguration mockConfiguration = new MockConfiguration();
    mockConfiguration.getConfiguration().setArchivaRuntimeConfiguration(new ArchivaRuntimeConfiguration());
    mockConfiguration.getConfiguration().getArchivaRuntimeConfiguration().setRepositoryBaseDirectory("repositories");
    provider.setArchivaConfiguration(mockConfiguration);
}
Also used : ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) MockConfiguration(org.apache.archiva.maven.repository.metadata.storage.mock.MockConfiguration) Before(org.junit.Before)

Example 3 with ArchivaRuntimeConfiguration

use of org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration 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 4 with ArchivaRuntimeConfiguration

use of org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration in project archiva by apache.

the class ConfigurationRegistryReader method readArchivaRuntimeConfiguration.

private ArchivaRuntimeConfiguration readArchivaRuntimeConfiguration(String prefix, Registry registry) {
    ArchivaRuntimeConfiguration value = new ArchivaRuntimeConfiguration();
    CacheConfiguration urlFailureCacheConfiguration = readCacheConfiguration(prefix + "urlFailureCacheConfiguration.", registry);
    value.setUrlFailureCacheConfiguration(urlFailureCacheConfiguration);
    FileLockConfiguration fileLockConfiguration = readFileLockConfiguration(prefix + "fileLockConfiguration.", registry);
    value.setFileLockConfiguration(fileLockConfiguration);
    // String dataDirectory = registry.getString( prefix + "dataDirectory", value.getDataDirectory() );
    List<String> dataDirectoryList = registry.getList(prefix + "dataDirectory");
    String dataDirectory = value.getDataDirectory();
    if (dataDirectoryList != null && !dataDirectoryList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = dataDirectoryList.size(); i < size; i++) {
            sb.append(dataDirectoryList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        dataDirectory = sb.toString();
    }
    value.setDataDirectory(dataDirectory);
    // String repositoryBaseDirectory = registry.getString( prefix + "repositoryBaseDirectory", value.getRepositoryBaseDirectory() );
    List<String> repositoryBaseDirectoryList = registry.getList(prefix + "repositoryBaseDirectory");
    String repositoryBaseDirectory = value.getRepositoryBaseDirectory();
    if (repositoryBaseDirectoryList != null && !repositoryBaseDirectoryList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = repositoryBaseDirectoryList.size(); i < size; i++) {
            sb.append(repositoryBaseDirectoryList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        repositoryBaseDirectory = sb.toString();
    }
    value.setRepositoryBaseDirectory(repositoryBaseDirectory);
    // String remoteRepositoryBaseDirectory = registry.getString( prefix + "remoteRepositoryBaseDirectory", value.getRemoteRepositoryBaseDirectory() );
    List<String> remoteRepositoryBaseDirectoryList = registry.getList(prefix + "remoteRepositoryBaseDirectory");
    String remoteRepositoryBaseDirectory = value.getRemoteRepositoryBaseDirectory();
    if (remoteRepositoryBaseDirectoryList != null && !remoteRepositoryBaseDirectoryList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = remoteRepositoryBaseDirectoryList.size(); i < size; i++) {
            sb.append(remoteRepositoryBaseDirectoryList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        remoteRepositoryBaseDirectory = sb.toString();
    }
    value.setRemoteRepositoryBaseDirectory(remoteRepositoryBaseDirectory);
    // String defaultLanguage = registry.getString( prefix + "defaultLanguage", value.getDefaultLanguage() );
    List<String> repositoryGroupBaseDirectoryList = registry.getList(prefix + "repositoryGroupBaseDirectory");
    String repositoryGroupBaseDirectory = value.getRepositoryGroupBaseDirectory();
    if (repositoryGroupBaseDirectoryList != null && !repositoryGroupBaseDirectoryList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = repositoryGroupBaseDirectoryList.size(); i < size; i++) {
            sb.append(repositoryGroupBaseDirectoryList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        repositoryGroupBaseDirectory = sb.toString();
    }
    value.setRepositoryGroupBaseDirectory(repositoryGroupBaseDirectory);
    List<String> defaultLanguageList = registry.getList(prefix + "defaultLanguage");
    String defaultLanguage = value.getDefaultLanguage();
    if (defaultLanguageList != null && !defaultLanguageList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = defaultLanguageList.size(); i < size; i++) {
            sb.append(defaultLanguageList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        defaultLanguage = sb.toString();
    }
    value.setDefaultLanguage(defaultLanguage);
    // String languageRange = registry.getString( prefix + "languageRange", value.getLanguageRange() );
    List<String> languageRangeList = registry.getList(prefix + "languageRange");
    String languageRange = value.getLanguageRange();
    if (languageRangeList != null && !languageRangeList.isEmpty()) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0, size = languageRangeList.size(); i < size; i++) {
            sb.append(languageRangeList.get(i));
            if (i < size - 1) {
                sb.append(',');
            }
        }
        languageRange = sb.toString();
    }
    value.setLanguageRange(languageRange);
    List<String> checksumTypeList = registry.getList(prefix + "checksumTypes.type");
    value.setChecksumTypes(checksumTypeList);
    return value;
}
Also used : ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) CacheConfiguration(org.apache.archiva.configuration.model.CacheConfiguration) FileLockConfiguration(org.apache.archiva.configuration.model.FileLockConfiguration)

Example 5 with ArchivaRuntimeConfiguration

use of org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration in project archiva by apache.

the class AbstractProxyTestCase method setUp.

@Before
public void setUp() throws Exception {
    config = (MockConfiguration) applicationContext.getBean("archivaConfiguration#mock", ArchivaConfiguration.class);
    config.getConfiguration().setManagedRepositories(new ArrayList<ManagedRepositoryConfiguration>());
    config.getConfiguration().setRemoteRepositories(new ArrayList<RemoteRepositoryConfiguration>());
    config.getConfiguration().setProxyConnectors(new ArrayList<ProxyConnectorConfiguration>());
    ArchivaRuntimeConfiguration runtimeConfiguration = new ArchivaRuntimeConfiguration();
    List<String> checksumTypes = new ArrayList<>();
    checksumTypes.add("md5");
    checksumTypes.add("sha256");
    checksumTypes.add("sha1");
    checksumTypes.add("asc");
    runtimeConfiguration.setChecksumTypes(checksumTypes);
    config.getConfiguration().setArchivaRuntimeConfiguration(runtimeConfiguration);
    repositoryRegistry.setArchivaConfiguration(config);
    // Setup source repository (using default layout)
    String name = getClass().getSimpleName();
    Path repoPath = Paths.get("target/test-repository/managed/" + name);
    managedDefaultRepository = createRepository(ID_DEFAULT_MANAGED, "Default Managed Repository", repoPath.toString(), "default");
    managedDefaultDir = repoPath.resolve(ID_DEFAULT_MANAGED);
    org.apache.archiva.repository.ManagedRepository repoConfig = repositoryRegistry.getManagedRepository(ID_DEFAULT_MANAGED);
    // Setup target (proxied to) repository.
    saveRemoteRepositoryConfig(ID_PROXIED1, "Proxied Repository 1", Paths.get(REPOPATH_PROXIED1).toUri().toURL().toExternalForm(), "default");
    // Setup target (proxied to) repository.
    saveRemoteRepositoryConfig(ID_PROXIED2, "Proxied Repository 2", Paths.get(REPOPATH_PROXIED2).toUri().toURL().toExternalForm(), "default");
    repositoryRegistry.reload();
    repositoryRegistry.putRepository(repoConfig);
    // Setup the proxy handler.
    // proxyHandler = applicationContext.getBean (RepositoryProxyHandler) lookup( RepositoryProxyHandler.class.getName() );
    proxyHandler = applicationContext.getBean("repositoryProxyHandler#test", RepositoryProxyHandler.class);
    assertNotNull(proxyRegistry);
    assertTrue(proxyRegistry.getAllHandler().get(RepositoryType.MAVEN).contains(proxyHandler));
    // Setup the wagon mock.
    wagonMock = mock(Wagon.class);
    delegate = (WagonDelegate) applicationContext.getBean("wagon#http", Wagon.class);
    delegate.setDelegate(wagonMock);
    log.info("\n.\\ {}() \\._________________________________________\n", name);
}
Also used : Path(java.nio.file.Path) ManagedRepositoryConfiguration(org.apache.archiva.configuration.model.ManagedRepositoryConfiguration) ArrayList(java.util.ArrayList) ProxyConnectorConfiguration(org.apache.archiva.configuration.model.ProxyConnectorConfiguration) Wagon(org.apache.maven.wagon.Wagon) ManagedRepository(org.apache.archiva.repository.ManagedRepository) ArchivaRuntimeConfiguration(org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration) RemoteRepositoryConfiguration(org.apache.archiva.configuration.model.RemoteRepositoryConfiguration) RepositoryProxyHandler(org.apache.archiva.proxy.model.RepositoryProxyHandler) Before(org.junit.Before)

Aggregations

ArchivaRuntimeConfiguration (org.apache.archiva.configuration.model.ArchivaRuntimeConfiguration)5 CacheConfiguration (org.apache.archiva.configuration.model.CacheConfiguration)2 FileLockConfiguration (org.apache.archiva.configuration.model.FileLockConfiguration)2 ManagedRepositoryConfiguration (org.apache.archiva.configuration.model.ManagedRepositoryConfiguration)2 ProxyConnectorConfiguration (org.apache.archiva.configuration.model.ProxyConnectorConfiguration)2 RemoteRepositoryConfiguration (org.apache.archiva.configuration.model.RemoteRepositoryConfiguration)2 RepositoryScanningConfiguration (org.apache.archiva.configuration.model.RepositoryScanningConfiguration)2 Before (org.junit.Before)2 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1 AbstractRepositoryConfiguration (org.apache.archiva.configuration.model.AbstractRepositoryConfiguration)1 AbstractRepositoryConnectorConfiguration (org.apache.archiva.configuration.model.AbstractRepositoryConnectorConfiguration)1 ArchivaDefaultConfiguration (org.apache.archiva.configuration.model.ArchivaDefaultConfiguration)1 Configuration (org.apache.archiva.configuration.model.Configuration)1 FileType (org.apache.archiva.configuration.model.FileType)1 LdapConfiguration (org.apache.archiva.configuration.model.LdapConfiguration)1 LegacyArtifactPath (org.apache.archiva.configuration.model.LegacyArtifactPath)1