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