From 2c12980a3a0a893375f89cd1ac60b8051483a377 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sat, 21 Oct 2017 14:41:59 +0200 Subject: [PATCH] Adding configuration entry and removing old v1 repositories --- .../DefaultArchivaConfiguration.java | 44 ------- .../src/main/mdo/configuration.mdo | 18 ++- .../ArchivaConfigurationTest.java | 108 ------------------ .../src/test/conf/repository-manager.xml | 54 ++++----- 4 files changed, 34 insertions(+), 190 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java index a9aa171a1..d31287d42 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/DefaultArchivaConfiguration.java @@ -215,50 +215,6 @@ public class DefaultArchivaConfiguration config.getRepositoryGroups(); config.getRepositoryGroupsAsMap(); - if ( !config.getRepositories().isEmpty() ) - { - for ( V1RepositoryConfiguration r : config.getRepositories() ) - { - r.setScanned( r.isIndexed() ); - - if ( StringUtils.startsWith( r.getUrl(), "file://" ) ) - { - r.setLocation( r.getUrl().substring( 7 ) ); - config.addManagedRepository( r ); - } - else if ( StringUtils.startsWith( r.getUrl(), "file:" ) ) - { - r.setLocation( r.getUrl().substring( 5 ) ); - config.addManagedRepository( r ); - } - else if ( StringUtils.isEmpty( r.getUrl() ) ) - { - // in case of empty url we can consider it as a managed one - // check if location is null - //file://${appserver.base}/repositories/${id} - if ( StringUtils.isEmpty( r.getLocation() ) ) - { - r.setLocation( "file://${appserver.base}/repositories/" + r.getId() ); - } - config.addManagedRepository( r ); - } - else - { - RemoteRepositoryConfiguration repo = new RemoteRepositoryConfiguration(); - repo.setId( r.getId() ); - repo.setLayout( r.getLayout() ); - repo.setName( r.getName() ); - repo.setUrl( r.getUrl() ); - config.addRemoteRepository( repo ); - } - } - - // Prevent duplicate repositories from showing up. - config.getRepositories().clear(); - - registry.removeSubset( KEY + ".repositories" ); - } - if ( !CollectionUtils.isEmpty( config.getRemoteRepositories() ) ) { List remoteRepos = config.getRemoteRepositories(); diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo index 1189ec006..971a83004 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -19,6 +19,7 @@ --> + configuration Configuration @@ -47,17 +48,12 @@ This is the version of the configuration format. - - @deprecated use managedRepositories or remoteRepositories instead. - - repositories - 1.0.0+ - - V1RepositoryConfiguration - * - + metadataStore + 3.0.0+ + String + true + jcr + The type of the metadata storage. Allowed values: jcr, file, cassandra. repositoryGroups diff --git a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java index ca4312cf6..36a8a7d64 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/test/java/org/apache/archiva/configuration/ArchivaConfigurationTest.java @@ -527,27 +527,6 @@ public class ArchivaConfigurationTest // Expected Path is: Should not have thrown an exception. } - @Test - public void testConfigurationUpgradeFrom09() - throws Exception - { - ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-upgrade-09" ); - - // we just use the defaults when upgrading from 0.9 at this point. - Configuration configuration = archivaConfiguration.getConfiguration(); - // test-upgrade-09 contains a managed with id: local so it's 3 managed - assertConfiguration( configuration, 3, 1, 1 ); - assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); - - ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 ); - - assertEquals( "check managed repositories", "${appserver.base}/repositories/internal", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isScanned() ); - } @Test public void testConfigurationUpgradeFrom13() @@ -583,93 +562,6 @@ public class ArchivaConfigurationTest configuration.getRepositoryScanning().getKnownContentConsumers().contains( "duplicate-artifacts" ) ); } - @Test - public void testAutoDetectV1() - throws Exception - { - // Setup the autodetect-v1.xml file in the target directory (so we can save/load it) - Path userFile = getTestFile( "target/test-autodetect-v1/archiva-user.xml" ); - Files.deleteIfExists(userFile); - assertFalse( Files.exists(userFile) ); - - Files.createDirectories(userFile.getParent()); - FileUtils.copyFile( getTestFile( "src/test/conf/autodetect-v1.xml" ).toFile(), userFile.toFile()); - - // Load the original (unconverted) archiva.xml - ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" ); - - archivaConfiguration.reload(); - - Configuration configuration = archivaConfiguration.getConfiguration(); - assertConfiguration( configuration, 2, 2, 2 ); - assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); - - ManagedRepositoryConfiguration repository = configuration.getManagedRepositories().get( 0 ); - - assertEquals( "check managed repositories", "${appserver.base}/repositories/internal", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isScanned() ); - - // Test that only 1 set of repositories exist. - assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() ); - assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() ); - assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); - - // Save the file. - archivaConfiguration.save( configuration ); - - // Reload. - archivaConfiguration = lookup( ArchivaConfiguration.class, "test-autodetect-v1" ); - configuration = archivaConfiguration.getConfiguration(); - - // Test that only 1 set of repositories exist. - assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositories().size() ); - assertEquals( "check managed repositories size.", 2, configuration.getManagedRepositoriesAsMap().size() ); - assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositories().size() ); - assertEquals( "check remote repositories size.", 2, configuration.getRemoteRepositoriesAsMap().size() ); - assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); - - String actualXML = FileUtils.readFileToString( userFile.toFile(), Charset.forName( "UTF-8" ) ); - XMLAssert.assertXpathNotExists( "//configuration/repositories/repository", actualXML ); - XMLAssert.assertXpathNotExists( "//configuration/repositories", actualXML ); - } - - @Test - public void testArchivaV1() - throws Exception - { - ArchivaConfiguration archivaConfiguration = lookup( ArchivaConfiguration.class, "test-archiva-v1" ); - - Configuration configuration = archivaConfiguration.getConfiguration(); - assertConfiguration( configuration, 2, 2, 2 ); - assertEquals( "check network proxies", 1, configuration.getNetworkProxies().size() ); - - assertEquals( "check managed repositories", 2, configuration.getManagedRepositories().size() ); - assertEquals( "check v1 repositories size.", 0, configuration.getRepositories().size() ); - - Map map = configuration.getManagedRepositoriesAsMap(); - - ManagedRepositoryConfiguration repository = map.get( "internal" ); - assertEquals( "check managed repositories", "${appserver.base}/repositories/internal", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Internal Repository", repository.getName() ); - assertEquals( "check managed repositories", "internal", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertTrue( "check managed repositories", repository.isScanned() ); - assertFalse( "check managed repositories", repository.isSnapshots() ); - - repository = map.get( "snapshots" ); - assertEquals( "check managed repositories", "${appserver.base}/repositories/snapshots", - repository.getLocation() ); - assertEquals( "check managed repositories", "Archiva Managed Snapshot Repository", repository.getName() ); - assertEquals( "check managed repositories", "snapshots", repository.getId() ); - assertEquals( "check managed repositories", "default", repository.getLayout() ); - assertFalse( "check managed repositories", repository.isScanned() ); - assertTrue( "check managed repositories", repository.isSnapshots() ); - } @Test public void testCronExpressionsWithComma() diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml index 171cfd131..384891f04 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/conf/repository-manager.xml @@ -19,29 +19,43 @@ --> - 1 - - + 3.0.0 + + internal Archiva Managed Internal Repository - file://${appserver.base}/repositories/internal + file://${appserver.base}/repositories/internal + ${appserver.base}/repositories/internal/.indexer default true false true 0 0 * * * ? - - + + snapshots Archiva Managed Snapshot Repository - file://${appserver.base}/repositories/snapshots + file://${appserver.base}/repositories/snapshots + .indexer default false true true 0 0,30 * * * ? - - + + + test-repo + Test Repository + file://${appserver.base}/test-repo + default + true + true + true + 0 0 * * * ? + + + + central Central Repository http://repo1.maven.org/maven2 @@ -49,29 +63,15 @@ true false false - - + + maven2-repository.dev.java.net Java.net Repository for Maven 2 https://maven2-repository.dev.java.net/nonav/repository default - true - false false - - - test-repo - Test Repository - file://${appserver.base}/test-repo - default - true - true - true - 0 0 * * * ? - 0 - 2 - - + + -- 2.39.5