From b2332f00ba4bcdc76aebaf03d93916faf132cbd8 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Thu, 22 Mar 2007 21:10:28 +0000 Subject: More directory moves git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/branches/archiva-jpox-database-refactor@521470 13f79535-47bb-0310-9956-ffa450edef68 --- archiva-base/archiva-common/pom.xml | 96 ++ .../maven/archiva/common/ArchivaException.java | 40 + .../builder/AbstractLayoutArtifactBuilder.java | 55 + .../common/artifact/builder/BuilderException.java | 43 + .../builder/DefaultLayoutArtifactBuilder.java | 218 ++++ .../artifact/builder/LayoutArtifactBuilder.java | 36 + .../builder/LegacyLayoutArtifactBuilder.java | 303 +++++ .../common/artifact/managed/ManagedArtifact.java | 76 ++ .../artifact/managed/ManagedArtifactTypes.java | 81 ++ .../artifact/managed/ManagedEjbArtifact.java | 49 + .../artifact/managed/ManagedJavaArtifact.java | 62 + .../maven/archiva/common/utils/BaseFile.java | 105 ++ .../maven/archiva/common/utils/DateUtil.java | 130 ++ .../maven/archiva/common/utils/PathUtil.java | 56 + .../common/AbstractArchivaCommonTestCase.java | 146 +++ .../org/apache/maven/archiva/common/AllTests.java | 44 + .../AbstractLayoutArtifactBuilderTestCase.java | 51 + .../archiva/common/artifact/builder/AllTests.java | 44 + .../builder/DefaultLayoutArtifactBuilderTest.java | 206 ++++ .../builder/LegacyLayoutArtifactBuilderTest.java | 160 +++ .../maven/archiva/common/utils/AllTests.java | 44 + .../maven/archiva/common/utils/BaseFileTest.java | 131 ++ .../maven/archiva/common/utils/DateUtilTest.java | 69 ++ .../maven/archiva/common/utils/PathUtilTest.java | 40 + .../src/test/legacy-repository/CVS/Root | 1 + .../archiva-common/src/test/legacy-repository/KEYS | 0 .../legacy-repository/invalid/foo/invalid-1.0.foo | 0 .../test/legacy-repository/invalid/invalid-1.0.jar | 0 .../invalid/jars/1.0/invalid-1.0.jar | 0 .../legacy-repository/invalid/jars/invalid-1.0.rar | 0 .../legacy-repository/invalid/jars/invalid.jar | 0 .../legacy-repository/invalid/jars/no-extension | 0 .../legacy-repository/javax.sql/jars/jdbc-2.0.jar | 0 .../jars/test-not-updated-1.0.jar | 1 + .../jars/test-updated-1.0.jar | 1 + .../org.apache.maven/jars/some-ejb-1.0-client.jar | 0 .../jars/testing-1.0-20050611.112233-1.jar | 0 .../org.apache.maven/jars/testing-1.0-sources.jar | 0 .../org.apache.maven/jars/testing-1.0.jar | 0 .../org.apache.maven/jars/testing-1.0.tar.gz | 0 .../org.apache.maven/jars/testing-1.0.zip | 0 .../org.apache.maven/jars/testing-UNKNOWN.jar | 0 .../archiva-common/src/test/repository/CVS/Root | 1 + .../archiva-common/src/test/repository/KEYS | 1 + .../src/test/repository/invalid/invalid-1.0.jar | 0 .../invalid-1.0-20050611.123456-1.jar | 0 .../invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar | 0 .../invalid/invalid/1.0/invalid-1.0b.jar | 0 .../repository/invalid/invalid/1.0/invalid-2.0.jar | 0 .../test/repository/invalid/invalid/1/invalid-1 | 0 .../src/test/repository/javax/maven-metadata.xml | 26 + .../repository/javax/sql/jdbc/2.0/jdbc-2.0.jar | 0 .../sql/jdbc/2.0/maven-metadata-repository.xml | 25 + .../javax/sql/jdbc/maven-metadata-repository.xml | 30 + .../javax/sql/maven-metadata-repository.xml | 25 + .../repository/org/apache/maven/A/1.0/A-1.0.pom | 28 + .../repository/org/apache/maven/A/1.0/A-1.0.war | 1 + .../repository/org/apache/maven/B/1.0/B-1.0.pom | 28 + .../repository/org/apache/maven/B/2.0/B-2.0.pom | 28 + .../repository/org/apache/maven/C/1.0/C-1.0.pom | 28 + .../repository/org/apache/maven/C/1.0/C-1.0.war | 1 + .../apache/maven/discovery/1.0/discovery-1.0.pom | 28 + .../repository/org/apache/maven/maven-metadata.xml | 23 + .../apache/maven/samplejar/1.0/samplejar-1.0.jar | 1 + .../apache/maven/samplejar/1.0/samplejar-1.0.pom | 29 + .../apache/maven/samplejar/2.0/samplejar-2.0.jar | 1 + .../apache/maven/samplejar/2.0/samplejar-2.0.pom | 29 + .../apache/maven/some-ejb/1.0/maven-metadata.xml | 0 .../maven/some-ejb/1.0/some-ejb-1.0-client.jar | 0 .../test-1.0-20050611.112233-1-javadoc.jar | 0 .../1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar | 0 .../wrong-artifactId-1.0-20050611.112233-1.jar | 0 .../maven/testing/1.0/testing-1.0-sources.jar | 0 .../maven/testing/1.0/testing-1.0-test-sources.jar | 0 .../org/apache/maven/testing/1.0/testing-1.0.jar | 0 .../apache/maven/testing/1.0/testing-1.0.tar.gz | 0 .../org/apache/maven/testing/1.0/testing-1.0.zip | 0 .../test-not-updated/1.0/test-not-updated-1.0.jar | 1 + .../test-not-updated/1.0/test-not-updated-1.0.pom | 29 + .../update/test-not-updated/maven-metadata.xml | 24 + .../update/test-updated/1.0/test-updated-1.0.jar | 1 + .../update/test-updated/1.0/test-updated-1.0.pom | 29 + .../maven/update/test-updated/maven-metadata.xml | 24 + .../testgroup/discovery/1.0/discovery-1.0.pom | 28 + .../testgroup/discovery/1.0/maven-metadata.xml | 25 + .../apache/testgroup/discovery/maven-metadata.xml | 24 + .../consumers/GenericArtifactConsumerTest.xml | 34 + .../common/consumers/GenericModelConsumerTest.xml | 34 + .../GenericRepositoryMetadataConsumerTest.xml | 34 + archiva-base/archiva-configuration/pom.xml | 109 ++ .../configuration/ArchivaConfiguration.java | 53 + .../configuration/DefaultArchivaConfiguration.java | 125 ++ .../InvalidConfigurationException.java | 49 + .../configuration/MavenProxyPropertyLoader.java | 163 +++ .../src/main/mdo/configuration.mdo | 479 ++++++++ ...edRepositoryConfiguration-conversion.properties | 21 + .../archiva/configuration/default-archiva.xml | 219 ++++ .../src/test/conf/corrupt.xml | 20 + .../src/test/conf/maven-proxy-complete.conf | 144 +++ .../src/test/conf/repository-manager.xml | 238 ++++ .../src/test/conf/with-proxied-repos.xml | 44 + .../configuration/ArchivaConfigurationTest.java | 200 +++ .../MavenProxyPropertyLoaderTest.java | 96 ++ .../configuration/ArchivaConfigurationTest.xml | 182 +++ archiva-base/archiva-converter/pom.xml | 83 ++ .../maven/archiva/converter/ConversionEvent.java | 128 ++ .../archiva/converter/ConversionListener.java | 31 + .../converter/DefaultRepositoryConverter.java | 741 ++++++++++++ .../converter/RepositoryConversionException.java | 39 + .../archiva/converter/RepositoryConverter.java | 67 + .../legacy/DefaultLegacyRepositoryConverter.java | 139 +++ .../legacy/LegacyConverterArtifactConsumer.java | 105 ++ .../legacy/LegacyRepositoryConverter.java | 64 + .../transaction/AbstractTransactionEvent.java | 225 ++++ .../converter/transaction/CopyFileEvent.java | 133 ++ .../converter/transaction/CreateFileEvent.java | 98 ++ .../converter/transaction/FileTransaction.java | 126 ++ .../converter/transaction/TransactionEvent.java | 46 + .../DefaultRepositoryConverter.properties | 38 + .../test/expected-files/converted-artifact-one.pom | 6 + .../expected-files/converted-artifact-three.pom | 6 + .../test/expected-files/converted-artifact-two.pom | 6 + .../test/expected-files/converted-v3-snapshot.pom | 28 + .../converted-v3-timestamped-snapshot.pom | 28 + .../test/expected-files/converted-v3-warnings.pom | 28 + .../src/test/expected-files/converted-v3.pom | 28 + .../test/expected-files/maven-foo-plugin-1.0.pom | 7 + .../newversion-artifact-metadata.xml | 10 + .../relocated-v3artifact/1.0.0/maven-metadata.xml | 6 + .../1.0.0/relocated-v3artifact-1.0.0.jar | 1 + .../1.0.0/relocated-v3artifact-1.0.0.pom | 28 + .../relocated-v3artifact/maven-metadata.xml | 9 + .../1.0.0/relocated-v3artifact-1.0.0.pom | 12 + .../test/expected-files/v3-artifact-metadata.xml | 9 + .../v3-snapshot-artifact-metadata.xml | 9 + .../test/expected-files/v3-snapshot-metadata.xml | 6 + .../v3-timestamped-snapshot-metadata.xml | 11 + .../test/expected-files/v3-version-metadata.xml | 6 + .../test/expected-files/v4-artifact-metadata.xml | 9 + .../v4-snapshot-artifact-metadata.xml | 9 + .../test/expected-files/v4-snapshot-metadata.xml | 6 + .../v4-timestamped-snapshot-metadata.xml | 11 + .../test/expected-files/v4-version-metadata.xml | 6 + .../apache/maven/archiva/converter/AllTests.java | 44 + .../archiva/converter/MockConversionListener.java | 163 +++ .../archiva/converter/RepositoryConverterTest.java | 1088 +++++++++++++++++ .../transaction/AbstractFileEventTest.java | 77 ++ .../archiva/converter/transaction/AllTests.java | 44 + .../converter/transaction/CopyFileEventTest.java | 180 +++ .../converter/transaction/CreateFileEventTest.java | 121 ++ .../src/test/resources/log4j.properties | 10 + .../archiva/converter/RepositoryConverterTest.xml | 125 ++ .../1.0.0/incorrectArtifactMetadata-1.0.0.jar | 1 + .../1.0.0/incorrectArtifactMetadata-1.0.0.pom | 25 + .../incorrectArtifactMetadata/maven-metadata.xml | 29 + ...ectSnapshotMetadata-1.0.0-20060102.030405-6.jar | 1 + ...ectSnapshotMetadata-1.0.0-20060102.030405-6.pom | 25 + .../1.0.0-SNAPSHOT/maven-metadata.xml | 31 + .../incorrectSnapshotMetadata/maven-metadata.xml | 29 + .../test/jars/artifact-one-1.0.0.jar | 1 + .../test/jars/artifact-three-1.0.0.jar | 1 + .../test/jars/artifact-two-1.0.0.jar | 1 + .../test/jars/dryrun-artifact-1.0.0.jar | 1 + .../test/jars/existing-artifact-1.0.0.jar | 1 + .../test/jars/incorrectMd5Artifact-1.0.0.jar | 1 + .../test/jars/incorrectMd5Artifact-1.0.0.jar.md5 | 1 + .../test/jars/incorrectSha1Artifact-1.0.0.jar | 1 + .../test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 | 1 + .../test/jars/modified-artifact-1.0.0.jar | 1 + .../test/jars/newversion-artifact-1.0.1.jar | 1 + .../test/jars/noPomArtifact-1.0.0.jar | 1 + .../test/jars/relocated-v3artifact-1.0.0.jar | 1 + .../test/jars/rollback-created-artifact-1.0.0.jar | 1 + .../test/jars/unmodified-artifact-1.0.0.jar | 1 + .../test/jars/v3-warnings-artifact-1.0.0.jar | 1 + .../jars/v3artifact-1.0.0-20060105.130101-3.jar | 1 + .../test/jars/v3artifact-1.0.0-SNAPSHOT.jar | 1 + .../test/jars/v3artifact-1.0.0.jar | 1 + .../jars/v4artifact-1.0.0-20060111.120115-1.jar | 1 + .../test/jars/v4artifact-1.0.0-SNAPSHOT.jar | 1 + .../test/jars/v4artifact-1.0.0.jar | 1 + .../test/jars/v4artifact-1.0.0.jar.md5 | 1 + .../test/jars/v4artifact-1.0.0.jar.sha1 | 1 + .../test/plugins/maven-foo-plugin-1.0.jar | 1 + .../test/poms/artifact-one-1.0.0.pom | 6 + .../test/poms/artifact-three-1.0.0.pom | 6 + .../test/poms/artifact-two-1.0.0.pom | 6 + .../test/poms/dryrun-artifact-1.0.0.pom | 22 + .../test/poms/incorrectMd5Artifact-1.0.0.pom | 6 + .../test/poms/incorrectSha1Artifact-1.0.0.pom | 6 + .../test/poms/maven-foo-plugin-1.0.pom | 6 + .../test/poms/modified-artifact-1.0.0.pom | 22 + .../test/poms/newversion-artifact-1.0.1.pom | 22 + .../test/poms/relocated-v3artifact-1.0.0.pom | 27 + .../test/poms/rollback-created-artifact-1.0.0.pom | 39 + .../test/poms/unmodified-artifact-1.0.0.pom | 25 + .../test/poms/v3-warnings-artifact-1.0.0.pom | 48 + .../poms/v3artifact-1.0.0-20060105.130101-3.pom | 40 + .../test/poms/v3artifact-1.0.0-SNAPSHOT.pom | 40 + .../test/poms/v3artifact-1.0.0.pom | 24 + .../poms/v4artifact-1.0.0-20060111.120115-1.pom | 22 + .../test/poms/v4artifact-1.0.0-SNAPSHOT.pom | 22 + .../test/poms/v4artifact-1.0.0.pom | 6 + .../1.0.0/modified-artifact-1.0.0.jar | 1 + .../1.0.0/modified-artifact-1.0.0.pom | 25 + .../1.0.0/newversion-artifact-1.0.0.jar | 1 + .../1.0.0/newversion-artifact-1.0.0.pom | 25 + .../test/newversion-artifact/maven-metadata.xml | 29 + .../1.0.0/unmodified-artifact-1.0.0.jar | 1 + .../1.0.0/unmodified-artifact-1.0.0.pom | 25 + archiva-base/archiva-model/pom.xml | 157 +++ .../maven/archiva/model/RepositoryContentKey.java | 170 +++ .../archiva-model/src/main/mdo/archiva-base.xml | 1277 ++++++++++++++++++++ .../archiva-model/src/test/resources/log4j.xml | 76 ++ archiva-base/archiva-repository-layer/pom.xml | 97 ++ .../archiva/layer/CachedRepositoryQueryLayer.java | 98 ++ .../archiva/layer/DefaultRepositoryQueryLayer.java | 105 ++ .../layer/DefaultRepositoryQueryLayerFactory.java | 38 + .../maven/archiva/layer/RepositoryQueryLayer.java | 40 + .../layer/RepositoryQueryLayerException.java | 37 + .../archiva/layer/RepositoryQueryLayerFactory.java | 41 + .../maven/archiva/repository/ArchivaArtifact.java | 161 +++ .../archiva/repository/ArchivaRepository.java | 135 +++ .../archiva/repository/RepositoryException.java | 52 + .../maven/archiva/repository/RepositoryURL.java | 156 +++ .../repository/connector/RepositoryConnector.java | 41 + .../archiva/repository/consumer/Consumer.java | 91 ++ .../repository/consumer/ConsumerException.java | 52 + .../repository/consumer/ConsumerFactory.java | 70 ++ .../content/AbstractArtifactExtensionMapping.java | 60 + .../content/ArtifactExtensionMapping.java | 36 + .../content/DefaultArtifactExtensionMapping.java | 76 ++ .../content/LegacyArtifactExtensionMapping.java | 76 ++ .../layout/BidirectionalRepositoryLayout.java | 56 + .../DefaultBidirectionalRepositoryLayout.java | 129 ++ .../archiva/repository/layout/LayoutException.java | 41 + .../LegacyBidirectionalRepositoryLayout.java | 135 +++ .../repository/layout/RepositoryLayoutUtils.java | 219 ++++ .../repository/scanner/RepositoryScanner.java | 197 +++ .../scanner/RepositoryScannerInstance.java | 199 +++ .../archiva/repository/version/VersionUtil.java | 62 + .../main/resources/META-INF/plexus/components.xml | 43 + .../java/org/apache/maven/archiva/AllTests.java | 44 + .../AbstractRepositoryQueryLayerTestCase.java | 116 ++ .../org/apache/maven/archiva/layer/AllTests.java | 44 + .../layer/CachedRepositoryQueryLayerTest.java | 56 + .../layer/DefaultRepositoryQueryLayerTest.java | 32 + .../apache/maven/archiva/repository/AllTests.java | 43 + .../archiva/repository/RepositoryURLTest.java | 90 ++ ...tractBidirectionalRepositoryLayoutTestCase.java | 100 ++ .../DefaultBidirectionalRepositoryLayoutTest.java | 105 ++ .../LegacyBidirectionalRepositoryLayoutTest.java | 107 ++ .../layout/RepositoryLayoutUtilsTest.java | 206 ++++ .../repository/scanner/CentralScannerTiming.java | 132 ++ .../repository/scanner/RepositoryScannerTest.java | 70 ++ .../archiva/repository/scanner/ScanConsumer.java | 82 ++ .../test/repositories/default-repository/CVS/Root | 1 + .../src/test/repositories/default-repository/KEYS | 1 + .../default-repository/invalid/invalid-1.0.jar | 0 .../invalid-1.0-20050611.123456-1.jar | 0 .../invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar | 0 .../invalid/invalid/1.0/invalid-1.0b.jar | 0 .../invalid/invalid/1.0/invalid-2.0.jar | 0 .../default-repository/invalid/invalid/1/invalid-1 | 0 .../default-repository/javax/maven-metadata.xml | 26 + .../javax/sql/jdbc/2.0/jdbc-2.0.jar | 0 .../sql/jdbc/2.0/maven-metadata-repository.xml | 25 + .../javax/sql/jdbc/maven-metadata-repository.xml | 30 + .../javax/sql/maven-metadata-repository.xml | 25 + .../org/apache/maven/A/1.0/A-1.0.pom | 28 + .../org/apache/maven/A/1.0/A-1.0.war | 1 + .../org/apache/maven/B/1.0/B-1.0.pom | 28 + .../org/apache/maven/B/2.0/B-2.0.pom | 28 + .../org/apache/maven/C/1.0/C-1.0.pom | 28 + .../org/apache/maven/C/1.0/C-1.0.war | 1 + .../apache/maven/discovery/1.0/discovery-1.0.pom | 28 + .../org/apache/maven/maven-metadata.xml | 23 + .../apache/maven/samplejar/1.0/samplejar-1.0.jar | 1 + .../apache/maven/samplejar/1.0/samplejar-1.0.pom | 29 + .../apache/maven/samplejar/2.0/samplejar-2.0.jar | 1 + .../apache/maven/samplejar/2.0/samplejar-2.0.pom | 29 + .../apache/maven/some-ejb/1.0/maven-metadata.xml | 0 .../maven/some-ejb/1.0/some-ejb-1.0-client.jar | 0 .../test-1.0-20050611.112233-1-javadoc.jar | 0 .../1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar | 0 .../wrong-artifactId-1.0-20050611.112233-1.jar | 0 .../maven/testing/1.0/testing-1.0-sources.jar | 0 .../maven/testing/1.0/testing-1.0-test-sources.jar | 0 .../org/apache/maven/testing/1.0/testing-1.0.jar | 0 .../apache/maven/testing/1.0/testing-1.0.tar.gz | 0 .../org/apache/maven/testing/1.0/testing-1.0.zip | 0 .../test-not-updated/1.0/test-not-updated-1.0.jar | 1 + .../test-not-updated/1.0/test-not-updated-1.0.pom | 29 + .../update/test-not-updated/maven-metadata.xml | 24 + .../update/test-updated/1.0/test-updated-1.0.jar | 1 + .../update/test-updated/1.0/test-updated-1.0.pom | 29 + .../maven/update/test-updated/maven-metadata.xml | 24 + .../testgroup/discovery/1.0/discovery-1.0.pom | 28 + .../testgroup/discovery/1.0/maven-metadata.xml | 25 + .../apache/testgroup/discovery/maven-metadata.xml | 24 + .../test/repositories/legacy-repository/CVS/Root | 1 + .../src/test/repositories/legacy-repository/KEYS | 0 .../legacy-repository/invalid/foo/invalid-1.0.foo | 0 .../legacy-repository/invalid/invalid-1.0.jar | 0 .../invalid/jars/1.0/invalid-1.0.jar | 0 .../legacy-repository/invalid/jars/invalid-1.0.rar | 0 .../legacy-repository/invalid/jars/invalid.jar | 0 .../legacy-repository/invalid/jars/no-extension | 0 .../legacy-repository/javax.sql/jars/jdbc-2.0.jar | 0 .../jars/test-not-updated-1.0.jar | 1 + .../jars/test-updated-1.0.jar | 1 + .../org.apache.maven/jars/some-ejb-1.0-client.jar | 0 .../jars/testing-1.0-20050611.112233-1.jar | 0 .../org.apache.maven/jars/testing-1.0-sources.jar | 0 .../org.apache.maven/jars/testing-1.0.jar | 0 .../org.apache.maven/jars/testing-1.0.tar.gz | 0 .../org.apache.maven/jars/testing-1.0.zip | 0 .../org.apache.maven/jars/testing-UNKNOWN.jar | 0 .../1.0-alpha-1/artifactId-1.0-alpha-1.jar | Bin 0 -> 45568 bytes .../1.0-alpha-1/artifactId-1.0-alpha-1.pom | 25 + .../groupId/artifactId/maven-metadata.xml | 30 + ...shot-artifact-1.0-alpha-1-20050611.202024-1.pom | 19 + .../src/test/resources/log4j.xml | 40 + archiva-common/pom.xml | 96 -- .../maven/archiva/common/ArchivaException.java | 40 - .../builder/AbstractLayoutArtifactBuilder.java | 55 - .../common/artifact/builder/BuilderException.java | 43 - .../builder/DefaultLayoutArtifactBuilder.java | 218 ---- .../artifact/builder/LayoutArtifactBuilder.java | 36 - .../builder/LegacyLayoutArtifactBuilder.java | 303 ----- .../common/artifact/managed/ManagedArtifact.java | 76 -- .../artifact/managed/ManagedArtifactTypes.java | 81 -- .../artifact/managed/ManagedEjbArtifact.java | 49 - .../artifact/managed/ManagedJavaArtifact.java | 62 - .../maven/archiva/common/utils/BaseFile.java | 105 -- .../maven/archiva/common/utils/DateUtil.java | 130 -- .../maven/archiva/common/utils/PathUtil.java | 56 - .../common/AbstractArchivaCommonTestCase.java | 146 --- .../org/apache/maven/archiva/common/AllTests.java | 44 - .../AbstractLayoutArtifactBuilderTestCase.java | 51 - .../archiva/common/artifact/builder/AllTests.java | 44 - .../builder/DefaultLayoutArtifactBuilderTest.java | 206 ---- .../builder/LegacyLayoutArtifactBuilderTest.java | 160 --- .../maven/archiva/common/utils/AllTests.java | 44 - .../maven/archiva/common/utils/BaseFileTest.java | 131 -- .../maven/archiva/common/utils/DateUtilTest.java | 69 -- .../maven/archiva/common/utils/PathUtilTest.java | 40 - archiva-common/src/test/legacy-repository/CVS/Root | 1 - archiva-common/src/test/legacy-repository/KEYS | 0 .../legacy-repository/invalid/foo/invalid-1.0.foo | 0 .../test/legacy-repository/invalid/invalid-1.0.jar | 0 .../invalid/jars/1.0/invalid-1.0.jar | 0 .../legacy-repository/invalid/jars/invalid-1.0.rar | 0 .../legacy-repository/invalid/jars/invalid.jar | 0 .../legacy-repository/invalid/jars/no-extension | 0 .../legacy-repository/javax.sql/jars/jdbc-2.0.jar | 0 .../jars/test-not-updated-1.0.jar | 1 - .../jars/test-updated-1.0.jar | 1 - .../org.apache.maven/jars/some-ejb-1.0-client.jar | 0 .../jars/testing-1.0-20050611.112233-1.jar | 0 .../org.apache.maven/jars/testing-1.0-sources.jar | 0 .../org.apache.maven/jars/testing-1.0.jar | 0 .../org.apache.maven/jars/testing-1.0.tar.gz | 0 .../org.apache.maven/jars/testing-1.0.zip | 0 .../org.apache.maven/jars/testing-UNKNOWN.jar | 0 archiva-common/src/test/repository/CVS/Root | 1 - archiva-common/src/test/repository/KEYS | 1 - .../src/test/repository/invalid/invalid-1.0.jar | 0 .../invalid-1.0-20050611.123456-1.jar | 0 .../invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar | 0 .../invalid/invalid/1.0/invalid-1.0b.jar | 0 .../repository/invalid/invalid/1.0/invalid-2.0.jar | 0 .../test/repository/invalid/invalid/1/invalid-1 | 0 .../src/test/repository/javax/maven-metadata.xml | 26 - .../repository/javax/sql/jdbc/2.0/jdbc-2.0.jar | 0 .../sql/jdbc/2.0/maven-metadata-repository.xml | 25 - .../javax/sql/jdbc/maven-metadata-repository.xml | 30 - .../javax/sql/maven-metadata-repository.xml | 25 - .../repository/org/apache/maven/A/1.0/A-1.0.pom | 28 - .../repository/org/apache/maven/A/1.0/A-1.0.war | 1 - .../repository/org/apache/maven/B/1.0/B-1.0.pom | 28 - .../repository/org/apache/maven/B/2.0/B-2.0.pom | 28 - .../repository/org/apache/maven/C/1.0/C-1.0.pom | 28 - .../repository/org/apache/maven/C/1.0/C-1.0.war | 1 - .../apache/maven/discovery/1.0/discovery-1.0.pom | 28 - .../repository/org/apache/maven/maven-metadata.xml | 23 - .../apache/maven/samplejar/1.0/samplejar-1.0.jar | 1 - .../apache/maven/samplejar/1.0/samplejar-1.0.pom | 29 - .../apache/maven/samplejar/2.0/samplejar-2.0.jar | 1 - .../apache/maven/samplejar/2.0/samplejar-2.0.pom | 29 - .../apache/maven/some-ejb/1.0/maven-metadata.xml | 0 .../maven/some-ejb/1.0/some-ejb-1.0-client.jar | 0 .../test-1.0-20050611.112233-1-javadoc.jar | 0 .../1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar | 0 .../wrong-artifactId-1.0-20050611.112233-1.jar | 0 .../maven/testing/1.0/testing-1.0-sources.jar | 0 .../maven/testing/1.0/testing-1.0-test-sources.jar | 0 .../org/apache/maven/testing/1.0/testing-1.0.jar | 0 .../apache/maven/testing/1.0/testing-1.0.tar.gz | 0 .../org/apache/maven/testing/1.0/testing-1.0.zip | 0 .../test-not-updated/1.0/test-not-updated-1.0.jar | 1 - .../test-not-updated/1.0/test-not-updated-1.0.pom | 29 - .../update/test-not-updated/maven-metadata.xml | 24 - .../update/test-updated/1.0/test-updated-1.0.jar | 1 - .../update/test-updated/1.0/test-updated-1.0.pom | 29 - .../maven/update/test-updated/maven-metadata.xml | 24 - .../testgroup/discovery/1.0/discovery-1.0.pom | 28 - .../testgroup/discovery/1.0/maven-metadata.xml | 25 - .../apache/testgroup/discovery/maven-metadata.xml | 24 - .../consumers/GenericArtifactConsumerTest.xml | 34 - .../common/consumers/GenericModelConsumerTest.xml | 34 - .../GenericRepositoryMetadataConsumerTest.xml | 34 - archiva-configuration/pom.xml | 109 -- .../configuration/ArchivaConfiguration.java | 53 - .../configuration/DefaultArchivaConfiguration.java | 125 -- .../InvalidConfigurationException.java | 49 - .../configuration/MavenProxyPropertyLoader.java | 163 --- .../src/main/mdo/configuration.mdo | 479 -------- ...edRepositoryConfiguration-conversion.properties | 21 - .../archiva/configuration/default-archiva.xml | 219 ---- archiva-configuration/src/test/conf/corrupt.xml | 20 - .../src/test/conf/maven-proxy-complete.conf | 144 --- .../src/test/conf/repository-manager.xml | 238 ---- .../src/test/conf/with-proxied-repos.xml | 44 - .../configuration/ArchivaConfigurationTest.java | 200 --- .../MavenProxyPropertyLoaderTest.java | 96 -- .../configuration/ArchivaConfigurationTest.xml | 182 --- archiva-converter/pom.xml | 83 -- .../maven/archiva/converter/ConversionEvent.java | 128 -- .../archiva/converter/ConversionListener.java | 31 - .../converter/DefaultRepositoryConverter.java | 741 ------------ .../converter/RepositoryConversionException.java | 39 - .../archiva/converter/RepositoryConverter.java | 67 - .../legacy/DefaultLegacyRepositoryConverter.java | 139 --- .../legacy/LegacyConverterArtifactConsumer.java | 105 -- .../legacy/LegacyRepositoryConverter.java | 64 - .../transaction/AbstractTransactionEvent.java | 225 ---- .../converter/transaction/CopyFileEvent.java | 133 -- .../converter/transaction/CreateFileEvent.java | 98 -- .../converter/transaction/FileTransaction.java | 126 -- .../converter/transaction/TransactionEvent.java | 46 - .../DefaultRepositoryConverter.properties | 38 - .../test/expected-files/converted-artifact-one.pom | 6 - .../expected-files/converted-artifact-three.pom | 6 - .../test/expected-files/converted-artifact-two.pom | 6 - .../test/expected-files/converted-v3-snapshot.pom | 28 - .../converted-v3-timestamped-snapshot.pom | 28 - .../test/expected-files/converted-v3-warnings.pom | 28 - .../src/test/expected-files/converted-v3.pom | 28 - .../test/expected-files/maven-foo-plugin-1.0.pom | 7 - .../newversion-artifact-metadata.xml | 10 - .../relocated-v3artifact/1.0.0/maven-metadata.xml | 6 - .../1.0.0/relocated-v3artifact-1.0.0.jar | 1 - .../1.0.0/relocated-v3artifact-1.0.0.pom | 28 - .../relocated-v3artifact/maven-metadata.xml | 9 - .../1.0.0/relocated-v3artifact-1.0.0.pom | 12 - .../test/expected-files/v3-artifact-metadata.xml | 9 - .../v3-snapshot-artifact-metadata.xml | 9 - .../test/expected-files/v3-snapshot-metadata.xml | 6 - .../v3-timestamped-snapshot-metadata.xml | 11 - .../test/expected-files/v3-version-metadata.xml | 6 - .../test/expected-files/v4-artifact-metadata.xml | 9 - .../v4-snapshot-artifact-metadata.xml | 9 - .../test/expected-files/v4-snapshot-metadata.xml | 6 - .../v4-timestamped-snapshot-metadata.xml | 11 - .../test/expected-files/v4-version-metadata.xml | 6 - .../apache/maven/archiva/converter/AllTests.java | 44 - .../archiva/converter/MockConversionListener.java | 163 --- .../archiva/converter/RepositoryConverterTest.java | 1088 ----------------- .../transaction/AbstractFileEventTest.java | 77 -- .../archiva/converter/transaction/AllTests.java | 44 - .../converter/transaction/CopyFileEventTest.java | 180 --- .../converter/transaction/CreateFileEventTest.java | 121 -- .../src/test/resources/log4j.properties | 10 - .../archiva/converter/RepositoryConverterTest.xml | 125 -- .../1.0.0/incorrectArtifactMetadata-1.0.0.jar | 1 - .../1.0.0/incorrectArtifactMetadata-1.0.0.pom | 25 - .../incorrectArtifactMetadata/maven-metadata.xml | 29 - ...ectSnapshotMetadata-1.0.0-20060102.030405-6.jar | 1 - ...ectSnapshotMetadata-1.0.0-20060102.030405-6.pom | 25 - .../1.0.0-SNAPSHOT/maven-metadata.xml | 31 - .../incorrectSnapshotMetadata/maven-metadata.xml | 29 - .../test/jars/artifact-one-1.0.0.jar | 1 - .../test/jars/artifact-three-1.0.0.jar | 1 - .../test/jars/artifact-two-1.0.0.jar | 1 - .../test/jars/dryrun-artifact-1.0.0.jar | 1 - .../test/jars/existing-artifact-1.0.0.jar | 1 - .../test/jars/incorrectMd5Artifact-1.0.0.jar | 1 - .../test/jars/incorrectMd5Artifact-1.0.0.jar.md5 | 1 - .../test/jars/incorrectSha1Artifact-1.0.0.jar | 1 - .../test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 | 1 - .../test/jars/modified-artifact-1.0.0.jar | 1 - .../test/jars/newversion-artifact-1.0.1.jar | 1 - .../test/jars/noPomArtifact-1.0.0.jar | 1 - .../test/jars/relocated-v3artifact-1.0.0.jar | 1 - .../test/jars/rollback-created-artifact-1.0.0.jar | 1 - .../test/jars/unmodified-artifact-1.0.0.jar | 1 - .../test/jars/v3-warnings-artifact-1.0.0.jar | 1 - .../jars/v3artifact-1.0.0-20060105.130101-3.jar | 1 - .../test/jars/v3artifact-1.0.0-SNAPSHOT.jar | 1 - .../test/jars/v3artifact-1.0.0.jar | 1 - .../jars/v4artifact-1.0.0-20060111.120115-1.jar | 1 - .../test/jars/v4artifact-1.0.0-SNAPSHOT.jar | 1 - .../test/jars/v4artifact-1.0.0.jar | 1 - .../test/jars/v4artifact-1.0.0.jar.md5 | 1 - .../test/jars/v4artifact-1.0.0.jar.sha1 | 1 - .../test/plugins/maven-foo-plugin-1.0.jar | 1 - .../test/poms/artifact-one-1.0.0.pom | 6 - .../test/poms/artifact-three-1.0.0.pom | 6 - .../test/poms/artifact-two-1.0.0.pom | 6 - .../test/poms/dryrun-artifact-1.0.0.pom | 22 - .../test/poms/incorrectMd5Artifact-1.0.0.pom | 6 - .../test/poms/incorrectSha1Artifact-1.0.0.pom | 6 - .../test/poms/maven-foo-plugin-1.0.pom | 6 - .../test/poms/modified-artifact-1.0.0.pom | 22 - .../test/poms/newversion-artifact-1.0.1.pom | 22 - .../test/poms/relocated-v3artifact-1.0.0.pom | 27 - .../test/poms/rollback-created-artifact-1.0.0.pom | 39 - .../test/poms/unmodified-artifact-1.0.0.pom | 25 - .../test/poms/v3-warnings-artifact-1.0.0.pom | 48 - .../poms/v3artifact-1.0.0-20060105.130101-3.pom | 40 - .../test/poms/v3artifact-1.0.0-SNAPSHOT.pom | 40 - .../test/poms/v3artifact-1.0.0.pom | 24 - .../poms/v4artifact-1.0.0-20060111.120115-1.pom | 22 - .../test/poms/v4artifact-1.0.0-SNAPSHOT.pom | 22 - .../test/poms/v4artifact-1.0.0.pom | 6 - .../1.0.0/modified-artifact-1.0.0.jar | 1 - .../1.0.0/modified-artifact-1.0.0.pom | 25 - .../1.0.0/newversion-artifact-1.0.0.jar | 1 - .../1.0.0/newversion-artifact-1.0.0.pom | 25 - .../test/newversion-artifact/maven-metadata.xml | 29 - .../1.0.0/unmodified-artifact-1.0.0.jar | 1 - .../1.0.0/unmodified-artifact-1.0.0.pom | 25 - archiva-repository-layer/pom.xml | 97 -- .../archiva/layer/CachedRepositoryQueryLayer.java | 98 -- .../archiva/layer/DefaultRepositoryQueryLayer.java | 105 -- .../layer/DefaultRepositoryQueryLayerFactory.java | 38 - .../maven/archiva/layer/RepositoryQueryLayer.java | 40 - .../layer/RepositoryQueryLayerException.java | 37 - .../archiva/layer/RepositoryQueryLayerFactory.java | 41 - .../maven/archiva/repository/ArchivaArtifact.java | 161 --- .../archiva/repository/ArchivaRepository.java | 135 --- .../archiva/repository/RepositoryException.java | 52 - .../maven/archiva/repository/RepositoryURL.java | 156 --- .../repository/connector/RepositoryConnector.java | 41 - .../archiva/repository/consumer/Consumer.java | 91 -- .../repository/consumer/ConsumerException.java | 52 - .../repository/consumer/ConsumerFactory.java | 70 -- .../content/AbstractArtifactExtensionMapping.java | 60 - .../content/ArtifactExtensionMapping.java | 36 - .../content/DefaultArtifactExtensionMapping.java | 76 -- .../content/LegacyArtifactExtensionMapping.java | 76 -- .../layout/BidirectionalRepositoryLayout.java | 56 - .../DefaultBidirectionalRepositoryLayout.java | 129 -- .../archiva/repository/layout/LayoutException.java | 41 - .../LegacyBidirectionalRepositoryLayout.java | 135 --- .../repository/layout/RepositoryLayoutUtils.java | 219 ---- .../repository/scanner/RepositoryScanner.java | 197 --- .../scanner/RepositoryScannerInstance.java | 199 --- .../archiva/repository/version/VersionUtil.java | 62 - .../main/resources/META-INF/plexus/components.xml | 43 - .../java/org/apache/maven/archiva/AllTests.java | 44 - .../AbstractRepositoryQueryLayerTestCase.java | 116 -- .../org/apache/maven/archiva/layer/AllTests.java | 44 - .../layer/CachedRepositoryQueryLayerTest.java | 56 - .../layer/DefaultRepositoryQueryLayerTest.java | 32 - .../apache/maven/archiva/repository/AllTests.java | 43 - .../archiva/repository/RepositoryURLTest.java | 90 -- ...tractBidirectionalRepositoryLayoutTestCase.java | 100 -- .../DefaultBidirectionalRepositoryLayoutTest.java | 105 -- .../LegacyBidirectionalRepositoryLayoutTest.java | 107 -- .../layout/RepositoryLayoutUtilsTest.java | 206 ---- .../repository/scanner/CentralScannerTiming.java | 132 -- .../repository/scanner/RepositoryScannerTest.java | 70 -- .../archiva/repository/scanner/ScanConsumer.java | 82 -- .../test/repositories/default-repository/CVS/Root | 1 - .../src/test/repositories/default-repository/KEYS | 1 - .../default-repository/invalid/invalid-1.0.jar | 0 .../invalid-1.0-20050611.123456-1.jar | 0 .../invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar | 0 .../invalid/invalid/1.0/invalid-1.0b.jar | 0 .../invalid/invalid/1.0/invalid-2.0.jar | 0 .../default-repository/invalid/invalid/1/invalid-1 | 0 .../default-repository/javax/maven-metadata.xml | 26 - .../javax/sql/jdbc/2.0/jdbc-2.0.jar | 0 .../sql/jdbc/2.0/maven-metadata-repository.xml | 25 - .../javax/sql/jdbc/maven-metadata-repository.xml | 30 - .../javax/sql/maven-metadata-repository.xml | 25 - .../org/apache/maven/A/1.0/A-1.0.pom | 28 - .../org/apache/maven/A/1.0/A-1.0.war | 1 - .../org/apache/maven/B/1.0/B-1.0.pom | 28 - .../org/apache/maven/B/2.0/B-2.0.pom | 28 - .../org/apache/maven/C/1.0/C-1.0.pom | 28 - .../org/apache/maven/C/1.0/C-1.0.war | 1 - .../apache/maven/discovery/1.0/discovery-1.0.pom | 28 - .../org/apache/maven/maven-metadata.xml | 23 - .../apache/maven/samplejar/1.0/samplejar-1.0.jar | 1 - .../apache/maven/samplejar/1.0/samplejar-1.0.pom | 29 - .../apache/maven/samplejar/2.0/samplejar-2.0.jar | 1 - .../apache/maven/samplejar/2.0/samplejar-2.0.pom | 29 - .../apache/maven/some-ejb/1.0/maven-metadata.xml | 0 .../maven/some-ejb/1.0/some-ejb-1.0-client.jar | 0 .../test-1.0-20050611.112233-1-javadoc.jar | 0 .../1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar | 0 .../wrong-artifactId-1.0-20050611.112233-1.jar | 0 .../maven/testing/1.0/testing-1.0-sources.jar | 0 .../maven/testing/1.0/testing-1.0-test-sources.jar | 0 .../org/apache/maven/testing/1.0/testing-1.0.jar | 0 .../apache/maven/testing/1.0/testing-1.0.tar.gz | 0 .../org/apache/maven/testing/1.0/testing-1.0.zip | 0 .../test-not-updated/1.0/test-not-updated-1.0.jar | 1 - .../test-not-updated/1.0/test-not-updated-1.0.pom | 29 - .../update/test-not-updated/maven-metadata.xml | 24 - .../update/test-updated/1.0/test-updated-1.0.jar | 1 - .../update/test-updated/1.0/test-updated-1.0.pom | 29 - .../maven/update/test-updated/maven-metadata.xml | 24 - .../testgroup/discovery/1.0/discovery-1.0.pom | 28 - .../testgroup/discovery/1.0/maven-metadata.xml | 25 - .../apache/testgroup/discovery/maven-metadata.xml | 24 - .../test/repositories/legacy-repository/CVS/Root | 1 - .../src/test/repositories/legacy-repository/KEYS | 0 .../legacy-repository/invalid/foo/invalid-1.0.foo | 0 .../legacy-repository/invalid/invalid-1.0.jar | 0 .../invalid/jars/1.0/invalid-1.0.jar | 0 .../legacy-repository/invalid/jars/invalid-1.0.rar | 0 .../legacy-repository/invalid/jars/invalid.jar | 0 .../legacy-repository/invalid/jars/no-extension | 0 .../legacy-repository/javax.sql/jars/jdbc-2.0.jar | 0 .../jars/test-not-updated-1.0.jar | 1 - .../jars/test-updated-1.0.jar | 1 - .../org.apache.maven/jars/some-ejb-1.0-client.jar | 0 .../jars/testing-1.0-20050611.112233-1.jar | 0 .../org.apache.maven/jars/testing-1.0-sources.jar | 0 .../org.apache.maven/jars/testing-1.0.jar | 0 .../org.apache.maven/jars/testing-1.0.tar.gz | 0 .../org.apache.maven/jars/testing-1.0.zip | 0 .../org.apache.maven/jars/testing-UNKNOWN.jar | 0 .../1.0-alpha-1/artifactId-1.0-alpha-1.jar | Bin 45568 -> 0 bytes .../1.0-alpha-1/artifactId-1.0-alpha-1.pom | 25 - .../groupId/artifactId/maven-metadata.xml | 30 - ...shot-artifact-1.0-alpha-1-20050611.202024-1.pom | 19 - .../src/test/resources/log4j.xml | 40 - 642 files changed, 16003 insertions(+), 14323 deletions(-) create mode 100644 archiva-base/archiva-common/pom.xml create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/ArchivaException.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/BaseFile.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/DateUtil.java create mode 100644 archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/PathUtil.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/AllTests.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java create mode 100644 archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/CVS/Root create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/KEYS create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/invalid/foo/invalid-1.0.foo create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/invalid/invalid-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid-1.0.rar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/no-extension create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip create mode 100644 archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar create mode 100644 archiva-base/archiva-common/src/test/repository/CVS/Root create mode 100644 archiva-base/archiva-common/src/test/repository/KEYS create mode 100644 archiva-base/archiva-common/src/test/repository/invalid/invalid-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar create mode 100644 archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar create mode 100644 archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/invalid/invalid/1/invalid-1 create mode 100644 archiva-base/archiva-common/src/test/repository/javax/maven-metadata.xml create mode 100644 archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml create mode 100644 archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml create mode 100644 archiva-base/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml create mode 100644 archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml create mode 100644 archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml create mode 100644 archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml create mode 100644 archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml create mode 100644 archiva-base/archiva-configuration/pom.xml create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java create mode 100644 archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java create mode 100644 archiva-base/archiva-configuration/src/main/mdo/configuration.mdo create mode 100644 archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties create mode 100644 archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml create mode 100644 archiva-base/archiva-configuration/src/test/conf/corrupt.xml create mode 100644 archiva-base/archiva-configuration/src/test/conf/maven-proxy-complete.conf create mode 100644 archiva-base/archiva-configuration/src/test/conf/repository-manager.xml create mode 100644 archiva-base/archiva-configuration/src/test/conf/with-proxied-repos.xml create mode 100644 archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java create mode 100644 archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java create mode 100644 archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml create mode 100644 archiva-base/archiva-converter/pom.xml create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionEvent.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionListener.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConversionException.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyRepositoryConverter.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/AbstractTransactionEvent.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CopyFileEvent.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CreateFileEvent.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/FileTransaction.java create mode 100644 archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/TransactionEvent.java create mode 100644 archiva-base/archiva-converter/src/main/resources/org/apache/maven/archiva/converter/DefaultRepositoryConverter.properties create mode 100644 archiva-base/archiva-converter/src/test/expected-files/converted-artifact-one.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/converted-artifact-three.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/converted-artifact-two.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/converted-v3-snapshot.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/converted-v3-timestamped-snapshot.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/converted-v3-warnings.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/converted-v3.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/maven-foo-plugin-1.0.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/newversion-artifact-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/maven-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/maven-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v3-artifact-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v3-snapshot-artifact-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v3-snapshot-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v3-timestamped-snapshot-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v3-version-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v4-artifact-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v4-snapshot-artifact-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v4-snapshot-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v4-timestamped-snapshot-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/expected-files/v4-version-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/AllTests.java create mode 100644 archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/MockConversionListener.java create mode 100644 archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java create mode 100644 archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AbstractFileEventTest.java create mode 100644 archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AllTests.java create mode 100644 archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CopyFileEventTest.java create mode 100644 archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CreateFileEventTest.java create mode 100644 archiva-base/archiva-converter/src/test/resources/log4j.properties create mode 100644 archiva-base/archiva-converter/src/test/resources/org/apache/maven/archiva/converter/RepositoryConverterTest.xml create mode 100644 archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/maven-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.jar create mode 100644 archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.pom create mode 100644 archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-one-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-three-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-two-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/dryrun-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/existing-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar.md5 create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/modified-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/newversion-artifact-1.0.1.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/noPomArtifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/relocated-v3artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/rollback-created-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/unmodified-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v3-warnings-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-20060105.130101-3.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-SNAPSHOT.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-20060111.120115-1.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-SNAPSHOT.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.md5 create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.sha1 create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-one-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-three-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-two-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/dryrun-artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/incorrectMd5Artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/incorrectSha1Artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/maven-foo-plugin-1.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/modified-artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/relocated-v3artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/rollback-created-artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/unmodified-artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-20060105.130101-3.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-SNAPSHOT.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-20060111.120115-1.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-SNAPSHOT.pom create mode 100644 archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom create mode 100644 archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/maven-metadata.xml create mode 100644 archiva-base/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.jar create mode 100644 archiva-base/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.pom create mode 100755 archiva-base/archiva-model/pom.xml create mode 100644 archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryContentKey.java create mode 100644 archiva-base/archiva-model/src/main/mdo/archiva-base.xml create mode 100644 archiva-base/archiva-model/src/test/resources/log4j.xml create mode 100644 archiva-base/archiva-repository-layer/pom.xml create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayer.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerFactory.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayer.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerException.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerFactory.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaArtifact.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaRepository.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryException.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryURL.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/Consumer.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerFactory.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractArtifactExtensionMapping.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultArtifactExtensionMapping.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyArtifactExtensionMapping.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/BidirectionalRepositoryLayout.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayout.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LayoutException.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayout.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtils.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java create mode 100644 archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/version/VersionUtil.java create mode 100644 archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AbstractRepositoryQueryLayerTestCase.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerTest.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/RepositoryURLTest.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/AbstractBidirectionalRepositoryLayoutTestCase.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayoutTest.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtilsTest.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/CentralScannerTiming.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java create mode 100644 archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/ScanConsumer.java create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/CVS/Root create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/KEYS create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-1.0b.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-2.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1/invalid-1 create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/maven-metadata.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/discovery/1.0/discovery-1.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.zip create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/maven-metadata.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/maven-metadata.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/CVS/Root create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/KEYS create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/no-extension create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.jar create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/maven-metadata.xml create mode 100644 archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/snapshot-artifact/1.0-alpha-1-SNAPSHOT/snapshot-artifact-1.0-alpha-1-20050611.202024-1.pom create mode 100644 archiva-base/archiva-repository-layer/src/test/resources/log4j.xml delete mode 100644 archiva-common/pom.xml delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/ArchivaException.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/utils/BaseFile.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/utils/DateUtil.java delete mode 100644 archiva-common/src/main/java/org/apache/maven/archiva/common/utils/PathUtil.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/utils/AllTests.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java delete mode 100644 archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java delete mode 100644 archiva-common/src/test/legacy-repository/CVS/Root delete mode 100644 archiva-common/src/test/legacy-repository/KEYS delete mode 100644 archiva-common/src/test/legacy-repository/invalid/foo/invalid-1.0.foo delete mode 100644 archiva-common/src/test/legacy-repository/invalid/invalid-1.0.jar delete mode 100644 archiva-common/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar delete mode 100644 archiva-common/src/test/legacy-repository/invalid/jars/invalid-1.0.rar delete mode 100644 archiva-common/src/test/legacy-repository/invalid/jars/invalid.jar delete mode 100644 archiva-common/src/test/legacy-repository/invalid/jars/no-extension delete mode 100644 archiva-common/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip delete mode 100644 archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar delete mode 100644 archiva-common/src/test/repository/CVS/Root delete mode 100644 archiva-common/src/test/repository/KEYS delete mode 100644 archiva-common/src/test/repository/invalid/invalid-1.0.jar delete mode 100644 archiva-common/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar delete mode 100644 archiva-common/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar delete mode 100644 archiva-common/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar delete mode 100644 archiva-common/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar delete mode 100644 archiva-common/src/test/repository/invalid/invalid/1/invalid-1 delete mode 100644 archiva-common/src/test/repository/javax/maven-metadata.xml delete mode 100644 archiva-common/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar delete mode 100644 archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml delete mode 100644 archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml delete mode 100644 archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml delete mode 100644 archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war delete mode 100644 archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war delete mode 100644 archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml delete mode 100644 archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml delete mode 100644 archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz delete mode 100644 archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip delete mode 100644 archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml delete mode 100644 archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar delete mode 100644 archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml delete mode 100644 archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom delete mode 100644 archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml delete mode 100644 archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml delete mode 100644 archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml delete mode 100644 archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml delete mode 100644 archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml delete mode 100644 archiva-configuration/pom.xml delete mode 100644 archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java delete mode 100644 archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java delete mode 100644 archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java delete mode 100644 archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java delete mode 100644 archiva-configuration/src/main/mdo/configuration.mdo delete mode 100644 archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties delete mode 100644 archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml delete mode 100644 archiva-configuration/src/test/conf/corrupt.xml delete mode 100644 archiva-configuration/src/test/conf/maven-proxy-complete.conf delete mode 100644 archiva-configuration/src/test/conf/repository-manager.xml delete mode 100644 archiva-configuration/src/test/conf/with-proxied-repos.xml delete mode 100644 archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java delete mode 100644 archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java delete mode 100644 archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml delete mode 100644 archiva-converter/pom.xml delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionEvent.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionListener.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConversionException.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyRepositoryConverter.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/AbstractTransactionEvent.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CopyFileEvent.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CreateFileEvent.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/FileTransaction.java delete mode 100644 archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/TransactionEvent.java delete mode 100644 archiva-converter/src/main/resources/org/apache/maven/archiva/converter/DefaultRepositoryConverter.properties delete mode 100644 archiva-converter/src/test/expected-files/converted-artifact-one.pom delete mode 100644 archiva-converter/src/test/expected-files/converted-artifact-three.pom delete mode 100644 archiva-converter/src/test/expected-files/converted-artifact-two.pom delete mode 100644 archiva-converter/src/test/expected-files/converted-v3-snapshot.pom delete mode 100644 archiva-converter/src/test/expected-files/converted-v3-timestamped-snapshot.pom delete mode 100644 archiva-converter/src/test/expected-files/converted-v3-warnings.pom delete mode 100644 archiva-converter/src/test/expected-files/converted-v3.pom delete mode 100644 archiva-converter/src/test/expected-files/maven-foo-plugin-1.0.pom delete mode 100644 archiva-converter/src/test/expected-files/newversion-artifact-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/maven-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/maven-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/expected-files/v3-artifact-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v3-snapshot-artifact-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v3-snapshot-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v3-timestamped-snapshot-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v3-version-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v4-artifact-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v4-snapshot-artifact-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v4-snapshot-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v4-timestamped-snapshot-metadata.xml delete mode 100644 archiva-converter/src/test/expected-files/v4-version-metadata.xml delete mode 100644 archiva-converter/src/test/java/org/apache/maven/archiva/converter/AllTests.java delete mode 100644 archiva-converter/src/test/java/org/apache/maven/archiva/converter/MockConversionListener.java delete mode 100644 archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java delete mode 100644 archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AbstractFileEventTest.java delete mode 100644 archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AllTests.java delete mode 100644 archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CopyFileEventTest.java delete mode 100644 archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CreateFileEventTest.java delete mode 100644 archiva-converter/src/test/resources/log4j.properties delete mode 100644 archiva-converter/src/test/resources/org/apache/maven/archiva/converter/RepositoryConverterTest.xml delete mode 100644 archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/maven-metadata.xml delete mode 100644 archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.jar delete mode 100644 archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.pom delete mode 100644 archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml delete mode 100644 archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml delete mode 100644 archiva-converter/src/test/source-repository/test/jars/artifact-one-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/artifact-three-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/artifact-two-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/dryrun-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/existing-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar.md5 delete mode 100644 archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 delete mode 100644 archiva-converter/src/test/source-repository/test/jars/modified-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/newversion-artifact-1.0.1.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/noPomArtifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/relocated-v3artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/rollback-created-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/unmodified-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v3-warnings-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-20060105.130101-3.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-SNAPSHOT.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-20060111.120115-1.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-SNAPSHOT.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.md5 delete mode 100644 archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.sha1 delete mode 100644 archiva-converter/src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar delete mode 100644 archiva-converter/src/test/source-repository/test/poms/artifact-one-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/artifact-three-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/artifact-two-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/dryrun-artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/incorrectMd5Artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/incorrectSha1Artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/maven-foo-plugin-1.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/modified-artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/relocated-v3artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/rollback-created-artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/unmodified-artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-20060105.130101-3.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-SNAPSHOT.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-20060111.120115-1.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-SNAPSHOT.pom delete mode 100644 archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom delete mode 100644 archiva-converter/src/test/target-repository/test/newversion-artifact/maven-metadata.xml delete mode 100644 archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.jar delete mode 100644 archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.pom delete mode 100644 archiva-repository-layer/pom.xml delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayer.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerFactory.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayer.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerException.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerFactory.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaArtifact.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaRepository.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryException.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryURL.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/Consumer.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerFactory.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractArtifactExtensionMapping.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultArtifactExtensionMapping.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyArtifactExtensionMapping.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/BidirectionalRepositoryLayout.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayout.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LayoutException.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayout.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtils.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java delete mode 100644 archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/version/VersionUtil.java delete mode 100644 archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AbstractRepositoryQueryLayerTestCase.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerTest.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/RepositoryURLTest.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/AbstractBidirectionalRepositoryLayoutTestCase.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayoutTest.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtilsTest.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/CentralScannerTiming.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java delete mode 100644 archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/ScanConsumer.java delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/CVS/Root delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/KEYS delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-1.0b.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-2.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1/invalid-1 delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/javax/maven-metadata.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/discovery/1.0/discovery-1.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.zip delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/maven-metadata.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/maven-metadata.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml delete mode 100644 archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/CVS/Root delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/KEYS delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/no-extension delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip delete mode 100644 archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar delete mode 100644 archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.jar delete mode 100644 archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.pom delete mode 100644 archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/maven-metadata.xml delete mode 100644 archiva-repository-layer/src/test/repositories/simple-repository/groupId/snapshot-artifact/1.0-alpha-1-SNAPSHOT/snapshot-artifact-1.0-alpha-1-20050611.202024-1.pom delete mode 100644 archiva-repository-layer/src/test/resources/log4j.xml diff --git a/archiva-base/archiva-common/pom.xml b/archiva-base/archiva-common/pom.xml new file mode 100644 index 000000000..47d3c6223 --- /dev/null +++ b/archiva-base/archiva-common/pom.xml @@ -0,0 +1,96 @@ + + + + + + archiva + org.apache.maven.archiva + 1.0-SNAPSHOT + + 4.0.0 + archiva-common + Archiva Common + + + + org.codehaus.plexus + plexus-component-api + + + org.apache.maven + maven-artifact-manager + + + org.apache.maven + maven-project + + + commons-lang + commons-lang + + + org.codehaus.plexus + plexus-container-default + + + + + + + org.codehaus.plexus + plexus-maven-plugin + + + + + diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/ArchivaException.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/ArchivaException.java new file mode 100644 index 000000000..c807d70c4 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/ArchivaException.java @@ -0,0 +1,40 @@ +package org.apache.maven.archiva.common; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * ArchivaException + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ArchivaException + extends Exception +{ + public ArchivaException( String message, Throwable cause ) + { + super( message, cause ); + } + + public ArchivaException( String message ) + { + super( message ); + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java new file mode 100644 index 000000000..b77826ad1 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java @@ -0,0 +1,55 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.factory.ArtifactFactory; + +/** + * AbstractLayoutArtifactBuilder + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public abstract class AbstractLayoutArtifactBuilder + implements LayoutArtifactBuilder +{ + /** + * @plexus.requirement + */ + protected ArtifactFactory artifactFactory; + + /** + * Constructor used by plexus + */ + public AbstractLayoutArtifactBuilder() + { + + } + + /** + * Constructor used by manual process. + * + * @param artifactFactory the artifact factory to use. + */ + public AbstractLayoutArtifactBuilder( ArtifactFactory artifactFactory ) + { + this.artifactFactory = artifactFactory; + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java new file mode 100644 index 000000000..0845dc750 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java @@ -0,0 +1,43 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.common.ArchivaException; + +/** + * BuilderException - used to indicate a problem during the building of an object from file. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class BuilderException + extends ArchivaException +{ + + public BuilderException( String message, Throwable cause ) + { + super( message, cause ); + } + + public BuilderException( String message ) + { + super( message ); + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java new file mode 100644 index 000000000..bfee01508 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java @@ -0,0 +1,218 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.codehaus.plexus.util.StringUtils; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.StringTokenizer; + +/** + * DefaultLayoutArtifactBuilder - artifact builder for default layout repositories. + * + * @author Brett Porter + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="org.apache.maven.archiva.common.artifact.builder.LayoutArtifactBuilder" + * role-hint="default" + */ +public class DefaultLayoutArtifactBuilder + extends AbstractLayoutArtifactBuilder + implements LayoutArtifactBuilder +{ + public DefaultLayoutArtifactBuilder() + { + super(); + } + + public DefaultLayoutArtifactBuilder( ArtifactFactory artifactFactory ) + { + super( artifactFactory ); + } + + public Artifact build( String pathToArtifact ) + throws BuilderException + { + if( artifactFactory == null ) + { + throw new IllegalStateException( "Unable to build artifact with a null artifactFactory." ); + } + + List pathParts = new ArrayList(); + StringTokenizer st = new StringTokenizer( pathToArtifact, "/\\" ); + while ( st.hasMoreTokens() ) + { + pathParts.add( st.nextToken() ); + } + + Collections.reverse( pathParts ); + + Artifact artifact; + if ( pathParts.size() >= 4 ) + { + // maven 2.x path + + // the actual artifact filename. + String filename = (String) pathParts.remove( 0 ); + + // the next one is the version. + String version = (String) pathParts.remove( 0 ); + + // the next one is the artifactId. + String artifactId = (String) pathParts.remove( 0 ); + + // the remaining are the groupId. + Collections.reverse( pathParts ); + String groupId = StringUtils.join( pathParts.iterator(), "." ); + + String remainingFilename = filename; + if ( remainingFilename.startsWith( artifactId + "-" ) ) + { + remainingFilename = remainingFilename.substring( artifactId.length() + 1 ); + + String classifier = null; + + // TODO: use artifact handler, share with legacy discoverer + String type; + if ( remainingFilename.endsWith( ".tar.gz" ) ) + { + type = "distribution-tgz"; + remainingFilename = remainingFilename + .substring( 0, remainingFilename.length() - ".tar.gz".length() ); + } + else if ( remainingFilename.endsWith( ".zip" ) ) + { + type = "distribution-zip"; + remainingFilename = remainingFilename.substring( 0, remainingFilename.length() - ".zip".length() ); + } + else if ( remainingFilename.endsWith( "-test-sources.jar" ) ) + { + type = "java-source"; + classifier = "test-sources"; + remainingFilename = remainingFilename.substring( 0, remainingFilename.length() + - "-test-sources.jar".length() ); + } + else if ( remainingFilename.endsWith( "-sources.jar" ) ) + { + type = "java-source"; + classifier = "sources"; + remainingFilename = remainingFilename.substring( 0, remainingFilename.length() + - "-sources.jar".length() ); + } + else + { + int index = remainingFilename.lastIndexOf( "." ); + if ( index >= 0 ) + { + type = remainingFilename.substring( index + 1 ); + remainingFilename = remainingFilename.substring( 0, index ); + } + else + { + throw new BuilderException( "Path filename does not have an extension." ); + } + } + + Artifact result; + if ( classifier == null ) + { + result = artifactFactory + .createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, type ); + } + else + { + result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, + classifier ); + } + + if ( result.isSnapshot() ) + { + // version is *-SNAPSHOT, filename is *-yyyyMMdd.hhmmss-b + int classifierIndex = remainingFilename.indexOf( '-', version.length() + 8 ); + if ( classifierIndex >= 0 ) + { + classifier = remainingFilename.substring( classifierIndex + 1 ); + remainingFilename = remainingFilename.substring( 0, classifierIndex ); + result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, remainingFilename, + type, classifier ); + } + else + { + result = artifactFactory.createArtifact( groupId, artifactId, remainingFilename, + Artifact.SCOPE_RUNTIME, type ); + } + + // poor encapsulation requires we do this to populate base version + if ( !result.isSnapshot() ) + { + throw new BuilderException( "Failed to create a snapshot artifact: " + result ); + } + else if ( !result.getBaseVersion().equals( version ) ) + { + throw new BuilderException( + "Built snapshot artifact base version does not match path version: " + + result.getBaseVersion() + "; should have been version: " + + version ); + } + else + { + artifact = result; + } + } + else if ( !remainingFilename.startsWith( version ) ) + { + throw new BuilderException( "Built artifact version does not match path version" ); + } + else if ( !remainingFilename.equals( version ) ) + { + if ( remainingFilename.charAt( version.length() ) == '-' ) + { + classifier = remainingFilename.substring( version.length() + 1 ); + artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, + classifier ); + } + else + { + throw new BuilderException( "Path version does not corresspond to an artifact version" ); + } + } + else + { + artifact = result; + } + } + else + { + throw new BuilderException( "Path filename does not correspond to an artifact." ); + } + } + else + { + throw new BuilderException( "Path is too short to build an artifact from." ); + } + + return artifact; + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java new file mode 100644 index 000000000..494a4a7c1 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java @@ -0,0 +1,36 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; + +/** + * LayoutArtifactBuilder + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @todo this concept should really exist inside of the {@link ArtifactRepositoryLayout} object in maven itself. + */ +public interface LayoutArtifactBuilder +{ + public Artifact build( String pathToArtifact ) throws BuilderException; +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java new file mode 100644 index 000000000..e3436e966 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java @@ -0,0 +1,303 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; + +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.StringTokenizer; + +/** + * LegacyLayoutArtifactBuilder + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="org.apache.maven.archiva.common.artifact.builder.LayoutArtifactBuilder" + * role-hint="legacy" + */ +public class LegacyLayoutArtifactBuilder + extends AbstractLayoutArtifactBuilder + implements LayoutArtifactBuilder +{ + public LegacyLayoutArtifactBuilder() + { + super(); + } + + public LegacyLayoutArtifactBuilder( ArtifactFactory artifactFactory ) + { + super( artifactFactory ); + } + + public Artifact build( String pathToArtifact ) + throws BuilderException + { + if( artifactFactory == null ) + { + throw new IllegalStateException( "Unable to build legacy artifact with a null artifactFactory." ); + } + + StringTokenizer tokens = new StringTokenizer( pathToArtifact, "/\\" ); + + Artifact result; + + int numberOfTokens = tokens.countTokens(); + + if ( numberOfTokens == 3 ) + { + String groupId = tokens.nextToken(); + + String type = tokens.nextToken(); + + if ( type.endsWith( "s" ) ) + { + type = type.substring( 0, type.length() - 1 ); + + // contains artifactId, version, classifier, and extension. + String avceGlob = tokens.nextToken(); + + //noinspection CollectionDeclaredAsConcreteClass + LinkedList avceTokenList = new LinkedList(); + + StringTokenizer avceTokenizer = new StringTokenizer( avceGlob, "-" ); + while ( avceTokenizer.hasMoreTokens() ) + { + avceTokenList.addLast( avceTokenizer.nextToken() ); + } + + String lastAvceToken = (String) avceTokenList.removeLast(); + + // TODO: share with other discoverer, use artifact handlers instead + if ( lastAvceToken.endsWith( ".tar.gz" ) ) + { + type = "distribution-tgz"; + + lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".tar.gz".length() ); + + avceTokenList.addLast( lastAvceToken ); + } + else if ( lastAvceToken.endsWith( "sources.jar" ) ) + { + type = "java-source"; + + lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() ); + + avceTokenList.addLast( lastAvceToken ); + } + else if ( lastAvceToken.endsWith( "javadoc.jar" ) ) + { + type = "javadoc.jar"; + + lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() ); + + avceTokenList.addLast( lastAvceToken ); + } + else if ( lastAvceToken.endsWith( ".zip" ) ) + { + type = "distribution-zip"; + + lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".zip".length() ); + + avceTokenList.addLast( lastAvceToken ); + } + else + { + int extPos = lastAvceToken.lastIndexOf( '.' ); + + if ( extPos > 0 ) + { + String ext = lastAvceToken.substring( extPos + 1 ); + if ( type.equals( ext ) || "plugin".equals( type ) ) + { + lastAvceToken = lastAvceToken.substring( 0, extPos ); + + avceTokenList.addLast( lastAvceToken ); + } + else + { + throw new BuilderException( "Path type does not match the extension" ); + } + } + else + { + throw new BuilderException( "Path filename does not have an extension" ); + } + } + + // let's discover the version, and whatever's leftover will be either + // a classifier, or part of the artifactId, depending on position. + // Since version is at the end, we have to move in from the back. + Collections.reverse( avceTokenList ); + + // TODO: this is obscene - surely a better way? + String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" + + "([0-9][_.0-9a-zA-Z]*)|" + "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" + + "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" + + "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" + + "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" + + "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" + + "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + "[Ff][Ii][Nn][Aa][Ll]|" + "([AaBb][_.0-9]*)"; + + StringBuffer classifierBuffer = new StringBuffer(); + StringBuffer versionBuffer = new StringBuffer(); + + boolean firstVersionTokenEncountered = false; + boolean firstToken = true; + + int tokensIterated = 0; + for ( Iterator it = avceTokenList.iterator(); it.hasNext(); ) + { + String token = (String) it.next(); + + boolean tokenIsVersionPart = token.matches( validVersionParts ); + + StringBuffer bufferToUpdate; + + // NOTE: logic in code is reversed, since we're peeling off the back + // Any token after the last versionPart will be in the classifier. + // Any token UP TO first non-versionPart is part of the version. + if ( !tokenIsVersionPart ) + { + if ( firstVersionTokenEncountered ) + { + //noinspection BreakStatement + break; + } + else + { + bufferToUpdate = classifierBuffer; + } + } + else + { + firstVersionTokenEncountered = true; + + bufferToUpdate = versionBuffer; + } + + if ( firstToken ) + { + firstToken = false; + } + else + { + bufferToUpdate.insert( 0, '-' ); + } + + bufferToUpdate.insert( 0, token ); + + tokensIterated++; + } + + // Now, restore the proper ordering so we can build the artifactId. + Collections.reverse( avceTokenList ); + + // if we didn't find a version, then punt. Use the last token + // as the version, and set the classifier empty. + if ( versionBuffer.length() < 1 ) + { + if ( avceTokenList.size() > 1 ) + { + int lastIdx = avceTokenList.size() - 1; + + versionBuffer.append( avceTokenList.get( lastIdx ) ); + avceTokenList.remove( lastIdx ); + } + + classifierBuffer.setLength( 0 ); + } + else + { + // if everything is kosher, then pop off all the classifier and + // version tokens, leaving the naked artifact id in the list. + avceTokenList = new LinkedList( avceTokenList.subList( 0, avceTokenList.size() - tokensIterated ) ); + } + + StringBuffer artifactIdBuffer = new StringBuffer(); + + firstToken = true; + for ( Iterator it = avceTokenList.iterator(); it.hasNext(); ) + { + String token = (String) it.next(); + + if ( firstToken ) + { + firstToken = false; + } + else + { + artifactIdBuffer.append( '-' ); + } + + artifactIdBuffer.append( token ); + } + + String artifactId = artifactIdBuffer.toString(); + + if ( artifactId.length() > 0 ) + { + int lastVersionCharIdx = versionBuffer.length() - 1; + if ( lastVersionCharIdx > -1 && versionBuffer.charAt( lastVersionCharIdx ) == '-' ) + { + versionBuffer.setLength( lastVersionCharIdx ); + } + + String version = versionBuffer.toString(); + + if ( version.length() > 0 ) + { + if ( classifierBuffer.length() > 0 ) + { + result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, + classifierBuffer.toString() ); + } + else + { + result = artifactFactory.createArtifact( groupId, artifactId, version, + Artifact.SCOPE_RUNTIME, type ); + } + } + else + { + throw new BuilderException( "Path filename version is empty" ); + } + } + else + { + throw new BuilderException( "Path filename artifactId is empty" ); + } + } + else + { + throw new BuilderException( "Path artifact type does not corresspond to an artifact type" ); + } + } + else + { + throw new BuilderException( "Path does not match a legacy repository path for an artifact" ); + } + + return result; + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java new file mode 100644 index 000000000..8e3c67838 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java @@ -0,0 +1,76 @@ +package org.apache.maven.archiva.common.artifact.managed; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; + +import java.util.HashMap; +import java.util.Map; + +/** + * ManagedArtifact + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ManagedArtifact +{ + private String repositoryId; + + private Artifact artifact; + + private String path; + + protected Map attached; + + public ManagedArtifact( String repoId, Artifact artifact, String path ) + { + super(); + this.repositoryId = repoId; + this.artifact = artifact; + this.path = path; + this.attached = new HashMap(); + } + + public Artifact getArtifact() + { + return artifact; + } + + public String getPath() + { + return path; + } + + public String getRepositoryId() + { + return repositoryId; + } + + public Map getAttached() + { + return attached; + } + + public void setAttached( Map attached ) + { + this.attached = attached; + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java new file mode 100644 index 000000000..b653d160a --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java @@ -0,0 +1,81 @@ +package org.apache.maven.archiva.common.artifact.managed; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * ManagedArtifactTypes - provides place to test an unknown artifact type. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ManagedArtifactTypes +{ + public static final int GENERIC = 0; + + public static final int JAVA = 1; + + public static final int EJB = 2; + + private static List javaArtifacts; + + private static List ejbArtifacts; + + static + { + javaArtifacts = new ArrayList(); + javaArtifacts.add( "jar" ); + javaArtifacts.add( "war" ); + javaArtifacts.add( "sar" ); + javaArtifacts.add( "rar" ); + javaArtifacts.add( "ear" ); + + ejbArtifacts = new ArrayList(); + ejbArtifacts.add( "ejb" ); + ejbArtifacts.add( "ejb-client" ); + } + + public static int whichType( String type ) + { + if ( StringUtils.isBlank( type ) ) + { + // TODO: is an empty type even possible? + return GENERIC; + } + + type = type.toLowerCase(); + + if ( ejbArtifacts.contains( type ) ) + { + return EJB; + } + + if ( javaArtifacts.contains( type ) ) + { + return JAVA; + } + + return GENERIC; + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java new file mode 100644 index 000000000..1759df2db --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java @@ -0,0 +1,49 @@ +package org.apache.maven.archiva.common.artifact.managed; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; + +/** + * ManagedEjbArtifact - adds the ability to reference the ejb-client jar too. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ManagedEjbArtifact + extends ManagedJavaArtifact +{ + public static final String CLIENT = "client"; + + public ManagedEjbArtifact( String repoId, Artifact artifact, String path ) + { + super( repoId, artifact, path ); + } + + public String getClientPath() + { + return (String) super.attached.get( CLIENT ); + } + + public void setClientPath( String clientPath ) + { + super.attached.put( CLIENT, clientPath ); + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java new file mode 100644 index 000000000..203234b06 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java @@ -0,0 +1,62 @@ +package org.apache.maven.archiva.common.artifact.managed; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; + +/** + * ManagedJavaArtifact - a ManagedArtifact with optional javadoc and source + * reference jars. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ManagedJavaArtifact + extends ManagedArtifact +{ + public static final String JAVADOC = "javadoc"; + + public static final String SOURCES = "sources"; + + public ManagedJavaArtifact( String repoId, Artifact artifact, String path ) + { + super( repoId, artifact, path ); + } + + public String getJavadocPath() + { + return (String) super.attached.get( JAVADOC ); + } + + public void setJavadocPath( String javadocPath ) + { + super.attached.put( JAVADOC, javadocPath ); + } + + public String getSourcesPath() + { + return (String) super.attached.get( SOURCES ); + } + + public void setSourcesPath( String sourcesPath ) + { + super.attached.put( SOURCES, sourcesPath ); + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/BaseFile.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/BaseFile.java new file mode 100644 index 000000000..a4b83db7e --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/BaseFile.java @@ -0,0 +1,105 @@ +package org.apache.maven.archiva.common.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.net.URI; + +/** + * BaseFile - convenient File object that tracks the Base Directory and can provide relative path values + * for the file object based on that Base Directory value. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class BaseFile + extends File +{ + private File baseDir; + + public BaseFile( File pathFile ) + { + this( pathFile.getAbsolutePath() ); + } + + public BaseFile( File repoDir, File pathFile ) + { + this( repoDir, PathUtil.getRelative( repoDir.getAbsolutePath(), pathFile ) ); + } + + public BaseFile( File parent, String child ) + { + super( parent, child ); + this.baseDir = parent; + } + + public BaseFile( String pathname ) + { + super( pathname ); + + // Calculate the top level directory. + + File parent = this; + while ( parent.getParentFile() != null ) + { + parent = parent.getParentFile(); + } + + this.baseDir = parent; + } + + public BaseFile( String repoDir, File pathFile ) + { + this( new File( repoDir ), pathFile ); + } + + public BaseFile( String parent, String child ) + { + super( parent, child ); + this.baseDir = new File( parent ); + } + + public BaseFile( URI uri ) + { + super( uri ); // only to satisfy java compiler. + throw new IllegalStateException( "The " + BaseFile.class.getName() + + " object does not support URI construction." ); + } + + public File getBaseDir() + { + return baseDir; + } + + public String getRelativePath() + { + return PathUtil.getRelative( this.baseDir.getAbsolutePath(), this ); + } + + public void setBaseDir( File baseDir ) + { + this.baseDir = baseDir; + } + + public void setBaseDir( String repoDir ) + { + setBaseDir( new File( repoDir ) ); + } +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/DateUtil.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/DateUtil.java new file mode 100644 index 000000000..212aece61 --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/DateUtil.java @@ -0,0 +1,130 @@ +package org.apache.maven.archiva.common.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * DateUtil - some (not-so) common date utility methods. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class DateUtil +{ + public static String getDuration( long duration ) + { + return getDuration( new Date( 0 ), new Date( duration ) ); + } + + public static String getDuration( long ms1, long ms2 ) + { + return getDuration( new Date( ms1 ), new Date( ms2 ) ); + } + + public static String getDuration( Date d1, Date d2 ) + { + Calendar cal1 = new GregorianCalendar(); + cal1.setTime( d1 ); + + Calendar cal2 = new GregorianCalendar(); + cal2.setTime( d2 ); + + return getDuration( cal1, cal2 ); + } + + public static String getDuration( Calendar cal1, Calendar cal2 ) + { + int year1 = cal1.get( Calendar.YEAR ); + int day1 = cal1.get( Calendar.DAY_OF_YEAR ); + int hour1 = cal1.get( Calendar.HOUR_OF_DAY ); + int min1 = cal1.get( Calendar.MINUTE ); + int sec1 = cal1.get( Calendar.SECOND ); + int ms1 = cal1.get( Calendar.MILLISECOND ); + + int year2 = cal2.get( Calendar.YEAR ); + int day2 = cal2.get( Calendar.DAY_OF_YEAR ); + int hour2 = cal2.get( Calendar.HOUR_OF_DAY ); + int min2 = cal2.get( Calendar.MINUTE ); + int sec2 = cal2.get( Calendar.SECOND ); + int ms2 = cal2.get( Calendar.MILLISECOND ); + + int leftDays = ( day1 - day2 ) + ( year1 - year2 ) * 365; + int leftHours = hour2 - hour1; + int leftMins = min2 - min1; + int leftSeconds = sec2 - sec1; + int leftMilliSeconds = ms2 - ms1; + + if ( leftMilliSeconds < 0 ) + { + leftMilliSeconds += 1000; + --leftSeconds; + } + + if ( leftSeconds < 0 ) + { + leftSeconds += 60; + --leftMins; + } + + if ( leftMins < 0 ) + { + leftMins += 60; + --leftHours; + } + + if ( leftHours < 0 ) + { + leftHours += 24; + --leftDays; + } + + StringBuffer interval = new StringBuffer(); + + appendInterval( interval, leftDays, "Day" ); + appendInterval( interval, leftHours, "Hour" ); + appendInterval( interval, leftMins, "Minute" ); + appendInterval( interval, leftSeconds, "Second" ); + appendInterval( interval, leftMilliSeconds, "Millisecond" ); + + return interval.toString(); + } + + private static void appendInterval( StringBuffer interval, int count, String type ) + { + if ( count > 0 ) + { + if ( interval.length() > 0 ) + { + interval.append( " " ); + } + + interval.append( count ); + interval.append( " " ).append( type ); + if ( count > 1 ) + { + interval.append( "s" ); + } + } + } + +} diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/PathUtil.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/PathUtil.java new file mode 100644 index 000000000..25df4254a --- /dev/null +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/PathUtil.java @@ -0,0 +1,56 @@ +package org.apache.maven.archiva.common.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +/** + * PathUtil - simple utility methods for path manipulation. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class PathUtil +{ + public static String getRelative( String basedir, File file ) + { + return getRelative( basedir, file.getAbsolutePath() ); + } + + public static String getRelative( String basedir, String child ) + { + if ( child.startsWith( basedir ) ) + { + // simple solution. + return child.substring( basedir.length() + 1 ); + } + + String absoluteBasedir = new File( basedir ).getAbsolutePath(); + if ( child.startsWith( absoluteBasedir ) ) + { + // resolved basedir solution. + return child.substring( absoluteBasedir.length() + 1 ); + } + + // File is not within basedir. + throw new IllegalStateException( "Unable to obtain relative path of file " + child + + ", it is not within basedir " + basedir + "." ); + } +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java new file mode 100644 index 000000000..4ee9785d0 --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java @@ -0,0 +1,146 @@ +package org.apache.maven.archiva.common; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.codehaus.plexus.PlexusTestCase; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * AbstractArchivaCommonTestCase + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public abstract class AbstractArchivaCommonTestCase + extends PlexusTestCase +{ + protected ArtifactRepository createRepository( File basedir, String layout ) + throws Exception + { + ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); + + ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, layout ); + + return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, repoLayout, null, null ); + } + + public List getLegacyLayoutArtifactPaths() + { + List files = new ArrayList(); + + files.add( "invalid/jars/1.0/invalid-1.0.jar" ); + files.add( "invalid/jars/invalid-1.0.rar" ); + files.add( "invalid/jars/invalid.jar" ); + files.add( "invalid/invalid-1.0.jar" ); + files.add( "javax.sql/jars/jdbc-2.0.jar" ); + files.add( "org.apache.maven/jars/some-ejb-1.0-client.jar" ); + files.add( "org.apache.maven/jars/testing-1.0.jar" ); + files.add( "org.apache.maven/jars/testing-1.0-sources.jar" ); + files.add( "org.apache.maven/jars/testing-UNKNOWN.jar" ); + files.add( "org.apache.maven/jars/testing-1.0.zip" ); + files.add( "org.apache.maven/jars/testing-1.0-20050611.112233-1.jar" ); + files.add( "org.apache.maven/jars/testing-1.0.tar.gz" ); + files.add( "org.apache.maven.update/jars/test-not-updated-1.0.jar" ); + files.add( "org.apache.maven.update/jars/test-updated-1.0.jar" ); + + return files; + } + + public List getDefaultLayoutArtifactPaths() + { + List files = new ArrayList(); + + files.add( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" ); + files.add( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" ); + files.add( "invalid/invalid/1.0/invalid-1.0b.jar" ); + files.add( "invalid/invalid/1.0/invalid-2.0.jar" ); + files.add( "invalid/invalid-1.0.jar" ); + files.add( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" ); + files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" ); + files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" ); + files.add( "org/apache/maven/A/1.0/A-1.0.war" ); + files.add( "org/apache/maven/A/1.0/A-1.0.pom" ); + files.add( "org/apache/maven/B/2.0/B-2.0.pom" ); + files.add( "org/apache/maven/B/1.0/B-1.0.pom" ); + files.add( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" ); + files.add( "org/apache/maven/C/1.0/C-1.0.war" ); + files.add( "org/apache/maven/C/1.0/C-1.0.pom" ); + files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" ); + files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar" ); + files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" ); + files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar" ); + files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" ); + files.add( "org/apache/maven/testing/1.0/testing-1.0-test-sources.jar" ); + files.add( "org/apache/maven/testing/1.0/testing-1.0.jar" ); + files.add( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" ); + files.add( "org/apache/maven/testing/1.0/testing-1.0.zip" ); + files.add( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" ); + files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" ); + files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.jar" ); + files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ); + files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ); + files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" ); + files.add( "javax/sql/jdbc/2.0/jdbc-2.0.jar" ); + + return files; + } + + public List getDefaultLayoutMetadataPaths() + { + List files = new ArrayList(); + + files.add( "org/apache/maven/some-ejb/1.0/maven-metadata.xml" ); + files.add( "org/apache/maven/update/test-not-updated/maven-metadata.xml" ); + files.add( "org/apache/maven/update/test-updated/maven-metadata.xml" ); + files.add( "org/apache/maven/maven-metadata.xml" ); + files.add( "org/apache/testgroup/discovery/1.0/maven-metadata.xml" ); + files.add( "org/apache/testgroup/discovery/maven-metadata.xml" ); + files.add( "javax/sql/jdbc/2.0/maven-metadata-repository.xml" ); + files.add( "javax/sql/jdbc/maven-metadata-repository.xml" ); + files.add( "javax/sql/maven-metadata-repository.xml" ); + files.add( "javax/maven-metadata.xml" ); + + return files; + } + + public List getDefaultLayoutModelPaths() + { + List files = new ArrayList(); + + files.add( "org/apache/maven/A/1.0/A-1.0.pom" ); + files.add( "org/apache/maven/B/2.0/B-2.0.pom" ); + files.add( "org/apache/maven/B/1.0/B-1.0.pom" ); + files.add( "org/apache/maven/C/1.0/C-1.0.pom" ); + files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" ); + files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" ); + files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" ); + files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" ); + files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ); + files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" ); + + return files; + } +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java new file mode 100644 index 000000000..b6bde475a --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva.common; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.common" ); + //$JUnit-BEGIN$ + suite.addTest( org.apache.maven.archiva.common.artifact.builder.AllTests.suite() ); + suite.addTest( org.apache.maven.archiva.common.utils.AllTests.suite() ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java new file mode 100644 index 000000000..9d9b55df0 --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java @@ -0,0 +1,51 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.artifact.Artifact; +import org.codehaus.plexus.PlexusTestCase; + +/** + * AbstractLayoutArtifactBuilderTestCase + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public abstract class AbstractLayoutArtifactBuilderTestCase +extends PlexusTestCase +{ + + protected void assertArtifact( String groupId, String artifactId, String version, String type, String classifier, Artifact artifact ) + { + assertNotNull( "Artifact cannot be null.", artifact ); + + assertEquals( "Artifact groupId", groupId, artifact.getGroupId() ); + assertEquals( "Artifact artifactId", artifactId, artifact.getArtifactId() ); + assertEquals( "Artifact version", version, artifact.getVersion() ); + assertEquals( "Artifact type", type, artifact.getType() ); + + if ( StringUtils.isNotBlank( classifier ) ) + { + assertEquals( "Artifact classifier", classifier, artifact.getClassifier() ); + } + } + +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java new file mode 100644 index 000000000..45511c374 --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.discoverer.builders" ); + //$JUnit-BEGIN$ + suite.addTestSuite( LegacyLayoutArtifactBuilderTest.class ); + suite.addTestSuite( DefaultLayoutArtifactBuilderTest.class ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java new file mode 100644 index 000000000..954a5bb68 --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java @@ -0,0 +1,206 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * DefaultLayoutArtifactBuilderTest + * + * @author Brett Porter + * @author Joakim Erdfelt + * @version $Id$ + */ +public class DefaultLayoutArtifactBuilderTest + extends AbstractLayoutArtifactBuilderTestCase +{ + LayoutArtifactBuilder builder; + + protected void setUp() + throws Exception + { + super.setUp(); + + builder = (LayoutArtifactBuilder) lookup( LayoutArtifactBuilder.class.getName(), "default" ); + assertNotNull( builder ); + } + + protected void tearDown() + throws Exception + { + if ( builder != null ) + { + release( builder ); + } + super.tearDown(); + } + + public void testPathDistributionArtifacts() + throws BuilderException + { + assertArtifact( "org.apache.maven", "testing", "1.0", "distribution-tgz", null, builder + .build( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" ) ); + + assertArtifact( "org.apache.maven", "testing", "1.0", "distribution-zip", null, builder + .build( "org/apache/maven/testing/1.0/testing-1.0.zip" ) ); + } + + public void testPathNormal() + throws BuilderException + { + assertArtifact( "org.apache.maven.wagon", "wagon", "1.0", "jar", null, builder + .build( "/org/apache/maven/wagon/wagon/1.0/wagon-1.0.jar" ) ); + + assertArtifact( "org.apache.maven.wagon", "wagon", "1.0", "jar", null, builder + .build( "org/apache/maven/wagon/wagon/1.0/wagon-1.0.jar" ) ); + + assertArtifact( "javax.sql", "jdbc", "2.0", "jar", null, builder.build( "javax/sql/jdbc/2.0/jdbc-2.0.jar" ) ); + + } + + public void testPathSnapshots() + throws BuilderException + { + assertArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT", "jar", null, builder + .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.jar" ) ); + + assertArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", null, builder + .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" ) ); + } + + public void testPathSnapshotWithClassifier() + throws BuilderException + { + assertArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", "javadoc", builder + .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" ) ); + } + + public void testPathWithClassifier() + throws BuilderException + { + assertArtifact( "org.apache.maven", "some-ejb", "1.0", "jar", "client", builder + .build( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" ) ); + } + + public void testPathWithJavaSourceInclusion() + throws BuilderException + { + assertArtifact( "org.apache.maven", "testing", "1.0", "java-source", "sources", builder + .build( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" ) ); + } + + public void testProblemMissingType() + { + try + { + builder.build( "invalid/invalid/1/invalid-1" ); + fail( "Should have detected missing type." ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Path filename does not have an extension.", e.getMessage() ); + } + } + + public void testProblemNonSnapshotInSnapshotDir() + { + try + { + builder.build( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" ); + fail( "Non Snapshot artifact inside of an Snapshot dir is invalid." ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Failed to create a snapshot artifact: invalid:invalid:jar:1.0:runtime", e.getMessage() ); + } + } + + public void testProblemPathTooShort() + { + try + { + builder.build( "invalid/invalid-1.0.jar" ); + fail( "Should have detected that path is too short." ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Path is too short to build an artifact from.", e.getMessage() ); + } + } + + public void testProblemTimestampSnapshotNotInSnapshotDir() + { + try + { + builder.build( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" ); + fail( "Timestamped Snapshot artifact not inside of an Snapshot dir is invalid." ); + } + catch ( BuilderException e ) + { + /* expected path */ + // TODO: Is this really the right thing to do for this kind of artifact?? + assertEquals( "Built snapshot artifact base version does not match path version: 1.0-SNAPSHOT; " + + "should have been version: 1.0-20050611.123456-1", e.getMessage() ); + } + } + + public void testProblemVersionPathMismatch() + { + try + { + builder.build( "invalid/invalid/1.0/invalid-2.0.jar" ); + fail( "Should have detected version mismatch between path and artifact." ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Built artifact version does not match path version", e.getMessage() ); + } + } + + public void testProblemVersionPathMismatchAlt() + { + try + { + builder.build( "invalid/invalid/1.0/invalid-1.0b.jar" ); + fail( "Should have version mismatch between directory and artifact." ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Path version does not corresspond to an artifact version", e.getMessage() ); + } + } + + public void testProblemWrongArtifactId() + { + try + { + builder.build( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" ); + fail( "Should have detected wrong artifact Id." ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Path filename does not correspond to an artifact.", e.getMessage() ); + } + } +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java new file mode 100644 index 000000000..2fdae4a14 --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java @@ -0,0 +1,160 @@ +package org.apache.maven.archiva.common.artifact.builder; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; + +/** + * LegacyLayoutArtifactBuilderTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class LegacyLayoutArtifactBuilderTest + extends AbstractLayoutArtifactBuilderTestCase +{ + LayoutArtifactBuilder builder; + + protected void setUp() + throws Exception + { + super.setUp(); + + builder = (LayoutArtifactBuilder) lookup( LayoutArtifactBuilder.class.getName(), "legacy" ); + assertNotNull( builder ); + } + + protected void tearDown() + throws Exception + { + if ( builder != null ) + { + release( builder ); + } + super.tearDown(); + } + + public void testPathNormal() + throws BuilderException + { + Artifact artifact = builder.build( "javax.sql/jars/jdbc-2.0.jar" ); + + assertArtifact( "javax.sql", "jdbc", "2.0", "jar", null, artifact ); + } + + public void testPathFinal() + throws BuilderException + { + Artifact artifact = builder.build( "org.apache.maven.test/jars/maven-model-1.0-final-20060606.jar" ); + + assertArtifact( "org.apache.maven.test", "maven-model", "1.0-final-20060606", "jar", null, artifact ); + } + + public void testPathSnapshot() + throws BuilderException + { + Artifact artifact = builder.build( "org.apache.maven.test/jars/maven-model-1.0-SNAPSHOT.jar" ); + + assertArtifact( "org.apache.maven.test", "maven-model", "1.0-SNAPSHOT", "jar", null, artifact ); + } + + public void testPathJavadoc() + throws BuilderException + { + Artifact artifact = builder.build( "javax.sql/javadoc.jars/jdbc-2.0-javadoc.jar" ); + + assertArtifact( "javax.sql", "jdbc", "2.0", "javadoc.jar", "javadoc", artifact ); + } + + public void testPathSources() + throws BuilderException + { + Artifact artifact = builder.build( "javax.sql/java-sources/jdbc-2.0-sources.jar" ); + + assertArtifact( "javax.sql", "jdbc", "2.0", "java-source", "sources", artifact ); + } + + public void testPathPlugin() + throws BuilderException + { + Artifact artifact = builder.build( "maven/plugins/maven-test-plugin-1.8.jar" ); + + assertArtifact( "maven", "maven-test-plugin", "1.8", "plugin", null, artifact ); + } + + public void testProblemNoType() + { + try + { + builder.build( "invalid/invalid/1/invalid-1" ); + + fail( "Should have detected no type." ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Path does not match a legacy repository path for an artifact", e.getMessage() ); + } + } + + public void testProblemWrongArtifactPackaging() + throws ComponentLookupException + { + try + { + builder.build( "org.apache.maven.test/jars/artifactId-1.0.jar.md5" ); + + fail( "Should have detected wrong package extension." ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Path type does not match the extension", e.getMessage() ); + } + } + + public void testProblemNoArtifactId() + { + try + { + builder.build( "groupId/jars/-1.0.jar" ); + + fail( "Should have detected artifactId is missing" ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Path filename artifactId is empty", e.getMessage() ); + } + + try + { + builder.build( "groupId/jars/1.0.jar" ); + + fail( "Should have detected artifactId is missing" ); + } + catch ( BuilderException e ) + { + /* expected path */ + assertEquals( "Path filename artifactId is empty", e.getMessage() ); + } + } +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/AllTests.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/AllTests.java new file mode 100644 index 000000000..db0ec4f38 --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva.common.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.common.utils" ); + //$JUnit-BEGIN$ + suite.addTestSuite( PathUtilTest.class ); + suite.addTestSuite( BaseFileTest.class ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java new file mode 100644 index 000000000..ab8c6718c --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java @@ -0,0 +1,131 @@ +package org.apache.maven.archiva.common.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.TestCase; +import org.codehaus.plexus.util.StringUtils; + +import java.io.File; + +/** + * BaseFileTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class BaseFileTest + extends TestCase +{ + public void testFileString() + { + File repoDir = new File( "/home/user/foo/repository" ); + String pathFile = "path/to/resource.xml"; + BaseFile file = new BaseFile( repoDir, pathFile ); + + assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); + assertRelativePath( "path/to/resource.xml", file ); + assertBasedir( "/home/user/foo/repository", file ); + } + + public void testFileFile() + { + File repoDir = new File( "/home/user/foo/repository" ); + File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" ); + BaseFile file = new BaseFile( repoDir, pathFile ); + + assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); + assertRelativePath( "path/to/resource.xml", file ); + assertBasedir( "/home/user/foo/repository", file ); + } + + public void testStringFile() + { + String repoDir = "/home/user/foo/repository"; + File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" ); + BaseFile file = new BaseFile( repoDir, pathFile ); + + assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); + assertRelativePath( "path/to/resource.xml", file ); + assertBasedir( "/home/user/foo/repository", file ); + } + + public void testFileThenSetBaseString() + { + String repoDir = "/home/user/foo/repository"; + File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" ); + BaseFile file = new BaseFile( pathFile ); + file.setBaseDir( repoDir ); + + assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); + assertRelativePath( "path/to/resource.xml", file ); + assertBasedir( "/home/user/foo/repository", file ); + } + + public void testFileThenSetBaseFile() + { + File repoDir = new File( "/home/user/foo/repository" ); + File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" ); + BaseFile file = new BaseFile( pathFile ); + file.setBaseDir( repoDir ); + + assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); + assertRelativePath( "path/to/resource.xml", file ); + assertBasedir( "/home/user/foo/repository", file ); + } + + public void testStringThenSetBaseString() + { + String repoDir = "/home/user/foo/repository"; + String pathFile = "/home/user/foo/repository/path/to/resource.xml"; + BaseFile file = new BaseFile( pathFile ); + file.setBaseDir( repoDir ); + + assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); + assertRelativePath( "path/to/resource.xml", file ); + assertBasedir( "/home/user/foo/repository", file ); + } + + public void testStringThenSetBaseFile() + { + File repoDir = new File( "/home/user/foo/repository" ); + String pathFile = "/home/user/foo/repository/path/to/resource.xml"; + BaseFile file = new BaseFile( pathFile ); + file.setBaseDir( repoDir ); + + assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); + assertRelativePath( "path/to/resource.xml", file ); + assertBasedir( "/home/user/foo/repository", file ); + } + + private void assertAbsolutePath( String expectedPath, BaseFile actualFile ) + { + assertEquals( new File( expectedPath ).getAbsolutePath(), actualFile.getAbsolutePath() ); + } + + private void assertRelativePath( String expectedPath, BaseFile actualFile ) + { + assertEquals( expectedPath, StringUtils.replace( actualFile.getRelativePath(), "\\", "/" ) ); + } + + private void assertBasedir( String expectedPath, BaseFile actualFile ) + { + assertEquals( new File( expectedPath ), actualFile.getBaseDir() ); + } +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java new file mode 100644 index 000000000..09785b6e5 --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java @@ -0,0 +1,69 @@ +package org.apache.maven.archiva.common.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +import junit.framework.TestCase; + +/** + * DateUtilTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class DateUtilTest extends TestCase +{ + private void assertDuration( String expectedDuration, String startTimestamp, String endTimestamp ) + throws ParseException + { + SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss SSS" ); + Date startDate = sdf.parse( startTimestamp ); + Date endDate = sdf.parse( endTimestamp ); + +// System.out.println( "Date: " + endTimestamp + " - " + startTimestamp + " = " +// + ( endDate.getTime() - startDate.getTime() ) + " ms" ); + + assertEquals( expectedDuration, DateUtil.getDuration( startDate, endDate ) ); + } + + public void testGetDurationDifference() throws ParseException + { + assertDuration( "2 Seconds", "2006-08-22 13:00:02 0000", + "2006-08-22 13:00:04 0000" ); + + assertDuration( "12 Minutes 12 Seconds 234 Milliseconds", "2006-08-22 13:12:02 0000", + "2006-08-22 13:24:14 0234" ); + + assertDuration( "12 Minutes 501 Milliseconds", "2006-08-22 13:12:01 0500", + "2006-08-22 13:24:02 0001" ); + } + + public void testGetDurationDirect() throws ParseException + { + assertEquals( "2 Seconds", DateUtil.getDuration( 2000 ) ); + + assertEquals( "12 Minutes 12 Seconds 234 Milliseconds", DateUtil.getDuration( 732234 ) ); + + assertEquals( "12 Minutes 501 Milliseconds", DateUtil.getDuration( 720501 ) ); + } +} diff --git a/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java new file mode 100644 index 000000000..58abbd2bf --- /dev/null +++ b/archiva-base/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java @@ -0,0 +1,40 @@ +package org.apache.maven.archiva.common.utils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.common.utils.PathUtil; + +import junit.framework.TestCase; + +/** + * PathUtilTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class PathUtilTest + extends TestCase +{ + public void testToRelative() + { + assertEquals( "path/to/resource.xml", PathUtil.getRelative( "/home/user/foo/repository", + "/home/user/foo/repository/path/to/resource.xml" ) ); + } +} diff --git a/archiva-base/archiva-common/src/test/legacy-repository/CVS/Root b/archiva-base/archiva-common/src/test/legacy-repository/CVS/Root new file mode 100644 index 000000000..2e65f24a6 --- /dev/null +++ b/archiva-base/archiva-common/src/test/legacy-repository/CVS/Root @@ -0,0 +1 @@ +not a real CVS root - for testing exclusions diff --git a/archiva-base/archiva-common/src/test/legacy-repository/KEYS b/archiva-base/archiva-common/src/test/legacy-repository/KEYS new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/invalid/foo/invalid-1.0.foo b/archiva-base/archiva-common/src/test/legacy-repository/invalid/foo/invalid-1.0.foo new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/invalid/invalid-1.0.jar b/archiva-base/archiva-common/src/test/legacy-repository/invalid/invalid-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar b/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid-1.0.rar b/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid-1.0.rar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid.jar b/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/invalid.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/no-extension b/archiva-base/archiva-common/src/test/legacy-repository/invalid/jars/no-extension new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar b/archiva-base/archiva-common/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar b/archiva-base/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/CVS/Root b/archiva-base/archiva-common/src/test/repository/CVS/Root new file mode 100644 index 000000000..2e65f24a6 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/CVS/Root @@ -0,0 +1 @@ +not a real CVS root - for testing exclusions diff --git a/archiva-base/archiva-common/src/test/repository/KEYS b/archiva-base/archiva-common/src/test/repository/KEYS new file mode 100644 index 000000000..d3b34d5ad --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/KEYS @@ -0,0 +1 @@ +test KEYS file \ No newline at end of file diff --git a/archiva-base/archiva-common/src/test/repository/invalid/invalid-1.0.jar b/archiva-base/archiva-common/src/test/repository/invalid/invalid-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar b/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar b/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar b/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar b/archiva-base/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/invalid/invalid/1/invalid-1 b/archiva-base/archiva-common/src/test/repository/invalid/invalid/1/invalid-1 new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/javax/maven-metadata.xml b/archiva-base/archiva-common/src/test/repository/javax/maven-metadata.xml new file mode 100644 index 000000000..b3baf545d --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/javax/maven-metadata.xml @@ -0,0 +1,26 @@ + + + + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar b/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml new file mode 100644 index 000000000..caf5b6697 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml @@ -0,0 +1,25 @@ + + + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml new file mode 100644 index 000000000..bb7570891 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml @@ -0,0 +1,30 @@ + + + + + javax.sql + jdbc + 2.0 + + + 2.0 + + + diff --git a/archiva-base/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml b/archiva-base/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml new file mode 100644 index 000000000..caf5b6697 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml @@ -0,0 +1,25 @@ + + + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom new file mode 100644 index 000000000..202a0a448 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + A + 1.0 + Maven Test Repository Artifact Discovery + war + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war b/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom new file mode 100644 index 000000000..fa5f8f6c8 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + B + 1.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom new file mode 100644 index 000000000..c3034e820 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + B + 2.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom new file mode 100644 index 000000000..ae14cd7eb --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + C + 1.0 + Maven Test Repository Artifact Discovery + war + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war b/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom new file mode 100644 index 000000000..5a29f6117 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + discovery + 1.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml b/archiva-base/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml new file mode 100644 index 000000000..8ce7fc7bb --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml @@ -0,0 +1,23 @@ + + + + + org.apache.maven + \ No newline at end of file diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom new file mode 100644 index 000000000..6ab57d162 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven + C + 1.0 + Maven Test Repository Artifact Discovery + + + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom new file mode 100644 index 000000000..a959980df --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven + C + 1.0 + Maven Test Repository Artifact Discovery + + jar + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml b/archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz b/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip b/archiva-base/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom new file mode 100644 index 000000000..452727f28 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven.update + test-not-updated + 1.0 + Maven Test Repository Artifact Discovery + + + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml new file mode 100644 index 000000000..bd56a21c1 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml @@ -0,0 +1,24 @@ + + + + + org.apache.maven.update + test-not-updated + \ No newline at end of file diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom new file mode 100644 index 000000000..edd7b6479 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven.update + test-updated + 1.0 + Maven Test Repository Artifact Discovery + + + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml new file mode 100644 index 000000000..86e063ca8 --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml @@ -0,0 +1,24 @@ + + + + + org.apache.maven.update + test-updated + \ No newline at end of file diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom new file mode 100644 index 000000000..12538e81a --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.testgroup + discovery + 1.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml new file mode 100644 index 000000000..8ee18048c --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml @@ -0,0 +1,25 @@ + + + + + org.apache.testgroup + discovery + 1.0 + \ No newline at end of file diff --git a/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml new file mode 100644 index 000000000..b024ef7ef --- /dev/null +++ b/archiva-base/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml @@ -0,0 +1,24 @@ + + + + + org.apache.testgroup + discovery + \ No newline at end of file diff --git a/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml b/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml new file mode 100644 index 000000000..5760e8918 --- /dev/null +++ b/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml @@ -0,0 +1,34 @@ + + + + + + + org.apache.maven.archiva.common.consumers.Consumer + mock-artifact + org.apache.maven.archiva.common.consumers.MockArtifactConsumer + + + org.apache.maven.artifact.factory.ArtifactFactory + + + + + \ No newline at end of file diff --git a/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml b/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml new file mode 100644 index 000000000..2ded1b62d --- /dev/null +++ b/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml @@ -0,0 +1,34 @@ + + + + + + + org.apache.maven.archiva.discoverer.DiscovererConsumer + mock-model + org.apache.maven.archiva.discoverer.consumers.MockModelConsumer + + + org.apache.maven.artifact.factory.ArtifactFactory + + + + + \ No newline at end of file diff --git a/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml b/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml new file mode 100644 index 000000000..da9864d00 --- /dev/null +++ b/archiva-base/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml @@ -0,0 +1,34 @@ + + + + + + + org.apache.maven.archiva.discoverer.DiscovererConsumer + mock-metadata + org.apache.maven.archiva.discoverer.consumers.MockRepositoryMetadataConsumer + + + org.apache.maven.artifact.factory.ArtifactFactory + + + + + \ No newline at end of file diff --git a/archiva-base/archiva-configuration/pom.xml b/archiva-base/archiva-configuration/pom.xml new file mode 100644 index 000000000..4a502130b --- /dev/null +++ b/archiva-base/archiva-configuration/pom.xml @@ -0,0 +1,109 @@ + + + + + + archiva + org.apache.maven.archiva + 1.0-SNAPSHOT + + 4.0.0 + archiva-configuration + Archiva Configuration + + + org.codehaus.plexus + plexus-component-api + + + org.codehaus.plexus + plexus-utils + + + commons-lang + commons-lang + + + commons-io + commons-io + + + org.codehaus.plexus.registry + plexus-registry-api + 1.0-alpha-2-SNAPSHOT + + + org.codehaus.plexus.registry + plexus-registry-commons + 1.0-alpha-2-SNAPSHOT + test + + + + easymock + easymock + 1.2_Java1.3 + test + + + org.codehaus.plexus + plexus-container-default + test + + + + + + org.codehaus.modello + modello-maven-plugin + 1.0-alpha-15-SNAPSHOT + + + + java + registry-reader + registry-writer + + + + + 1.0.0 + src/main/mdo/configuration.mdo + + + + org.codehaus.mojo + cobertura-maven-plugin + + + + + org/apache/maven/archiva/configuration/io/** + org/apache/maven/archiva/configuration/*RepositoryConfiguration.* + org/apache/maven/archiva/configuration/Configuration.* + org/apache/maven/archiva/configuration/Proxy.* + + + + + + + diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java new file mode 100644 index 000000000..a914ce712 --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java @@ -0,0 +1,53 @@ +package org.apache.maven.archiva.configuration; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.codehaus.plexus.registry.RegistryException; +import org.codehaus.plexus.registry.RegistryListener; + +/** + * Configuration holder for the model read from the registry. + */ +public interface ArchivaConfiguration +{ + /** + * Get the configuration. + * + * @return the configuration + */ + Configuration getConfiguration(); + + /** + * Save any updated configuration. + * + * @param configuration the configuration to save + * @throws org.codehaus.plexus.registry.RegistryException + * if there is a problem saving the registry data + */ + void save( Configuration configuration ) + throws RegistryException; + + /** + * Add a change listener so that registry changes are propogated. + * + * @param listener the listener + */ + void addChangeListener( RegistryListener listener ); +} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java new file mode 100644 index 000000000..ab64a661d --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java @@ -0,0 +1,125 @@ +package org.apache.maven.archiva.configuration; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryReader; +import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryWriter; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; +import org.codehaus.plexus.registry.Registry; +import org.codehaus.plexus.registry.RegistryException; +import org.codehaus.plexus.registry.RegistryListener; +import org.codehaus.plexus.util.StringUtils; + +import java.util.Iterator; + +/** + * Implementation of configuration holder that retrieves it from the registry. + * + * @plexus.component + */ +public class DefaultArchivaConfiguration + implements ArchivaConfiguration, RegistryListener, Initializable +{ + /** + * Plexus registry to read the configuration from. + * + * @plexus.requirement role-hint="commons-configuration" + */ + private Registry registry; + + /** + * The configuration that has been converted. + */ + private Configuration configuration; + + private static final String KEY = "org.apache.maven.archiva"; + + public synchronized Configuration getConfiguration() + { + if ( configuration == null ) + { + // TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties) + configuration = new ConfigurationRegistryReader().read( registry.getSubset( KEY ) ); + + // TODO: for commons-configuration 1.3 only + for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); ) + { + RepositoryConfiguration c = (RepositoryConfiguration) i.next(); + c.setUrl( removeExpressions( c.getUrl() ) ); + } + } + return configuration; + } + + public void save( Configuration configuration ) + throws RegistryException + { + Registry section = registry.getSection( KEY + ".user" ); + if ( section == null ) + { + section = registry.getSection( KEY + ".base" ); + } + new ConfigurationRegistryWriter().write( configuration, section ); + section.save(); + + this.configuration = configuration; + } + + public void addChangeListener( RegistryListener listener ) + { + Registry section = registry.getSection( KEY + ".user" ); + if ( section != null ) + { + section.addChangeListener( listener ); + } + section = registry.getSection( KEY + ".base" ); + if ( section != null ) + { + section.addChangeListener( listener ); + } + } + + public void initialize() + throws InitializationException + { + registry.addChangeListener( this ); + } + + public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) + { + // nothing to do here + } + + public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) + { + configuration = null; + } + + private String removeExpressions( String directory ) + { + String value = StringUtils.replace( directory, "${appserver.base}", + registry.getString( "appserver.base", "${appserver.base}" ) ); + value = StringUtils.replace( value, "${appserver.home}", + registry.getString( "appserver.home", "${appserver.home}" ) ); + return value; + } + +} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java new file mode 100644 index 000000000..0efcde250 --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java @@ -0,0 +1,49 @@ +package org.apache.maven.archiva.configuration; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * An error in the configuration. + * + * @author Brett Porter + */ +public class InvalidConfigurationException + extends Exception +{ + private final String name; + + public InvalidConfigurationException( String name, String message ) + { + super( message ); + this.name = name; + } + + public InvalidConfigurationException( String name, String message, Throwable cause ) + { + super( message, cause ); + + this.name = name; + } + + public String getName() + { + return name; + } +} diff --git a/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java new file mode 100644 index 000000000..070ed0539 --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java @@ -0,0 +1,163 @@ +package org.apache.maven.archiva.configuration; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.util.Enumeration; +import java.util.Properties; +import java.util.StringTokenizer; + +/** + * @author Ben Walding + * @author Brett Porter + */ +public class MavenProxyPropertyLoader +{ + private static final String REPO_LOCAL_STORE = "repo.local.store"; + + private static final String PROXY_LIST = "proxy.list"; + + private static final String REPO_LIST = "repo.list"; + + public void load( Properties props, Configuration configuration ) throws InvalidConfigurationException + { + // set up the managed repository + String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE ); + + RepositoryConfiguration config = new RepositoryConfiguration(); + config.setUrl( toURL( localCachePath ) ); + config.setName( "Imported Maven-Proxy Cache" ); + config.setId( "maven-proxy" ); + configuration.addRepository( config ); + + // Add the network proxies. + String propertyList = props.getProperty( PROXY_LIST ); + if ( propertyList != null ) + { + StringTokenizer tok = new StringTokenizer( propertyList, "," ); + while ( tok.hasMoreTokens() ) + { + String key = tok.nextToken(); + if ( StringUtils.isNotEmpty( key ) ) + { + ProxyConfiguration proxy = new ProxyConfiguration(); + proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) ); + proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) ); + + // the username and password isn't required + proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) ); + proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) ); + + configuration.addNetworkProxy( proxy ); + } + } + } + + // Add the remote repository list + String repoList = getMandatoryProperty( props, REPO_LIST ); + + StringTokenizer tok = new StringTokenizer( repoList, "," ); + while ( tok.hasMoreTokens() ) + { + String key = tok.nextToken(); + + Properties repoProps = getSubset( props, "repo." + key + "." ); + String url = getMandatoryProperty( props, "repo." + key + ".url" ); + String proxyKey = repoProps.getProperty( "proxy" ); + + int cachePeriod = Integer.parseInt( repoProps.getProperty( "cache.period", "60" ) ); + + RepositoryConfiguration repository = new RepositoryConfiguration(); + repository.setId( key ); + repository.setName( "Imported Maven-Proxy Remote Proxy" ); + repository.setUrl( url ); + repository.setLayout( "legacy" ); + repository.setIndexed( false ); + repository.setReleases( true ); + repository.setSnapshots( false ); + + configuration.addRepository( repository ); + + RepositoryProxyConnectorConfiguration proxyConnector = new RepositoryProxyConnectorConfiguration(); + proxyConnector.setSourceRepoId( "maven-proxy" ); + proxyConnector.setTargetRepoId( key ); + proxyConnector.setProxyId( proxyKey ); + proxyConnector.setFailurePolicy( RepositoryProxyConnectorConfiguration.NOT_FOUND ); + proxyConnector.setSnapshotsPolicy( String.valueOf( cachePeriod ) ); + proxyConnector.setReleasesPolicy( RepositoryProxyConnectorConfiguration.NEVER ); + + configuration.addProxyConnector( proxyConnector ); + } + } + + private String toURL( String path ) + { + File file = new File( path ); + try + { + return file.toURL().toExternalForm(); + } + catch ( MalformedURLException e ) + { + return "file://" + StringUtils.replaceChars( file.getAbsolutePath(), '\\', '/' ); + } + } + + private Properties getSubset( Properties props, String prefix ) + { + Enumeration keys = props.keys(); + Properties result = new Properties(); + while ( keys.hasMoreElements() ) + { + String key = (String) keys.nextElement(); + String value = props.getProperty( key ); + if ( key.startsWith( prefix ) ) + { + String newKey = key.substring( prefix.length() ); + result.setProperty( newKey, value ); + } + } + return result; + } + + public void load( InputStream is, Configuration configuration ) throws IOException, InvalidConfigurationException + { + Properties props = new Properties(); + props.load( is ); + load( props, configuration ); + } + + private String getMandatoryProperty( Properties props, String key ) throws InvalidConfigurationException + { + String value = props.getProperty( key ); + + if ( value == null ) + { + throw new InvalidConfigurationException( key, "Missing required field: " + key ); + } + + return value; + } +} \ No newline at end of file diff --git a/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo new file mode 100644 index 000000000..75ba48c53 --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/mdo/configuration.mdo @@ -0,0 +1,479 @@ + + + + configuration + Configuration + + Configuration for the Maven Repository Manager. + + + + package + org.apache.maven.archiva.configuration + + + + + Configuration + 1.0.0+ + + + repositories + 1.0.0+ + + RepositoryConfiguration + * + + The list of repositories that this archiva instance uses. + + + proxyConnectors + 1.0.0+ + + RepositoryProxyConnectorConfiguration + * + + The list of proxy connectors for this archiva instance. + + + + networkProxies + 1.0.0+ + + ProxyConfiguration + * + + + The list of network proxies to use for outgoing requests. + + + + fileProcessors + 1.0.0+ + + FileProcessor + * + + + The file processors setup. + + + + + + + + + RepositoryConfiguration + 1.0.0+ + + + id + 1.0.0+ + String + true + + The repository identifier. + + + + name + 1.0.0+ + String + true + + The descriptive name of the repository. + + + + url + 1.0.0+ + String + true + + The URL for this repository. + + + + layout + 1.0.0+ + String + true + + The layout of the repository. Valid values are "default" and "legacy". + + + default + + + releases + 1.0.0+ + boolean + True if this repository contains release versioned artifacts. + true + + + snapshots + 1.0.0+ + boolean + True if this repository contains snapshot versioned artifacts. + false + + + indexed + 1.0.0+ + boolean + True if this repository should be indexed. + true + + + refreshCronExpression + 1.0.0+ + String + + When to run the refresh task. + Default is every 30 minutes (translated as every 0 and 30 minute reading of every hour) + + 0 0,30 * * * ? + + + + + + + + AbstractRepositoryConnectorConfiguration + true + 1.0.0+ + + + sourceRepoId + 1.0.0+ + String + true + + The Repository Source for this connector. + + + + targetRepoId + 1.0.0+ + String + true + + The Repository Target for this connector. + + + + proxyId + 1.0.0+ + String + + The network proxy ID to use for this connector. + + + + blackListPatterns + 1.0.0+ + + String + * + + + The list of blacklisted patterns for this connector. + + + + whiteListPatterns + 1.0.0+ + + String + * + + + The list of whitelisted patterns for this connector. + + + + + + + AbstractRepositoryConnectorConfiguration + RepositoryProxyConnectorConfiguration + 1.0.0+ + + + snapshotsPolicy + 1.0.0+ + String + disabled + + The policy for snapshots: + Can be one of the following keywords: + "disabled" - means retrieval isn't even attempted. + "daily" - means snapshot is fetched, but only updated on + a daily basis. (equivalent to "1440" minutes) + "hourly" - means snapshot is fetched, but only updated on + an hourly basis. (equivalent to "60" minutes) + "never" - means snapshot is fetched once, but never updated. + (equivalent to "-1" minutes) + Or it can be a number of minutes before updating of the snapshot. + + + + releasesPolicy + 1.0.0+ + String + never + + The policy for releases: + Can be one of the following keywords: + "disabled" - means retrieval isn't even attempted. + "daily" - means release is fetched, but only updated on + a daily basis. (equivalent to "1440" minutes) + "hourly" - means release is fetched, but only updated on + an hourly basis. (equivalent to "60" minutes) + "never" - means release is fetched once, but never updated. + (equivalent to "-1" minutes) + Or it can be a number of minutes before updating of the release. + + + + failurePolicy + 1.0.0+ + String + not-found + + The policy for dealing with proxy failures. + Can be one of the following keywords: + "not-found" - means if the retrieval has a failure, an HTTP 404 + (not found) is returned to the client of this + archiva instance. + This policy setting will allow other proxies + to be checked for content. + "failure" - means if the retrieval has a failure, an HTTP 500 + (server error) is returned to the client of this + archiva instance. + This policy setting will return immediately to the + client of the archiva instance and not allow + furthor attempts on other proxies for this content. + + + + + + 1.0.0+ + + + + + + + AbstractRepositoryConnectorConfiguration + RepositorySynchConnectorConfiguration + true + 1.0.0+ + + + cronExpression + 1.0.0+ + String + When to run the sync mechanism. Default is every hour on the hour. + 0 0 * * * ? + + + method + 1.0.0+ + String + The type of synchronization to use. + rsync + + + properties + 1.0.0+ + Properties + Configuration for the repository synchronization. + + String + * + + + + + + + + + ProxyConfiguration + 1.0.0+ + + + id + 1.0.0+ + String + + The ID for this proxy. + + + + protocol + 1.0.0+ + + The network protocol to use with this proxy. + + String + true + http + + + host + 1.0.0+ + + The proxy host. + + String + true + + + port + 1.0.0+ + + The proxy port. + + int + 8080 + + + username + 1.0.0+ + + The proxy user. + + String + + + password + 1.0.0+ + + The proxy password. + + String + + + + + + + FileProcessor + 1.0.0+ + + + id + 1.0.0+ + true + String + + The ID for this file processor + + + + patterns + 1.0.0+ + true + + String + * + + + The list of patterns for this processor. + + + + consumers + 1.0.0+ + true + + String + * + + + The list of consumer IDs for this file processor. + + + + + + + + + diff --git a/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties b/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties new file mode 100644 index 000000000..2beeea469 --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties @@ -0,0 +1,21 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +Key_properties=java.lang.String +Element_properties=java.lang.String diff --git a/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml b/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml new file mode 100644 index 000000000..4c48beb5d --- /dev/null +++ b/archiva-base/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml @@ -0,0 +1,219 @@ + + + + + internal + Archiva Managed Internal Repository + file://${appserver.home}/repositories/internal + default + true + false + true + 0 0 * * ? + + + snapshots + Archiva Managed Snapshot Repository + file://${appserver.home}/repositories/internal + default + false + true + true + 0 0,30 * * ? + + + central + Central Repository + http://repo1.maven.org/maven2 + default + 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 + + + + + internal + central + + disabled + never + not-found + + + internal + maven2-repository.dev.java.net + + disabled + never + not-found + + javax/** + + + + + + + + artifacts + + **/*.pom + **/*.jar + **/*.ear + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + **/*.dtd + **/*.tld + **/*.tar.gz + **/*.tar.bz2 + **/*.zip + + + artifact-to-db + artifact-to-lucene + artifact-create-missing-checksums + + + + projects + + **/*.pom + + + project-to-db + + + + repository-metadata + + **/maven-metadata.xml + + + repository-metadata-to-db + repository-metadata-version-mismatch + + + + checksums + + **/*.sha1 + **/*.md5 + + + checksum-validate + + + + signatures + + **/*.asc + + + signature-validate + + + + archives + + **/*.jar + **/*.ear + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + **/*.tar.gz + **/*.tar.bz2 + **/*.zip + **/*.nbm + + + archive-toc-to-lucene + + + + bytecode + + **/*.jar + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + + + bytecode-to-db + bytecode-to-lucene + + + + xmls + + **/*.pom + **/*.xml + **/*.xsd + + + xml-to-lucene + + + + text + + **/*.txt + **/*.TXT + **/*.block + **/*.config + + + + ignored + + **/.htaccess + **/KEYS + **/*.rb + **/*.sh + **/.svn/** + **/.DAV/** + + + ignored + + + + auto-remove + + **/*.bak + **/*~ + **/*- + + + auto-remove + + + + auto-rename + + **/*.distribution-tgz + **/*.distribution-zip + **/*.plugin + + + auto-rename + + + + diff --git a/archiva-base/archiva-configuration/src/test/conf/corrupt.xml b/archiva-base/archiva-configuration/src/test/conf/corrupt.xml new file mode 100644 index 000000000..b4469289a --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/conf/corrupt.xml @@ -0,0 +1,20 @@ + + + diff --git a/archiva-base/archiva-configuration/src/test/conf/maven-proxy-complete.conf b/archiva-base/archiva-configuration/src/test/conf/maven-proxy-complete.conf new file mode 100644 index 000000000..7908a9ad9 --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/conf/maven-proxy-complete.conf @@ -0,0 +1,144 @@ +################ GLOBAL SETTINGS +# This is where maven-proxy stores files it has downloaded +repo.local.store=target + +#The port to listen on - not used if loaded as a webapp +port=9999 + +#This is the base area that all files are loaded from. While it is possible to leave this blank, this behaviour +#is deprecated and will be disabled in version 2.0. There are too many namespace conflicts caused by not using +#a prefix. +#The repository will be shown at http://localhost:9999/repository/ +#for the .war loaded into a webapp server, the default prefix is "repository" (edit the web.xml to change) +# As maven doesn't like a trailing slash, this address shouldn't have one either. +prefix=repository + +#This is the simple date format used to display the last modified date while browsing the repository. +lastModifiedDateFormat=yyyy/MM/dd HH:mm:ss + +################ SNAPSHOT HANDLING +#If you want the proxy to look for newer snapshots, set to true +snapshot.update=true + +################ M2 METADATA HANDLING +#If you want the proxy to prevent looking for newer metadata, set to false (default is true) +#metadata.update=false + +################ M2 POM HANDLING +#If you want the proxy to look for newer POMs, set to true (default is false) +pom.update=true + +################ PROMOTION HANDLING +# ***** NOT CURRENTLY IMPLEMENTED ***** +#Promotion describes the process by which new artifacts are loaded to global maven-proxy repository. It +# is designed to be used by "higher security installations" that do not want to acquire artifacts from +# remote repositories without approval. +# +#If promotion handling is enabled, then the proxy will not download remote artifacts without permission +# (local repositories with copy=false are considered to be local) +# +#Permission to download is granted via the Promotion menu which will be enabled +# when promotion handling is enabled. +# +#If promotion is false, artifacts are sourced from any repository as per normal. +# +#Promotion and snapshots: If promotion is enabled, snapshots are not downloadable. The concept of using +# a snapshot in a production build (which is primarily what promotion is for) is counterintuitive. +## +promotion=false + +################ WEB INTERFACE +# This defines the absolute URL the server should use to identify itself. +# This can often be determined automatically, but we recommend you specify +# it explicitly to prevent problems during startup. +# The prefix will be added to this for the actual repository +# i.e. proxy available at http://localhost:9999/, repository at http://localhost:9999/repository +serverName=http://localhost:9999 + +#If true, the repository can be browsed +browsable=true + +#If true, the repository can be searched +searchable=true + +#Not currently implemented. Will allow webdav access to the repository at some point. +webdav=true + +#Stylesheet - if configured, will override the default stylesheet shipped with maven-proxy - absolute URLs only +#eg. /maven-proxy/style.css, http://www.example.com/style.css +stylesheet=/maven-proxy/style.css + +#bgColor / bgColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. +#If a stylesheet is set, these are not used. +bgColor=#14B +bgColorHighlight=#94B + +#rowColor / rowColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. +#If a stylesheet is set, these are not used. +rowColor=#CCF +rowColorHighlight=#DDF + + +################ PROXIES +#This is just a hack, it should auto discover them +proxy.list=one,two,three + +#Unauthenticated proxy +proxy.one.host=proxy1.example.com +proxy.one.port=3128 + +#Authenticated proxy +proxy.two.host=proxy2.example.org +proxy.two.port=80 +proxy.two.username=username2 +proxy.two.password=password2 + +#Authenticated proxy +proxy.three.host=proxy3.example.net +proxy.three.port=3129 +proxy.three.username=username3 +proxy.three.password=password3 + + +################# REPOSITORIES +#This is not just a hack, it specifies the order repositories should be checked +#Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/" +repo.list=local-repo,www-ibiblio-org,dist-codehaus-org,private-example-com + +#local-store +# The local store represents a location that local jars you host can be located. +# This could also be achieved by having a local http repository, but this is less cumbersome +repo.local-repo.url=file://target +repo.local-repo.description=Super Secret Custom Repository +#If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos +repo.local-repo.copy=false +#If hardfail is true, any unexpected errors from the repository will cause +#the client download to fail (typically with a 500 error) +repo.local-repo.hardfail=true +#Don't cache a file repository +repo.local-repo.cache.period=0 + + +#www.ibiblio.org +repo.www-ibiblio-org.url=http://www.ibiblio.org/maven2 +repo.www-ibiblio-org.description=www.ibiblio.org +repo.www-ibiblio-org.proxy=one +repo.www-ibiblio-org.hardfail=true +#Cache this repository for 1 hour +repo.www-ibiblio-org.cache.period=3600 +repo.www-ibiblio-org.cache.failures=true + +#dist.codehaus.org +repo.dist-codehaus-org.url=http://dist.codehaus.org +repo.dist-codehaus-org.proxy=two +repo.dist-codehaus-org.hardfail=false +repo.dist-codehaus-org.cache.period=3600 +repo.dist-codehaus-org.cache.failures=true + +#private.example.com +repo.private-example-com.url=http://private.example.com/internal +repo.private-example-com.description=Commercial In Confidence Repository +repo.private-example-com.username=username1 +repo.private-example-com.password=password1 +repo.private-example-com.proxy=three +repo.private-example-com.cache.period=3600 diff --git a/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml b/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml new file mode 100644 index 000000000..44e7fc155 --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/conf/repository-manager.xml @@ -0,0 +1,238 @@ + + + + + + + internal + Archiva Managed Internal Repository + file://${appserver.home}/repositories/internal + default + true + false + true + 0 0 * * ? + + + snapshots + Archiva Managed Snapshot Repository + file://${appserver.home}/repositories/internal + default + false + true + true + 0 0,30 * * ? + + + central + Central Repository + http://repo1.maven.org/maven2 + default + 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 + + + + + internal + central + + disabled + never + not-found + + + internal + maven2-repository.dev.java.net + + disabled + never + not-found + + javax/** + + + + + + + + artifacts + + **/*.pom + **/*.jar + **/*.ear + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + **/*.dtd + **/*.tld + **/*.tar.gz + **/*.tar.bz2 + **/*.zip + + + artifact-to-db + artifact-to-lucene + artifact-create-missing-checksums + + + + projects + + **/*.pom + + + project-to-db + + + + repository-metadata + + **/maven-metadata.xml + + + repository-metadata-to-db + repository-metadata-version-mismatch + + + + checksums + + **/*.sha1 + **/*.md5 + + + checksum-validate + + + + signatures + + **/*.asc + + + signature-validate + + + + archives + + **/*.jar + **/*.ear + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + **/*.tar.gz + **/*.tar.bz2 + **/*.zip + **/*.nbm + + + archive-toc-to-lucene + + + + bytecode + + **/*.jar + **/*.war + **/*.car + **/*.sar + **/*.mar + **/*.rar + + + bytecode-to-db + bytecode-to-lucene + + + + xmls + + **/*.pom + **/*.xml + **/*.xsd + + + xml-to-lucene + + + + text + + **/*.txt + **/*.TXT + **/*.block + **/*.config + + + + ignored + + **/.htaccess + **/KEYS + **/*.rb + **/*.sh + **/.svn/** + **/.DAV/** + + + ignored + + + + auto-remove + + **/*.bak + **/*~ + **/*- + + + auto-remove + + + + auto-rename + + **/*.distribution-tgz + **/*.distribution-zip + **/*.plugin + + + auto-rename + + + + diff --git a/archiva-base/archiva-configuration/src/test/conf/with-proxied-repos.xml b/archiva-base/archiva-configuration/src/test/conf/with-proxied-repos.xml new file mode 100644 index 000000000..c8032436a --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/conf/with-proxied-repos.xml @@ -0,0 +1,44 @@ + + + + + + + managed-repository + local + local + + + + + http://www.ibiblio.org/maven2/ + local + true + ibiblio + Ibiblio + + + http://repository.codehaus.org/ + local + codehaus + Codehaus + + + diff --git a/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java b/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java new file mode 100644 index 000000000..8f4243c27 --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java @@ -0,0 +1,200 @@ +package org.apache.maven.archiva.configuration; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.io.FileUtils; +import org.codehaus.plexus.PlexusTestCase; + +import java.io.File; +import java.util.Properties; + +/** + * Test the configuration store. + * + * @author Brett Porter + */ +public class ArchivaConfigurationTest extends PlexusTestCase +{ + public void testDefaults() throws Exception + { + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-defaults" ); + + Configuration configuration = archivaConfiguration.getConfiguration(); + + // check default configuration + assertNotNull( "check configuration returned", configuration ); + assertTrue( "check configuration has default elements", configuration.getRepositories().isEmpty() ); + } + + public void testGetConfiguration() throws Exception + { + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); + + Configuration configuration = archivaConfiguration.getConfiguration(); + + assertEquals( "check repositories", 4, configuration.getRepositories().size() ); + assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() ); + assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); + assertEquals( "check file processors", 12, configuration.getFileProcessors().size() ); + + RepositoryConfiguration repository = + (RepositoryConfiguration) configuration.getRepositories().iterator().next(); + + assertEquals( "check managed repositories", "file://${appserver.home}/repositories/internal", repository.getUrl() ); + 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.isIndexed() ); + } + + public void testGetConfigurationSystemOverride() throws Exception + { + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); + + System.setProperty( "org.apache.maven.archiva.localRepository", "system-repository" ); + + Configuration configuration = archivaConfiguration.getConfiguration(); + + // assertEquals( "check localRepository", "system-repository", configuration.getLocalRepository() ); + // assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); + } + + public void testStoreConfiguration() throws Exception + { + File file = getTestFile( "target/test/test-file.xml" ); + file.delete(); + assertFalse( file.exists() ); + + // TODO: remove with commons-configuration 1.4 + file.getParentFile().mkdirs(); + org.codehaus.plexus.util.FileUtils.fileWrite( file.getAbsolutePath(), "" ); + + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save" ); + + Configuration configuration = new Configuration(); + // configuration.setIndexPath( "index-path" ); + + archivaConfiguration.save( configuration ); + + assertTrue( "Check file exists", file.exists() ); + + // check it + configuration = archivaConfiguration.getConfiguration(); + // assertEquals( "check value", "index-path", configuration.getIndexPath() ); + + // read it back + archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-saved" ); + configuration = archivaConfiguration.getConfiguration(); + // assertEquals( "check value", "index-path", configuration.getIndexPath() ); + } + + public void testStoreConfigurationUser() throws Exception + { + File baseFile = getTestFile( "target/test/test-file.xml" ); + baseFile.delete(); + assertFalse( baseFile.exists() ); + + File userFile = getTestFile( "target/test/test-file-user.xml" ); + userFile.delete(); + assertFalse( userFile.exists() ); + + // TODO: remove with commons-configuration 1.4 + userFile.getParentFile().mkdirs(); + org.codehaus.plexus.util.FileUtils.fileWrite( userFile.getAbsolutePath(), "" ); + + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); + + Configuration configuration = new Configuration(); + // configuration.setIndexPath( "index-path" ); + + archivaConfiguration.save( configuration ); + + assertTrue( "Check file exists", userFile.exists() ); + assertFalse( "Check file not created", baseFile.exists() ); + + // check it + configuration = archivaConfiguration.getConfiguration(); + // assertEquals( "check value", "index-path", configuration.getIndexPath() ); + } + + public void testStoreConfigurationFallback() throws Exception + { + File baseFile = getTestFile( "target/test/test-file.xml" ); + baseFile.delete(); + assertFalse( baseFile.exists() ); + + File userFile = getTestFile( "target/test/test-file-user.xml" ); + userFile.delete(); + assertFalse( userFile.exists() ); + + // TODO: remove with commons-configuration 1.4 + baseFile.getParentFile().mkdirs(); + org.codehaus.plexus.util.FileUtils.fileWrite( baseFile.getAbsolutePath(), "" ); + + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); + + Configuration configuration = new Configuration(); + // configuration.setIndexPath( "index-path" ); + + archivaConfiguration.save( configuration ); + + assertTrue( "Check file exists", baseFile.exists() ); + assertFalse( "Check file not created", userFile.exists() ); + + // check it + configuration = archivaConfiguration.getConfiguration(); + // assertEquals( "check value", "index-path", configuration.getIndexPath() ); + } + + public void testRemoveProxiedRepositoryAndStoreConfiguration() throws Exception + { + // MRM-300 + + File src = getTestFile( "src/test/conf/with-proxied-repos.xml" ); + File dest = getTestFile( "target/test/with-proxied-repos.xml" ); + FileUtils.copyFile( src, dest ); + + ArchivaConfiguration archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-remove-proxied-repo" ); + + Configuration configuration = archivaConfiguration.getConfiguration(); + // configuration.getProxiedRepositories().remove( 0 ); + + archivaConfiguration.save( configuration ); + + // check it + configuration = archivaConfiguration.getConfiguration(); + // assertEquals( 1, configuration.getProxiedRepositories().size() ); + + release( archivaConfiguration ); + + // read it back + archivaConfiguration = + (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-back-remove-proxied-repo" ); + configuration = archivaConfiguration.getConfiguration(); + // assertEquals( 1, configuration.getProxiedRepositories().size() ); + } +} diff --git a/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java b/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java new file mode 100644 index 000000000..091126087 --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java @@ -0,0 +1,96 @@ +package org.apache.maven.archiva.configuration; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.codehaus.plexus.PlexusTestCase; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Properties; + +/** + * @author Edwin Punzalan + */ +public class MavenProxyPropertyLoaderTest extends PlexusTestCase +{ + private MavenProxyPropertyLoader loader; + + public void testLoadValidMavenProxyConfiguration() throws IOException, InvalidConfigurationException + { + File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" ); + + Configuration configuration = new Configuration(); + ProxyConfiguration proxy = new ProxyConfiguration(); + proxy.setHost( "original-host" ); + configuration.addNetworkProxy( proxy ); // overwritten + + loader.load( new FileInputStream( confFile ), configuration ); + + List repos = configuration.getRepositories(); + assertEquals( "Count repositories", 5, repos.size() ); + + Map repositoryIdMap = new HashMap(); + + for ( Iterator itRepo = repos.iterator(); itRepo.hasNext(); ) + { + RepositoryConfiguration repo = (RepositoryConfiguration) itRepo.next(); + repositoryIdMap.put( repo.getId(), repo ); + } + + assertRepositoryExists( repositoryIdMap, "local-repo", "file://target" ); + + assertRepositoryExists( repositoryIdMap, "www-ibiblio-org", "http://www.ibiblio.org/maven2" ); + assertRepositoryExists( repositoryIdMap, "dist-codehaus-org", "http://dist.codehaus.org" ); + assertRepositoryExists( repositoryIdMap, "private-example-com", "http://private.example.com/internal" ); + } + + private void assertRepositoryExists( Map repoMap, String id, String expectedUrl ) + { + RepositoryConfiguration repo = (RepositoryConfiguration) repoMap.get( id ); + assertNotNull( "Repository id [" + id + "] should not be null", repo ); + assertEquals( "Repository id", id, repo.getId() ); + assertEquals( "Repository url", expectedUrl, repo.getUrl() ); + } + + public void testInvalidConfiguration() + { + Configuration configuration = new Configuration(); + try + { + loader.load( new Properties(), configuration ); + fail( "Incomplete config should have failed" ); + } + catch ( InvalidConfigurationException e ) + { + assertTrue( true ); + } + } + + protected void setUp() throws Exception + { + super.setUp(); + loader = new MavenProxyPropertyLoader(); + } +} diff --git a/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml b/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml new file mode 100644 index 000000000..00c6fceb1 --- /dev/null +++ b/archiva-base/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml @@ -0,0 +1,182 @@ + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-defaults + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + empty + + + + + org.codehaus.plexus.registry.Registry + empty + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-configuration + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + configured + + + + + org.codehaus.plexus.registry.Registry + configured + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-save + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + save + + + + + org.codehaus.plexus.registry.Registry + save + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-save-user + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + save-user + + + + + org.codehaus.plexus.registry.Registry + save-user + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-read-saved + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + read-saved + + + + + org.codehaus.plexus.registry.Registry + read-saved + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-remove-proxied-repo + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + read-remove-proxied-repo + + + + + org.codehaus.plexus.registry.Registry + read-remove-proxied-repo + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + org.apache.maven.archiva.configuration.ArchivaConfiguration + test-read-back-remove-proxied-repo + org.apache.maven.archiva.configuration.DefaultArchivaConfiguration + + + org.codehaus.plexus.registry.Registry + read-back-remove-proxied-repo + + + + + org.codehaus.plexus.registry.Registry + read-back-remove-proxied-repo + org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry + + + + + + + + diff --git a/archiva-base/archiva-converter/pom.xml b/archiva-base/archiva-converter/pom.xml new file mode 100644 index 000000000..a8fefa798 --- /dev/null +++ b/archiva-base/archiva-converter/pom.xml @@ -0,0 +1,83 @@ + + + + + + org.apache.maven.archiva + archiva + 1.0-SNAPSHOT + + 4.0.0 + archiva-converter + Archiva Repository Converter + + + org.apache.maven.archiva + archiva-consumer-api + + + org.apache.maven.archiva + archiva-discoverer + + + org.codehaus.plexus + plexus-utils + + + org.codehaus.plexus + plexus-component-api + + + org.apache.maven + maven-artifact + + + org.apache.maven.shared + maven-model-converter + + + org.codehaus.plexus + plexus-digest + + + org.codehaus.plexus + plexus-i18n + 1.0-beta-6 + + + commons-io + commons-io + + + + hsqldb + hsqldb + 1.7.3.3 + test + + + + org.codehaus.plexus + plexus-container-default + test + + + diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionEvent.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionEvent.java new file mode 100644 index 000000000..bd5ef5854 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionEvent.java @@ -0,0 +1,128 @@ +package org.apache.maven.archiva.converter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.converter.legacy.LegacyRepositoryConverter; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; + +/** + * ConversionEvent + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ConversionEvent +{ + public static final int STARTED = 0; + + public static final int PROCESSED = 1; + + public static final int WARNING = 2; + + public static final int ERROR = 3; + + public static final int FINISHED = 4; + + private int type; + + private String message; + + private Artifact artifact; + + private ArtifactRepository repository; + + private Exception exception; + + public ConversionEvent( ArtifactRepository repository, int type ) + { + this.repository = repository; + this.type = type; + } + + public ConversionEvent( ArtifactRepository repository, int type, Artifact artifact ) + { + this( repository, type ); + this.artifact = artifact; + } + + public ConversionEvent( ArtifactRepository repository, int type, Artifact artifact, String message ) + { + this( repository, type ); + this.artifact = artifact; + this.message = message; + } + + public ConversionEvent( ArtifactRepository repository, int type, Artifact artifact, Exception exception ) + { + this( repository, type ); + this.artifact = artifact; + this.exception = exception; + } + + public Artifact getArtifact() + { + return artifact; + } + + public Exception getException() + { + return exception; + } + + public String getMessage() + { + return message; + } + + public ArtifactRepository getRepository() + { + return repository; + } + + /** + *

+ * The type of event. + *

+ * + *

+ * Can be one of the following ... + *

+ * + *
    + *
  • {@link #STARTED} - the whole repository conversion process has started. + * only seen when using the whole repository conversion technique with the + * {@link LegacyRepositoryConverter#convertLegacyRepository(java.io.File, java.io.File, java.util.List, boolean)} + * method.
  • + *
  • {@link #PROCESSED} - a specific artifact has been processed.
  • + *
  • {@link #WARNING} - a warning has been detected for a specific artifact during the conversion process.
  • + *
  • {@link #ERROR} - an error in the processing of an artifact has been detected.
  • + *
  • {@link #FINISHED} - the whole repository conversion process has finished. + * only seen when using the whole repository conversion technique with the + * {@link LegacyRepositoryConverter#convertLegacyRepository(java.io.File, java.io.File, java.util.List, boolean)} + * method.
  • + *
+ * @return + */ + public int getType() + { + return type; + } +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionListener.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionListener.java new file mode 100644 index 000000000..3193bd475 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionListener.java @@ -0,0 +1,31 @@ +package org.apache.maven.archiva.converter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * ConversionListener + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public interface ConversionListener +{ + public void conversionEvent( ConversionEvent event ); +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java new file mode 100644 index 000000000..5b03d6f48 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java @@ -0,0 +1,741 @@ +package org.apache.maven.archiva.converter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.maven.archiva.converter.transaction.FileTransaction; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; +import org.apache.maven.artifact.repository.metadata.Snapshot; +import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; +import org.apache.maven.artifact.repository.metadata.Versioning; +import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; +import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer; +import org.apache.maven.model.DistributionManagement; +import org.apache.maven.model.Model; +import org.apache.maven.model.Relocation; +import org.apache.maven.model.converter.ModelConverter; +import org.apache.maven.model.converter.PomTranslationException; +import org.apache.maven.model.io.xpp3.MavenXpp3Writer; +import org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader; +import org.codehaus.plexus.digest.Digester; +import org.codehaus.plexus.digest.DigesterException; +import org.codehaus.plexus.i18n.I18N; +import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Properties; +import java.util.regex.Matcher; + +/** + * Implementation of repository conversion class. + * + * @author Brett Porter + * @plexus.component role="org.apache.maven.archiva.converter.RepositoryConverter" role-hint="default" + */ +public class DefaultRepositoryConverter + extends AbstractLogEnabled + implements RepositoryConverter +{ + /** + * {@link List}<{@link Digester}> + * + * @plexus.requirement role="org.codehaus.plexus.digest.Digester" + */ + private List digesters; + + /** + * @plexus.requirement + */ + private ArtifactFactory artifactFactory; + + /** + * @plexus.requirement + */ + private ModelConverter translator; + + /** + * @plexus.requirement + */ + private ArtifactHandlerManager artifactHandlerManager; + + /** + * @plexus.configuration default-value="false" + */ + private boolean force; + + /** + * @plexus.configuration default-value="false" + */ + private boolean dryrun; + + /** + * @plexus.requirement + */ + private I18N i18n; + + private List listeners = new ArrayList(); + + public void convert( Artifact artifact, ArtifactRepository targetRepository ) + throws RepositoryConversionException + { + if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) ) + { + throw new RepositoryConversionException( getI18NString( "exception.repositories.match" ) ); + } + + if ( validateMetadata( artifact ) ) + { + FileTransaction transaction = new FileTransaction(); + + if ( copyPom( artifact, targetRepository, transaction ) ) + { + if ( copyArtifact( artifact, targetRepository, transaction ) ) + { + Metadata metadata = createBaseMetadata( artifact ); + Versioning versioning = new Versioning(); + versioning.addVersion( artifact.getBaseVersion() ); + metadata.setVersioning( versioning ); + updateMetadata( new ArtifactRepositoryMetadata( artifact ), targetRepository, metadata, transaction ); + + metadata = createBaseMetadata( artifact ); + metadata.setVersion( artifact.getBaseVersion() ); + versioning = new Versioning(); + + Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( artifact.getVersion() ); + if ( matcher.matches() ) + { + Snapshot snapshot = new Snapshot(); + snapshot.setBuildNumber( Integer.valueOf( matcher.group( 3 ) ).intValue() ); + snapshot.setTimestamp( matcher.group( 2 ) ); + versioning.setSnapshot( snapshot ); + } + + // TODO: merge latest/release/snapshot from source instead + metadata.setVersioning( versioning ); + updateMetadata( new SnapshotArtifactRepositoryMetadata( artifact ), targetRepository, metadata, + transaction ); + + if ( !dryrun ) + { + transaction.commit(); + } + } + } + } + } + + private static Metadata createBaseMetadata( Artifact artifact ) + { + Metadata metadata = new Metadata(); + metadata.setArtifactId( artifact.getArtifactId() ); + metadata.setGroupId( artifact.getGroupId() ); + return metadata; + } + + private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository targetRepository, + Metadata newMetadata, FileTransaction transaction ) + throws RepositoryConversionException + { + File file = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + + Metadata metadata; + boolean changed; + + if ( file.exists() ) + { + metadata = readMetadata( file ); + changed = metadata.merge( newMetadata ); + } + else + { + changed = true; + metadata = newMetadata; + } + + if ( changed ) + { + StringWriter writer = null; + try + { + writer = new StringWriter(); + + MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer(); + + mappingWriter.write( writer, metadata ); + + transaction.createFile( writer.toString(), file, digesters ); + } + catch ( IOException e ) + { + throw new RepositoryConversionException( "Error writing target metadata", e ); + } + finally + { + IOUtils.closeQuietly( writer ); + } + } + } + + private Metadata readMetadata( File file ) + throws RepositoryConversionException + { + Metadata metadata; + MetadataXpp3Reader reader = new MetadataXpp3Reader(); + FileReader fileReader = null; + try + { + fileReader = new FileReader( file ); + metadata = reader.read( fileReader ); + } + catch ( FileNotFoundException e ) + { + throw new RepositoryConversionException( "Error reading target metadata", e ); + } + catch ( IOException e ) + { + throw new RepositoryConversionException( "Error reading target metadata", e ); + } + catch ( XmlPullParserException e ) + { + throw new RepositoryConversionException( "Error reading target metadata", e ); + } + finally + { + IOUtils.closeQuietly( fileReader ); + } + return metadata; + } + + private boolean validateMetadata( Artifact artifact ) + throws RepositoryConversionException + { + ArtifactRepository repository = artifact.getRepository(); + + boolean result = true; + + RepositoryMetadata repositoryMetadata = new ArtifactRepositoryMetadata( artifact ); + File file = new File( repository.getBasedir(), repository.pathOfRemoteRepositoryMetadata( repositoryMetadata ) ); + if ( file.exists() ) + { + Metadata metadata = readMetadata( file ); + result = validateMetadata( metadata, repositoryMetadata, artifact ); + } + + repositoryMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + file = new File( repository.getBasedir(), repository.pathOfRemoteRepositoryMetadata( repositoryMetadata ) ); + if ( file.exists() ) + { + Metadata metadata = readMetadata( file ); + result = result && validateMetadata( metadata, repositoryMetadata, artifact ); + } + + return result; + } + + private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact ) + { + String groupIdKey; + String artifactIdKey = null; + String snapshotKey = null; + String versionKey = null; + String versionsKey = null; + + if ( repositoryMetadata.storedInGroupDirectory() ) + { + groupIdKey = "failure.incorrect.groupMetadata.groupId"; + } + else if ( repositoryMetadata.storedInArtifactVersionDirectory() ) + { + groupIdKey = "failure.incorrect.snapshotMetadata.groupId"; + artifactIdKey = "failure.incorrect.snapshotMetadata.artifactId"; + versionKey = "failure.incorrect.snapshotMetadata.version"; + snapshotKey = "failure.incorrect.snapshotMetadata.snapshot"; + } + else + { + groupIdKey = "failure.incorrect.artifactMetadata.groupId"; + artifactIdKey = "failure.incorrect.artifactMetadata.artifactId"; + versionsKey = "failure.incorrect.artifactMetadata.versions"; + } + + boolean result = true; + + if ( metadata.getGroupId() == null || !metadata.getGroupId().equals( artifact.getGroupId() ) ) + { + addFailure( artifact, groupIdKey ); + result = false; + } + if ( !repositoryMetadata.storedInGroupDirectory() ) + { + if ( metadata.getGroupId() == null || !metadata.getArtifactId().equals( artifact.getArtifactId() ) ) + { + addFailure( artifact, artifactIdKey ); + result = false; + } + if ( !repositoryMetadata.storedInArtifactVersionDirectory() ) + { + // artifact metadata + + boolean foundVersion = false; + if ( metadata.getVersioning() != null ) + { + for ( Iterator i = metadata.getVersioning().getVersions().iterator(); i.hasNext() && !foundVersion; ) + { + String version = (String) i.next(); + if ( version.equals( artifact.getBaseVersion() ) ) + { + foundVersion = true; + } + } + } + + if ( !foundVersion ) + { + addFailure( artifact, versionsKey ); + result = false; + } + } + else + { + // snapshot metadata + if ( !artifact.getBaseVersion().equals( metadata.getVersion() ) ) + { + addFailure( artifact, versionKey ); + result = false; + } + + if ( artifact.isSnapshot() ) + { + Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( artifact.getVersion() ); + if ( matcher.matches() ) + { + boolean correct = false; + if ( metadata.getVersioning() != null && metadata.getVersioning().getSnapshot() != null ) + { + Snapshot snapshot = metadata.getVersioning().getSnapshot(); + int build = Integer.valueOf( matcher.group( 3 ) ).intValue(); + String ts = matcher.group( 2 ); + if ( build == snapshot.getBuildNumber() && ts.equals( snapshot.getTimestamp() ) ) + { + correct = true; + } + } + + if ( !correct ) + { + addFailure( artifact, snapshotKey ); + result = false; + } + } + } + } + } + return result; + } + + private void addFailure( Artifact artifact, String key ) + { + addFailureWithReason( artifact, getI18NString( key ) ); + } + + private void addWarning( Artifact artifact, String message ) + { + // TODO: should we be able to identify/fix these? + // TODO: write archiva-artifact-repair module + triggerConversionEvent( new ConversionEvent( artifact.getRepository(), ConversionEvent.WARNING, artifact, + message ) ); + } + + private void addFailureWithReason( Artifact artifact, String reason ) + { + // TODO: should we be able to identify/fix these? + triggerConversionEvent( new ConversionEvent( artifact.getRepository(), ConversionEvent.ERROR, artifact, reason ) ); + } + + private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction ) + throws RepositoryConversionException + { + Artifact pom = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact + .getVersion() ); + pom.setBaseVersion( artifact.getBaseVersion() ); + ArtifactRepository repository = artifact.getRepository(); + File file = new File( repository.getBasedir(), repository.pathOf( pom ) ); + + boolean result = true; + if ( file.exists() ) + { + File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pom ) ); + + String contents = null; + boolean checksumsValid = false; + try + { + if ( testChecksums( artifact, file ) ) + { + checksumsValid = true; + } + + // Even if the checksums for the POM are invalid we should still convert the POM + contents = FileUtils.readFileToString( file, null ); + } + catch ( IOException e ) + { + throw new RepositoryConversionException( "Unable to read source POM: " + e.getMessage(), e ); + } + + if ( checksumsValid && contents.indexOf( "modelVersion" ) >= 0 ) + { + // v4 POM + try + { + boolean matching = false; + if ( !force && targetFile.exists() ) + { + String targetContents = FileUtils.readFileToString( targetFile, null ); + matching = targetContents.equals( contents ); + } + if ( force || !matching ) + { + transaction.createFile( contents, targetFile, digesters ); + } + } + catch ( IOException e ) + { + throw new RepositoryConversionException( "Unable to write target POM: " + e.getMessage(), e ); + } + } + else + { + // v3 POM + StringReader stringReader = new StringReader( contents ); + StringWriter writer = null; + try + { + MavenXpp3Reader v3Reader = new MavenXpp3Reader(); + org.apache.maven.model.v3_0_0.Model v3Model = v3Reader.read( stringReader ); + + if ( doRelocation( artifact, v3Model, targetRepository, transaction ) ) + { + Artifact relocatedPom = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact + .getArtifactId(), artifact.getVersion() ); + targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( relocatedPom ) ); + } + + Model v4Model = translator.translate( v3Model ); + + translator.validateV4Basics( v4Model, v3Model.getGroupId(), v3Model.getArtifactId(), v3Model + .getVersion(), v3Model.getPackage() ); + + writer = new StringWriter(); + MavenXpp3Writer Xpp3Writer = new MavenXpp3Writer(); + Xpp3Writer.write( writer, v4Model ); + + transaction.createFile( writer.toString(), targetFile, digesters ); + + List warnings = translator.getWarnings(); + + for ( Iterator i = warnings.iterator(); i.hasNext(); ) + { + String message = (String) i.next(); + addWarning( artifact, message ); + } + } + catch ( XmlPullParserException e ) + { + addFailureWithReason( artifact, getI18NString( "failure.invalid.source.pom", e.getMessage() ) ); + result = false; + } + catch ( IOException e ) + { + throw new RepositoryConversionException( "Unable to write converted POM", e ); + } + catch ( PomTranslationException e ) + { + addFailureWithReason( artifact, getI18NString( "failure.invalid.source.pom", e.getMessage() ) ); + result = false; + } + finally + { + IOUtils.closeQuietly( writer ); + } + } + } + else + { + addWarning( artifact, getI18NString( "warning.missing.pom" ) ); + } + return result; + } + + private boolean doRelocation( Artifact artifact, org.apache.maven.model.v3_0_0.Model v3Model, + ArtifactRepository repository, FileTransaction transaction ) + throws IOException + { + Properties properties = v3Model.getProperties(); + if ( properties.containsKey( "relocated.groupId" ) || properties.containsKey( "relocated.artifactId" ) + || properties.containsKey( "relocated.version" ) ) + { + String newGroupId = properties.getProperty( "relocated.groupId", v3Model.getGroupId() ); + properties.remove( "relocated.groupId" ); + + String newArtifactId = properties.getProperty( "relocated.artifactId", v3Model.getArtifactId() ); + properties.remove( "relocated.artifactId" ); + + String newVersion = properties.getProperty( "relocated.version", v3Model.getVersion() ); + properties.remove( "relocated.version" ); + + String message = properties.getProperty( "relocated.message", "" ); + properties.remove( "relocated.message" ); + + if ( properties.isEmpty() ) + { + v3Model.setProperties( null ); + } + + writeRelocationPom( v3Model.getGroupId(), v3Model.getArtifactId(), v3Model.getVersion(), newGroupId, + newArtifactId, newVersion, message, repository, transaction ); + + v3Model.setGroupId( newGroupId ); + v3Model.setArtifactId( newArtifactId ); + v3Model.setVersion( newVersion ); + + artifact.setGroupId( newGroupId ); + artifact.setArtifactId( newArtifactId ); + artifact.setVersion( newVersion ); + + return true; + } + else + { + return false; + } + } + + private void writeRelocationPom( String groupId, String artifactId, String version, String newGroupId, + String newArtifactId, String newVersion, String message, + ArtifactRepository repository, FileTransaction transaction ) + throws IOException + { + Model pom = new Model(); + pom.setGroupId( groupId ); + pom.setArtifactId( artifactId ); + pom.setVersion( version ); + + DistributionManagement dMngt = new DistributionManagement(); + + Relocation relocation = new Relocation(); + relocation.setGroupId( newGroupId ); + relocation.setArtifactId( newArtifactId ); + relocation.setVersion( newVersion ); + if ( message != null && message.length() > 0 ) + { + relocation.setMessage( message ); + } + + dMngt.setRelocation( relocation ); + + pom.setDistributionManagement( dMngt ); + + Artifact artifact = artifactFactory.createBuildArtifact( groupId, artifactId, version, "pom" ); + File pomFile = new File( repository.getBasedir(), repository.pathOf( artifact ) ); + + StringWriter strWriter = new StringWriter(); + MavenXpp3Writer pomWriter = new MavenXpp3Writer(); + pomWriter.write( strWriter, pom ); + + transaction.createFile( strWriter.toString(), pomFile, digesters ); + } + + private String getI18NString( String key, String arg0 ) + { + return i18n.format( getClass().getName(), Locale.getDefault(), key, arg0 ); + } + + private String getI18NString( String key ) + { + return i18n.getString( getClass().getName(), Locale.getDefault(), key ); + } + + private boolean testChecksums( Artifact artifact, File file ) + throws IOException + { + boolean result = true; + Iterator it = digesters.iterator(); + while ( it.hasNext() ) + { + Digester digester = (Digester) it.next(); + result &= verifyChecksum( file, file.getName() + "." + getDigesterFileExtension( digester ), digester, + artifact, "failure.incorrect." + getDigesterFileExtension( digester ) ); + } + return result; + } + + /** + * File extension for checksums + * TODO should be moved to plexus-digester ? + */ + private String getDigesterFileExtension( Digester digester ) + { + return digester.getAlgorithm().toLowerCase().replaceAll( "-", "" ); + } + + private boolean verifyChecksum( File file, String fileName, Digester digester, Artifact artifact, String key ) + throws IOException + { + boolean result = true; + + File checksumFile = new File( file.getParentFile(), fileName ); + if ( checksumFile.exists() ) + { + String checksum = FileUtils.readFileToString( checksumFile, null ); + try + { + digester.verify( file, checksum ); + } + catch ( DigesterException e ) + { + addFailure( artifact, key ); + result = false; + } + } + return result; + } + + private boolean copyArtifact( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction ) + throws RepositoryConversionException + { + File sourceFile = artifact.getFile(); + + if ( sourceFile.getAbsolutePath().indexOf( "/plugins/" ) > -1 ) + { + artifact.setArtifactHandler( artifactHandlerManager.getArtifactHandler( "maven-plugin" ) ); + } + + File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + + boolean result = true; + try + { + boolean matching = false; + if ( !force && targetFile.exists() ) + { + matching = FileUtils.contentEquals( sourceFile, targetFile ); + if ( !matching ) + { + addFailure( artifact, "failure.target.already.exists" ); + result = false; + } + } + if ( result ) + { + if ( force || !matching ) + { + if ( testChecksums( artifact, sourceFile ) ) + { + transaction.copyFile( sourceFile, targetFile, digesters ); + } + else + { + result = false; + } + } + } + } + catch ( IOException e ) + { + throw new RepositoryConversionException( "Error copying artifact", e ); + } + return result; + } + + public void convert( List artifacts, ArtifactRepository targetRepository ) + throws RepositoryConversionException + { + for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + { + Artifact artifact = (Artifact) i.next(); + + try + { + convert( artifact, targetRepository ); + } + catch ( RepositoryConversionException e ) + { + triggerConversionEvent( new ConversionEvent( targetRepository, ConversionEvent.ERROR, artifact, e ) ); + } + } + } + + /** + * Add a listener to the conversion process. + * + * @param listener the listener to add. + */ + public void addConversionListener( ConversionListener listener ) + { + listeners.add( listener ); + } + + /** + * Remove a listener from the conversion process. + * + * @param listener the listener to remove. + */ + public void removeConversionListener( ConversionListener listener ) + { + listeners.remove( listener ); + } + + private void triggerConversionEvent( ConversionEvent event ) + { + Iterator it = listeners.iterator(); + while ( it.hasNext() ) + { + ConversionListener listener = (ConversionListener) it.next(); + + try + { + listener.conversionEvent( event ); + } + catch ( Throwable t ) + { + getLogger().warn( "ConversionEvent resulted in exception from listener: " + t.getMessage(), t ); + } + } + } +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConversionException.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConversionException.java new file mode 100644 index 000000000..cbc622d64 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConversionException.java @@ -0,0 +1,39 @@ +package org.apache.maven.archiva.converter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * Exception occuring during repository conversion. + * + * @author Brett Porter + */ +public class RepositoryConversionException + extends Exception +{ + public RepositoryConversionException( String message ) + { + super( message ); + } + + public RepositoryConversionException( String message, Throwable cause ) + { + super( message, cause ); + } +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java new file mode 100644 index 000000000..37c21fcce --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java @@ -0,0 +1,67 @@ +package org.apache.maven.archiva.converter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; + +import java.util.List; + +/** + * Copy a set of artifacts from one repository to the other, converting if necessary. + * + * @author Brett Porter + */ +public interface RepositoryConverter +{ + String ROLE = RepositoryConverter.class.getName(); + + /** + * Convert a single artifact, writing it into the target repository. + * + * @param artifact the artifact to convert + * @param targetRepository the target repository + */ + void convert( Artifact artifact, ArtifactRepository targetRepository ) + throws RepositoryConversionException; + + /** + * Convert a set of artifacts, writing them into the target repository. + * + * @param artifacts the set of artifacts to convert + * @param targetRepository the target repository + */ + void convert( List artifacts, ArtifactRepository targetRepository ) + throws RepositoryConversionException; + + /** + * Add a listener to the conversion process. + * + * @param listener the listener to add. + */ + void addConversionListener( ConversionListener listener ); + + /** + * Remove a listener from the conversion process. + * + * @param listener the listener to remove. + */ + void removeConversionListener( ConversionListener listener ); +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java new file mode 100644 index 000000000..abf303bcb --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java @@ -0,0 +1,139 @@ +package org.apache.maven.archiva.converter.legacy; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.converter.ConversionListener; +import org.apache.maven.archiva.converter.RepositoryConversionException; +import org.apache.maven.archiva.discoverer.Discoverer; +import org.apache.maven.archiva.discoverer.DiscovererException; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; + +import java.io.File; +import java.net.MalformedURLException; +import java.util.ArrayList; +import java.util.List; + +/** + * @author Jason van Zyl + * @plexus.component + * @todo turn this into a general conversion component and hide all this crap here. + * @todo it should be possible to move this to the converter module without causing it to gain additional dependencies + */ +public class DefaultLegacyRepositoryConverter + implements LegacyRepositoryConverter +{ + /** + * @plexus.requirement role-hint="legacy" + */ + private ArtifactRepositoryLayout legacyLayout; + + /** + * @plexus.requirement role-hint="default" + */ + private ArtifactRepositoryLayout defaultLayout; + + /** + * @plexus.requirement + */ + private ArtifactRepositoryFactory artifactRepositoryFactory; + + /** + * @plexus.requirement role-hint="default" + */ + private Discoverer discoverer; + + /** + * @plexus.requirement role="org.apache.maven.archiva.common.consumers.Consumer" role-hint="legacy-converter" + */ + private LegacyConverterArtifactConsumer legacyConverterConsumer; + + public void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory, + List fileExclusionPatterns, boolean includeSnapshots ) + throws RepositoryConversionException + { + ArtifactRepository legacyRepository; + + ArtifactRepository repository; + + try + { + String legacyRepositoryDir = legacyRepositoryDirectory.toURI().toURL().toString(); + String repositoryDir = repositoryDirectory.toURI().toURL().toString(); + + //workaround for spaces non converted by PathUtils in wagon + //TODO: remove it when PathUtils will be fixed + if ( legacyRepositoryDir.indexOf( "%20" ) >= 0 ) + { + legacyRepositoryDir = StringUtils.replace( legacyRepositoryDir, "%20", " " ); + } + if ( repositoryDir.indexOf( "%20" ) >= 0 ) + { + repositoryDir = StringUtils.replace( repositoryDir, "%20", " " ); + } + + legacyRepository = artifactRepositoryFactory.createArtifactRepository( "legacy", legacyRepositoryDir, + legacyLayout, null, null ); + + repository = artifactRepositoryFactory.createArtifactRepository( "default", repositoryDir, defaultLayout, + null, null ); + } + catch ( MalformedURLException e ) + { + throw new RepositoryConversionException( "Error convering legacy repository.", e ); + } + + try + { + List consumers = new ArrayList(); + legacyConverterConsumer.setDestinationRepository( repository ); + consumers.add( legacyConverterConsumer ); + + discoverer.walkRepository( legacyRepository, consumers, includeSnapshots ); + } + catch ( DiscovererException e ) + { + throw new RepositoryConversionException( + "Unable to convert repository due to discoverer error:" + e.getMessage(), e ); + } + } + + /** + * Add a listener to the conversion process. + * + * @param listener the listener to add. + */ + public void addConversionListener( ConversionListener listener ) + { + legacyConverterConsumer.addConversionListener( listener ); + } + + /** + * Remove a listener from the conversion process. + * + * @param listener the listener to remove. + */ + public void removeConversionListener( ConversionListener listener ) + { + legacyConverterConsumer.removeConversionListener( listener ); + } +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java new file mode 100644 index 000000000..03e9d47d0 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java @@ -0,0 +1,105 @@ +package org.apache.maven.archiva.converter.legacy; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.common.utils.BaseFile; +import org.apache.maven.archiva.consumers.GenericArtifactConsumer; +import org.apache.maven.archiva.converter.ConversionListener; +import org.apache.maven.archiva.converter.RepositoryConversionException; +import org.apache.maven.archiva.converter.RepositoryConverter; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; + +/** + * LegacyConverterArtifactConsumer - convert artifacts as they are found + * into the destination repository. + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="org.apache.maven.archiva.common.consumers.Consumers" + * role-hint="legacy-converter" + * instantiation-strategy="per-lookup" + */ +public class LegacyConverterArtifactConsumer + extends GenericArtifactConsumer +{ + /** + * @plexus.requirement + */ + private RepositoryConverter repositoryConverter; + + private ArtifactRepository destinationRepository; + + public void processArtifact( Artifact artifact, BaseFile file ) + { + try + { + repositoryConverter.convert( artifact, destinationRepository ); + } + catch ( RepositoryConversionException e ) + { + getLogger().error( + "Unable to convert artifact " + artifact + " to destination repository " + + destinationRepository, e ); + } + } + + public void processFileProblem( BaseFile path, String message ) + { + getLogger().error( "Artifact Build Failure on " + path + " : " + message ); + // TODO: report this to the ConversionListener? + } + + public ArtifactRepository getDestinationRepository() + { + return destinationRepository; + } + + public void setDestinationRepository( ArtifactRepository destinationRepository ) + { + this.destinationRepository = destinationRepository; + } + + public String getName() + { + return "Legacy Artifact Converter Consumer"; + } + + /** + * Add a listener to the conversion process. + * + * @param listener the listener to add. + */ + public void addConversionListener( ConversionListener listener ) + { + repositoryConverter.addConversionListener( listener ); + } + + /** + * Remove a listener from the conversion process. + * + * @param listener the listener to remove. + */ + public void removeConversionListener( ConversionListener listener ) + { + repositoryConverter.removeConversionListener( listener ); + } +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyRepositoryConverter.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyRepositoryConverter.java new file mode 100644 index 000000000..60d3d5599 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyRepositoryConverter.java @@ -0,0 +1,64 @@ +package org.apache.maven.archiva.converter.legacy; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.converter.ConversionListener; +import org.apache.maven.archiva.converter.RepositoryConversionException; + +import java.io.File; +import java.util.List; + +/** + * Convert an entire repository. + * + * @author Jason van Zyl + */ +public interface LegacyRepositoryConverter +{ + String ROLE = LegacyRepositoryConverter.class.getName(); + + /** + * Convert a legacy repository to a modern repository. This means a Maven 1.x repository + * using v3 POMs to a Maven 2.x repository using v4.0.0 POMs. + * + * @param legacyRepositoryDirectory the directory of the legacy repository. + * @param destinationRepositoryDirectory the directory of the modern repository. + * @param fileExclusionPatterns the list of patterns to exclude from the conversion. + * @param includeSnapshots true to include snapshots in conversion or not. + * @throws RepositoryConversionException + */ + void convertLegacyRepository( File legacyRepositoryDirectory, File destinationRepositoryDirectory, + List fileExclusionPatterns, boolean includeSnapshots ) + throws RepositoryConversionException; + + /** + * Add a listener to the conversion process. + * + * @param listener the listener to add. + */ + void addConversionListener( ConversionListener listener ); + + /** + * Remove a listener from the conversion process. + * + * @param listener the listener to remove. + */ + void removeConversionListener( ConversionListener listener ); +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/AbstractTransactionEvent.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/AbstractTransactionEvent.java new file mode 100644 index 000000000..10479ec62 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/AbstractTransactionEvent.java @@ -0,0 +1,225 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.FileUtils; +import org.codehaus.plexus.digest.Digester; +import org.codehaus.plexus.digest.DigesterException; +import org.codehaus.plexus.logging.AbstractLogEnabled; + +/** + * Abstract class for the TransactionEvents + * + * @author Edwin Punzalan + * @author Carlos Sanchez + * @version $Id$ + */ +public abstract class AbstractTransactionEvent + extends AbstractLogEnabled + implements TransactionEvent +{ + private Map backups = new HashMap();; + + private List createdDirs = new ArrayList(); + + private List createdFiles = new ArrayList(); + + /** {@link List}<{@link Digester}> */ + private List digesters; + + protected AbstractTransactionEvent() + { + this( new ArrayList( 0 ) ); + } + + protected AbstractTransactionEvent( List digesters ) + { + this.digesters = digesters; + } + + protected List getDigesters() + { + return digesters; + } + + /** + * Method that creates a directory as well as all the parent directories needed + * + * @param dir The File directory to be created + * @throws IOException when an unrecoverable error occurred + */ + protected void mkDirs( File dir ) + throws IOException + { + List createDirs = new ArrayList(); + + File parent = dir; + while ( !parent.exists() || !parent.isDirectory() ) + { + createDirs.add( parent ); + + parent = parent.getParentFile(); + } + + while ( !createDirs.isEmpty() ) + { + File directory = (File) createDirs.remove( createDirs.size() - 1 ); + + if ( directory.mkdir() ) + { + createdDirs.add( directory ); + } + else + { + throw new IOException( "Failed to create directory: " + directory.getAbsolutePath() ); + } + } + } + + protected void revertMkDirs() + throws IOException + { + if ( createdDirs != null ) + { + Collections.reverse( createdDirs ); + + while ( !createdDirs.isEmpty() ) + { + File dir = (File) createdDirs.remove( 0 ); + + if ( dir.isDirectory() && dir.list().length == 0 ) + { + FileUtils.deleteDirectory( dir ); + } + else + { + //cannot rollback created directory if it still contains files + break; + } + } + } + } + + protected void revertFilesCreated() + throws IOException + { + Iterator it = createdFiles.iterator(); + while ( it.hasNext() ) + { + File file = (File) it.next(); + file.delete(); + it.remove(); + } + } + + protected void createBackup( File file ) + throws IOException + { + if ( file.exists() && file.isFile() ) + { + File backup = File.createTempFile( "temp-", ".backup" ); + + FileUtils.copyFile( file, backup ); + + backup.deleteOnExit(); + + backups.put( file, backup ); + } + } + + protected void restoreBackups() + throws IOException + { + Iterator it = backups.entrySet().iterator(); + while ( it.hasNext() ) + { + Map.Entry entry = (Map.Entry) it.next(); + FileUtils.copyFile( (File) entry.getValue(), (File) entry.getKey() ); + } + } + + protected void restoreBackup( File file ) + throws IOException + { + File backup = (File) backups.get( file ); + if ( backup != null ) + { + FileUtils.copyFile( backup, file ); + } + } + + /** + * Create checksums of file using all digesters defined at construction time. + * + * @param file + * @param force whether existing checksums should be overwritten or not + * @throws IOException + */ + protected void createChecksums( File file, boolean force ) + throws IOException + { + Iterator it = getDigesters().iterator(); + while ( it.hasNext() ) + { + Digester digester = (Digester) it.next(); + File checksumFile = new File( file.getAbsolutePath() + "." + getDigesterFileExtension( digester ) ); + if ( checksumFile.exists() ) + { + if ( !force ) + { + continue; + } + createBackup( checksumFile ); + } + else + { + createdFiles.add( checksumFile ); + } + try + { + FileUtils.writeStringToFile( checksumFile, digester.calc( file ), null ); + } + catch ( DigesterException e ) + { + // the Digester API just wraps IOException and should be fixed + throw (IOException) e.getCause(); + } + } + } + + /** + * File extension for checksums + * TODO should be moved to plexus-digester ? + */ + protected String getDigesterFileExtension( Digester digester ) + { + return digester.getAlgorithm().toLowerCase().replaceAll( "-", "" ); + } + +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CopyFileEvent.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CopyFileEvent.java new file mode 100644 index 000000000..96cc72d07 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CopyFileEvent.java @@ -0,0 +1,133 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.codehaus.plexus.digest.Digester; + +/** + * Event to copy a file. + * + * @author Brett Porter + * @author Carlos Sanchez + * @version $Id$ + */ +public class CopyFileEvent + extends AbstractTransactionEvent +{ + private final File source; + + private final File destination; + + /** + * Creates a copy file event with no digesters + * + * @deprecated use other constructors + * + * @param source + * @param destination + */ + public CopyFileEvent( File source, File destination ) + { + this( source, destination, new ArrayList( 0 ) ); + } + + /** + * + * @param source + * @param destination + * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming + */ + public CopyFileEvent( File source, File destination, List digesters ) + { + super( digesters ); + this.source = source; + this.destination = destination; + } + + public void commit() + throws IOException + { + createBackup( destination ); + + mkDirs( destination.getParentFile() ); + + FileUtils.copyFile( source, destination ); + + createChecksums( destination, true ); + copyChecksums(); + + copyChecksum( "asc" ); + } + + /** + * Copy checksums of source file with all digesters if exist + * + * @throws IOException + */ + private void copyChecksums() + throws IOException + { + Iterator it = getDigesters().iterator(); + while ( it.hasNext() ) + { + Digester digester = (Digester) it.next(); + copyChecksum( getDigesterFileExtension( digester ) ); + } + } + + /** + * Copy checksum of source file with extension provided if exists + * + * @param extension + * @return whether the checksum exists or not + * @throws IOException + */ + private boolean copyChecksum( String extension ) + throws IOException + { + File checksumSource = new File( source.getAbsolutePath() + "." + extension ); + if ( checksumSource.exists() ) + { + File checksumDestination = new File( destination.getAbsolutePath() + "." + extension ); + FileUtils.copyFile( checksumSource, checksumDestination ); + return true; + } + return false; + } + + public void rollback() + throws IOException + { + destination.delete(); + + revertFilesCreated(); + + revertMkDirs(); + + restoreBackups(); + } +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CreateFileEvent.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CreateFileEvent.java new file mode 100644 index 000000000..d8c567997 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CreateFileEvent.java @@ -0,0 +1,98 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.codehaus.plexus.digest.Digester; + +/** + * Event for creating a file from a string content. + * + * @author Brett Porter + * @author Carlos Sanchez + * @version $Id$ + */ +public class CreateFileEvent + extends AbstractTransactionEvent +{ + private final File destination; + + private final String content; + + /** + * Creates a create file event with no digesters + * + * @deprecated use other constructors + * + * @param content + * @param destination + */ + public CreateFileEvent( String content, File destination ) + { + this( content, destination, new ArrayList( 0 ) ); + } + + /** + * + * @param content + * @param destination + * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming + */ + public CreateFileEvent( String content, File destination, List digesters ) + { + super( digesters ); + this.content = content; + this.destination = destination; + } + + public void commit() + throws IOException + { + createBackup( destination ); + + mkDirs( destination.getParentFile() ); + + if ( !destination.exists() && !destination.createNewFile() ) + { + throw new IOException( "Unable to create new file" ); + } + + FileUtils.writeStringToFile( destination, content, null ); + + createChecksums( destination, true ); + } + + public void rollback() + throws IOException + { + destination.delete(); + + revertFilesCreated(); + + revertMkDirs(); + + restoreBackups(); + } +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/FileTransaction.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/FileTransaction.java new file mode 100644 index 000000000..f1c668ab5 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/FileTransaction.java @@ -0,0 +1,126 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.converter.RepositoryConversionException; +import org.codehaus.plexus.digest.Digester; + +import java.io.File; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +/** + * Implement commit/rollback semantics for a set of files. + * + * @author Brett Porter + */ +public class FileTransaction +{ + private List events = new ArrayList(); + + public void commit() + throws RepositoryConversionException + { + List toRollback = new ArrayList( events.size() ); + + for ( Iterator i = events.iterator(); i.hasNext(); ) + { + TransactionEvent event = (TransactionEvent) i.next(); + + try + { + event.commit(); + + toRollback.add( event ); + } + catch ( IOException e ) + { + try + { + rollback( toRollback ); + + throw new RepositoryConversionException( "Unable to commit file transaction", e ); + } + catch ( IOException ioe ) + { + throw new RepositoryConversionException( + "Unable to commit file transaction, and rollback failed with error: '" + ioe.getMessage() + "'", + e ); + } + } + } + } + + private void rollback( List toRollback ) + throws IOException + { + for ( Iterator i = toRollback.iterator(); i.hasNext(); ) + { + TransactionEvent event = (TransactionEvent) i.next(); + + event.rollback(); + } + } + + /** + * @deprecated use {@link #copyFile(File, File, List)} + * @param source + * @param destination + */ + public void copyFile( File source, File destination ) + { + copyFile( source, destination, Collections.EMPTY_LIST ); + } + + /** + * + * @param source + * @param destination + * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming + */ + public void copyFile( File source, File destination, List digesters ) + { + events.add( new CopyFileEvent( source, destination, digesters ) ); + } + + /** + * @deprecated use {@link #createFile(String, File, List)} + * @param content + * @param destination + */ + public void createFile( String content, File destination ) + { + createFile( content, destination, Collections.EMPTY_LIST ); + } + + /** + * + * @param content + * @param destination + * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming + */ + public void createFile( String content, File destination, List digesters ) + { + events.add( new CreateFileEvent( content, destination, digesters ) ); + } +} diff --git a/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/TransactionEvent.java b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/TransactionEvent.java new file mode 100644 index 000000000..eda17fc04 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/TransactionEvent.java @@ -0,0 +1,46 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.IOException; + +/** + * Interface for individual events in a transaction. + * + * @author Brett Porter + */ +public interface TransactionEvent +{ + /** + * Commit this event. + * + * @throws IOException if an error occurred committing the change + */ + void commit() + throws IOException; + + /** + * Rollback the even already committed. + * + * @throws IOException if an error occurred reverting the change + */ + void rollback() + throws IOException; +} diff --git a/archiva-base/archiva-converter/src/main/resources/org/apache/maven/archiva/converter/DefaultRepositoryConverter.properties b/archiva-base/archiva-converter/src/main/resources/org/apache/maven/archiva/converter/DefaultRepositoryConverter.properties new file mode 100644 index 000000000..8589df468 --- /dev/null +++ b/archiva-base/archiva-converter/src/main/resources/org/apache/maven/archiva/converter/DefaultRepositoryConverter.properties @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +failure.incorrect.md5=The MD5 checksum value was incorrect. +failure.incorrect.sha1=The SHA1 checksum value was incorrect. +failure.target.already.exists=The artifact could not be converted because it already exists. +failure.invalid.source.pom=The source POM was invalid: {0}. + +warning.missing.pom=The artifact had no POM in the source repository. + +exception.repositories.match=Source and target repositories are identical. + +failure.incorrect.groupMetadata.groupId=The group ID in the source group metadata is incorrect. + +failure.incorrect.artifactMetadata.artifactId=The artifact ID in the source artifact metadata is incorrect. +failure.incorrect.artifactMetadata.groupId=The group ID in the source artifact metadata is incorrect. +failure.incorrect.artifactMetadata.versions=The version list in the source artifact metadata is incorrect. + +failure.incorrect.snapshotMetadata.artifactId=The artifact ID in the source artifact version metadata is incorrect. +failure.incorrect.snapshotMetadata.groupId=The group ID in the source artifact version metadata is incorrect. +failure.incorrect.snapshotMetadata.version=The version in the source artifact version metadata is incorrect. +failure.incorrect.snapshotMetadata.snapshot=The snapshot information in the source artifact version metadata is incorrect. diff --git a/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-one.pom b/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-one.pom new file mode 100644 index 000000000..cd3862d35 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-one.pom @@ -0,0 +1,6 @@ + + 4.0.0 + test + artifact-one + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-three.pom b/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-three.pom new file mode 100644 index 000000000..343291037 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-three.pom @@ -0,0 +1,6 @@ + + 4.0.0 + test + artifact-three + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-two.pom b/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-two.pom new file mode 100644 index 000000000..227470167 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/converted-artifact-two.pom @@ -0,0 +1,6 @@ + + 4.0.0 + test + artifact-two + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/expected-files/converted-v3-snapshot.pom b/archiva-base/archiva-converter/src/test/expected-files/converted-v3-snapshot.pom new file mode 100644 index 000000000..1615b6663 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/converted-v3-snapshot.pom @@ -0,0 +1,28 @@ + + 4.0.0 + test + v3artifact + 1.0.0-SNAPSHOT + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + + + groupId + artifactId + version + + + groupId + test-artifactId + version + test + + + junit + junit + 3.8.2 + test + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/converted-v3-timestamped-snapshot.pom b/archiva-base/archiva-converter/src/test/expected-files/converted-v3-timestamped-snapshot.pom new file mode 100644 index 000000000..94307d863 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/converted-v3-timestamped-snapshot.pom @@ -0,0 +1,28 @@ + + 4.0.0 + test + v3artifact + 1.0.0-20060105.130101-3 + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + + + groupId + artifactId + version + + + groupId + test-artifactId + version + test + + + junit + junit + 3.8.2 + test + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/converted-v3-warnings.pom b/archiva-base/archiva-converter/src/test/expected-files/converted-v3-warnings.pom new file mode 100644 index 000000000..25f4e76d0 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/converted-v3-warnings.pom @@ -0,0 +1,28 @@ + + 4.0.0 + test + v3-warnings-artifact + 1.0.0 + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + + + groupId + artifactId + version + + + groupId + test-artifactId + version + test + + + junit + junit + 3.8.2 + test + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/converted-v3.pom b/archiva-base/archiva-converter/src/test/expected-files/converted-v3.pom new file mode 100644 index 000000000..9f8b63e16 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/converted-v3.pom @@ -0,0 +1,28 @@ + + 4.0.0 + test + v3artifact + 1.0.0 + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + + + groupId + artifactId + version + + + groupId + test-artifactId + version + test + + + junit + junit + 3.8.2 + test + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/maven-foo-plugin-1.0.pom b/archiva-base/archiva-converter/src/test/expected-files/maven-foo-plugin-1.0.pom new file mode 100644 index 000000000..17095cc57 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/maven-foo-plugin-1.0.pom @@ -0,0 +1,7 @@ + + 4.0.0 + org.apache.maven.plugins + maven-foo-plugin + 1.0.0 + maven-plugin + diff --git a/archiva-base/archiva-converter/src/test/expected-files/newversion-artifact-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/newversion-artifact-metadata.xml new file mode 100644 index 000000000..ecc7f09a0 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/newversion-artifact-metadata.xml @@ -0,0 +1,10 @@ + + test + newversion-artifact + + + 1.0.0 + 1.0.1 + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/maven-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/maven-metadata.xml new file mode 100644 index 000000000..ebd9be970 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/maven-metadata.xml @@ -0,0 +1,6 @@ + + relocated-test + relocated-v3artifact + 1.0.0 + + \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom new file mode 100644 index 000000000..0180549f0 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom @@ -0,0 +1,28 @@ + + 4.0.0 + relocated-test + relocated-v3artifact + 1.0.0 + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + + + groupId + artifactId + version + + + groupId + test-artifactId + version + test + + + junit + junit + 3.8.2 + test + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/maven-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/maven-metadata.xml new file mode 100644 index 000000000..b4b1a864a --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/maven-metadata.xml @@ -0,0 +1,9 @@ + + relocated-test + relocated-v3artifact + + + 1.0.0 + + + \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/expected-files/test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/expected-files/test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom new file mode 100644 index 000000000..b20f62f9e --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom @@ -0,0 +1,12 @@ + + test + relocated-v3artifact + 1.0.0 + + + relocated-test + relocated-v3artifact + 1.0.0 + + + \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/expected-files/v3-artifact-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v3-artifact-metadata.xml new file mode 100644 index 000000000..a8a7f3748 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v3-artifact-metadata.xml @@ -0,0 +1,9 @@ + + test + v3artifact + + + 1.0.0 + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v3-snapshot-artifact-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v3-snapshot-artifact-metadata.xml new file mode 100644 index 000000000..24d25a0e0 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v3-snapshot-artifact-metadata.xml @@ -0,0 +1,9 @@ + + test + v3artifact + + + 1.0.0-SNAPSHOT + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v3-snapshot-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v3-snapshot-metadata.xml new file mode 100644 index 000000000..b19c537b5 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v3-snapshot-metadata.xml @@ -0,0 +1,6 @@ + + test + v3artifact + 1.0.0-SNAPSHOT + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v3-timestamped-snapshot-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v3-timestamped-snapshot-metadata.xml new file mode 100644 index 000000000..602c38ec8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v3-timestamped-snapshot-metadata.xml @@ -0,0 +1,11 @@ + + test + v3artifact + 1.0.0-SNAPSHOT + + + 20060105.130101 + 3 + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v3-version-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v3-version-metadata.xml new file mode 100644 index 000000000..3c8938984 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v3-version-metadata.xml @@ -0,0 +1,6 @@ + + test + v3artifact + 1.0.0 + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v4-artifact-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v4-artifact-metadata.xml new file mode 100644 index 000000000..c0cdbfdb4 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v4-artifact-metadata.xml @@ -0,0 +1,9 @@ + + test + v4artifact + + + 1.0.0 + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v4-snapshot-artifact-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v4-snapshot-artifact-metadata.xml new file mode 100644 index 000000000..f8072b0df --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v4-snapshot-artifact-metadata.xml @@ -0,0 +1,9 @@ + + test + v4artifact + + + 1.0.0-SNAPSHOT + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v4-snapshot-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v4-snapshot-metadata.xml new file mode 100644 index 000000000..d5ecb7d47 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v4-snapshot-metadata.xml @@ -0,0 +1,6 @@ + + test + v4artifact + 1.0.0-SNAPSHOT + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v4-timestamped-snapshot-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v4-timestamped-snapshot-metadata.xml new file mode 100644 index 000000000..060a79cdd --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v4-timestamped-snapshot-metadata.xml @@ -0,0 +1,11 @@ + + test + v4artifact + 1.0.0-SNAPSHOT + + + 20060111.120115 + 1 + + + diff --git a/archiva-base/archiva-converter/src/test/expected-files/v4-version-metadata.xml b/archiva-base/archiva-converter/src/test/expected-files/v4-version-metadata.xml new file mode 100644 index 000000000..7cbd8ad3d --- /dev/null +++ b/archiva-base/archiva-converter/src/test/expected-files/v4-version-metadata.xml @@ -0,0 +1,6 @@ + + test + v4artifact + 1.0.0 + + diff --git a/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/AllTests.java b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/AllTests.java new file mode 100644 index 000000000..dbd54f604 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva.converter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.converter" ); + //$JUnit-BEGIN$ + suite.addTest( org.apache.maven.archiva.converter.transaction.AllTests.suite() ); + suite.addTestSuite( RepositoryConverterTest.class ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/MockConversionListener.java b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/MockConversionListener.java new file mode 100644 index 000000000..92b70069b --- /dev/null +++ b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/MockConversionListener.java @@ -0,0 +1,163 @@ +package org.apache.maven.archiva.converter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.artifact.Artifact; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * MockConversionListener + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class MockConversionListener + implements ConversionListener +{ + private Map warnings = new HashMap(); + + private Map errors = new HashMap(); + + private Map exceptions = new HashMap(); + + private List processed = new ArrayList(); + + private List repositories = new ArrayList(); + + public void conversionEvent( ConversionEvent event ) + { + switch ( event.getType() ) + { + case ConversionEvent.STARTED: + addUnique( repositories, event.getRepository() ); + break; + case ConversionEvent.PROCESSED: + addUnique( processed, event.getArtifact() ); + break; + case ConversionEvent.WARNING: + if ( event.getException() != null ) + { + addObjectList( exceptions, toKey( event.getArtifact() ), event.getException() ); + } + + if ( event.getMessage() != null ) + { + addObjectList( warnings, toKey( event.getArtifact() ), event.getMessage() ); + } + break; + case ConversionEvent.ERROR: + if ( event.getException() != null ) + { + addObjectList( exceptions, toKey( event.getArtifact() ), event.getException() ); + } + + if ( event.getMessage() != null ) + { + addObjectList( errors, toKey( event.getArtifact() ), event.getMessage() ); + } + break; + case ConversionEvent.FINISHED: + addUnique( repositories, event.getRepository() ); + break; + } + } + + public String toKey( Artifact artifact ) + { + return StringUtils.defaultString( artifact.getGroupId() ) + ":" + + StringUtils.defaultString( artifact.getArtifactId() ) + ":" + + StringUtils.defaultString( artifact.getVersion() ) + ":" + StringUtils.defaultString( artifact.getType() ) + + ":" + StringUtils.defaultString( artifact.getClassifier() ); + } + + private void addObjectList( Map map, String key, Object value ) + { + List objlist = (List) map.get( key ); + if ( objlist == null ) + { + objlist = new ArrayList(); + } + + objlist.add( value ); + + map.put( key, objlist ); + } + + private void addUnique( Collection collection, Object obj ) + { + if ( !collection.contains( obj ) ) + { + collection.add( obj ); + } + } + + public Map getErrors() + { + return errors; + } + + public Map getExceptions() + { + return exceptions; + } + + public List getProcessed() + { + return processed; + } + + public List getRepositories() + { + return repositories; + } + + public Map getWarnings() + { + return warnings; + } + + private int getObjectListCount( Map map ) + { + int count = 0; + for ( Iterator it = map.values().iterator(); it.hasNext(); ) + { + List objList = (List) it.next(); + count += objList.size(); + } + return count; + } + + public int getWarningMessageCount() + { + return getObjectListCount( warnings ); + } + + public int getErrorMessageCount() + { + return getObjectListCount( errors ); + } +} diff --git a/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java new file mode 100644 index 000000000..8e0c676e3 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java @@ -0,0 +1,1088 @@ +package org.apache.maven.archiva.converter; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.io.FileUtils; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.metadata.ArtifactMetadata; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; +import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.i18n.I18N; + +import java.io.File; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Map.Entry; +import java.util.regex.Matcher; + +/** + * Test the repository converter. + * + * @author Brett Porter + * @todo what about deletions from the source repository? + * @todo use artifact-test instead + * @todo should reject if dependencies are missing - rely on reporting? + * @todo group metadata + */ +public class RepositoryConverterTest + extends PlexusTestCase +{ + private ArtifactRepository sourceRepository; + + private ArtifactRepository targetRepository; + + private RepositoryConverter repositoryConverter; + + private ArtifactFactory artifactFactory; + + private static final int SLEEP_MILLIS = 100; + + private I18N i18n; + + protected void setUp() + throws Exception + { + super.setUp(); + + ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); + + ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); + + File sourceBase = getTestFile( "src/test/source-repository" ); + sourceRepository = factory.createArtifactRepository( "source", sourceBase.toURL().toString(), layout, null, + null ); + + layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); + + File targetBase = getTestFile( "target/test-target-repository" ); + copyDirectoryStructure( getTestFile( "src/test/target-repository" ), targetBase ); + + targetRepository = factory.createArtifactRepository( "target", targetBase.toURL().toString(), layout, null, + null ); + + repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "default" ); + + artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + + i18n = (I18N) lookup( I18N.ROLE ); + } + + protected void tearDown() + throws Exception + { + super.tearDown(); + } + + private void copyDirectoryStructure( File sourceDirectory, File destinationDirectory ) + throws IOException + { + if ( !sourceDirectory.exists() ) + { + throw new IOException( "Source directory doesn't exists (" + sourceDirectory.getAbsolutePath() + ")." ); + } + + File[] files = sourceDirectory.listFiles(); + + String sourcePath = sourceDirectory.getAbsolutePath(); + + for ( int i = 0; i < files.length; i++ ) + { + File file = files[i]; + + String dest = file.getAbsolutePath(); + + dest = dest.substring( sourcePath.length() + 1 ); + + File destination = new File( destinationDirectory, dest ); + + if ( file.isFile() ) + { + destination = destination.getParentFile(); + + FileUtils.copyFileToDirectory( file, destination ); + } + else if ( file.isDirectory() ) + { + if ( !".svn".equals( file.getName() ) ) + { + if ( !destination.exists() && !destination.mkdirs() ) + { + throw new IOException( "Could not create destination directory '" + + destination.getAbsolutePath() + "'." ); + } + copyDirectoryStructure( file, destination ); + } + } + else + { + throw new IOException( "Unknown file type: " + file.getAbsolutePath() ); + } + } + } + + public void testV4PomConvert() + throws IOException, RepositoryConversionException + { + // test that it is copied as is + + Artifact artifact = createArtifact( "test", "v4artifact", "1.0.0" ); + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + artifactMetadataFile.delete(); + + ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( versionMetadata ) ); + versionMetadataFile.delete(); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + artifactFile.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkSuccess(listener); + + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + assertTrue( "Check POM created", pomFile.exists() ); + + compareFiles( sourcePomFile, pomFile ); + + assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); + + File expectedMetadataFile = getTestFile( "src/test/expected-files/v4-artifact-metadata.xml" ); + + compareFiles( expectedMetadataFile, artifactMetadataFile ); + + assertTrue( "Check snapshot metadata created", versionMetadataFile.exists() ); + + expectedMetadataFile = getTestFile( "src/test/expected-files/v4-version-metadata.xml" ); + + compareFiles( expectedMetadataFile, versionMetadataFile ); + } + + public void testV3PomConvert() + throws IOException, RepositoryConversionException + { + // test that the pom is coverted + + Artifact artifact = createArtifact( "test", "v3artifact", "1.0.0" ); + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + artifactMetadataFile.delete(); + + ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( versionMetadata ) ); + versionMetadataFile.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkSuccess(listener); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3.pom" ); + assertTrue( "Check POM created", pomFile.exists() ); + + compareFiles( expectedPomFile, pomFile ); + + assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); + + File expectedMetadataFile = getTestFile( "src/test/expected-files/v3-artifact-metadata.xml" ); + + compareFiles( expectedMetadataFile, artifactMetadataFile ); + + assertTrue( "Check snapshot metadata created", versionMetadataFile.exists() ); + + expectedMetadataFile = getTestFile( "src/test/expected-files/v3-version-metadata.xml" ); + + compareFiles( expectedMetadataFile, versionMetadataFile ); + } + + public void testV3PomConvertWithRelocation() + throws RepositoryConversionException, IOException + { + Artifact artifact = createArtifact( "test", "relocated-v3artifact", "1.0.0" ); + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + artifactMetadataFile.delete(); + + ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( versionMetadata ) ); + versionMetadataFile.delete(); + + repositoryConverter.convert( artifact, targetRepository ); + //checkSuccess(); --> commented until MNG-2100 is fixed + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check if relocated artifact created", artifactFile.exists() ); + assertTrue( "Check if relocated artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + Artifact pomArtifact = createArtifact( "relocated-test", "relocated-v3artifact", "1.0.0", "1.0.0", "pom" ); + File pomFile = getTestFile( "src/test/expected-files/" + targetRepository.pathOf( pomArtifact ) ); + File testFile = getTestFile( "target/test-target-repository/" + targetRepository.pathOf( pomArtifact ) ); + compareFiles( pomFile, testFile ); + + Artifact orig = createArtifact( "test", "relocated-v3artifact", "1.0.0", "1.0.0", "pom" ); + artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( orig ) ); + assertTrue( "Check if relocation artifact pom is created", artifactFile.exists() ); + testFile = getTestFile( "src/test/expected-files/" + targetRepository.pathOf( orig ) ); + compareFiles( artifactFile, testFile ); + } + + public void testV3PomWarningsOnConvert() + throws RepositoryConversionException, IOException + { + // test that the pom is converted but that warnings are reported + + Artifact artifact = createArtifact( "test", "v3-warnings-artifact", "1.0.0" ); + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + artifactMetadataFile.delete(); + + ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( versionMetadata ) ); + versionMetadataFile.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 0, 2 ); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3-warnings.pom" ); + assertTrue( "Check POM created", pomFile.exists() ); + + compareFiles( expectedPomFile, pomFile ); + + // TODO: check 2 warnings (extend and versions) matched on i18n key + } + + private void doTestV4SnapshotPomConvert( String version, String expectedMetadataFileName ) + throws RepositoryConversionException, IOException + { + // test that it is copied as is + + Artifact artifact = createArtifact( "test", "v4artifact", version ); + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + artifactMetadataFile.delete(); + + ArtifactMetadata snapshotMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + File snapshotMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( snapshotMetadata ) ); + snapshotMetadataFile.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 0, 0 ); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + assertTrue( "Check POM created", pomFile.exists() ); + + compareFiles( sourcePomFile, pomFile ); + + assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); + + File expectedMetadataFile = getTestFile( "src/test/expected-files/v4-snapshot-artifact-metadata.xml" ); + + compareFiles( expectedMetadataFile, artifactMetadataFile ); + + assertTrue( "Check snapshot metadata created", snapshotMetadataFile.exists() ); + + expectedMetadataFile = getTestFile( expectedMetadataFileName ); + + compareFiles( expectedMetadataFile, snapshotMetadataFile ); + } + + public void testV3SnapshotPomConvert() + throws IOException, RepositoryConversionException + { + // test that the pom is coverted + + Artifact artifact = createArtifact( "test", "v3artifact", "1.0.0-SNAPSHOT" ); + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + artifactMetadataFile.delete(); + + ArtifactMetadata snapshotMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + File snapshotMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( snapshotMetadata ) ); + snapshotMetadataFile.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 0, 0 ); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3-snapshot.pom" ); + assertTrue( "Check POM created", pomFile.exists() ); + + compareFiles( expectedPomFile, pomFile ); + + assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); + + File expectedMetadataFile = getTestFile( "src/test/expected-files/v3-snapshot-artifact-metadata.xml" ); + + compareFiles( expectedMetadataFile, artifactMetadataFile ); + + assertTrue( "Check snapshot metadata created", snapshotMetadataFile.exists() ); + + expectedMetadataFile = getTestFile( "src/test/expected-files/v3-snapshot-metadata.xml" ); + + compareFiles( expectedMetadataFile, snapshotMetadataFile ); + } + + public void testV4SnapshotPomConvert() + throws IOException, RepositoryConversionException + { + doTestV4SnapshotPomConvert( "1.0.0-SNAPSHOT", "src/test/expected-files/v4-snapshot-metadata.xml" ); + + assertTrue( true ); + } + + public void testV4TimestampedSnapshotPomConvert() + throws IOException, RepositoryConversionException + { + doTestV4SnapshotPomConvert( "1.0.0-20060111.120115-1", + "src/test/expected-files/v4-timestamped-snapshot-metadata.xml" ); + + assertTrue( true ); + } + + public void testMavenOnePluginConversion() + throws Exception + { + Artifact artifact = createArtifact( "org.apache.maven.plugins", "maven-foo-plugin", "1.0", "1.0", + "maven-plugin" ); + artifact.setFile( new File( getBasedir(), "src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar" ) ); + repositoryConverter.convert( artifact, targetRepository ); + // There is a warning but I can't figure out how to look at it. Eyeballing the results it appears + // the plugin is being coverted correctly. + //checkSuccess(); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + /* + The POM isn't needed for Maven 1.x plugins but the raw conversion for + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File expectedPomFile = getTestFile( "src/test/expected-files/maven-foo-plugin-1.0.pom" ); + assertTrue( "Check POM created", pomFile.exists() ); + compareFiles( expectedPomFile, pomFile ); + */ + } + + public void testV3TimestampedSnapshotPomConvert() + throws IOException, RepositoryConversionException + { + // test that the pom is coverted + + Artifact artifact = createArtifact( "test", "v3artifact", "1.0.0-20060105.130101-3" ); + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + artifactMetadataFile.delete(); + + ArtifactMetadata snapshotMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + File snapshotMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( snapshotMetadata ) ); + snapshotMetadataFile.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 0, 0 ); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3-timestamped-snapshot.pom" ); + assertTrue( "Check POM created", pomFile.exists() ); + + compareFiles( expectedPomFile, pomFile ); + + assertTrue( "Check artifact snapshotMetadata created", artifactMetadataFile.exists() ); + + File expectedMetadataFile = getTestFile( "src/test/expected-files/v3-snapshot-artifact-metadata.xml" ); + + compareFiles( expectedMetadataFile, artifactMetadataFile ); + + assertTrue( "Check snapshot snapshotMetadata created", snapshotMetadataFile.exists() ); + + expectedMetadataFile = getTestFile( "src/test/expected-files/v3-timestamped-snapshot-metadata.xml" ); + + compareFiles( expectedMetadataFile, snapshotMetadataFile ); + } + + public void testNoPomConvert() + throws IOException, RepositoryConversionException + { + // test that a POM is not created when there was none at the source + + Artifact artifact = createArtifact( "test", "noPomArtifact", "1.0.0" ); + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 0, 1 ); + + assertHasWarningReason( listener, getI18nString( "warning.missing.pom" ) ); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + + assertFalse( "Check no POM created", pomFile.exists() ); + assertFalse( "No source POM", sourcePomFile.exists() ); + } + + public void testIncorrectSourceChecksumMd5() + throws RepositoryConversionException + { + // test that it fails when the source md5 is wrong + + Artifact artifact = createArtifact( "test", "incorrectMd5Artifact", "1.0.0" ); + File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + file.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 1, 0 ); + + assertHasErrorReason( listener, getI18nString( "failure.incorrect.md5" ) ); + + assertFalse( "Check artifact not created", file.exists() ); + + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + File metadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( metadata ) ); + assertFalse( "Check metadata not created", metadataFile.exists() ); + } + + public void testIncorrectSourceChecksumSha1() + throws RepositoryConversionException + { + // test that it fails when the source sha1 is wrong + + Artifact artifact = createArtifact( "test", "incorrectSha1Artifact", "1.0.0" ); + File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + file.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 1, 0 ); + + assertHasErrorReason( listener, getI18nString( "failure.incorrect.sha1" ) ); + + assertFalse( "Check artifact not created", file.exists() ); + + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + File metadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( metadata ) ); + assertFalse( "Check metadata not created", metadataFile.exists() ); + } + + public void testUnmodifiedArtifact() + throws RepositoryConversionException, IOException, InterruptedException + { + // test the unmodified artifact is untouched + + Artifact artifact = createArtifact( "test", "unmodified-artifact", "1.0.0" ); + Artifact pomArtifact = createPomArtifact( artifact ); + + File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); + File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); + + assertTrue( "Check target file exists", targetFile.exists() ); + assertTrue( "Check target POM exists", targetPomFile.exists() ); + + sourceFile.setLastModified( System.currentTimeMillis() ); + sourcePomFile.setLastModified( System.currentTimeMillis() ); + + long origTime = targetFile.lastModified(); + long origPomTime = targetPomFile.lastModified(); + + // Need to guarantee last modified is not equal + Thread.sleep( SLEEP_MILLIS ); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 0, 0 ); + + compareFiles( sourceFile, targetFile ); + compareFiles( sourcePomFile, targetPomFile ); + + assertEquals( "Check artifact unmodified", origTime, targetFile.lastModified() ); + assertEquals( "Check POM unmodified", origPomTime, targetPomFile.lastModified() ); + } + + public void testModifedArtifactFails() + throws InterruptedException, RepositoryConversionException, IOException + { + // test that it fails when the source artifact has changed and is different to the existing artifact in the + // target repository + + Artifact artifact = createArtifact( "test", "modified-artifact", "1.0.0" ); + Artifact pomArtifact = createPomArtifact( artifact ); + + File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); + File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); + + assertTrue( "Check target file exists", targetFile.exists() ); + assertTrue( "Check target POM exists", targetPomFile.exists() ); + + sourceFile.setLastModified( System.currentTimeMillis() ); + sourcePomFile.setLastModified( System.currentTimeMillis() ); + + long origTime = targetFile.lastModified(); + long origPomTime = targetPomFile.lastModified(); + + // Need to guarantee last modified is not equal + Thread.sleep( SLEEP_MILLIS ); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 1, 0 ); + + assertHasErrorReason( listener, getI18nString( "failure.target.already.exists" ) ); + + assertEquals( "Check unmodified", origTime, targetFile.lastModified() ); + assertEquals( "Check unmodified", origPomTime, targetPomFile.lastModified() ); + + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + File metadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( metadata ) ); + assertFalse( "Check metadata not created", metadataFile.exists() ); + } + + public void testForcedUnmodifiedArtifact() + throws Exception + { + // test unmodified artifact is still converted when set to force + + repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "force-repository-converter" ); + + Artifact artifact = createArtifact( "test", "unmodified-artifact", "1.0.0" ); + Artifact pomArtifact = createPomArtifact( artifact ); + + File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); + File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); + + SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd", Locale.getDefault() ); + long origTime = dateFormat.parse( "2006-03-03" ).getTime(); + targetFile.setLastModified( origTime ); + targetPomFile.setLastModified( origTime ); + + sourceFile.setLastModified( dateFormat.parse( "2006-01-01" ).getTime() ); + sourcePomFile.setLastModified( dateFormat.parse( "2006-02-02" ).getTime() ); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 0, 0 ); + + compareFiles( sourceFile, targetFile ); + compareFiles( sourcePomFile, targetPomFile ); + + assertFalse( "Check modified", origTime == targetFile.lastModified() ); + assertFalse( "Check modified", origTime == targetPomFile.lastModified() ); + + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + File metadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( metadata ) ); + assertTrue( "Check metadata created", metadataFile.exists() ); + } + + public void testDryRunSuccess() + throws Exception + { + // test dry run does nothing on a run that will be successful, and returns success + + repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "dryrun-repository-converter" ); + + Artifact artifact = createArtifact( "test", "dryrun-artifact", "1.0.0" ); + Artifact pomArtifact = createPomArtifact( artifact ); + + File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); + File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 0, 0 ); + + assertTrue( "Check source file exists", sourceFile.exists() ); + assertTrue( "Check source POM exists", sourcePomFile.exists() ); + + assertFalse( "Check target file doesn't exist", targetFile.exists() ); + assertFalse( "Check target POM doesn't exist", targetPomFile.exists() ); + + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + File metadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( metadata ) ); + assertFalse( "Check metadata not created", metadataFile.exists() ); + } + + public void testDryRunFailure() + throws Exception + { + // test dry run does nothing on a run that will fail, and returns failure + + repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "dryrun-repository-converter" ); + + Artifact artifact = createArtifact( "test", "modified-artifact", "1.0.0" ); + Artifact pomArtifact = createPomArtifact( artifact ); + + File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); + File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); + + assertTrue( "Check target file exists", targetFile.exists() ); + assertTrue( "Check target POM exists", targetPomFile.exists() ); + + sourceFile.setLastModified( System.currentTimeMillis() ); + sourcePomFile.setLastModified( System.currentTimeMillis() ); + + long origTime = targetFile.lastModified(); + long origPomTime = targetPomFile.lastModified(); + + // Need to guarantee last modified is not equal + Thread.sleep( SLEEP_MILLIS ); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkFailure(listener); + + assertHasErrorReason( listener, getI18nString( "failure.target.already.exists" ) ); + + assertEquals( "Check unmodified", origTime, targetFile.lastModified() ); + assertEquals( "Check unmodified", origPomTime, targetPomFile.lastModified() ); + + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + File metadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( metadata ) ); + assertFalse( "Check metadata not created", metadataFile.exists() ); + } + + public void testRollbackArtifactCreated() + throws RepositoryConversionException, IOException + { + // test rollback can remove a created artifact, including checksums + + Artifact artifact = createArtifact( "test", "rollback-created-artifact", "1.0.0" ); + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + FileUtils.deleteDirectory( artifactMetadataFile.getParentFile() ); + + ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); + File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( versionMetadata ) ); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkCounts( listener, 1, 0 ); + + List messages = (List) listener.getErrors().get( listener.toKey( artifact )); + assertNotNull("Should have error messages."); + + boolean found = false; + String pattern = "^" + getI18nString( "failure.invalid.source.pom" ).replaceFirst( "\\{0\\}", ".*" ) + "$"; + for ( Iterator it = messages.iterator(); it.hasNext(); ) + { + String reason = (String) it.next(); + if( reason.matches( pattern ) ) + { + found = true; + break; + } + } + + assertTrue( "Check failure message.", found ); + + assertFalse( "check artifact rolled back", artifactFile.exists() ); + assertFalse( "check metadata rolled back", artifactMetadataFile.exists() ); + assertFalse( "check metadata rolled back", versionMetadataFile.exists() ); + } + + public void testMultipleArtifacts() + throws RepositoryConversionException, IOException + { + // test multiple artifacts are converted + + List artifacts = new ArrayList(); + artifacts.add( createArtifact( "test", "artifact-one", "1.0.0" ) ); + artifacts.add( createArtifact( "test", "artifact-two", "1.0.0" ) ); + artifacts.add( createArtifact( "test", "artifact-three", "1.0.0" ) ); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifacts, targetRepository ); + checkCounts( listener, 0, 0 ); + + for ( Iterator i = artifacts.iterator(); i.hasNext(); ) + { + Artifact artifact = (Artifact) i.next(); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File expectedPomFile = getTestFile( "src/test/expected-files/converted-" + artifact.getArtifactId() + + ".pom" ); + assertTrue( "Check POM created", pomFile.exists() ); + + compareFiles( expectedPomFile, pomFile ); + } + } + + public void testInvalidSourceArtifactMetadata() + throws Exception + { + // test artifact is not converted when source metadata is invalid, and returns failure + + createModernSourceRepository(); + + Artifact artifact = createArtifact( "test", "incorrectArtifactMetadata", "1.0.0" ); + File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + file.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkFailure(listener); + + assertHasErrorReason( listener, getI18nString( "failure.incorrect.artifactMetadata.versions" ) ); + + assertFalse( "Check artifact not created", file.exists() ); + + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + File metadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( metadata ) ); + assertFalse( "Check metadata not created", metadataFile.exists() ); + } + + public void testInvalidSourceSnapshotMetadata() + throws Exception + { + // test artifact is not converted when source snapshot metadata is invalid and returns failure + + createModernSourceRepository(); + + Artifact artifact = createArtifact( "test", "incorrectSnapshotMetadata", "1.0.0-20060102.030405-6" ); + File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + file.delete(); + + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkFailure(listener); + + assertHasErrorReason( listener, getI18nString( "failure.incorrect.snapshotMetadata.snapshot" ) ); + + assertFalse( "Check artifact not created", file.exists() ); + + ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); + File metadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( metadata ) ); + assertFalse( "Check metadata not created", metadataFile.exists() ); + } + + public void testMergeArtifactMetadata() + throws RepositoryConversionException, IOException + { + // test artifact level metadata is merged when it already exists on successful conversion + + Artifact artifact = createArtifact( "test", "newversion-artifact", "1.0.1" ); + MockConversionListener listener = new MockConversionListener(); + + repositoryConverter.addConversionListener( listener ); + repositoryConverter.convert( artifact, targetRepository ); + checkSuccess(listener); + + File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + assertTrue( "Check artifact created", artifactFile.exists() ); + assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); + + artifact = createPomArtifact( artifact ); + File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); + File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); + assertTrue( "Check POM created", pomFile.exists() ); + + compareFiles( sourcePomFile, pomFile ); + + ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); + File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository + .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); + assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); + + File expectedMetadataFile = getTestFile( "src/test/expected-files/newversion-artifact-metadata.xml" ); + + compareFiles( expectedMetadataFile, artifactMetadataFile ); + } + + public void testSourceAndTargetRepositoriesMatch() + throws Exception + { + // test that it fails if the same + + ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); + + sourceRepository = factory.createArtifactRepository( "source", targetRepository.getUrl(), targetRepository + .getLayout(), null, null ); + + Artifact artifact = createArtifact( "test", "repository-artifact", "1.0" ); + + try + { + repositoryConverter.convert( artifact, targetRepository ); + fail( "Should have failed trying to convert within the same repository" ); + } + catch ( RepositoryConversionException e ) + { + // expected + assertEquals( "check message", getI18nString( "exception.repositories.match" ), e.getMessage() ); + assertNull( "Check no additional cause", e.getCause() ); + } + } + + private Artifact createArtifact( String groupId, String artifactId, String version ) + { + Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( version ); + String baseVersion; + if ( matcher.matches() ) + { + baseVersion = matcher.group( 1 ) + "-SNAPSHOT"; + } + else + { + baseVersion = version; + } + return createArtifact( groupId, artifactId, baseVersion, version, "jar" ); + } + + private Artifact createArtifact( String groupId, String artifactId, String baseVersion, String version, String type ) + { + Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, type ); + artifact.setBaseVersion( baseVersion ); + artifact.setRepository( sourceRepository ); + artifact.setFile( new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ) ); + return artifact; + } + + private Artifact createPomArtifact( Artifact artifact ) + { + return createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact + .getVersion(), "pom" ); + } + + private static void compareFiles( File expectedPomFile, File pomFile ) + throws IOException + { + String expectedContent = normalizeString( FileUtils.readFileToString( expectedPomFile, null ) ); + String targetContent = normalizeString( FileUtils.readFileToString( pomFile, null ) ); + assertEquals( "Check file match between " + expectedPomFile + " and " + pomFile, expectedContent, targetContent ); + } + + private static String normalizeString( String path ) + { + return path.trim().replaceAll( "\r\n", "\n" ).replace( '\r', '\n' ).replaceAll( "<\\?xml .+\\?>", "" ); + } + + private void checkSuccess(MockConversionListener listener) + { + checkCounts( listener, 0, 0 ); + } + + private void checkFailure(MockConversionListener listener) + { + checkCounts( listener, 1, 0 ); + } + + private void checkCounts( MockConversionListener listener, int failures, int warnings ) + { + int actualFailures = listener.getErrorMessageCount(); + int actualWarnings = listener.getWarningMessageCount(); + + if ( ( failures != actualFailures ) || ( warnings != actualWarnings ) ) + { + fail( "Check Results Counts expected:<" + failures + "," + warnings + "> but was:<" + actualFailures + "," + + actualWarnings + ">" ); + } + } + + private String getI18nString( String key ) + { + return i18n.getString( repositoryConverter.getClass().getName(), Locale.getDefault(), key ); + } + + private void assertHasWarningReason( MockConversionListener listener, String reason ) + { + assertHasMessage( listener.getWarnings(), "warning", reason ); + } + + private void assertHasErrorReason( MockConversionListener listener, String reason ) + { + assertHasMessage( listener.getErrors(), "error", reason ); + } + + private void assertHasMessage( Map map, String type, String message ) + { + if ( ( map == null ) || ( map.isEmpty() ) ) + { + fail( "No " + type + "s captured, expected " + type + " <" + message + ">" ); + } + + // Attempt to find the message ... + for ( Iterator it = map.values().iterator(); it.hasNext(); ) + { + List msgList = (List) it.next(); + + if ( msgList.contains( message ) ) + { + // Found it! + return; + } + } + + // Didn't find it! whoops ... + for ( Iterator it = map.entrySet().iterator(); it.hasNext(); ) + { + Map.Entry entry = (Entry) it.next(); + String key = (String) entry.getKey(); + List msgList = (List) entry.getValue(); + + System.err.println( " Artifact: " + key ); + + for ( Iterator itMsgs = msgList.iterator(); itMsgs.hasNext(); ) + { + String msg = (String) itMsgs.next(); + System.err.println( " " + msg ); + } + } + + fail( "Unable to find " + type + " reason <" + message + "> in any artifact." ); + } + + private void createModernSourceRepository() + throws Exception + { + ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); + + ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); + + File sourceBase = getTestFile( "src/test/source-modern-repository" ); + sourceRepository = factory.createArtifactRepository( "source", sourceBase.toURL().toString(), layout, null, + null ); + } +} diff --git a/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AbstractFileEventTest.java b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AbstractFileEventTest.java new file mode 100644 index 000000000..f768e1e72 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AbstractFileEventTest.java @@ -0,0 +1,77 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; +import java.util.List; + +import org.codehaus.plexus.PlexusTestCase; +import org.codehaus.plexus.digest.Digester; + +/** + * + * @author Carlos Sanchez + * @version $Id$ + */ +public abstract class AbstractFileEventTest + extends PlexusTestCase +{ + protected List digesters; + + public void setUp() + throws Exception + { + super.setUp(); + + digesters = getContainer().lookupList( Digester.class.getName() ); + } + + protected void assertChecksumExists( File file, String algorithm ) + { + assertChecksum( file, algorithm, true ); + } + + protected void assertChecksumDoesNotExist( File file, String algorithm ) + { + assertChecksum( file, algorithm, false ); + } + + private void assertChecksum( File file, String algorithm, boolean exist ) + { + String msg = exist ? "exists" : "does not exist"; + File checksumFile = new File( file.getPath() + "." + algorithm ); + assertEquals( "Test file " + algorithm + " checksum " + msg, exist, checksumFile.exists() ); + } + + protected void assertChecksumCommit( File file ) + throws IOException + { + assertChecksumExists( file, "md5" ); + assertChecksumExists( file, "sha1" ); + } + + protected void assertChecksumRollback( File file ) + throws IOException + { + assertChecksumDoesNotExist( file, "md5" ); + assertChecksumDoesNotExist( file, "sha1" ); + } +} \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AllTests.java b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AllTests.java new file mode 100644 index 000000000..9274035d8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.converter.transaction" ); + //$JUnit-BEGIN$ + suite.addTestSuite( CreateFileEventTest.class ); + suite.addTestSuite( CopyFileEventTest.class ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CopyFileEventTest.java b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CopyFileEventTest.java new file mode 100644 index 000000000..acb6a3fdc --- /dev/null +++ b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CopyFileEventTest.java @@ -0,0 +1,180 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; +import java.io.IOException; + +import org.apache.commons.io.FileUtils; +import org.codehaus.plexus.PlexusTestCase; + +/** + * @author Edwin Punzalan + */ +public class CopyFileEventTest + extends AbstractFileEventTest +{ + private File testDir = new File( PlexusTestCase.getBasedir(), "target/transaction-tests/copy-file" ); + + private File testDest = new File( testDir, "test-file.txt" ); + + private File testSource = new File( PlexusTestCase.getBasedir(), "target/transaction-tests/test-file.txt" ); + + private File testDestChecksum; + + private String source, oldChecksum; + + public void setUp() + throws Exception + { + super.setUp(); + + testSource.getParentFile().mkdirs(); + + testSource.createNewFile(); + + FileUtils.writeStringToFile( testSource, "source contents", null ); + + testDestChecksum = new File( testDest.getPath() + ".sha1" ); + + testDestChecksum.getParentFile().mkdirs(); + + testDestChecksum.createNewFile(); + + FileUtils.writeStringToFile( testDestChecksum, "this is the checksum", null ); + + assertTrue( "Test if the source exists", testSource.exists() ); + + assertTrue( "Test if the destination checksum exists", testDestChecksum.exists() ); + + source = FileUtils.readFileToString( testSource, null ); + + oldChecksum = FileUtils.readFileToString( testDestChecksum, null ); + } + + public void testCopyCommitRollback() + throws Exception + { + CopyFileEvent event = new CopyFileEvent( testSource, testDest, digesters ); + + assertFalse( "Test that the destination is not yet created", testDest.exists() ); + + event.commit(); + + assertTrue( "Test that the destination is created", testDest.exists() ); + + assertChecksumCommit( testDest ); + + String target = FileUtils.readFileToString( testDest, null ); + + assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) ); + + event.rollback(); + + assertFalse( "Test that the destination file has been deleted", testDest.exists() ); + + assertChecksumRollback( testDest ); + } + + public void testCopyCommitRollbackWithBackup() + throws Exception + { + testDest.getParentFile().mkdirs(); + + testDest.createNewFile(); + + FileUtils.writeStringToFile( testDest, "overwritten contents", null ); + + assertTrue( "Test that the destination exists", testDest.exists() ); + + CopyFileEvent event = new CopyFileEvent( testSource, testDest, digesters ); + + String target = FileUtils.readFileToString( testDest, null ); + + assertTrue( "Test that the destination contents have not changed", target.equals( "overwritten contents" ) ); + + event.commit(); + + target = FileUtils.readFileToString( testDest, null ); + + assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) ); + + assertChecksumCommit( testDest ); + + event.rollback(); + + target = FileUtils.readFileToString( testDest, null ); + + assertTrue( "Test the destination file contents have been restored", target.equals( "overwritten contents" ) ); + + assertChecksumRollback( testDest ); + } + + public void testCreateRollbackCommit() + throws Exception + { + CopyFileEvent event = new CopyFileEvent( testSource, testDest, digesters ); + + assertFalse( "Test that the destination is not yet created", testDest.exists() ); + + event.rollback(); + + assertFalse( "Test that the destination file is not yet created", testDest.exists() ); + + event.commit(); + + assertTrue( "Test that the destination is created", testDest.exists() ); + + assertChecksumCommit( testDest ); + + String target = FileUtils.readFileToString( testDest, null ); + + assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) ); + } + + protected void tearDown() + throws Exception + { + super.tearDown(); + + FileUtils.deleteDirectory( new File( PlexusTestCase.getBasedir(), "target/transaction-tests" ) ); + } + + protected void assertChecksumCommit( File file ) + throws IOException + { + super.assertChecksumCommit( file ); + + String target = FileUtils.readFileToString( testDestChecksum, null ); + + assertFalse( "Test that the destination checksum contents are created correctly", oldChecksum.equals( target ) ); + } + + protected void assertChecksumRollback( File file ) + throws IOException + { + assertChecksumDoesNotExist( file, "md5" ); + assertChecksumExists( file, "sha1" ); + + String target = FileUtils.readFileToString( testDestChecksum, null ); + + assertEquals( "Test that the destination checksum contents are reverted correctly", oldChecksum, target ); + } +} diff --git a/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CreateFileEventTest.java b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CreateFileEventTest.java new file mode 100644 index 000000000..d27701e20 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CreateFileEventTest.java @@ -0,0 +1,121 @@ +package org.apache.maven.archiva.converter.transaction; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.io.File; + +import org.apache.commons.io.FileUtils; +import org.codehaus.plexus.PlexusTestCase; + +/** + * @author Edwin Punzalan + */ +public class CreateFileEventTest + extends AbstractFileEventTest +{ + private File testDir = new File( PlexusTestCase.getBasedir(), "target/transaction-tests/create-file" ); + + public void testCreateCommitRollback() + throws Exception + { + File testFile = new File( testDir, "test-file.txt" ); + + CreateFileEvent event = new CreateFileEvent( "file contents", testFile, digesters ); + + assertFalse( "Test file is not yet created", testFile.exists() ); + + event.commit(); + + assertTrue( "Test file has been created", testFile.exists() ); + + assertChecksumCommit( testFile ); + + event.rollback(); + + assertFalse( "Test file is has been deleted after rollback", testFile.exists() ); + + assertChecksumRollback( testFile ); + + assertFalse( "Test file parent directories has been rolledback too", testDir.exists() ); + assertTrue( "target directory still exists", new File( PlexusTestCase.getBasedir(), "target" ).exists() ); + } + + public void testCreateCommitRollbackWithBackup() + throws Exception + { + File testFile = new File( testDir, "test-file.txt" ); + + testFile.getParentFile().mkdirs(); + + testFile.createNewFile(); + + FileUtils.writeStringToFile( testFile, "original contents", null ); + + CreateFileEvent event = new CreateFileEvent( "modified contents", testFile, digesters ); + + String contents = FileUtils.readFileToString( testFile, null ); + + assertEquals( "Test contents have not changed", "original contents", contents ); + + event.commit(); + + contents = FileUtils.readFileToString( testFile, null ); + + assertEquals( "Test contents have not changed", "modified contents", contents ); + + assertChecksumCommit( testFile ); + + event.rollback(); + + contents = FileUtils.readFileToString( testFile, null ); + + assertEquals( "Test contents have not changed", "original contents", contents ); + + assertChecksumRollback( testFile ); + } + + public void testCreateRollbackCommit() + throws Exception + { + File testFile = new File( testDir, "test-file.txt" ); + + CreateFileEvent event = new CreateFileEvent( "file contents", testFile, digesters ); + + assertFalse( "Test file is not yet created", testFile.exists() ); + + event.rollback(); + + assertFalse( "Test file is not yet created", testFile.exists() ); + + event.commit(); + + assertTrue( "Test file is not yet created", testFile.exists() ); + + assertChecksumCommit( testFile ); + } + + protected void tearDown() + throws Exception + { + super.tearDown(); + + FileUtils.deleteDirectory( new File( PlexusTestCase.getBasedir(), "target/transaction-tests" ) ); + } +} diff --git a/archiva-base/archiva-converter/src/test/resources/log4j.properties b/archiva-base/archiva-converter/src/test/resources/log4j.properties new file mode 100644 index 000000000..9b2c26ade --- /dev/null +++ b/archiva-base/archiva-converter/src/test/resources/log4j.properties @@ -0,0 +1,10 @@ +# Set root logger level to DEBUG and its only appender to A1. +log4j.rootLogger=WARN, A1 + +# A1 is set to be a ConsoleAppender. +log4j.appender.A1=org.apache.log4j.ConsoleAppender + +# A1 uses PatternLayout. +log4j.appender.A1.layout=org.apache.log4j.PatternLayout +log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n + diff --git a/archiva-base/archiva-converter/src/test/resources/org/apache/maven/archiva/converter/RepositoryConverterTest.xml b/archiva-base/archiva-converter/src/test/resources/org/apache/maven/archiva/converter/RepositoryConverterTest.xml new file mode 100644 index 000000000..b1cf9640a --- /dev/null +++ b/archiva-base/archiva-converter/src/test/resources/org/apache/maven/archiva/converter/RepositoryConverterTest.xml @@ -0,0 +1,125 @@ + + + + + + + + org.apache.maven.archiva.converter.RepositoryConverter + org.apache.maven.archiva.converter.DefaultRepositoryConverter + force-repository-converter + + true + + + + org.codehaus.plexus.digest.Digester + digesters + + + org.apache.maven.artifact.factory.ArtifactFactory + artifactFactory + + + org.codehaus.plexus.i18n.I18N + i18n + + + + + org.apache.maven.archiva.converter.RepositoryConverter + org.apache.maven.archiva.converter.DefaultRepositoryConverter + dryrun-repository-converter + + true + + + + org.codehaus.plexus.digest.Digester + digesters + + + org.apache.maven.artifact.factory.ArtifactFactory + artifactFactory + + + org.codehaus.plexus.i18n.I18N + i18n + + + + + + + org.codehaus.plexus.jdo.JdoFactory + archiva + org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory + + + + org.hsqldb.jdbcDriver + jdbc:hsqldb:mem:TESTDB + sa + + + + org.jpox.PersistenceManagerFactoryImpl + + + javax.jdo.PersistenceManagerFactoryClass + org.jpox.PersistenceManagerFactoryImpl + + + org.jpox.autoCreateSchema + true + + + org.jpox.validateTables + false + + + org.jpox.validateConstraints + false + + + org.jpox.validateColumns + false + + + org.jpox.autoStartMechanism + None + + + org.jpox.transactionIsolation + READ_UNCOMMITTED + + + org.jpox.poid.transactionIsolation + READ_UNCOMMITTED + + + org.jpox.rdbms.dateTimezone + JDK_DEFAULT_TIMEZONE + + + + + + diff --git a/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.jar new file mode 100644 index 000000000..72af4bc10 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.jar @@ -0,0 +1 @@ +incorrectMd5 diff --git a/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.pom new file mode 100644 index 000000000..b64e1d0f0 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.pom @@ -0,0 +1,25 @@ + + + + 3 + incorrectArtifactMetadata + test + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/maven-metadata.xml b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/maven-metadata.xml new file mode 100644 index 000000000..b393bcd3d --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/maven-metadata.xml @@ -0,0 +1,29 @@ + + + + + test + incorrectArtifactMetadata + + + 0.9 + + + \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.jar b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.jar new file mode 100644 index 000000000..72af4bc10 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.jar @@ -0,0 +1 @@ +incorrectMd5 diff --git a/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.pom b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.pom new file mode 100644 index 000000000..929190af2 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.pom @@ -0,0 +1,25 @@ + + + + 3 + incorrectSnapshotMetadata + test + 1.0.0-20060102.030405-6 + diff --git a/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml new file mode 100644 index 000000000..5980278b3 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml @@ -0,0 +1,31 @@ + + + + + test + incorrectSnapshotMetadata + 1.0.0-SNAPSHOT + + + 10 + 20060102.040506 + + + \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml new file mode 100644 index 000000000..3f9a0cef2 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml @@ -0,0 +1,29 @@ + + + + + test + incorrectSnapshotMetadata + + + 1.0.0-SNAPSHOT + + + \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-one-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-one-1.0.0.jar new file mode 100644 index 000000000..5626abf0f --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-one-1.0.0.jar @@ -0,0 +1 @@ +one diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-three-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-three-1.0.0.jar new file mode 100644 index 000000000..2bdf67abb --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-three-1.0.0.jar @@ -0,0 +1 @@ +three diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-two-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-two-1.0.0.jar new file mode 100644 index 000000000..f719efd43 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/artifact-two-1.0.0.jar @@ -0,0 +1 @@ +two diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/dryrun-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/dryrun-artifact-1.0.0.jar new file mode 100644 index 000000000..cbaf024e5 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/dryrun-artifact-1.0.0.jar @@ -0,0 +1 @@ +existing diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/existing-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/existing-artifact-1.0.0.jar new file mode 100644 index 000000000..cbaf024e5 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/existing-artifact-1.0.0.jar @@ -0,0 +1 @@ +existing diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar new file mode 100644 index 000000000..72af4bc10 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar @@ -0,0 +1 @@ +incorrectMd5 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar.md5 b/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar.md5 new file mode 100644 index 000000000..316d9a4eb --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar.md5 @@ -0,0 +1 @@ +379dcfcd1e6312cc859111f696047eb4 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar new file mode 100644 index 000000000..f5812f3e5 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar @@ -0,0 +1 @@ +incorrectSha1 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 b/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 new file mode 100644 index 000000000..cce322eb2 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 @@ -0,0 +1 @@ +52e07b82d944741f66bba5896d4cd74e9879e289 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/modified-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/modified-artifact-1.0.0.jar new file mode 100644 index 000000000..2e0996000 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/modified-artifact-1.0.0.jar @@ -0,0 +1 @@ +modified diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/newversion-artifact-1.0.1.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/newversion-artifact-1.0.1.jar new file mode 100644 index 000000000..c694117fd --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/newversion-artifact-1.0.1.jar @@ -0,0 +1 @@ +v4 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/noPomArtifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/noPomArtifact-1.0.0.jar new file mode 100644 index 000000000..3d27acdcc --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/noPomArtifact-1.0.0.jar @@ -0,0 +1 @@ +noPom diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/relocated-v3artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/relocated-v3artifact-1.0.0.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/relocated-v3artifact-1.0.0.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/rollback-created-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/rollback-created-artifact-1.0.0.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/rollback-created-artifact-1.0.0.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/unmodified-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/unmodified-artifact-1.0.0.jar new file mode 100644 index 000000000..27597bc21 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/unmodified-artifact-1.0.0.jar @@ -0,0 +1 @@ +unmodified diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3-warnings-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3-warnings-artifact-1.0.0.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3-warnings-artifact-1.0.0.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-20060105.130101-3.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-20060105.130101-3.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-20060105.130101-3.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-SNAPSHOT.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-SNAPSHOT.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-SNAPSHOT.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-20060111.120115-1.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-20060111.120115-1.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-20060111.120115-1.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-SNAPSHOT.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-SNAPSHOT.jar new file mode 100644 index 000000000..29ef827e8 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-SNAPSHOT.jar @@ -0,0 +1 @@ +v3 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar new file mode 100644 index 000000000..c694117fd --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar @@ -0,0 +1 @@ +v4 diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.md5 b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.md5 new file mode 100644 index 000000000..1930bc6d3 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.md5 @@ -0,0 +1 @@ +4289bbdd6fba75013b317b2f9a540736 *v4artifact-1.0.0.jar diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.sha1 b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.sha1 new file mode 100644 index 000000000..466f209a7 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.sha1 @@ -0,0 +1 @@ +e3e4159da65a4257f0bffb7cac8e3e78241a4dca *v4artifact-1.0.0.jar diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar b/archiva-base/archiva-converter/src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar new file mode 100644 index 000000000..5626abf0f --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar @@ -0,0 +1 @@ +one diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-one-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-one-1.0.0.pom new file mode 100644 index 000000000..cd3862d35 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-one-1.0.0.pom @@ -0,0 +1,6 @@ + + 4.0.0 + test + artifact-one + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-three-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-three-1.0.0.pom new file mode 100644 index 000000000..343291037 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-three-1.0.0.pom @@ -0,0 +1,6 @@ + + 4.0.0 + test + artifact-three + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-two-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-two-1.0.0.pom new file mode 100644 index 000000000..227470167 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/artifact-two-1.0.0.pom @@ -0,0 +1,6 @@ + + 4.0.0 + test + artifact-two + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/dryrun-artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/dryrun-artifact-1.0.0.pom new file mode 100644 index 000000000..1953c5523 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/dryrun-artifact-1.0.0.pom @@ -0,0 +1,22 @@ + + + + 4.0.0 + dryrun-artifact + test + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/incorrectMd5Artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/incorrectMd5Artifact-1.0.0.pom new file mode 100644 index 000000000..74d5e12b4 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/incorrectMd5Artifact-1.0.0.pom @@ -0,0 +1,6 @@ + + 3 + incorrectMd5Artifact + test + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/incorrectSha1Artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/incorrectSha1Artifact-1.0.0.pom new file mode 100644 index 000000000..fe3c7fd91 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/incorrectSha1Artifact-1.0.0.pom @@ -0,0 +1,6 @@ + + 3 + incorrectSha1Artifact + test + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/maven-foo-plugin-1.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/maven-foo-plugin-1.0.pom new file mode 100644 index 000000000..a5a02c42d --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/maven-foo-plugin-1.0.pom @@ -0,0 +1,6 @@ + + 3 + maven-foo-plugin + org.apache.maven.plugins + 1.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/modified-artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/modified-artifact-1.0.0.pom new file mode 100644 index 000000000..fcfdaacb4 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/modified-artifact-1.0.0.pom @@ -0,0 +1,22 @@ + + + + 4.0.0 + modified-artifact + test + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom new file mode 100644 index 000000000..f441c9a46 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom @@ -0,0 +1,22 @@ + + + + 4.0.0 + test + newversoin-artifact + 1.0.1 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/relocated-v3artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/relocated-v3artifact-1.0.0.pom new file mode 100644 index 000000000..ab112a296 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/relocated-v3artifact-1.0.0.pom @@ -0,0 +1,27 @@ + + 3 + relocated-v3artifact + test + 1.0.0 + + + groupId + artifactId + version + + + groupId + test-artifactId + version + + test + + + + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + + relocated-test + + \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/rollback-created-artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/rollback-created-artifact-1.0.0.pom new file mode 100644 index 000000000..00692be72 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/rollback-created-artifact-1.0.0.pom @@ -0,0 +1,39 @@ + + + + 3 + v3artifact + test + 1.0.0 + + + groupId + artifactId + version + + + groupId + test-artifactId + version + + test + + + + + + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/unmodified-artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/unmodified-artifact-1.0.0.pom new file mode 100644 index 000000000..a8428a8a4 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/unmodified-artifact-1.0.0.pom @@ -0,0 +1,25 @@ + + + + 4.0.0 + unmodified-artifact + test + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom new file mode 100644 index 000000000..5f347f371 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom @@ -0,0 +1,48 @@ + + + + 3 + ../project.xml + v3-warnings-artifact + test + 1.0.0 + + + 1.0 + 1.0 + 1_0 + + + + + groupId + artifactId + version + + + groupId + test-artifactId + version + + test + + + + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-20060105.130101-3.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-20060105.130101-3.pom new file mode 100644 index 000000000..d7ae8953b --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-20060105.130101-3.pom @@ -0,0 +1,40 @@ + + + + 3 + v3artifact + test + 1.0.0-20060105.130101-3 + + + groupId + artifactId + version + + + groupId + test-artifactId + version + + test + + + + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-SNAPSHOT.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-SNAPSHOT.pom new file mode 100644 index 000000000..3958a3358 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-SNAPSHOT.pom @@ -0,0 +1,40 @@ + + + + 3 + v3artifact + test + 1.0.0-SNAPSHOT + + + groupId + artifactId + version + + + groupId + test-artifactId + version + + test + + + + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0.pom new file mode 100644 index 000000000..5aed3437a --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0.pom @@ -0,0 +1,24 @@ + + 3 + v3artifact + test + 1.0.0 + + + groupId + artifactId + version + + + groupId + test-artifactId + version + + test + + + + + scm:cvs:ext:${maven.username}@localhost:/home/cvs + + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-20060111.120115-1.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-20060111.120115-1.pom new file mode 100644 index 000000000..e4f36566a --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-20060111.120115-1.pom @@ -0,0 +1,22 @@ + + + + 4.0.0 + test + v4artifact + 1.0.0-20060111.120115-1 + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-SNAPSHOT.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-SNAPSHOT.pom new file mode 100644 index 000000000..be5b8b7e2 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-SNAPSHOT.pom @@ -0,0 +1,22 @@ + + + + 4.0.0 + test + v4artifact + 1.0.0-SNAPSHOT + diff --git a/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0.pom new file mode 100644 index 000000000..fa6e82b1e --- /dev/null +++ b/archiva-base/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0.pom @@ -0,0 +1,6 @@ + + 4.0.0 + test + v4artifact + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.jar new file mode 100644 index 000000000..27597bc21 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.jar @@ -0,0 +1 @@ +unmodified diff --git a/archiva-base/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.pom new file mode 100644 index 000000000..d23afd027 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.pom @@ -0,0 +1,25 @@ + + + + 4.0.0 + modified-artifact + test + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.jar new file mode 100644 index 000000000..27597bc21 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.jar @@ -0,0 +1 @@ +unmodified diff --git a/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom new file mode 100644 index 000000000..e21492ebf --- /dev/null +++ b/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom @@ -0,0 +1,25 @@ + + + + 4.0.0 + newversion-artifact + test + 1.0.0 + diff --git a/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/maven-metadata.xml b/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/maven-metadata.xml new file mode 100644 index 000000000..42537e4c5 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/target-repository/test/newversion-artifact/maven-metadata.xml @@ -0,0 +1,29 @@ + + + + + test + newversion-artifact + + + 1.0.0 + + + \ No newline at end of file diff --git a/archiva-base/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.jar b/archiva-base/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.jar new file mode 100644 index 000000000..27597bc21 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.jar @@ -0,0 +1 @@ +unmodified diff --git a/archiva-base/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.pom b/archiva-base/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.pom new file mode 100644 index 000000000..a8428a8a4 --- /dev/null +++ b/archiva-base/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.pom @@ -0,0 +1,25 @@ + + + + 4.0.0 + unmodified-artifact + test + 1.0.0 + diff --git a/archiva-base/archiva-model/pom.xml b/archiva-base/archiva-model/pom.xml new file mode 100755 index 000000000..3fcb6843f --- /dev/null +++ b/archiva-base/archiva-model/pom.xml @@ -0,0 +1,157 @@ + + + + + + org.apache.maven.archiva + archiva + 1.0-SNAPSHOT + + 4.0.0 + archiva-model + Archiva Model + + + org.apache.maven.archiva + archiva-common + + + org.codehaus.plexus + plexus-utils + + + javax.jdo + jdo2-api + 2.0 + + + org.codehaus.plexus + plexus-container-default + + + commons-lang + commons-lang + + + commons-io + commons-io + + + + + + org.codehaus.plexus + plexus-maven-plugin + + + org.codehaus.modello + modello-maven-plugin + 1.0-alpha-15-SNAPSHOT + + 1.0.0 + false + src/main/mdo/archiva-base.xml + + + + archiva-base + + java + xsd + jpox-jdo-mapping + jpox-metadata-class + xpp3-writer + xpp3-reader + + + + + + org.codehaus.mojo + jpox-maven-plugin + 1.1.6 + + + org.apache.derby + derby + 10.2.1.6 + + + + + create-ddl + generate-test-resources + + schema-create + + + ${basedir}/target/classes/org/apache/maven/archiva/model/schema.ddl + + + javax.jdo.option.ConnectionDriverName + org.apache.derby.jdbc.EmbeddedDriver + + + javax.jdo.option.ConnectionURL + jdbc:derby:target/jdo-schema-create;create=true + + + javax.jdo.option.ConnectionUserName + sa + + + javax.jdo.option.ConnectionPassword + + + + log4j.configuration + ${basedir}/src/test/resources/log4j.xml + + + org.jpox.autoCreateTables + true + + + + + + enhance + + enhance + + + + + + org.codehaus.mojo + cobertura-maven-plugin + + + + + org/apache/maven/archiva/reporting/model/** + + + + + + + diff --git a/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryContentKey.java b/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryContentKey.java new file mode 100644 index 000000000..a198eaec2 --- /dev/null +++ b/archiva-base/archiva-model/src/main/java/org/apache/maven/archiva/model/RepositoryContentKey.java @@ -0,0 +1,170 @@ +package org.apache.maven.archiva.model; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; + +import java.io.Serializable; + +/** + * RepositoryContentKey - the jpox application key support class for all content within the repository. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryContentKey implements Serializable +{ + /** + * The Repository ID. (JPOX Requires this remain public) + */ + public String repositoryId = ""; + + /** + * The Group ID. (JPOX Requires this remain public) + */ + public String groupId = ""; + + /** + * The Artifact ID. (JPOX Requires this remain public) + */ + public String artifactId = ""; + + /** + * The Version. (JPOX Requires this remain public) + */ + public String version = ""; + + /** + * Default Constructor. Required by JPOX. + */ + public RepositoryContentKey() + { + + } + + /** + * Key Based Constructor. Required by JPOX. + * + * @param key the String representing this object's values. + */ + public RepositoryContentKey( String key ) + { + String parts[] = StringUtils.splitPreserveAllTokens( key, ':' ); + repositoryId = parts[0]; + groupId = parts[1]; + artifactId = parts[2]; + version = parts[3]; + } + + /** + * Get the String representation of this object. - Required by JPOX. + */ + public String toString() + { + return StringUtils.join( new String[] { repositoryId, groupId, artifactId, version } ); + } + + /** + * Get the hashcode for this object's values - Required by JPOX. + */ + public int hashCode() + { + final int PRIME = 31; + int result = 1; + result = PRIME * result + ( ( repositoryId == null ) ? 0 : repositoryId.hashCode() ); + result = PRIME * result + ( ( groupId == null ) ? 0 : groupId.hashCode() ); + result = PRIME * result + ( ( artifactId == null ) ? 0 : artifactId.hashCode() ); + result = PRIME * result + ( ( version == null ) ? 0 : version.hashCode() ); + return result; + } + + /** + * Get the equals for this object's values - Required by JPOX. + */ + public boolean equals( Object obj ) + { + if ( this == obj ) + { + return true; + } + + if ( obj == null ) + { + return false; + } + + if ( getClass() != obj.getClass() ) + { + return false; + } + + final RepositoryContentKey other = (RepositoryContentKey) obj; + + if ( repositoryId == null ) + { + if ( other.repositoryId != null ) + { + return false; + } + } + else if ( !repositoryId.equals( other.repositoryId ) ) + { + return false; + } + + if ( groupId == null ) + { + if ( other.groupId != null ) + { + return false; + } + } + else if ( !groupId.equals( other.groupId ) ) + { + return false; + } + + if ( artifactId == null ) + { + if ( other.artifactId != null ) + { + return false; + } + } + else if ( !artifactId.equals( other.artifactId ) ) + { + return false; + } + + if ( version == null ) + { + if ( other.version != null ) + { + return false; + } + } + else if ( !version.equals( other.version ) ) + { + return false; + } + + return true; + } +} diff --git a/archiva-base/archiva-model/src/main/mdo/archiva-base.xml b/archiva-base/archiva-model/src/main/mdo/archiva-base.xml new file mode 100644 index 000000000..a6cc0fc40 --- /dev/null +++ b/archiva-base/archiva-model/src/main/mdo/archiva-base.xml @@ -0,0 +1,1277 @@ + + + archiva-base-model + ArchivaBaseModel + 1.0.0 + Archiva Model + + + package + org.apache.maven.archiva.model + + + + + + ArchivaAll + 1.0.0+ + + This object is only used for the XML backup / restore features of Archiva. + This object is not serialized to the Database. + + + + repositories + 1.0.0+ + + ArchivaRepositoryModel + * + + + + artifacts + 1.0.0+ + + ArchivaArtifactModel + * + + + + repositoryMetadata + 1.0.0+ + + ArchivaRepositoryMetadata + * + + + + projects + 1.0.0+ + + ArchivaProjectModel + * + + + + artifactHealth + 1.0.0+ + + ArchivaArtifactHealth + * + + + + repositoryMetadataHealth + 1.0.0+ + + ArchivaRepositoryMetadataHealth + * + + + + repositoryContentStatistics + 1.0.0+ + + RepositoryContentStatistics + * + + + + + + + + + ArchivaRepositoryModel + 1.0.0+ + + + id + true + 1.0.0+ + String + true + + The unique ID for the repository. + + + + name + false + 1.0.0+ + String + true + + The Name of the repository. + + + + url + false + 1.0.0+ + String + true + + The URL of the repository. + + + + creationSource + false + 1.0.0+ + String + true + + The Source of this repository. + (Example: Configuration, POM) + + + + layoutName + false + 1.0.0+ + String + true + + The layout of the repository. + (Either 'default', or 'legacy') + + default + + + releasePolicy + false + 1.0.0+ + boolean + true + + The releases policy of the repository. + + true + + + snapshotPolicy + false + 1.0.0+ + boolean + true + + The snapshot policy of the repository. + + false + + + + + RepositoryContent + 1.0.0+ + + Repository Content Identifier. + + + + groupId + true + 1.0.0+ + String + true + + The Group ID of the repository content. + + + + artifactId + true + 1.0.0+ + String + true + + The Artifact ID of the repository content. + + + + version + true + 1.0.0+ + String + false + + The version of the repository content. + + + + repositoryId + true + 1.0.0+ + true + String + + The repository associated with this content. + + + + + + 1.0.0+ + + + + + + + + + + ArchivaArtifactModel + 1.0.0+ + + + contentKey + true + 1.0.0+ + true + + RepositoryContent + 1 + + + The content key for this artifact. + + + + classifier + false + 1.0.0+ + String + false + + The classifier for this artifact. + + + + type + true + 1.0.0+ + String + true + + The type of artifact. + + + + checksumMD5 + false + 1.0.0+ + String + false + + The MD5 checksum for the artifact file. + + + + checksumSHA1 + false + 1.0.0+ + String + false + + The SHA1 checksum for the artifact file. + + + + checksumBytecode + false + 1.0.0+ + String + false + + The SHA1 checksum for the bytecode in the artifact file. (Can be empty if + the artifact contains no bytecode) + + + + whenIndexed + false + 1.0.0+ + Date + false + + The timestamp when this artifact was indexed. + + + + origin + false + 1.0.0+ + String + false + + The origin of this artifact. (Filesystem, Proxy, Deploy) + + + + + + ArchivaRepositoryMetadata + 1.0.0+ + + + contentKey + true + 1.0.0+ + true + + RepositoryContent + 1 + + + The content key for this repository metadata. + + + + releasedVersion + false + 1.0.0+ + false + String + + The released version id. + + + + availableVersions + false + 1.0.0+ + false + + String + * + + + The list of available version ids. + + + + whenIndexed + false + 1.0.0+ + Date + false + + The timestamp when this artifact was indexed. + + + + lastUpdated + false + 1.0.0+ + Date + false + + the timestamp when this artifact was indexed. + + + + origin + false + 1.0.0+ + String + false + + The origin of this artifact. (Filesystem, Proxy, Deploy) + + + + + + + + + ArchivaProjectModel + 1.0.0+ + + + contentKey + true + 1.0.0+ + true + + RepositoryContent + 1 + + + The content key for this artifact. + + + + parentContentKey + false + 1.0.0+ + false + + RepositoryContent + 1 + + + The content key for a parent reference. + + + + packaging + false + 1.0.0+ + true + String + + The declared packaging for this project model. + + + + origin + false + 1.0.0+ + true + String + + The Origin of this Model. (Filesystem, Proxy, or Deploy) + + + + whenIndexed + false + 1.0.0+ + true + Date + + The timestamp when this model was indexed. + + + + url + false + 1.0.0+ + false + String + + The URL for the project's homepage. + + + + organization + false + 1.0.0+ + false + + Organization + + + + licenses + false + 1.0.0+ + false + + License + * + + + + issueManagement + 1.0.0+ + + + IssueManagement + + + + ciManagement + 1.0.0+ + + + CiManagement + + + + scm + 1.0.0+ + + + + Scm + + + + individuals + 1.0.0+ + + The list of individuals around this project. + + + Individual + * + + + + dependencies + 1.0.0+ + + + Dependency + * + + + + repositories + 1.0.0+ + + The list project repositories in use by this project. + + + ProjectRepository + * + + + + plugins + 1.0.0+ + + The list of plugins that this project uses. + + + RepositoryContent + * + + + + reports + 1.0.0+ + + The list of reports that this project uses. + + + RepositoryContent + * + + + + + + Organization + Specifies the organization that produces this project. + 1.0.0+ + + + name + 1.0.0+ + + String + + + url + 1.0.0+ + + String + + + favicon + 1.0.0+ + /images/org-logo.png) or an absolute URL + (e.g., http://my.corp/logo.png). This value is used + when generating the project documentation. + ]]> + String + + + + + License + + 1.0.0+ + + + id + 1.0.0+ + int + + The type of license. + + + + name + 1.0.0+ + + String + + + url + 1.0.0+ + + String + + + comments + + Addendum information pertaining to this license. + + 1.0.0+ + String + + + + + IssueManagement + + Information about the issue tracking (or bug tracking) system used to manage this project. + + 1.0.0+ + + + system + 1.0.0+ + + String + + + url + 1.0.0+ + + String + + + + + CiManagement + 1.0.0+ + + + system + 1.0.0+ + + continuum.]]> + String + + + url + 1.0.0+ + + + String + + + + + Individual + + Description of a person who has contributed to the project. + This includes contributors and commitors. + + 1.0.0+ + + + name + 1.0.0+ + + String + + + email + 1.0.0+ + + String + + + principal + 1.0.0+ + + The RedBack (plexus security) principal associated with this Invididual. + + String + + + commitor + 1.0.0+ + + The flag if this user is a developer and/or commitor. + + boolean + + + url + 1.0.0+ + + String + + + + organization + organisation + 1.0.0+ + + String + + + organizationUrl + organisationUrl + 1.0.0+ + + String + + + roles + 1.0.0+ + role element, the body of which is a + role name. This can also be used to describe the contribution. + ]]> + + String + * + + + + timezone + 1.0.0+ + + String + + + properties + 1.0.0+ + + Properties + + String + * + + + + + + Dependency + 1.0.0+ + + + contentKey + true + 1.0.0+ + true + + RepositoryContent + 1 + + + The content key for this dependency. + + + + url + 1.0.0+ + + String + + + type + 1.0.0+ + jar. While it usually represents the extension on + the filename of the dependency, that is not always the case. A type can be mapped to a different + extension and a classifier. + The type often correspongs to the packaging used, though this is also not always the case. + Some examples are jar, war, ejb-client and test-jar. + New types can be defined by plugins that set + extensions to true, so this is not a complete list. + ]]> + String + jar + + + classifier + 1.0.0+ + jdk14 and jdk15. + ]]> + String + false + + + scope + 1.0.0+ + compile, runtime, test, + system, and provided. Used to + calculate the various classpaths used for compilation, testing, and so on. It also assists in determining + which artifacts to include in a distribution of this project. For more information, see + the + dependency mechanism.]]> + + String + + + systemPath + 1.0.0+ + discouraged and may be replaced in later + versions. This specifies the path on the filesystem for this dependency. + Requires an absolute path for the value, not relative. + Use a property that gives the machine specific absolute path, + e.g. ${java.home}. + ]]> + String + + + exclusions + 1.0.0+ + + Lists a set of artifacts that should be excluded from this dependency's artifact list when it comes to + calculating transitive dependencies. + + + Exclusion + * + + + + optional + 1.0.0+ + + Indicates the dependency is optional for use of this library. While the version of the dependency will be + taken into account for dependency calculation if the library is used elsewhere, it will not be passed on + transitively. + + boolean + false + + + + + Exclusion + 1.0.0+ + + + groupId + 4.0.0 + + String + true + + + artifactId + 4.0.0 + + String + true + + + + + Scm + 1.0.0+ + + + connection + 1.0.0 + URL format + and list of supported SCMs. + This connection is read-only. + ]]> + String + + + developerConnection + 1.0.0 + connection, but for developers, i.e. this scm connection + will not be read only. + ]]> + String + + + url + 1.0.0 + + + String + + + + + ProjectRepository + 1.0.0+ + + + id + 4.0.0 + settings.xml file, for example. + ]]> + String + + + name + 4.0.0 + + String + + + url + 4.0.0 + protocol://hostname/path. + ]]> + String + + + layout + 4.0.0 + legacy or + default. + ]]> + String + default + + + plugins + 1.0.0+ + + Flag indicating if this repository is for plugin resolution. + + boolean + + + releases + 1.0.0+ + + Flag indicating if this repository has release versioned artifacts. + + boolean + + + snapshots + 1.0.0+ + + Flag indicating if this repository has snapshot versioned artifacts. + + boolean + + + + + + + + HealthProblem + 1.0.0+ + + + type + false + 1.0.0+ + true + String + + The type of health problem. + + + + origin + false + 1.0.0+ + true + String + + The origin of the health problem. + + + + message + false + 1.0.0+ + true + String + + The origin of the health problem. + + + + + + ArchivaArtifactHealth + 1.0.0+ + + + artifact + true + 1.0.0+ + true + + ArchivaArtifactModel + 1 + + + The Artifact to report on. + + + + problems + false + 1.0.0+ + false + + HealthProblem + * + + + The list of problems associated with this artifact. + + + + + + ArchivaRepositoryMetadataHealth + 1.0.0+ + + + repositoryMetadata + true + 1.0.0+ + true + + ArchivaRepositoryMetadata + 1 + + + The ArchivaRepositoryMetadata to report on. + + + + problems + false + 1.0.0+ + false + + HealthProblem + * + + + The list of problems associated with this repository metadata. + + + + + + + + + RepositoryContentStatistics + 1.0.0+ + + + repositoryId + 1.0.0+ + false + true + String + + The repository id the statistics belong to. + + + + whenGathered + 1.0.0+ + false + true + Date + + The timestamp on when this set of statistics was gathered. + + + + duration + 1.0.0+ + false + true + long + + The duration (in milliseconds) for the gathering of the statistics. + + + + totalFileCount + 1.0.0+ + false + true + long + + The total number of files in the repository. + + + + newFileCount + 1.0.0+ + false + true + long + + The number of new files discovered. + + + + + + 1.0.0+ + + private transient long startTimestamp; + + public void triggerStart() { + startTimestamp = System.currentTimeMillis(); + } + + public void triggerFinished() { + long finished = System.currentTimeMillis(); + setDuration( finished - startTimestamp ); + setWhenGathered( new java.util.Date( finished ) ); + } + + public void increaseFileCount() { + this.totalFileCount++; + } + + public void increaseNewFileCount() { + this.newFileCount++; + } + + + + + + diff --git a/archiva-base/archiva-model/src/test/resources/log4j.xml b/archiva-base/archiva-model/src/test/resources/log4j.xml new file mode 100644 index 000000000..395941ac3 --- /dev/null +++ b/archiva-base/archiva-model/src/test/resources/log4j.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archiva-base/archiva-repository-layer/pom.xml b/archiva-base/archiva-repository-layer/pom.xml new file mode 100644 index 000000000..210563124 --- /dev/null +++ b/archiva-base/archiva-repository-layer/pom.xml @@ -0,0 +1,97 @@ + + + + + + archiva + org.apache.maven.archiva + 1.0-SNAPSHOT + + 4.0.0 + org.apache.maven.archiva + archiva-repository-layer + Archiva Repository Interface Layer + + + org.apache.maven.archiva + archiva-common + + + org.apache.maven.archiva + archiva-model + 1.0-SNAPSHOT + + + org.codehaus.plexus + plexus-utils + + + org.codehaus.plexus.cache + plexus-cache-api + 1.0-alpha-2-SNAPSHOT + compile + + + org.codehaus.plexus.cache + plexus-cache-ehcache + 1.0-alpha-2-SNAPSHOT + compile + + + org.apache.maven + maven-artifact + + + org.apache.maven + maven-artifact-manager + + + org.apache.maven + maven-repository-metadata + + + org.slf4j + slf4j-log4j12 + + + + + + org.codehaus.plexus + plexus-maven-plugin + + + merge + + merge-descriptors + + + + ${basedir}/src/main/resources/META-INF/plexus/components.xml + ${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml + + + + + + + + diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java new file mode 100644 index 000000000..2f7f35fe9 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java @@ -0,0 +1,98 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.codehaus.plexus.cache.Cache; +import org.codehaus.plexus.cache.CacheException; +import org.codehaus.plexus.cache.CacheHints; +import org.codehaus.plexus.cache.factory.CacheFactory; + +import java.util.List; + +/** + * CachedRepositoryQueryLayer - simple wrapper around another non-cached Repository Query Layer. + * + * @version $Id$ + */ +public class CachedRepositoryQueryLayer + implements RepositoryQueryLayer +{ + private Cache cache; + + private RepositoryQueryLayer layer; + + public CachedRepositoryQueryLayer( RepositoryQueryLayer layer ) + throws RepositoryQueryLayerException + { + this.layer = layer; + String repoId = layer.getRepository().getId(); + + CacheHints hints = new CacheHints(); + hints.setName( repoId ); + hints.setOverflowToDisk( false ); + try + { + this.cache = CacheFactory.getInstance().getCache( repoId, hints ); + } + catch ( CacheException e ) + { + throw new RepositoryQueryLayerException( "Unable to initialize cache: " + e.getMessage(), e ); + } + } + + public boolean containsArtifact( Artifact artifact ) + { + boolean artifactFound = true; + + String artifactPath = layer.getRepository().pathOf( artifact ); + + if ( cache.get( artifactPath ) == null ) + { + artifactFound = layer.containsArtifact( artifact ); + if ( artifactFound ) + { + cache.put( artifactPath, artifactPath ); + } + } + + return artifactFound; + } + + public List getVersions( Artifact artifact ) + throws RepositoryQueryLayerException + { + List list = (List) cache.get( artifact.getId() ); + + if ( list == null ) + { + list = layer.getVersions( artifact ); + cache.put( artifact.getId(), list ); + } + + return list; + } + + public ArtifactRepository getRepository() + { + return layer.getRepository(); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayer.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayer.java new file mode 100644 index 000000000..d664dad1b --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayer.java @@ -0,0 +1,105 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; +import org.apache.maven.artifact.repository.metadata.Metadata; +import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.List; + +/** + * DefaultRepositoryQueryLayer + * + * @version $Id$ + * @plexus.component role="org.apache.maven.archiva.layer.RepositoryQueryLayer" role-hint="default" + */ +public class DefaultRepositoryQueryLayer + implements RepositoryQueryLayer +{ + protected ArtifactRepository repository; + + public DefaultRepositoryQueryLayer( ArtifactRepository repository ) + { + this.repository = repository; + } + + public boolean containsArtifact( Artifact artifact ) + { + File f = new File( repository.getBasedir(), repository.pathOf( artifact ) ); + return f.exists(); + } + + public List getVersions( Artifact artifact ) + throws RepositoryQueryLayerException + { + Metadata metadata = getMetadata( artifact ); + + return metadata.getVersioning().getVersions(); + } + + public ArtifactRepository getRepository() + { + return repository; + } + + private Metadata getMetadata( Artifact artifact ) + throws RepositoryQueryLayerException + { + Metadata metadata; + + ArtifactRepositoryMetadata repositoryMetadata = new ArtifactRepositoryMetadata( artifact ); + String path = repository.pathOfRemoteRepositoryMetadata( repositoryMetadata ); + File metadataFile = new File( repository.getBasedir(), path ); + if ( metadataFile.exists() ) + { + MetadataXpp3Reader reader = new MetadataXpp3Reader(); + try + { + metadata = reader.read( new FileReader( metadataFile ) ); + } + catch ( FileNotFoundException e ) + { + throw new RepositoryQueryLayerException( "Error occurred while attempting to read metadata file", e ); + } + catch ( IOException e ) + { + throw new RepositoryQueryLayerException( "Error occurred while attempting to read metadata file", e ); + } + catch ( XmlPullParserException e ) + { + throw new RepositoryQueryLayerException( "Error occurred while attempting to read metadata file", e ); + } + } + else + { + throw new RepositoryQueryLayerException( "Metadata not found: " + metadataFile.getAbsolutePath() ); + } + + return metadata; + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerFactory.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerFactory.java new file mode 100644 index 000000000..a7e794b19 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerFactory.java @@ -0,0 +1,38 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.repository.ArtifactRepository; + +/** + * Gets the default implementation of a repository query layer for the given repository. + * + * @author Brett Porter + * @version $Id:DefaultRepositoryQueryLayerFactory.java 437105 2006-08-26 17:22:22 +1000 (Sat, 26 Aug 2006) brett $ + * @plexus.component role="org.apache.maven.archiva.layer.RepositoryQueryLayerFactory" + */ +public class DefaultRepositoryQueryLayerFactory + implements RepositoryQueryLayerFactory +{ + public RepositoryQueryLayer createRepositoryQueryLayer( ArtifactRepository repository ) + { + return new DefaultRepositoryQueryLayer( repository ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayer.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayer.java new file mode 100644 index 000000000..16ee0b378 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayer.java @@ -0,0 +1,40 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; + +import java.util.List; + +/** + * The transitive and metadata validation reports will need to query the repository for artifacts. + */ +public interface RepositoryQueryLayer +{ + String ROLE = RepositoryQueryLayer.class.getName(); + + boolean containsArtifact( Artifact artifact ); + + List getVersions( Artifact artifact ) + throws RepositoryQueryLayerException; + + ArtifactRepository getRepository(); +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerException.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerException.java new file mode 100644 index 000000000..08ef9d932 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerException.java @@ -0,0 +1,37 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * + */ +public class RepositoryQueryLayerException + extends Exception +{ + public RepositoryQueryLayerException( String message, Throwable cause ) + { + super( message, cause ); + } + + public RepositoryQueryLayerException( String message ) + { + super( message ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerFactory.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerFactory.java new file mode 100644 index 000000000..2aad42224 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerFactory.java @@ -0,0 +1,41 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.repository.ArtifactRepository; + +/** + * Gets the preferred implementation of a repository query layer for the given repository. + * + * @author Brett Porter + * @version $Id:RepositoryQueryLayerFactory.java 437105 2006-08-26 17:22:22 +1000 (Sat, 26 Aug 2006) brett $ + */ +public interface RepositoryQueryLayerFactory +{ + String ROLE = RepositoryQueryLayerFactory.class.getName(); + + /** + * Create or obtain a query interface. + * + * @param repository the repository to query + * @return the obtained query layer + */ + RepositoryQueryLayer createRepositoryQueryLayer( ArtifactRepository repository ); +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaArtifact.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaArtifact.java new file mode 100644 index 000000000..2456f29f3 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaArtifact.java @@ -0,0 +1,161 @@ +package org.apache.maven.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.model.ArchivaArtifactModel; +import org.apache.maven.archiva.model.RepositoryContent; +import org.apache.maven.archiva.repository.version.VersionUtil; +import org.codehaus.plexus.util.StringUtils; + +/** + * ArchivaArtifact - Mutable artifact object. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ArchivaArtifact +{ + private ArchivaArtifactModel model; + + private String baseVersion; + + private boolean snapshot = false; + + public ArchivaArtifact( String groupId, String artifactId, String version, String classifier, String type ) + { + this( null, groupId, artifactId, version, classifier, type ); + } + + public ArchivaArtifact( ArchivaRepository repository, String groupId, String artifactId, String version, + String classifier, String type ) + { + if ( empty( groupId ) ) + { + throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty groupId." ); + } + + if ( empty( artifactId ) ) + { + throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty artifactId." ); + } + + if ( empty( version ) ) + { + throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty version." ); + } + + if ( empty( type ) ) + { + throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty type." ); + } + + model = new ArchivaArtifactModel(); + + if( repository == null ) + { + model.setContentKey( new RepositoryContent( groupId, artifactId, version ) ); + } + else + { + model.setContentKey( new RepositoryContent( repository.getModel(), groupId, artifactId, version ) ); + } + model.setClassifier( StringUtils.defaultString( classifier ) ); + model.setType( type ); + + this.snapshot = VersionUtil.isSnapshot( version ); + this.baseVersion = VersionUtil.getBaseVersion( version ); + } + + public String getGroupId() + { + return model.getContentKey().getGroupId(); + } + + public String getArtifactId() + { + return model.getContentKey().getArtifactId(); + } + + public String getVersion() + { + return model.getContentKey().getVersion(); + } + + public String getBaseVersion() + { + return baseVersion; + } + + public boolean isSnapshot() + { + return snapshot; + } + + public String getClassifier() + { + return model.getClassifier(); + } + + public String getType() + { + return model.getType(); + } + + public boolean hasClassifier() + { + return StringUtils.isNotEmpty( model.getClassifier() ); + } + + public String toString() + { + StringBuffer sb = new StringBuffer(); + if ( model.getContentKey().getGroupId() != null ) + { + sb.append( model.getContentKey().getGroupId() ); + sb.append( ":" ); + } + appendArtifactTypeClassifierString( sb ); + sb.append( ":" ); + if ( model.getContentKey().getVersion() != null ) + { + sb.append( model.getContentKey().getVersion() ); + } + + return sb.toString(); + } + + private void appendArtifactTypeClassifierString( StringBuffer sb ) + { + sb.append( model.getContentKey().getArtifactId() ); + sb.append( ":" ); + sb.append( getType() ); + if ( hasClassifier() ) + { + sb.append( ":" ); + sb.append( getClassifier() ); + } + } + + private boolean empty( String value ) + { + return value == null || value.trim().length() < 1; + } + +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaRepository.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaRepository.java new file mode 100644 index 000000000..c1fb4f0fe --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaRepository.java @@ -0,0 +1,135 @@ +package org.apache.maven.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.model.ArchivaRepositoryModel; +import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; + +/** + * ArchivaRepository + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ArchivaRepository +{ + protected ArtifactRepositoryPolicy releases; + + protected ArtifactRepositoryPolicy snapshots; + + private ArchivaRepositoryModel model; + + private RepositoryURL url; + + protected boolean blacklisted; + + /** + * Construct a Repository. + * + * @param id the unique identifier for this repository. + * @param name the name for this repository. + * @param url the base URL for this repository (this should point to the top level URL for the entire repository) + * @param layout the layout technique for this repository. + */ + public ArchivaRepository( String id, String name, String url ) + { + model = new ArchivaRepositoryModel(); + + model.setId( id ); + model.setName( name ); + setUrl( new RepositoryURL( url ) ); + } + + /** + * Construct a Repository. + * + * @param id the unique identifier for this repository. + * @param name the name for this repository. + * @param url the base URL for this repository (this should point to the top level URL for the entire repository) + * @param layout the layout technique for this repository. + */ + public ArchivaRepository( ArchivaRepositoryModel model ) + { + this.model = model; + + this.url = new RepositoryURL( model.getUrl() ); + } + + public String getId() + { + return model.getId(); + } + + public void setUrl( RepositoryURL url ) + { + this.url = url; + model.setUrl( url.getUrl() ); + } + + public RepositoryURL getUrl() + { + return this.url; + } + + public ArchivaRepositoryModel getModel() + { + return this.model; + } + + public boolean isBlacklisted() + { + return blacklisted; + } + + public void setBlacklisted( boolean blacklisted ) + { + this.blacklisted = blacklisted; + } + + public ArtifactRepositoryPolicy getReleases() + { + return releases; + } + + public void setReleases( ArtifactRepositoryPolicy releases ) + { + this.releases = releases; + } + + public ArtifactRepositoryPolicy getSnapshots() + { + return snapshots; + } + + public void setSnapshots( ArtifactRepositoryPolicy snapshots ) + { + this.snapshots = snapshots; + } + + public boolean isRemote() + { + return this.url.getProtocol().equals( "file" ); + } + + public boolean isManaged() + { + return this.url.getProtocol().equals( "file" ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryException.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryException.java new file mode 100644 index 000000000..0cafdc92d --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryException.java @@ -0,0 +1,52 @@ +package org.apache.maven.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * RepositoryException + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryException + extends Exception +{ + + public RepositoryException() + { + super(); + } + + public RepositoryException( String message, Throwable cause ) + { + super( message, cause ); + } + + public RepositoryException( String message ) + { + super( message ); + } + + public RepositoryException( Throwable cause ) + { + super( cause ); + } + +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryURL.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryURL.java new file mode 100644 index 000000000..13ed57fc9 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryURL.java @@ -0,0 +1,156 @@ +package org.apache.maven.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +/** + * RepositoryURL - Mutable (and protocol forgiving) URL object. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryURL +{ + private String url; + + private String protocol; + + private String host; + + private String port; + + private String username; + + private String password; + + private String path; + + public RepositoryURL( String url ) + { + this.url = url; + + // .\ Parse the URL \.____________________________________________ + + int pos; + + pos = url.indexOf( "://" ); + if ( pos == ( -1 ) ) + { + throw new IllegalArgumentException( "Invalid URL, unable to parse protocol:// from " + url ); + } + + protocol = url.substring( 0, pos ); + + // attempt to find the start of the 'path' + pos = url.indexOf( "/", protocol.length() + 3 ); + + // no path specified - ex "http://localhost" + if ( pos == ( -1 ) ) + { + // set pos to end of string. (needed for 'middle section') + pos = url.length(); + // default path + path = "/"; + } + else + { + // get actual path. + path = url.substring( pos ); + } + + // get the middle section ( username : password @ hostname : port ) + String middle = url.substring( protocol.length() + 3, pos ); + + pos = middle.indexOf( '@' ); + + // we have an authentication section. + if ( pos > 0 ) + { + String authentication = middle.substring( 0, pos ); + middle = middle.substring( pos + 1 ); // lop off authentication for host:port search + + pos = authentication.indexOf( ':' ); + + // we have a password. + if ( pos > 0 ) + { + username = authentication.substring( 0, pos ); + password = authentication.substring( pos + 1 ); + } + else + { + username = authentication; + } + } + + pos = middle.indexOf( ':' ); + + // we have a defined port + if ( pos > 0 ) + { + host = middle.substring( 0, pos ); + port = middle.substring( pos + 1 ); + } + else + { + host = middle; + } + } + + public String toString() + { + return url; + } + + public String getUsername() + { + return username; + } + + public String getPassword() + { + return password; + } + + public String getHost() + { + return host; + } + + public String getPath() + { + return path; + } + + public String getPort() + { + return port; + } + + public String getProtocol() + { + return protocol; + } + + public String getUrl() + { + return url; + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java new file mode 100644 index 000000000..f7adfedac --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java @@ -0,0 +1,41 @@ +package org.apache.maven.archiva.repository.connector; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.repository.ArchivaRepository; + +import java.util.List; + +/** + * RepositoryConnector + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public interface RepositoryConnector +{ + public ArchivaRepository getSourceRepository(); + + public ArchivaRepository getTargetRepository(); + + public List getBlacklist(); + + public List getWhitelist(); +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/Consumer.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/Consumer.java new file mode 100644 index 000000000..66b35a232 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/Consumer.java @@ -0,0 +1,91 @@ +package org.apache.maven.archiva.repository.consumer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.common.utils.BaseFile; +import org.apache.maven.archiva.repository.ArchivaRepository; +import org.apache.maven.artifact.repository.ArtifactRepository; + +import java.util.List; + +/** + * DiscovererConsumer + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public interface Consumer +{ + public static final String ROLE = Consumer.class.getName(); + + /** + * This is the human readable name for the discoverer. + * + * @return the human readable discoverer name. + */ + public String getName(); + + /** + * This is used to initialize any internals in the consumer before it is used. + * + * This method is called by the internals of archiva and is not meant to be used by other developers. + * This method is called once per repository. + * + * @param repository the repository to initialize the consumer against. + * @return true if the repository is valid for this consumer. false will result in consumer being disabled + * for the provided repository. + */ + public boolean init( ArchivaRepository repository ); + + /** + * Get the List of excluded file patterns for this consumer. + * + * @return the list of excluded file patterns for this consumer. + */ + public List getExcludePatterns(); + + /** + * Get the List of included file patterns for this consumer. + * + * @return the list of included file patterns for this consumer. + */ + public List getIncludePatterns(); + + /** + * Called by archiva framework to indicate that there is a file suitable for consuming, + * This method will only be called if the {@link #init(ArtifactRepository)} and {@link #getExcludePatterns()} + * and {@link #getIncludePatterns()} all pass for this consumer. + * + * @param file the file to process. + * @throws ConsumerException if there was a problem processing this file. + */ + public void processFile( BaseFile file ) throws ConsumerException; + + /** + * Called by archiva framework to indicate that there has been a problem detected + * on a specific file. + * + * NOTE: It is very possible for 1 file to have more than 1 problem associated with it. + * + * @param file the file to process. + * @param message the message describing the problem. + */ + public void processFileProblem( BaseFile file, String message ); +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java new file mode 100644 index 000000000..709be8e6d --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java @@ -0,0 +1,52 @@ +package org.apache.maven.archiva.repository.consumer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.common.ArchivaException; +import org.apache.maven.archiva.common.utils.BaseFile; + +/** + * ConsumerException - details about the failure of a consumer. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ConsumerException + extends ArchivaException +{ + private BaseFile file; + + public ConsumerException( BaseFile file, String message, Throwable cause ) + { + super( message, cause ); + this.file = file; + } + + public ConsumerException( BaseFile file, String message ) + { + super( message ); + this.file = file; + } + + public BaseFile getFile() + { + return file; + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerFactory.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerFactory.java new file mode 100644 index 000000000..00c88064d --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerFactory.java @@ -0,0 +1,70 @@ +package org.apache.maven.archiva.repository.consumer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.codehaus.plexus.PlexusConstants; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.context.Context; +import org.codehaus.plexus.context.ContextException; +import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; + +/** + * DiscovererConsumerFactory - factory for consumers. + * + * @author Joakim Erdfelt + * @version $Id$ + * @plexus.component role="org.apache.maven.archiva.common.consumers.ConsumerFactory" + */ +public class ConsumerFactory + extends AbstractLogEnabled + implements Contextualizable +{ + public static final String ROLE = ConsumerFactory.class.getName(); + + private PlexusContainer container; + + public Consumer createConsumer( String name ) + throws ConsumerException + { + getLogger().info( "Attempting to create consumer [" + name + "]" ); + + Consumer consumer; + try + { + consumer = (Consumer) container.lookup( Consumer.ROLE, name, container.getLookupRealm() ); + } + catch ( Throwable t ) + { + String emsg = "Unable to create consumer [" + name + "]: " + t.getMessage(); + getLogger().warn( t.getMessage(), t ); + throw new ConsumerException( null, emsg, t ); + } + + getLogger().info( "Created consumer [" + name + "|" + consumer.getName() + "]" ); + return consumer; + } + + public void contextualize( Context context ) + throws ContextException + { + container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractArtifactExtensionMapping.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractArtifactExtensionMapping.java new file mode 100644 index 000000000..3b1ab31c1 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractArtifactExtensionMapping.java @@ -0,0 +1,60 @@ +package org.apache.maven.archiva.repository.content; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.repository.ArchivaArtifact; + +import java.util.HashMap; +import java.util.Map; + +/** + * AbstractArtifactExtensionMapping + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public abstract class AbstractArtifactExtensionMapping implements ArtifactExtensionMapping +{ + protected final Map typeToExtensionMap; + + public AbstractArtifactExtensionMapping() + { + typeToExtensionMap = new HashMap(); + typeToExtensionMap.put( "ejb-client", "jar" ); + typeToExtensionMap.put( "ejb", "jar" ); + typeToExtensionMap.put( "distribution-tgz", "tar.gz" ); + typeToExtensionMap.put( "distribution-zip", "zip" ); + typeToExtensionMap.put( "java-source", "jar" ); + typeToExtensionMap.put( "aspect", "jar" ); + typeToExtensionMap.put( "uberjar", "jar" ); + } + + public String getExtension( ArchivaArtifact artifact ) + { + // Try specialized types first. + if ( typeToExtensionMap.containsKey( artifact.getType() ) ) + { + return (String) typeToExtensionMap.get( artifact.getType() ); + } + + // Return type + return artifact.getType(); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java new file mode 100644 index 000000000..0f6c990e7 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java @@ -0,0 +1,36 @@ +package org.apache.maven.archiva.repository.content; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.repository.ArchivaArtifact; + +/** + * ArtifactExtensionMapping - Utility to provide the mapping between an Artifact's extension and it's type and + * vice versa. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public interface ArtifactExtensionMapping +{ + public String getExtension( ArchivaArtifact artifact ); + + public String getType( String filename ); +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultArtifactExtensionMapping.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultArtifactExtensionMapping.java new file mode 100644 index 000000000..70f036259 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultArtifactExtensionMapping.java @@ -0,0 +1,76 @@ +package org.apache.maven.archiva.repository.content; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; + +/** + * DefaultArtifactExtensionMapping - extension mapping for Maven 2.x projects. + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="org.apache.maven.archiva.repository.content.ArtifactExtensionMapping" + * role-hint="default" + */ +public class DefaultArtifactExtensionMapping extends AbstractArtifactExtensionMapping + implements ArtifactExtensionMapping +{ + public DefaultArtifactExtensionMapping() + { + super(); + } + + public String getType( String filename ) + { + if ( StringUtils.isBlank( filename ) ) + { + return null; + } + + String normalizedName = filename.toLowerCase().trim(); + + if ( normalizedName.endsWith( ".tar.gz" ) ) + { + return "distribution-tgz"; + } + else if ( normalizedName.endsWith( ".zip" ) ) + { + return "distribution-zip"; + } + else if ( normalizedName.endsWith( "-sources.jar" ) ) + { + return "java-source"; + } + // TODO: handle type for -javadoc.jar ? + else + { + int index = normalizedName.lastIndexOf( '.' ); + if ( index >= 0 ) + { + return normalizedName.substring( index + 1 ); + } + else + { + throw new IllegalArgumentException( "Filename " + filename + " does not have an extension." ); + } + } + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyArtifactExtensionMapping.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyArtifactExtensionMapping.java new file mode 100644 index 000000000..10fd815c8 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyArtifactExtensionMapping.java @@ -0,0 +1,76 @@ +package org.apache.maven.archiva.repository.content; + +import org.apache.commons.lang.StringUtils; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * LegacyArtifactExtensionMapping + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role="org.apache.maven.archiva.repository.content.ArtifactExtensionMapping" + * role-hint="legacy" + */ +public class LegacyArtifactExtensionMapping extends AbstractArtifactExtensionMapping + implements ArtifactExtensionMapping +{ + public LegacyArtifactExtensionMapping() + { + super(); + } + + public String getType( String filename ) + { + if ( StringUtils.isBlank( filename ) ) + { + return null; + } + + String normalizedName = filename.toLowerCase().trim(); + + if ( normalizedName.endsWith( ".tar.gz" ) ) + { + return "distribution-tgz"; + } + else if ( normalizedName.endsWith( ".zip" ) ) + { + return "distribution-zip"; + } + else if ( normalizedName.endsWith( "-sources.jar" ) ) + { + return "java-source"; + } + // TODO: handle type for -javadoc.jar ? + else + { + int index = normalizedName.lastIndexOf( '.' ); + if ( index >= 0 ) + { + return normalizedName.substring( index + 1 ); + } + else + { + throw new IllegalArgumentException( "Filename " + filename + " does not have an extension." ); + } + } + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/BidirectionalRepositoryLayout.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/BidirectionalRepositoryLayout.java new file mode 100644 index 000000000..29770dffc --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/BidirectionalRepositoryLayout.java @@ -0,0 +1,56 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.repository.ArchivaArtifact; + +/** + * BidirectionalRepositoryLayout - Similar in scope to ArtifactRepositoryLayout, but does + * the both the Path to Artifact, and Artifact to Path conversions. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public interface BidirectionalRepositoryLayout +{ + /** + * Get the identifier for this layout. + * + * @return the identifier for this layout. + */ + public String getId(); + + /** + * Given an ArchivaArtifact, return the relative path to the artifact. + * + * @param artifact the artifact to compute the path of. + * @return the relative path to the artifact. + */ + public String pathOf( ArchivaArtifact artifact ); + + /** + * Given a repository relative path to a filename, return the ArchivaArtifact object suitable for the path. + * + * @param path the path relative to the repository base dir for the artifact. + * @return the ArchivaArtifact representing the path. (or null if path cannot be converted to an ArchivaArtifact) + * @throws LayoutException if there was a problem converting the path to an artifact. + */ + public ArchivaArtifact toArtifact( String path ) throws LayoutException; +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayout.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayout.java new file mode 100644 index 000000000..35406aa07 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayout.java @@ -0,0 +1,129 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.repository.ArchivaArtifact; +import org.apache.maven.archiva.repository.content.ArtifactExtensionMapping; +import org.apache.maven.archiva.repository.content.DefaultArtifactExtensionMapping; + +/** + * DefaultBidirectionalRepositoryLayout - the layout mechanism for use by Maven 2.x repositories. + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role-hint="default" + */ +public class DefaultBidirectionalRepositoryLayout + implements BidirectionalRepositoryLayout +{ + private static final char PATH_SEPARATOR = '/'; + + private static final char GROUP_SEPARATOR = '.'; + + private static final char ARTIFACT_SEPARATOR = '-'; + + private ArtifactExtensionMapping extensionMapper = new DefaultArtifactExtensionMapping(); + + public String getId() + { + return "default"; + } + + public String pathOf( ArchivaArtifact artifact ) + { + StringBuffer path = new StringBuffer(); + + path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR ); + path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR ); + path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR ); + path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); + + if ( artifact.hasClassifier() ) + { + path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() ); + } + + path.append( GROUP_SEPARATOR ).append( extensionMapper.getExtension( artifact ) ); + + return path.toString(); + } + + private String formatAsDirectory( String directory ) + { + return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR ); + } + + public ArchivaArtifact toArtifact( String path ) throws LayoutException + { + String normalizedPath = StringUtils.replace( path, "\\", "/" ); + + String pathParts[] = StringUtils.split( normalizedPath, '/' ); + + /* Minimum parts. + * + * path = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar" + * path[0] = "commons-lang"; // The Group ID + * path[1] = "commons-lang"; // The Artifact ID + * path[2] = "2.1"; // The Version + * path[3] = "commons-lang-2.1.jar" // The filename. + */ + + if ( pathParts.length < 4 ) + { + // Illegal Path Parts Length. + throw new LayoutException( "Not enough parts to the path [" + path + + "] to construct an ArchivaArtifact from. (Requires at least 4 parts)" ); + } + + // Maven 2.x path. + int partCount = pathParts.length; + + // Last part is the filename + String filename = pathParts[partCount - 1]; + + // Second to last is the baseVersion (the directory version) + // (Don't need it) String baseVersion = pathParts[partCount - 2]; + + // Third to last is the artifact Id. + String artifactId = pathParts[partCount - 3]; + + // Remaining pieces are the groupId. + String groupId = ""; + for ( int i = 0; i <= partCount - 4; i++ ) + { + if ( groupId.length() > 0 ) + { + groupId += "."; + } + groupId += pathParts[i]; + } + + // Now we need to parse the filename to get the artifact version Id. + String fileParts[] = RepositoryLayoutUtils.splitFilename( filename, artifactId ); + String version = fileParts[1]; + String classifier = fileParts[2]; + + String type = extensionMapper.getType( filename ); + + return new ArchivaArtifact( groupId, artifactId, version, classifier, type ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LayoutException.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LayoutException.java new file mode 100644 index 000000000..0fc833689 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LayoutException.java @@ -0,0 +1,41 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.common.ArchivaException; + +/** + * LayoutException + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class LayoutException extends ArchivaException +{ + public LayoutException( String message, Throwable cause ) + { + super( message, cause ); + } + + public LayoutException( String message ) + { + super( message ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayout.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayout.java new file mode 100644 index 000000000..0344a5245 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayout.java @@ -0,0 +1,135 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.repository.ArchivaArtifact; +import org.apache.maven.archiva.repository.content.ArtifactExtensionMapping; +import org.apache.maven.archiva.repository.content.LegacyArtifactExtensionMapping; + +import java.util.HashMap; +import java.util.Map; + +/** + * LegacyBidirectionalRepositoryLayout - the layout mechanism for use by Maven 1.x repositories. + * + * @author Joakim Erdfelt + * @version $Id$ + * + * @plexus.component role-hint="legacy" + */ +public class LegacyBidirectionalRepositoryLayout implements BidirectionalRepositoryLayout +{ + private static final String PATH_SEPARATOR = "/"; + + private ArtifactExtensionMapping extensionMapper = new LegacyArtifactExtensionMapping(); + + private Map typeToDirectoryMap; + + public LegacyBidirectionalRepositoryLayout() + { + typeToDirectoryMap = new HashMap(); + typeToDirectoryMap.put( "ejb-client", "ejb" ); + typeToDirectoryMap.put( "distribution-tgz", "distribution" ); + typeToDirectoryMap.put( "distribution-zip", "distribution" ); + } + + public String getId() + { + return "legacy"; + } + + public String pathOf( ArchivaArtifact artifact ) + { + StringBuffer path = new StringBuffer(); + + path.append( artifact.getGroupId() ).append( PATH_SEPARATOR ); + path.append( getDirectory( artifact ) ).append( PATH_SEPARATOR ); + path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); + + if ( artifact.hasClassifier() ) + { + path.append( '-' ).append( artifact.getClassifier() ); + } + + path.append( '.' ).append( extensionMapper.getExtension( artifact ) ); + + return path.toString(); + } + + private String getDirectory( ArchivaArtifact artifact ) + { + // Special Cases involving classifiers and type. + if ( "jar".equals( artifact.getType() ) && "sources".equals( artifact.getClassifier() ) ) + { + return "javadoc.jars"; + } + + // Special Cases involving only type. + String dirname = (String) typeToDirectoryMap.get( artifact.getType() ); + + if ( dirname != null ) + { + return dirname + "s"; + } + + // Default process. + return artifact.getType() + "s"; + } + + public ArchivaArtifact toArtifact( String path ) throws LayoutException + { + String normalizedPath = StringUtils.replace( path, "\\", "/" ); + + String pathParts[] = StringUtils.split( normalizedPath, '/' ); + + /* Always 3 parts. (Never more or less) + * + * path = "commons-lang/jars/commons-lang-2.1.jar" + * path[0] = "commons-lang"; // The Group ID + * path[1] = "jars"; // The Directory Type + * path[2] = "commons-lang-2.1.jar"; // The Filename. + */ + + if ( pathParts.length != 3 ) + { + // Illegal Path Parts Length. + throw new LayoutException( "Invalid number of parts to the path [" + path + + "] to construct an ArchivaArtifact from. (Required to be 3 parts)" ); + } + + // The Group ID. + String groupId = pathParts[0]; + + // The Filename. + String filename = pathParts[2]; + + String fileParts[] = RepositoryLayoutUtils.splitFilename( filename, null ); + + String artifactId = fileParts[0]; + String version = fileParts[1]; + String classifier = fileParts[2]; + + String type = extensionMapper.getType( filename ); + + return new ArchivaArtifact( groupId, artifactId, version, classifier, type ); + } + +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtils.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtils.java new file mode 100644 index 000000000..8e2c144c9 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtils.java @@ -0,0 +1,219 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * RepositoryLayoutUtils - utility methods common for most BidirectionalRepositoryLayout implementation. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryLayoutUtils +{ + /** + * Complex 2+ part extensions. + * Do not include initial "." character in extension names here. + */ + private static final String ComplexExtensions[] = new String[] { "tar.gz", "tar.bz2" }; + + /** + * These are the version patterns found in the filenames of the various artifact's versions IDs. + * These patterns are all tackling lowercase version IDs. + */ + private static final String VersionPatterns[] = + new String[] { "(snapshot)", "([0-9][_.0-9a-z]*)", "(g?[_.0-9ab]*(pre|rc|g|m)[_.0-9]*)", "(dev[_.0-9]*)", + "(alpha[_.0-9]*)", "(beta[_.0-9]*)", "(rc[_.0-9]*)", "(test[_.0-9]*)", "(debug[_.0-9]*)", + "(unofficial[_.0-9]*)", "(current)", "(latest)", "(fcs)", "(release[_.0-9]*)", "(nightly)", "(final)", + "(incubating)", "(incubator)", "([ab][_.0-9]*)" }; + + private static final String VersionMegaPattern = StringUtils.join( VersionPatterns, '|' ); + + /** + * Filename Parsing Mode - Artifact Id. + */ + private static final int ARTIFACTID = 1; + + /** + * Filename Parsing Mode - Version. + */ + private static final int VERSION = 2; + + /** + * Filename Parsing Mode - Classifier. + */ + private static final int CLASSIFIER = 3; + + /** + * Split the provided filename into 4 String parts. + * + *
+     * String part[] = splitFilename( filename );
+     * artifactId = part[0];
+     * version    = part[1];
+     * classifier = part[2];
+     * extension  = part[3];
+     * 
+ * + * @param filename the filename to split. + * @param possibleArtifactId the optional artifactId to aide in splitting the filename. + * (null to allow algorithm to calculate one) + * @return the parts of the filename. + * @throws LayoutException + */ + public static String[] splitFilename( String filename, String possibleArtifactId ) throws LayoutException + { + if ( StringUtils.isBlank( filename ) ) + { + throw new IllegalArgumentException( "Unable to split blank filename." ); + } + + String filestring = filename.trim(); + + String artifactId = ""; + String version = ""; + String classifier = ""; + String extension = ""; + + // I like working backwards. + + // Find the extension. + + // Work on multipart extensions first. + boolean found = false; + + String lowercaseFilename = filestring.toLowerCase(); + for ( int i = 0; i < ComplexExtensions.length && !found; i++ ) + { + if ( lowercaseFilename.endsWith( "." + ComplexExtensions[i] ) ) + { + extension = ComplexExtensions[i]; + filestring = filestring.substring( 0, filestring.length() - ComplexExtensions[i].length() - 1 ); + found = true; + } + } + + if ( !found ) + { + // Default to 1 part extension. + + int index = filestring.lastIndexOf( '.' ); + if ( index <= 0 ) + { + // Bad Filename - No Extension + throw new LayoutException( "Unable to determine extension from filename " + filename ); + } + extension = filestring.substring( index + 1 ); + filestring = filestring.substring( 0, index ); + } + + // Work on version string. + + if ( ( possibleArtifactId != null ) && filename.startsWith( possibleArtifactId ) ) + { + artifactId = possibleArtifactId; + filestring = filestring.substring( possibleArtifactId.length() + 1 ); + } + + String fileParts[] = StringUtils.split( filestring, '-' ); + + int versionStart = -1; + int versionEnd = -1; + + Pattern pat = Pattern.compile( VersionMegaPattern, Pattern.CASE_INSENSITIVE ); + Matcher mat; + + for ( int i = 0; i < fileParts.length; i++ ) + { + String part = fileParts[i]; + mat = pat.matcher( part ); + + if ( mat.matches() ) + { + // It is a potential verion part. + if ( versionStart < 0 ) + { + versionStart = i; + } + + versionEnd = i; + } + } + + if ( versionStart < 0 ) + { + throw new LayoutException( "Unable to determine version from filename " + filename ); + } + + // Gather up the ArtifactID - Version - Classifier pieces found. + + int mode = ARTIFACTID; + for ( int i = 0; i < fileParts.length; i++ ) + { + String part = fileParts[i]; + + if ( ( mode == ARTIFACTID ) && ( i >= versionStart ) ) + { + if ( StringUtils.isBlank( artifactId ) ) + { + throw new LayoutException( "No Artifact Id detected." ); + } + mode = VERSION; + } + + switch ( mode ) + { + case ARTIFACTID: + if ( artifactId.length() > 0 ) + { + artifactId += "-"; + } + artifactId += part; + break; + case VERSION: + if ( version.length() > 0 ) + { + version += "-"; + } + version += part; + break; + case CLASSIFIER: + if ( classifier.length() > 0 ) + { + classifier += "-"; + } + classifier += part; + break; + } + + if ( i >= versionEnd ) + { + mode = CLASSIFIER; + } + } + + return new String[] { artifactId, version, classifier, extension }; + } + +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java new file mode 100644 index 000000000..568c07c9c --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java @@ -0,0 +1,197 @@ +package org.apache.maven.archiva.repository.scanner; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.model.RepositoryContentStatistics; +import org.apache.maven.archiva.repository.ArchivaRepository; +import org.apache.maven.archiva.repository.RepositoryException; +import org.apache.maven.archiva.repository.consumer.Consumer; +import org.codehaus.plexus.util.DirectoryWalker; +import org.codehaus.plexus.util.FileUtils; + +import java.io.File; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +/** + * RepositoryScanner + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryScanner +{ + /** + * Standard patterns to exclude from discovery as they are usually noise. + */ + private static final String[] STANDARD_SCANNER_EXCLUDES = { + "bin/**", + "reports/**", + ".index", + ".reports/**", + ".maven/**", + "**/*snapshot-version", + "*/website/**", + "*/licences/**", + "**/.htaccess", + "**/*.html", + "**/*.txt", + "**/README*", + "**/CHANGELOG*", + "**/KEYS*" }; + + /** + * Walk the repository, and report to the consumers the files found. + * + * Report changes to the appropriate Consumer. + * + * This is just a convenience method to {@link #scan(ArtifactRepository, List, boolean, long, List, List)} + * equivalent to calling scan( repository, consumers, includeSnapshots, 0, null, null ); + * + * @param repository the repository to change. + * @param consumers use the provided list of consumers. + * @param includeSnapshots true to include snapshots in the walking of this repository. + * @return the statistics for this scan. + * @throws RepositoryException if there was a fundamental problem with getting the discoverer started. + */ + public RepositoryContentStatistics scan( ArchivaRepository repository, List consumers, boolean includeSnapshots ) + throws RepositoryException + { + return scan( repository, consumers, includeSnapshots, 0, null, null ); + } + + /** + * Walk the repository, and report to the consumers the files found. + * + * Report changes to the appropriate Consumer. + * + * @param repository the repository to change. + * @param consumers use the provided list of consumers. + * @param includeSnapshots true to include snapshots in the scanning of this repository. + * @param onlyModifiedAfterTimestamp Only report to the consumers, files that have a {@link File#lastModified()}) + * after the provided timestamp. + * @param extraFileExclusions an optional list of file exclusions on the walk. + * @param extraFileInclusions an optional list of file inclusions on the walk. + * @return the statistics for this scan. + * @throws RepositoryException if there was a fundamental problem with getting the discoverer started. + */ + public RepositoryContentStatistics scan( ArchivaRepository repository, List consumers, boolean includeSnapshots, + long onlyModifiedAfterTimestamp, List extraFileExclusions, List extraFileInclusions ) + throws RepositoryException + { + if ( repository == null ) + { + throw new IllegalArgumentException( "Unable to operate on a null repository." ); + } + + if ( !"file".equals( repository.getUrl().getProtocol() ) ) + { + throw new UnsupportedOperationException( "Only filesystem repositories are supported." ); + } + + File repositoryBase = new File( repository.getUrl().getPath() ); + + if ( !repositoryBase.exists() ) + { + throw new UnsupportedOperationException( "Unable to scan a repository, directory " + + repositoryBase.getAbsolutePath() + " does not exist." ); + } + + if ( !repositoryBase.isDirectory() ) + { + throw new UnsupportedOperationException( "Unable to scan a repository, path " + + repositoryBase.getAbsolutePath() + " is not a directory." ); + } + + // Setup Includes / Excludes. + + List allExcludes = new ArrayList(); + List allIncludes = new ArrayList(); + + // Exclude all of the SCM patterns. + allExcludes.addAll( FileUtils.getDefaultExcludesAsList() ); + + // Exclude all of the archiva noise patterns. + allExcludes.addAll( Arrays.asList( STANDARD_SCANNER_EXCLUDES ) ); + + if ( !includeSnapshots ) + { + allExcludes.add( "**/*-SNAPSHOT*" ); + } + + if ( extraFileExclusions != null ) + { + allExcludes.addAll( extraFileExclusions ); + } + + Iterator it = consumers.iterator(); + while ( it.hasNext() ) + { + Consumer consumer = (Consumer) it.next(); + + /* NOTE: Do not insert the consumer exclusion patterns here. + * Exclusion patterns are handled by RepositoryScanner.wantsFile(Consumer, String) + * + * addUniqueElements( consumer.getExcludePatterns(), allExcludes ); + */ + addUniqueElements( consumer.getIncludePatterns(), allIncludes ); + } + + if ( extraFileInclusions != null ) + { + allIncludes.addAll( extraFileInclusions ); + } + + // Setup Directory Walker + + DirectoryWalker dirWalker = new DirectoryWalker(); + + dirWalker.setBaseDir( repositoryBase ); + + dirWalker.setIncludes( allIncludes ); + dirWalker.setExcludes( allExcludes ); + + // Setup the Scan Instance + RepositoryScannerInstance scannerInstance = new RepositoryScannerInstance( repository, consumers ); + scannerInstance.setOnlyModifiedAfterTimestamp( onlyModifiedAfterTimestamp ); + + dirWalker.addDirectoryWalkListener( scannerInstance ); + + // Execute scan. + dirWalker.scan(); + + return scannerInstance.getStatistics(); + } + + private void addUniqueElements( List fromList, List toList ) + { + Iterator itFrom = fromList.iterator(); + while ( itFrom.hasNext() ) + { + Object o = itFrom.next(); + if ( !toList.contains( o ) ) + { + toList.add( o ); + } + } + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java new file mode 100644 index 000000000..349618273 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java @@ -0,0 +1,199 @@ +package org.apache.maven.archiva.repository.scanner; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.SystemUtils; +import org.apache.maven.archiva.common.utils.BaseFile; +import org.apache.maven.archiva.model.RepositoryContentStatistics; +import org.apache.maven.archiva.repository.ArchivaRepository; +import org.apache.maven.archiva.repository.consumer.Consumer; +import org.codehaus.plexus.util.DirectoryWalkListener; +import org.codehaus.plexus.util.SelectorUtils; +import org.codehaus.plexus.util.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.util.Iterator; +import java.util.List; + +/** + * RepositoryScannerInstance + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryScannerInstance implements DirectoryWalkListener +{ + private static Logger log = LoggerFactory.getLogger( RepositoryScannerInstance.class ); + + private List consumers; + + private ArchivaRepository repository; + + private boolean isCaseSensitive = true; + + private RepositoryContentStatistics stats; + + private long onlyModifiedAfterTimestamp = 0; + + public RepositoryScannerInstance( ArchivaRepository repository, List consumerList ) + { + this.repository = repository; + this.consumers = consumerList; + stats = new RepositoryContentStatistics(); + stats.setRepositoryId( repository.getId() ); + + + Iterator it = this.consumers.iterator(); + while ( it.hasNext() ) + { + Consumer consumer = (Consumer) it.next(); + + if ( !consumer.init( this.repository ) ) + { + throw new IllegalStateException( "Consumer [" + consumer.getName() + + "] is reporting that it is incompatible with the [" + repository.getId() + "] repository." ); + } + } + + if ( SystemUtils.IS_OS_WINDOWS ) + { + isCaseSensitive = false; + } + } + + public RepositoryContentStatistics getStatistics() + { + return stats; + } + + public void directoryWalkStarting( File basedir ) + { + log.info( "Walk Started: [" + this.repository.getId() + "] " + this.repository.getUrl() ); + stats.triggerStart(); + } + + public void directoryWalkStep( int percentage, File file ) + { + log.debug( "Walk Step: " + percentage + ", " + file ); + + stats.increaseFileCount(); + + // Timestamp finished points to the last successful scan, not this current one. + if ( file.lastModified() < onlyModifiedAfterTimestamp ) + { + // Skip file as no change has occured. + log.debug( "Skipping, No Change: " + file.getAbsolutePath() ); + return; + } + + synchronized ( consumers ) + { + stats.increaseNewFileCount(); + + BaseFile basefile = new BaseFile( repository.getUrl().getPath(), file ); + + Iterator itConsumers = this.consumers.iterator(); + while ( itConsumers.hasNext() ) + { + Consumer consumer = (Consumer) itConsumers.next(); + + if ( wantsFile( consumer, StringUtils.replace( basefile.getRelativePath(), "\\", "/" ) ) ) + { + try + { + log.debug( "Sending to consumer: " + consumer.getName() ); + consumer.processFile( basefile ); + } + catch ( Exception e ) + { + /* Intentionally Catch all exceptions. + * So that the discoverer processing can continue. + */ + log.error( "Consumer [" + consumer.getName() + "] had an error when processing file [" + + basefile.getAbsolutePath() + "]: " + e.getMessage(), e ); + } + } + else + { + log.debug( + "Skipping consumer " + consumer.getName() + " for file " + basefile.getRelativePath() ); + } + } + } + } + + public void directoryWalkFinished() + { + log.info( "Walk Finished: [" + this.repository.getId() + "] " + this.repository.getUrl() ); + stats.triggerFinished(); + } + + private boolean wantsFile( Consumer consumer, String relativePath ) + { + Iterator it; + + // Test excludes first. + it = consumer.getExcludePatterns().iterator(); + while ( it.hasNext() ) + { + String pattern = (String) it.next(); + if ( SelectorUtils.matchPath( pattern, relativePath, isCaseSensitive ) ) + { + // Definately does NOT WANT FILE. + return false; + } + } + + // Now test includes. + it = consumer.getIncludePatterns().iterator(); + while ( it.hasNext() ) + { + String pattern = (String) it.next(); + if ( SelectorUtils.matchPath( pattern, relativePath, isCaseSensitive ) ) + { + // Specifically WANTS FILE. + return true; + } + } + + // Not included, and Not excluded? Default to EXCLUDE. + return false; + } + + public long getOnlyModifiedAfterTimestamp() + { + return onlyModifiedAfterTimestamp; + } + + public void setOnlyModifiedAfterTimestamp( long onlyModifiedAfterTimestamp ) + { + this.onlyModifiedAfterTimestamp = onlyModifiedAfterTimestamp; + } + + /** + * Debug method from DirectoryWalker. + */ + public void debug( String message ) + { + log.debug( "Repository Scanner: " + message ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/version/VersionUtil.java b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/version/VersionUtil.java new file mode 100644 index 000000000..c8ce3716f --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/version/VersionUtil.java @@ -0,0 +1,62 @@ +package org.apache.maven.archiva.repository.version; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * VersionConstants + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class VersionUtil +{ + public static final String SNAPSHOT = "SNAPSHOT"; + + public static final Pattern UNIQUE_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}\\.[0-9]{6})-([0-9]+)$" ); + + public static boolean isSnapshot( String version ) + { + Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version ); + if ( m.matches() ) + { + return true; + } + else + { + return version.endsWith( SNAPSHOT ); + } + } + + public static String getBaseVersion( String version ) + { + Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version ); + if ( m.matches() ) + { + return m.group( 1 ) + "-" + SNAPSHOT; + } + else + { + return version; + } + } +} diff --git a/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml b/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml new file mode 100644 index 000000000..c2ee003f5 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml @@ -0,0 +1,43 @@ + + + + + + + + org.codehaus.plexus.cache.Cache + repository-query + org.codehaus.plexus.cache.ehcache.EhcacheCache + EhcacheCache + + 600 + true + ${java.io.tmpdir}/ehcache/repo-query + false + 1000 + LRU + repository-query + false + 600 + 300 + + + + diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java new file mode 100644 index 000000000..e23eb09f7 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests - conveinence test suite for IDE users. + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva" ); + //$JUnit-BEGIN$ + suite.addTest( org.apache.maven.archiva.repository.AllTests.suite() ); + suite.addTest( org.apache.maven.archiva.layer.AllTests.suite() ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AbstractRepositoryQueryLayerTestCase.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AbstractRepositoryQueryLayerTestCase.java new file mode 100644 index 000000000..55f509457 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AbstractRepositoryQueryLayerTestCase.java @@ -0,0 +1,116 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.factory.ArtifactFactory; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; +import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; +import org.codehaus.plexus.PlexusTestCase; + +import java.io.File; +import java.util.List; + +/** + * + */ +public abstract class AbstractRepositoryQueryLayerTestCase + extends PlexusTestCase +{ + private ArtifactFactory artifactFactory; + + protected ArtifactRepository repository; + + protected RepositoryQueryLayer queryLayer; + + protected void setUp() + throws Exception + { + super.setUp(); + File repositoryDirectory = getTestFile( "src/test/repositories/simple-repository" ); + + artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); + ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); + ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); + + repository = + factory.createArtifactRepository( "test", repositoryDirectory.toURL().toString(), layout, null, null ); + } + + public void testContainsArtifactTrue() + { + Artifact artifact = getArtifact( "groupId", "artifactId", "1.0-alpha-1" ); + + assertTrue( "check artifact", queryLayer.containsArtifact( artifact ) ); + } + + public void testContainsArtifactFalse() + { + Artifact artifact = getArtifact( "groupId", "artifactId", "1.0-beta-1" ); + + assertFalse( "check non-existent artifact", queryLayer.containsArtifact( artifact ) ); + } + + public void testContainsSnapshotArtifactTrue() + { + Artifact artifact = getArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-20050611.202024-1" ); + assertTrue( "check for snapshot artifact", queryLayer.containsArtifact( artifact ) ); + } + + public void testContainsSnapshotArtifactFalse() + { + Artifact artifact = getArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-20050611.202024-2" ); + assertFalse( "check for non-existent snapshot artifact", queryLayer.containsArtifact( artifact ) ); + } + + public void testArtifactVersions() + throws Exception + { + Artifact artifact = getArtifact( "groupId", "artifactId", "ignored" ); + + List versions = queryLayer.getVersions( artifact ); + + assertTrue( "check version 1.0-alpha-1", versions.contains( "1.0-alpha-1" ) ); + assertFalse( "check version 1.0-alpha-2", versions.contains( "1.0-alpha-2" ) ); + } + + public void testArtifactVersionsError() + { + Artifact artifact = getArtifact( "groupId", "none", "ignored" ); + + try + { + queryLayer.getVersions( artifact ); + fail( "expected error not thrown" ); + } + catch ( RepositoryQueryLayerException e ) + { + //expected + } + } + + private Artifact getArtifact( String groupId, String artifactId, String version ) + { + Artifact projectArtifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); + projectArtifact.isSnapshot(); + return projectArtifact; + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java new file mode 100644 index 000000000..c87f2710e --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java @@ -0,0 +1,44 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.layer" ); + //$JUnit-BEGIN$ + suite.addTestSuite( CachedRepositoryQueryLayerTest.class ); + suite.addTestSuite( DefaultRepositoryQueryLayerTest.class ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java new file mode 100644 index 000000000..1451e380c --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java @@ -0,0 +1,56 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/** + * CachedRepositoryQueryLayerTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class CachedRepositoryQueryLayerTest + extends AbstractRepositoryQueryLayerTestCase +{ + protected void setUp() + throws Exception + { + super.setUp(); + + RepositoryQueryLayer defaultLayer = new DefaultRepositoryQueryLayer( repository ); + + queryLayer = new CachedRepositoryQueryLayer( defaultLayer ); + } + + public void testUseFileCache() + { + testContainsArtifactTrue(); + } + + public void testUseMetadataCache() + throws Exception + { + testArtifactVersions(); + } + + public void testUseFileCacheOnSnapshot() + { + testContainsSnapshotArtifactTrue(); + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerTest.java new file mode 100644 index 000000000..4a50f8c66 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerTest.java @@ -0,0 +1,32 @@ +package org.apache.maven.archiva.layer; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class DefaultRepositoryQueryLayerTest + extends AbstractRepositoryQueryLayerTestCase +{ + protected void setUp() + throws Exception + { + super.setUp(); + + queryLayer = new DefaultRepositoryQueryLayer( repository ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java new file mode 100644 index 000000000..e25a55e80 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java @@ -0,0 +1,43 @@ +package org.apache.maven.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * AllTests + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AllTests +{ + + public static Test suite() + { + TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.repository" ); + //$JUnit-BEGIN$ + suite.addTestSuite( RepositoryURLTest.class ); + //$JUnit-END$ + return suite; + } + +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/RepositoryURLTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/RepositoryURLTest.java new file mode 100644 index 000000000..c91eef8c8 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/RepositoryURLTest.java @@ -0,0 +1,90 @@ +package org.apache.maven.archiva.repository; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + + +import java.net.MalformedURLException; + +import junit.framework.TestCase; + +/** + * RepositoryURLTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryURLTest + extends TestCase +{ + private void assertURL( String actualURL, String protocol, String username, String password, String hostname, + String port, String path ) + { + RepositoryURL url = new RepositoryURL( actualURL ); + + assertEquals( protocol, url.getProtocol() ); + assertEquals( username, url.getUsername() ); + assertEquals( password, url.getPassword() ); + assertEquals( hostname, url.getHost() ); + assertEquals( port, url.getPort() ); + assertEquals( path, url.getPath() ); + } + + public void testProtocolHttp() + throws MalformedURLException + { + assertURL( "http://localhost/path/to/resource.txt", "http", null, null, "localhost", null, + "/path/to/resource.txt" ); + } + + public void testProtocolWagonWebdav() + throws MalformedURLException + { + assertURL( "dav:http://localhost/path/to/resource.txt", "dav:http", null, null, "localhost", null, + "/path/to/resource.txt" ); + } + + public void testProtocolHttpWithPort() + throws MalformedURLException + { + assertURL( "http://localhost:9090/path/to/resource.txt", "http", null, null, "localhost", "9090", + "/path/to/resource.txt" ); + } + + public void testProtocolHttpWithUsername() + throws MalformedURLException + { + assertURL( "http://user@localhost/path/to/resource.txt", "http", "user", null, "localhost", null, + "/path/to/resource.txt" ); + } + + public void testProtocolHttpWithUsernamePassword() + throws MalformedURLException + { + assertURL( "http://user:pass@localhost/path/to/resource.txt", "http", "user", "pass", "localhost", null, + "/path/to/resource.txt" ); + } + + public void testProtocolHttpWithUsernamePasswordPort() + throws MalformedURLException + { + assertURL( "http://user:pass@localhost:9090/path/to/resource.txt", "http", "user", "pass", "localhost", "9090", + "/path/to/resource.txt" ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/AbstractBidirectionalRepositoryLayoutTestCase.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/AbstractBidirectionalRepositoryLayoutTestCase.java new file mode 100644 index 000000000..b15685a3b --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/AbstractBidirectionalRepositoryLayoutTestCase.java @@ -0,0 +1,100 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.repository.ArchivaArtifact; +import org.apache.maven.archiva.repository.ArchivaRepository; +import org.codehaus.plexus.PlexusTestCase; + +import java.io.File; + +/** + * AbstractBidirectionalRepositoryLayoutTestCase + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class AbstractBidirectionalRepositoryLayoutTestCase extends PlexusTestCase +{ + protected ArchivaRepository repository; + + protected void setUp() throws Exception + { + super.setUp(); + + repository = createTestRepository(); + } + + protected ArchivaRepository createTestRepository() + { + File targetDir = new File( getBasedir(), "target" ); + File testRepo = new File( targetDir, "test-repo" ); + + if ( !testRepo.exists() ) + { + testRepo.mkdirs(); + } + + String repoUri = "file://" + StringUtils.replace( testRepo.getAbsolutePath(), "\\", "/" ); + + ArchivaRepository repo = new ArchivaRepository( "testRepo", "Test Repository", repoUri ); + + return repo; + } + + protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier, + String type ) + { + ArchivaArtifact artifact = new ArchivaArtifact( repository, groupId, artifactId, version, classifier, type ); + assertNotNull( artifact ); + return artifact; + } + + protected void assertArtifact( ArchivaArtifact actualArtifact, String groupId, String artifactId, String version, + String classifier, String type ) + { + String expectedId = groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type; + + assertNotNull( expectedId + " - Should not be null.", actualArtifact ); + + assertEquals( expectedId + " - Group ID", actualArtifact.getGroupId(), groupId ); + assertEquals( expectedId + " - Artifact ID", actualArtifact.getArtifactId(), artifactId ); + assertEquals( expectedId + " - Version ID", actualArtifact.getVersion(), version ); + assertEquals( expectedId + " - Classifier", actualArtifact.getClassifier(), classifier ); + assertEquals( expectedId + " - Type", actualArtifact.getType(), type ); + } + + protected void assertSnapshotArtifact( ArchivaArtifact actualArtifact, String groupId, String artifactId, + String version, String classifier, String type ) + { + String expectedId = groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type; + + assertNotNull( expectedId + " - Should not be null.", actualArtifact ); + + assertEquals( expectedId + " - Group ID", actualArtifact.getGroupId(), groupId ); + assertEquals( expectedId + " - Artifact ID", actualArtifact.getArtifactId(), artifactId ); + assertEquals( expectedId + " - Version ID", actualArtifact.getVersion(), version ); + assertEquals( expectedId + " - Classifier", actualArtifact.getClassifier(), classifier ); + assertEquals( expectedId + " - Type", actualArtifact.getType(), type ); + assertTrue( expectedId + " - Snapshot", actualArtifact.isSnapshot() ); + } + +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java new file mode 100644 index 000000000..249104a7f --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java @@ -0,0 +1,105 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.repository.ArchivaArtifact; +import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; +import org.apache.maven.archiva.repository.layout.LayoutException; + +/** + * DefaultBidirectionalRepositoryLayoutTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class DefaultBidirectionalRepositoryLayoutTest extends AbstractBidirectionalRepositoryLayoutTestCase +{ + private BidirectionalRepositoryLayout layout; + + protected void setUp() throws Exception + { + super.setUp(); + + layout = (BidirectionalRepositoryLayout) lookup( BidirectionalRepositoryLayout.class.getName(), "default" ); + } + + public void testToPathBasic() + { + ArchivaArtifact artifact = createArtifact( "com.foo", "foo-tool", "1.0", "", "jar" ); + + assertEquals( "com/foo/foo-tool/1.0/foo-tool-1.0.jar", layout.pathOf( artifact ) ); + } + + public void testToPathEjbClient() + { + ArchivaArtifact artifact = createArtifact( "com.foo", "foo-client", "1.0", "", "ejb-client" ); + + assertEquals( "com/foo/foo-client/1.0/foo-client-1.0.jar", layout.pathOf( artifact ) ); + } + + public void testToPathWithClassifier() + { + ArchivaArtifact artifact = createArtifact( "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "java-source" ); + + assertEquals( "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar", layout.pathOf( artifact ) ); + } + + public void testToPathUsingUniqueSnapshot() + { + ArchivaArtifact artifact = createArtifact( "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" ); + + assertEquals( "com/foo/foo-connector/2.1-SNAPSHOT/foo-connector-2.1-20060822.123456-35.jar", + layout.pathOf( artifact ) ); + } + + public void testToArtifactBasicSimpleGroupId() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "commons-lang/commons-lang/2.1/commons-lang-2.1.jar" ); + assertArtifact( artifact, "commons-lang", "commons-lang", "2.1", "", "jar" ); + } + + public void testToArtifactBasicLongGroupId() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "com/foo/foo-tool/1.0/foo-tool-1.0.jar" ); + assertArtifact( artifact, "com.foo", "foo-tool", "1.0", "", "jar" ); + } + + public void testToArtifactEjbClient() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "com/foo/foo-client/1.0/foo-client-1.0.jar" ); + // The type is correct. as we cannot possibly know this is an ejb client without parsing the pom + assertArtifact( artifact, "com.foo", "foo-client", "1.0", "", "jar" ); + } + + public void testToArtifactWithClassifier() throws LayoutException + { + ArchivaArtifact artifact = + layout.toArtifact( "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar" ); + // The 'java-source' type is correct. You might be thinking of extension, which we are not testing here. + assertArtifact( artifact, "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "java-source" ); + } + + public void testToArtifactUsingUniqueSnapshot() throws LayoutException + { + ArchivaArtifact artifact = + layout.toArtifact( "com/foo/foo-connector/2.1-SNAPSHOT/foo-connector-2.1-20060822.123456-35.jar" ); + assertSnapshotArtifact( artifact, "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayoutTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayoutTest.java new file mode 100644 index 000000000..c90f3b56f --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayoutTest.java @@ -0,0 +1,107 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.repository.ArchivaArtifact; +import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; + +/** + * LegacyBidirectionalRepositoryLayoutTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class LegacyBidirectionalRepositoryLayoutTest extends AbstractBidirectionalRepositoryLayoutTestCase +{ + private BidirectionalRepositoryLayout layout; + + protected void setUp() throws Exception + { + super.setUp(); + + layout = (BidirectionalRepositoryLayout) lookup( BidirectionalRepositoryLayout.class.getName(), "legacy" ); + } + + public void testToPathBasic() + { + ArchivaArtifact artifact = createArtifact( "com.foo", "foo-tool", "1.0", "", "jar" ); + + assertEquals( "com.foo/jars/foo-tool-1.0.jar", layout.pathOf( artifact ) ); + } + + public void testToPathEjbClient() + { + ArchivaArtifact artifact = createArtifact( "com.foo", "foo-client", "1.0", "", "ejb-client" ); + + assertEquals( "com.foo/ejbs/foo-client-1.0.jar", layout.pathOf( artifact ) ); + } + + public void testToPathWithClassifier() + { + ArchivaArtifact artifact = createArtifact( "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "jar" ); + + assertEquals( "com.foo.lib/javadoc.jars/foo-lib-2.1-alpha-1-sources.jar", layout.pathOf( artifact ) ); + } + + public void testToPathUsingUniqueSnapshot() + { + ArchivaArtifact artifact = createArtifact( "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" ); + + assertEquals( "com.foo/jars/foo-connector-2.1-20060822.123456-35.jar", layout.pathOf( artifact ) ); + } + + public void testToArtifactBasicSimpleGroupId() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "commons-lang/jars/commons-lang-2.1.jar" ); + assertArtifact( artifact, "commons-lang", "commons-lang", "2.1", "", "jar" ); + } + + public void testToArtifactBasicLongGroupId() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "org.apache.derby/jars/derby-10.2.2.0.jar" ); + assertArtifact( artifact, "org.apache.derby", "derby", "10.2.2.0", "", "jar" ); + } + + public void testToArtifactLongGroupId() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "org.apache.geronimo.specs/jars/geronimo-ejb_2.1_spec-1.0.1.jar" ); + assertArtifact( artifact, "org.apache.geronimo.specs", "geronimo-ejb_2.1_spec", "1.0.1", "", "jar" ); + } + + public void testToArtifactEjbClient() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "org.apache.beehive/jars/beehive-ejb-control-1.0.1.jar" ); + // The type is correct. as we cannot possibly know this is an ejb client without parsing the pom + assertArtifact( artifact, "org.apache.beehive", "beehive-ejb-control", "1.0.1", "", "jar" ); + } + + public void testToArtifactWithClassifier() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "commons-lang/jars/commons-lang-2.3-sources.jar" ); + // The 'java-source' type is correct. You might be thinking of extension, which we are not testing here. + assertArtifact( artifact, "commons-lang", "commons-lang", "2.3", "sources", "java-source" ); + } + + public void testToArtifactSnapshot() throws LayoutException + { + ArchivaArtifact artifact = layout.toArtifact( "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom" ); + assertSnapshotArtifact( artifact, "directory-clients", "ldap-clients", "0.9.1-SNAPSHOT", "", "pom" ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtilsTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtilsTest.java new file mode 100644 index 000000000..5a4e7049e --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtilsTest.java @@ -0,0 +1,206 @@ +package org.apache.maven.archiva.repository.layout; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import junit.framework.TestCase; + +/** + * RepositoryLayoutUtilsTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryLayoutUtilsTest extends TestCase +{ + public void testSplitFilenameBasic() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.1.jar", "commons-lang" ), "commons-lang", + "2.1", "", "jar" ); + } + + public void testSplitFilenameAlphaVersion() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.0-alpha-1.jar", "commons-lang" ), + "commons-lang", "2.0-alpha-1", "", "jar" ); + } + + public void testSplitFilenameSnapshot() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "foo-2.0-SNAPSHOT.jar", "foo" ), "foo", "2.0-SNAPSHOT", "", + "jar" ); + } + + public void testSplitFilenameUniqueSnapshot() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "fletch-2.0-20060822-123456-35.tar.gz", "fletch" ), "fletch", + "2.0-20060822-123456-35", "", "tar.gz" ); + } + + public void testSplitFilenameBasicClassifier() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.1-sources.jar", "commons-lang" ), + "commons-lang", "2.1", "sources", "jar" ); + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.1-javadoc.jar", "commons-lang" ), + "commons-lang", "2.1", "javadoc", "jar" ); + } + + public void testSplitFilenameAlphaClassifier() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.0-alpha-1-sources.jar", "commons-lang" ), + "commons-lang", "2.0-alpha-1", "sources", "jar" ); + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.0-alpha-1-javadoc.jar", "commons-lang" ), + "commons-lang", "2.0-alpha-1", "javadoc", "jar" ); + } + + public void testSplitFilenameSnapshotClassifier() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-3.1-SNAPSHOT-sources.jar", "commons-lang" ), + "commons-lang", "3.1-SNAPSHOT", "sources", "jar" ); + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-3.1-SNAPSHOT-javadoc.jar", "commons-lang" ), + "commons-lang", "3.1-SNAPSHOT", "javadoc", "jar" ); + } + + public void testSplitFilenameUniqueSnapshotClassifier() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-3.1-SNAPSHOT-sources.jar", "commons-lang" ), + "commons-lang", "3.1-SNAPSHOT", "sources", "jar" ); + assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-3.1-SNAPSHOT-javadoc.jar", "commons-lang" ), + "commons-lang", "3.1-SNAPSHOT", "javadoc", "jar" ); + } + + public void testSplitFilenameApacheIncubator() throws LayoutException + { + assertSplit( RepositoryLayoutUtils.splitFilename( "cxf-common-2.0-incubator-M1.pom", null ), "cxf-common", + "2.0-incubator-M1", "", "pom" ); + assertSplit( RepositoryLayoutUtils.splitFilename( "commonj-api_r1.1-1.0-incubator-M2.jar", null ), + "commonj-api_r1.1", "1.0-incubator-M2", "", "jar" ); + } + + public void testSplitFilenameBlankInputs() + { + try + { + RepositoryLayoutUtils.splitFilename( null, null ); + fail( "Should have thrown an IllegalArgumentException." ); + } + catch ( IllegalArgumentException e ) + { + /* expected path */ + } + catch ( LayoutException e ) + { + fail( "Should have thrown an IllegalArgumentException." ); + } + + try + { + RepositoryLayoutUtils.splitFilename( "", null ); + fail( "Should have thrown an IllegalArgumentException." ); + } + catch ( IllegalArgumentException e ) + { + /* expected path */ + } + catch ( LayoutException e ) + { + fail( "Should have thrown an IllegalArgumentException." ); + } + + try + { + RepositoryLayoutUtils.splitFilename( " ", null ); + fail( "Should have thrown an IllegalArgumentException." ); + } + catch ( IllegalArgumentException e ) + { + /* expected path */ + } + catch ( LayoutException e ) + { + fail( "Should have thrown an IllegalArgumentException." ); + } + + try + { + RepositoryLayoutUtils.splitFilename( " \t \n ", null ); + fail( "Should have thrown an IllegalArgumentException." ); + } + catch ( IllegalArgumentException e ) + { + /* expected path */ + } + catch ( LayoutException e ) + { + fail( "Should have thrown an IllegalArgumentException." ); + } + } + + public void testSplitFilenameBadInputs() + { + try + { + RepositoryLayoutUtils.splitFilename( "commons-lang.jar", null ); + fail( "Should have thrown a LayoutException (No Version)." ); + } + catch ( LayoutException e ) + { + /* Expected Path */ + } + + try + { + RepositoryLayoutUtils.splitFilename( "geronimo-store", null ); + fail( "Should have thrown a LayoutException (No Extension)." ); + } + catch ( LayoutException e ) + { + /* Expected Path */ + } + + try + { + RepositoryLayoutUtils.splitFilename( "The Sixth Sick Sheiks Sixth Sheep is Sick.", null ); + fail( "Should have thrown a LayoutException (No Extension)." ); + } + catch ( LayoutException e ) + { + /* Expected Path */ + } + + try + { + RepositoryLayoutUtils.splitFilename( "1.0.jar", null ); + fail( "Should have thrown a LayoutException (No Artifact ID)." ); + } + catch ( LayoutException e ) + { + /* Expected Path */ + } + } + + private void assertSplit( String[] actualSplit, String artifactId, String version, String classifier, + String extension ) + { + assertEquals( "Split - artifactId", artifactId, actualSplit[0] ); + assertEquals( "Split - version", version, actualSplit[1] ); + assertEquals( "Split - classifier", classifier, actualSplit[2] ); + assertEquals( "Split - extension", extension, actualSplit[3] ); + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/CentralScannerTiming.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/CentralScannerTiming.java new file mode 100644 index 000000000..3c2c3a2aa --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/CentralScannerTiming.java @@ -0,0 +1,132 @@ +package org.apache.maven.archiva.repository.scanner; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.common.utils.BaseFile; +import org.apache.maven.archiva.common.utils.DateUtil; +import org.apache.maven.archiva.model.RepositoryContentStatistics; +import org.apache.maven.archiva.repository.ArchivaRepository; +import org.apache.maven.archiva.repository.RepositoryException; +import org.apache.maven.archiva.repository.consumer.Consumer; +import org.apache.maven.archiva.repository.consumer.ConsumerException; + +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * CentralScannerTiming + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class CentralScannerTiming +{ + public static void main( String[] args ) + { + String pathToCentral = "/home/repo1/ibiblio"; + + ( new CentralScannerTiming() ).scanIt( pathToCentral ); + } + + public void scanIt( String path ) + { + ArchivaRepository centralRepo = new ArchivaRepository( "central", "Central Mirror", "file://" + path ); + + RepositoryScanner scanner = new RepositoryScanner(); + + List consumerList = new ArrayList(); + BasicConsumer consumer = new BasicConsumer(); + consumerList.add( consumer ); + + try + { + RepositoryContentStatistics stats = scanner.scan( centralRepo, consumerList, true ); + + SimpleDateFormat df = new SimpleDateFormat(); + System.out.println( "-------" ); + System.out.println( " Repository ID : " + stats.getRepositoryId() ); + System.out.println( " Duration : " + DateUtil.getDuration( stats.getDuration() ) ); + System.out.println( " When Gathered : " + df.format( stats.getWhenGathered() ) ); + System.out.println( " Total File Count: " + stats.getTotalFileCount() ); + System.out.println( " New File Count : " + stats.getNewFileCount() ); + } + catch ( RepositoryException e ) + { + e.printStackTrace( System.err ); + } + } + + class BasicConsumer implements Consumer + { + int count = 0; + + public List getExcludePatterns() + { + return Collections.EMPTY_LIST; + } + + public List getIncludePatterns() + { + List includes = new ArrayList(); + includes.add( "**/*.pom" ); + includes.add( "**/*.jar" ); + includes.add( "**/*.war" ); + includes.add( "**/*.ear" ); + includes.add( "**/*.sar" ); + includes.add( "**/*.car" ); + includes.add( "**/*.mar" ); +// includes.add( "**/*.sha1" ); +// includes.add( "**/*.md5" ); +// includes.add( "**/*.asc" ); + includes.add( "**/*.dtd" ); + includes.add( "**/*.tld" ); + includes.add( "**/*.gz" ); + includes.add( "**/*.bz2" ); + includes.add( "**/*.zip" ); + return includes; + } + + public String getName() + { + return "Basic No-op Consumer"; + } + + public boolean init( ArchivaRepository repository ) + { + return true; + } + + public void processFile( BaseFile file ) throws ConsumerException + { + count++; + if ( ( count % 1000 ) == 0 ) + { + System.out.println( "Files Processed: " + count ); + } + } + + public void processFileProblem( BaseFile file, String message ) + { + /* no-op */ + } + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java new file mode 100644 index 000000000..4907819f0 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java @@ -0,0 +1,70 @@ +package org.apache.maven.archiva.repository.scanner; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.commons.lang.StringUtils; +import org.apache.maven.archiva.model.RepositoryContentStatistics; +import org.apache.maven.archiva.repository.ArchivaRepository; +import org.apache.maven.archiva.repository.RepositoryException; +import org.codehaus.plexus.PlexusTestCase; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * RepositoryScannerTest + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class RepositoryScannerTest extends PlexusTestCase +{ + private ArchivaRepository createDefaultRepository() + { + File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" ); + + assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() ); + + String repoUri = "file://" + StringUtils.replace( repoDir.getAbsolutePath(), "\\", "/" ); + + ArchivaRepository repo = new ArchivaRepository( "testDefaultRepo", "Test Default Repository", repoUri ); + + return repo; + } + + public void testDefaultRepositoryScanner() throws RepositoryException + { + ArchivaRepository repository = createDefaultRepository(); + + List consumers = new ArrayList(); + ScanConsumer consumer = new ScanConsumer(); + consumers.add( consumer ); + + RepositoryScanner scanner = new RepositoryScanner(); + boolean includeSnapshots = true; + RepositoryContentStatistics stats = scanner.scan( repository, consumers, includeSnapshots ); + + assertNotNull( "Stats should not be null.", stats ); + assertEquals( "Stats.totalFileCount", 17, stats.getTotalFileCount() ); + assertEquals( "Processed Count", 17, consumer.getProcessCount() ); + } + +} diff --git a/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/ScanConsumer.java b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/ScanConsumer.java new file mode 100644 index 000000000..d1c8e0a10 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/ScanConsumer.java @@ -0,0 +1,82 @@ +package org.apache.maven.archiva.repository.scanner; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.archiva.common.utils.BaseFile; +import org.apache.maven.archiva.repository.ArchivaRepository; +import org.apache.maven.archiva.repository.consumer.Consumer; +import org.apache.maven.archiva.repository.consumer.ConsumerException; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * ScanConsumer + * + * @author Joakim Erdfelt + * @version $Id$ + */ +public class ScanConsumer implements Consumer +{ + private int processCount = 0; + + public List getExcludePatterns() + { + return Collections.EMPTY_LIST; + } + + public List getIncludePatterns() + { + List includes = new ArrayList(); + includes.add( "**/*.jar" ); + return includes; + } + + public String getName() + { + return "Scan Consumer"; + } + + public boolean init( ArchivaRepository repository ) + { + return true; + } + + public void processFile( BaseFile file ) throws ConsumerException + { + this.processCount++; + } + + public void processFileProblem( BaseFile file, String message ) + { + /* do nothing */ + } + + public int getProcessCount() + { + return processCount; + } + + public void setProcessCount( int processCount ) + { + this.processCount = processCount; + } +} diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/CVS/Root b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/CVS/Root new file mode 100644 index 000000000..2e65f24a6 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/CVS/Root @@ -0,0 +1 @@ +not a real CVS root - for testing exclusions diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/KEYS b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/KEYS new file mode 100644 index 000000000..d3b34d5ad --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/KEYS @@ -0,0 +1 @@ +test KEYS file \ No newline at end of file diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-1.0b.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-1.0b.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-2.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-2.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1/invalid-1 b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1/invalid-1 new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/maven-metadata.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/maven-metadata.xml new file mode 100644 index 000000000..b3baf545d --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/maven-metadata.xml @@ -0,0 +1,26 @@ + + + + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml new file mode 100644 index 000000000..caf5b6697 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml @@ -0,0 +1,25 @@ + + + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml new file mode 100644 index 000000000..bb7570891 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml @@ -0,0 +1,30 @@ + + + + + javax.sql + jdbc + 2.0 + + + 2.0 + + + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml new file mode 100644 index 000000000..caf5b6697 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml @@ -0,0 +1,25 @@ + + + + + javax.sql + jdbc + 2.0 + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom new file mode 100644 index 000000000..202a0a448 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + A + 1.0 + Maven Test Repository Artifact Discovery + war + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom new file mode 100644 index 000000000..fa5f8f6c8 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + B + 1.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom new file mode 100644 index 000000000..c3034e820 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + B + 2.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom new file mode 100644 index 000000000..ae14cd7eb --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + C + 1.0 + Maven Test Repository Artifact Discovery + war + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/discovery/1.0/discovery-1.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/discovery/1.0/discovery-1.0.pom new file mode 100644 index 000000000..5a29f6117 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/discovery/1.0/discovery-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.maven + discovery + 1.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml new file mode 100644 index 000000000..8ce7fc7bb --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml @@ -0,0 +1,23 @@ + + + + + org.apache.maven + \ No newline at end of file diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom new file mode 100644 index 000000000..6ab57d162 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven + C + 1.0 + Maven Test Repository Artifact Discovery + + + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom new file mode 100644 index 000000000..a959980df --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven + C + 1.0 + Maven Test Repository Artifact Discovery + + jar + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.zip b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.zip new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom new file mode 100644 index 000000000..452727f28 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven.update + test-not-updated + 1.0 + Maven Test Repository Artifact Discovery + + + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/maven-metadata.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/maven-metadata.xml new file mode 100644 index 000000000..bd56a21c1 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/maven-metadata.xml @@ -0,0 +1,24 @@ + + + + + org.apache.maven.update + test-not-updated + \ No newline at end of file diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom new file mode 100644 index 000000000..edd7b6479 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom @@ -0,0 +1,29 @@ + + + + 4.0.0 + org.apache.maven.update + test-updated + 1.0 + Maven Test Repository Artifact Discovery + + + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/maven-metadata.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/maven-metadata.xml new file mode 100644 index 000000000..86e063ca8 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/maven-metadata.xml @@ -0,0 +1,24 @@ + + + + + org.apache.maven.update + test-updated + \ No newline at end of file diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom new file mode 100644 index 000000000..12538e81a --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom @@ -0,0 +1,28 @@ + + + + 4.0.0 + org.apache.testgroup + discovery + 1.0 + Maven Test Repository Artifact Discovery + pom + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml new file mode 100644 index 000000000..8ee18048c --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml @@ -0,0 +1,25 @@ + + + + + org.apache.testgroup + discovery + 1.0 + \ No newline at end of file diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml new file mode 100644 index 000000000..b024ef7ef --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml @@ -0,0 +1,24 @@ + + + + + org.apache.testgroup + discovery + \ No newline at end of file diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/CVS/Root b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/CVS/Root new file mode 100644 index 000000000..2e65f24a6 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/CVS/Root @@ -0,0 +1 @@ +not a real CVS root - for testing exclusions diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/KEYS b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/KEYS new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/no-extension b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/no-extension new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar new file mode 100644 index 000000000..54d190b23 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar @@ -0,0 +1 @@ +dummy content. sample file only. diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar b/archiva-base/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar new file mode 100644 index 000000000..e69de29bb diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.jar b/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.jar new file mode 100644 index 000000000..c2ea777c1 Binary files /dev/null and b/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.jar differ diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.pom b/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.pom new file mode 100644 index 000000000..a987f03ec --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.pom @@ -0,0 +1,25 @@ + + + + 4.0.0 + groupId + artifactId + 1.0-alpha-1 + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/maven-metadata.xml b/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/maven-metadata.xml new file mode 100644 index 000000000..526cc825a --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/maven-metadata.xml @@ -0,0 +1,30 @@ + + + + + groupId + artifactId + 1.0-alpha-1 + + + 1.0-alpha-1 + + + diff --git a/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/snapshot-artifact/1.0-alpha-1-SNAPSHOT/snapshot-artifact-1.0-alpha-1-20050611.202024-1.pom b/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/snapshot-artifact/1.0-alpha-1-SNAPSHOT/snapshot-artifact-1.0-alpha-1-20050611.202024-1.pom new file mode 100644 index 000000000..cf613e847 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/repositories/simple-repository/groupId/snapshot-artifact/1.0-alpha-1-SNAPSHOT/snapshot-artifact-1.0-alpha-1-20050611.202024-1.pom @@ -0,0 +1,19 @@ + + diff --git a/archiva-base/archiva-repository-layer/src/test/resources/log4j.xml b/archiva-base/archiva-repository-layer/src/test/resources/log4j.xml new file mode 100644 index 000000000..23d4d08d6 --- /dev/null +++ b/archiva-base/archiva-repository-layer/src/test/resources/log4j.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/archiva-common/pom.xml b/archiva-common/pom.xml deleted file mode 100644 index 47d3c6223..000000000 --- a/archiva-common/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - archiva - org.apache.maven.archiva - 1.0-SNAPSHOT - - 4.0.0 - archiva-common - Archiva Common - - - - org.codehaus.plexus - plexus-component-api - - - org.apache.maven - maven-artifact-manager - - - org.apache.maven - maven-project - - - commons-lang - commons-lang - - - org.codehaus.plexus - plexus-container-default - - - - - - - org.codehaus.plexus - plexus-maven-plugin - - - - - diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/ArchivaException.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/ArchivaException.java deleted file mode 100644 index c807d70c4..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/ArchivaException.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.archiva.common; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * ArchivaException - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ArchivaException - extends Exception -{ - public ArchivaException( String message, Throwable cause ) - { - super( message, cause ); - } - - public ArchivaException( String message ) - { - super( message ); - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java deleted file mode 100644 index b77826ad1..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilder.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.factory.ArtifactFactory; - -/** - * AbstractLayoutArtifactBuilder - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public abstract class AbstractLayoutArtifactBuilder - implements LayoutArtifactBuilder -{ - /** - * @plexus.requirement - */ - protected ArtifactFactory artifactFactory; - - /** - * Constructor used by plexus - */ - public AbstractLayoutArtifactBuilder() - { - - } - - /** - * Constructor used by manual process. - * - * @param artifactFactory the artifact factory to use. - */ - public AbstractLayoutArtifactBuilder( ArtifactFactory artifactFactory ) - { - this.artifactFactory = artifactFactory; - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java deleted file mode 100644 index 0845dc750..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/BuilderException.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.ArchivaException; - -/** - * BuilderException - used to indicate a problem during the building of an object from file. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class BuilderException - extends ArchivaException -{ - - public BuilderException( String message, Throwable cause ) - { - super( message, cause ); - } - - public BuilderException( String message ) - { - super( message ); - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java deleted file mode 100644 index bfee01508..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilder.java +++ /dev/null @@ -1,218 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.codehaus.plexus.util.StringUtils; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.StringTokenizer; - -/** - * DefaultLayoutArtifactBuilder - artifact builder for default layout repositories. - * - * @author Brett Porter - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.common.artifact.builder.LayoutArtifactBuilder" - * role-hint="default" - */ -public class DefaultLayoutArtifactBuilder - extends AbstractLayoutArtifactBuilder - implements LayoutArtifactBuilder -{ - public DefaultLayoutArtifactBuilder() - { - super(); - } - - public DefaultLayoutArtifactBuilder( ArtifactFactory artifactFactory ) - { - super( artifactFactory ); - } - - public Artifact build( String pathToArtifact ) - throws BuilderException - { - if( artifactFactory == null ) - { - throw new IllegalStateException( "Unable to build artifact with a null artifactFactory." ); - } - - List pathParts = new ArrayList(); - StringTokenizer st = new StringTokenizer( pathToArtifact, "/\\" ); - while ( st.hasMoreTokens() ) - { - pathParts.add( st.nextToken() ); - } - - Collections.reverse( pathParts ); - - Artifact artifact; - if ( pathParts.size() >= 4 ) - { - // maven 2.x path - - // the actual artifact filename. - String filename = (String) pathParts.remove( 0 ); - - // the next one is the version. - String version = (String) pathParts.remove( 0 ); - - // the next one is the artifactId. - String artifactId = (String) pathParts.remove( 0 ); - - // the remaining are the groupId. - Collections.reverse( pathParts ); - String groupId = StringUtils.join( pathParts.iterator(), "." ); - - String remainingFilename = filename; - if ( remainingFilename.startsWith( artifactId + "-" ) ) - { - remainingFilename = remainingFilename.substring( artifactId.length() + 1 ); - - String classifier = null; - - // TODO: use artifact handler, share with legacy discoverer - String type; - if ( remainingFilename.endsWith( ".tar.gz" ) ) - { - type = "distribution-tgz"; - remainingFilename = remainingFilename - .substring( 0, remainingFilename.length() - ".tar.gz".length() ); - } - else if ( remainingFilename.endsWith( ".zip" ) ) - { - type = "distribution-zip"; - remainingFilename = remainingFilename.substring( 0, remainingFilename.length() - ".zip".length() ); - } - else if ( remainingFilename.endsWith( "-test-sources.jar" ) ) - { - type = "java-source"; - classifier = "test-sources"; - remainingFilename = remainingFilename.substring( 0, remainingFilename.length() - - "-test-sources.jar".length() ); - } - else if ( remainingFilename.endsWith( "-sources.jar" ) ) - { - type = "java-source"; - classifier = "sources"; - remainingFilename = remainingFilename.substring( 0, remainingFilename.length() - - "-sources.jar".length() ); - } - else - { - int index = remainingFilename.lastIndexOf( "." ); - if ( index >= 0 ) - { - type = remainingFilename.substring( index + 1 ); - remainingFilename = remainingFilename.substring( 0, index ); - } - else - { - throw new BuilderException( "Path filename does not have an extension." ); - } - } - - Artifact result; - if ( classifier == null ) - { - result = artifactFactory - .createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, type ); - } - else - { - result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, - classifier ); - } - - if ( result.isSnapshot() ) - { - // version is *-SNAPSHOT, filename is *-yyyyMMdd.hhmmss-b - int classifierIndex = remainingFilename.indexOf( '-', version.length() + 8 ); - if ( classifierIndex >= 0 ) - { - classifier = remainingFilename.substring( classifierIndex + 1 ); - remainingFilename = remainingFilename.substring( 0, classifierIndex ); - result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, remainingFilename, - type, classifier ); - } - else - { - result = artifactFactory.createArtifact( groupId, artifactId, remainingFilename, - Artifact.SCOPE_RUNTIME, type ); - } - - // poor encapsulation requires we do this to populate base version - if ( !result.isSnapshot() ) - { - throw new BuilderException( "Failed to create a snapshot artifact: " + result ); - } - else if ( !result.getBaseVersion().equals( version ) ) - { - throw new BuilderException( - "Built snapshot artifact base version does not match path version: " - + result.getBaseVersion() + "; should have been version: " - + version ); - } - else - { - artifact = result; - } - } - else if ( !remainingFilename.startsWith( version ) ) - { - throw new BuilderException( "Built artifact version does not match path version" ); - } - else if ( !remainingFilename.equals( version ) ) - { - if ( remainingFilename.charAt( version.length() ) == '-' ) - { - classifier = remainingFilename.substring( version.length() + 1 ); - artifact = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, - classifier ); - } - else - { - throw new BuilderException( "Path version does not corresspond to an artifact version" ); - } - } - else - { - artifact = result; - } - } - else - { - throw new BuilderException( "Path filename does not correspond to an artifact." ); - } - } - else - { - throw new BuilderException( "Path is too short to build an artifact from." ); - } - - return artifact; - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java deleted file mode 100644 index 494a4a7c1..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LayoutArtifactBuilder.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; - -/** - * LayoutArtifactBuilder - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @todo this concept should really exist inside of the {@link ArtifactRepositoryLayout} object in maven itself. - */ -public interface LayoutArtifactBuilder -{ - public Artifact build( String pathToArtifact ) throws BuilderException; -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java deleted file mode 100644 index e3436e966..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilder.java +++ /dev/null @@ -1,303 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; - -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.StringTokenizer; - -/** - * LegacyLayoutArtifactBuilder - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.common.artifact.builder.LayoutArtifactBuilder" - * role-hint="legacy" - */ -public class LegacyLayoutArtifactBuilder - extends AbstractLayoutArtifactBuilder - implements LayoutArtifactBuilder -{ - public LegacyLayoutArtifactBuilder() - { - super(); - } - - public LegacyLayoutArtifactBuilder( ArtifactFactory artifactFactory ) - { - super( artifactFactory ); - } - - public Artifact build( String pathToArtifact ) - throws BuilderException - { - if( artifactFactory == null ) - { - throw new IllegalStateException( "Unable to build legacy artifact with a null artifactFactory." ); - } - - StringTokenizer tokens = new StringTokenizer( pathToArtifact, "/\\" ); - - Artifact result; - - int numberOfTokens = tokens.countTokens(); - - if ( numberOfTokens == 3 ) - { - String groupId = tokens.nextToken(); - - String type = tokens.nextToken(); - - if ( type.endsWith( "s" ) ) - { - type = type.substring( 0, type.length() - 1 ); - - // contains artifactId, version, classifier, and extension. - String avceGlob = tokens.nextToken(); - - //noinspection CollectionDeclaredAsConcreteClass - LinkedList avceTokenList = new LinkedList(); - - StringTokenizer avceTokenizer = new StringTokenizer( avceGlob, "-" ); - while ( avceTokenizer.hasMoreTokens() ) - { - avceTokenList.addLast( avceTokenizer.nextToken() ); - } - - String lastAvceToken = (String) avceTokenList.removeLast(); - - // TODO: share with other discoverer, use artifact handlers instead - if ( lastAvceToken.endsWith( ".tar.gz" ) ) - { - type = "distribution-tgz"; - - lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".tar.gz".length() ); - - avceTokenList.addLast( lastAvceToken ); - } - else if ( lastAvceToken.endsWith( "sources.jar" ) ) - { - type = "java-source"; - - lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() ); - - avceTokenList.addLast( lastAvceToken ); - } - else if ( lastAvceToken.endsWith( "javadoc.jar" ) ) - { - type = "javadoc.jar"; - - lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".jar".length() ); - - avceTokenList.addLast( lastAvceToken ); - } - else if ( lastAvceToken.endsWith( ".zip" ) ) - { - type = "distribution-zip"; - - lastAvceToken = lastAvceToken.substring( 0, lastAvceToken.length() - ".zip".length() ); - - avceTokenList.addLast( lastAvceToken ); - } - else - { - int extPos = lastAvceToken.lastIndexOf( '.' ); - - if ( extPos > 0 ) - { - String ext = lastAvceToken.substring( extPos + 1 ); - if ( type.equals( ext ) || "plugin".equals( type ) ) - { - lastAvceToken = lastAvceToken.substring( 0, extPos ); - - avceTokenList.addLast( lastAvceToken ); - } - else - { - throw new BuilderException( "Path type does not match the extension" ); - } - } - else - { - throw new BuilderException( "Path filename does not have an extension" ); - } - } - - // let's discover the version, and whatever's leftover will be either - // a classifier, or part of the artifactId, depending on position. - // Since version is at the end, we have to move in from the back. - Collections.reverse( avceTokenList ); - - // TODO: this is obscene - surely a better way? - String validVersionParts = "([Dd][Ee][Vv][_.0-9]*)|" + "([Ss][Nn][Aa][Pp][Ss][Hh][Oo][Tt])|" - + "([0-9][_.0-9a-zA-Z]*)|" + "([Gg]?[_.0-9ab]*([Pp][Rr][Ee]|[Rr][Cc]|[Gg]|[Mm])[_.0-9]*)|" - + "([Aa][Ll][Pp][Hh][Aa][_.0-9]*)|" + "([Bb][Ee][Tt][Aa][_.0-9]*)|" + "([Rr][Cc][_.0-9]*)|" - + "([Tt][Ee][Ss][Tt][_.0-9]*)|" + "([Dd][Ee][Bb][Uu][Gg][_.0-9]*)|" - + "([Uu][Nn][Oo][Ff][Ff][Ii][Cc][Ii][Aa][Ll][_.0-9]*)|" + "([Cc][Uu][Rr][Rr][Ee][Nn][Tt])|" - + "([Ll][Aa][Tt][Ee][Ss][Tt])|" + "([Ff][Cc][Ss])|" + "([Rr][Ee][Ll][Ee][Aa][Ss][Ee][_.0-9]*)|" - + "([Nn][Ii][Gg][Hh][Tt][Ll][Yy])|" + "[Ff][Ii][Nn][Aa][Ll]|" + "([AaBb][_.0-9]*)"; - - StringBuffer classifierBuffer = new StringBuffer(); - StringBuffer versionBuffer = new StringBuffer(); - - boolean firstVersionTokenEncountered = false; - boolean firstToken = true; - - int tokensIterated = 0; - for ( Iterator it = avceTokenList.iterator(); it.hasNext(); ) - { - String token = (String) it.next(); - - boolean tokenIsVersionPart = token.matches( validVersionParts ); - - StringBuffer bufferToUpdate; - - // NOTE: logic in code is reversed, since we're peeling off the back - // Any token after the last versionPart will be in the classifier. - // Any token UP TO first non-versionPart is part of the version. - if ( !tokenIsVersionPart ) - { - if ( firstVersionTokenEncountered ) - { - //noinspection BreakStatement - break; - } - else - { - bufferToUpdate = classifierBuffer; - } - } - else - { - firstVersionTokenEncountered = true; - - bufferToUpdate = versionBuffer; - } - - if ( firstToken ) - { - firstToken = false; - } - else - { - bufferToUpdate.insert( 0, '-' ); - } - - bufferToUpdate.insert( 0, token ); - - tokensIterated++; - } - - // Now, restore the proper ordering so we can build the artifactId. - Collections.reverse( avceTokenList ); - - // if we didn't find a version, then punt. Use the last token - // as the version, and set the classifier empty. - if ( versionBuffer.length() < 1 ) - { - if ( avceTokenList.size() > 1 ) - { - int lastIdx = avceTokenList.size() - 1; - - versionBuffer.append( avceTokenList.get( lastIdx ) ); - avceTokenList.remove( lastIdx ); - } - - classifierBuffer.setLength( 0 ); - } - else - { - // if everything is kosher, then pop off all the classifier and - // version tokens, leaving the naked artifact id in the list. - avceTokenList = new LinkedList( avceTokenList.subList( 0, avceTokenList.size() - tokensIterated ) ); - } - - StringBuffer artifactIdBuffer = new StringBuffer(); - - firstToken = true; - for ( Iterator it = avceTokenList.iterator(); it.hasNext(); ) - { - String token = (String) it.next(); - - if ( firstToken ) - { - firstToken = false; - } - else - { - artifactIdBuffer.append( '-' ); - } - - artifactIdBuffer.append( token ); - } - - String artifactId = artifactIdBuffer.toString(); - - if ( artifactId.length() > 0 ) - { - int lastVersionCharIdx = versionBuffer.length() - 1; - if ( lastVersionCharIdx > -1 && versionBuffer.charAt( lastVersionCharIdx ) == '-' ) - { - versionBuffer.setLength( lastVersionCharIdx ); - } - - String version = versionBuffer.toString(); - - if ( version.length() > 0 ) - { - if ( classifierBuffer.length() > 0 ) - { - result = artifactFactory.createArtifactWithClassifier( groupId, artifactId, version, type, - classifierBuffer.toString() ); - } - else - { - result = artifactFactory.createArtifact( groupId, artifactId, version, - Artifact.SCOPE_RUNTIME, type ); - } - } - else - { - throw new BuilderException( "Path filename version is empty" ); - } - } - else - { - throw new BuilderException( "Path filename artifactId is empty" ); - } - } - else - { - throw new BuilderException( "Path artifact type does not corresspond to an artifact type" ); - } - } - else - { - throw new BuilderException( "Path does not match a legacy repository path for an artifact" ); - } - - return result; - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java deleted file mode 100644 index 8e3c67838..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifact.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.apache.maven.archiva.common.artifact.managed; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; - -import java.util.HashMap; -import java.util.Map; - -/** - * ManagedArtifact - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ManagedArtifact -{ - private String repositoryId; - - private Artifact artifact; - - private String path; - - protected Map attached; - - public ManagedArtifact( String repoId, Artifact artifact, String path ) - { - super(); - this.repositoryId = repoId; - this.artifact = artifact; - this.path = path; - this.attached = new HashMap(); - } - - public Artifact getArtifact() - { - return artifact; - } - - public String getPath() - { - return path; - } - - public String getRepositoryId() - { - return repositoryId; - } - - public Map getAttached() - { - return attached; - } - - public void setAttached( Map attached ) - { - this.attached = attached; - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java deleted file mode 100644 index b653d160a..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedArtifactTypes.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.apache.maven.archiva.common.artifact.managed; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * ManagedArtifactTypes - provides place to test an unknown artifact type. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ManagedArtifactTypes -{ - public static final int GENERIC = 0; - - public static final int JAVA = 1; - - public static final int EJB = 2; - - private static List javaArtifacts; - - private static List ejbArtifacts; - - static - { - javaArtifacts = new ArrayList(); - javaArtifacts.add( "jar" ); - javaArtifacts.add( "war" ); - javaArtifacts.add( "sar" ); - javaArtifacts.add( "rar" ); - javaArtifacts.add( "ear" ); - - ejbArtifacts = new ArrayList(); - ejbArtifacts.add( "ejb" ); - ejbArtifacts.add( "ejb-client" ); - } - - public static int whichType( String type ) - { - if ( StringUtils.isBlank( type ) ) - { - // TODO: is an empty type even possible? - return GENERIC; - } - - type = type.toLowerCase(); - - if ( ejbArtifacts.contains( type ) ) - { - return EJB; - } - - if ( javaArtifacts.contains( type ) ) - { - return JAVA; - } - - return GENERIC; - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java deleted file mode 100644 index 1759df2db..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedEjbArtifact.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.maven.archiva.common.artifact.managed; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; - -/** - * ManagedEjbArtifact - adds the ability to reference the ejb-client jar too. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ManagedEjbArtifact - extends ManagedJavaArtifact -{ - public static final String CLIENT = "client"; - - public ManagedEjbArtifact( String repoId, Artifact artifact, String path ) - { - super( repoId, artifact, path ); - } - - public String getClientPath() - { - return (String) super.attached.get( CLIENT ); - } - - public void setClientPath( String clientPath ) - { - super.attached.put( CLIENT, clientPath ); - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java deleted file mode 100644 index 203234b06..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/artifact/managed/ManagedJavaArtifact.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.archiva.common.artifact.managed; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; - -/** - * ManagedJavaArtifact - a ManagedArtifact with optional javadoc and source - * reference jars. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ManagedJavaArtifact - extends ManagedArtifact -{ - public static final String JAVADOC = "javadoc"; - - public static final String SOURCES = "sources"; - - public ManagedJavaArtifact( String repoId, Artifact artifact, String path ) - { - super( repoId, artifact, path ); - } - - public String getJavadocPath() - { - return (String) super.attached.get( JAVADOC ); - } - - public void setJavadocPath( String javadocPath ) - { - super.attached.put( JAVADOC, javadocPath ); - } - - public String getSourcesPath() - { - return (String) super.attached.get( SOURCES ); - } - - public void setSourcesPath( String sourcesPath ) - { - super.attached.put( SOURCES, sourcesPath ); - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/BaseFile.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/BaseFile.java deleted file mode 100644 index a4b83db7e..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/BaseFile.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.apache.maven.archiva.common.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.net.URI; - -/** - * BaseFile - convenient File object that tracks the Base Directory and can provide relative path values - * for the file object based on that Base Directory value. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class BaseFile - extends File -{ - private File baseDir; - - public BaseFile( File pathFile ) - { - this( pathFile.getAbsolutePath() ); - } - - public BaseFile( File repoDir, File pathFile ) - { - this( repoDir, PathUtil.getRelative( repoDir.getAbsolutePath(), pathFile ) ); - } - - public BaseFile( File parent, String child ) - { - super( parent, child ); - this.baseDir = parent; - } - - public BaseFile( String pathname ) - { - super( pathname ); - - // Calculate the top level directory. - - File parent = this; - while ( parent.getParentFile() != null ) - { - parent = parent.getParentFile(); - } - - this.baseDir = parent; - } - - public BaseFile( String repoDir, File pathFile ) - { - this( new File( repoDir ), pathFile ); - } - - public BaseFile( String parent, String child ) - { - super( parent, child ); - this.baseDir = new File( parent ); - } - - public BaseFile( URI uri ) - { - super( uri ); // only to satisfy java compiler. - throw new IllegalStateException( "The " + BaseFile.class.getName() - + " object does not support URI construction." ); - } - - public File getBaseDir() - { - return baseDir; - } - - public String getRelativePath() - { - return PathUtil.getRelative( this.baseDir.getAbsolutePath(), this ); - } - - public void setBaseDir( File baseDir ) - { - this.baseDir = baseDir; - } - - public void setBaseDir( String repoDir ) - { - setBaseDir( new File( repoDir ) ); - } -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/DateUtil.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/DateUtil.java deleted file mode 100644 index 212aece61..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/DateUtil.java +++ /dev/null @@ -1,130 +0,0 @@ -package org.apache.maven.archiva.common.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.Calendar; -import java.util.Date; -import java.util.GregorianCalendar; - -/** - * DateUtil - some (not-so) common date utility methods. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class DateUtil -{ - public static String getDuration( long duration ) - { - return getDuration( new Date( 0 ), new Date( duration ) ); - } - - public static String getDuration( long ms1, long ms2 ) - { - return getDuration( new Date( ms1 ), new Date( ms2 ) ); - } - - public static String getDuration( Date d1, Date d2 ) - { - Calendar cal1 = new GregorianCalendar(); - cal1.setTime( d1 ); - - Calendar cal2 = new GregorianCalendar(); - cal2.setTime( d2 ); - - return getDuration( cal1, cal2 ); - } - - public static String getDuration( Calendar cal1, Calendar cal2 ) - { - int year1 = cal1.get( Calendar.YEAR ); - int day1 = cal1.get( Calendar.DAY_OF_YEAR ); - int hour1 = cal1.get( Calendar.HOUR_OF_DAY ); - int min1 = cal1.get( Calendar.MINUTE ); - int sec1 = cal1.get( Calendar.SECOND ); - int ms1 = cal1.get( Calendar.MILLISECOND ); - - int year2 = cal2.get( Calendar.YEAR ); - int day2 = cal2.get( Calendar.DAY_OF_YEAR ); - int hour2 = cal2.get( Calendar.HOUR_OF_DAY ); - int min2 = cal2.get( Calendar.MINUTE ); - int sec2 = cal2.get( Calendar.SECOND ); - int ms2 = cal2.get( Calendar.MILLISECOND ); - - int leftDays = ( day1 - day2 ) + ( year1 - year2 ) * 365; - int leftHours = hour2 - hour1; - int leftMins = min2 - min1; - int leftSeconds = sec2 - sec1; - int leftMilliSeconds = ms2 - ms1; - - if ( leftMilliSeconds < 0 ) - { - leftMilliSeconds += 1000; - --leftSeconds; - } - - if ( leftSeconds < 0 ) - { - leftSeconds += 60; - --leftMins; - } - - if ( leftMins < 0 ) - { - leftMins += 60; - --leftHours; - } - - if ( leftHours < 0 ) - { - leftHours += 24; - --leftDays; - } - - StringBuffer interval = new StringBuffer(); - - appendInterval( interval, leftDays, "Day" ); - appendInterval( interval, leftHours, "Hour" ); - appendInterval( interval, leftMins, "Minute" ); - appendInterval( interval, leftSeconds, "Second" ); - appendInterval( interval, leftMilliSeconds, "Millisecond" ); - - return interval.toString(); - } - - private static void appendInterval( StringBuffer interval, int count, String type ) - { - if ( count > 0 ) - { - if ( interval.length() > 0 ) - { - interval.append( " " ); - } - - interval.append( count ); - interval.append( " " ).append( type ); - if ( count > 1 ) - { - interval.append( "s" ); - } - } - } - -} diff --git a/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/PathUtil.java b/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/PathUtil.java deleted file mode 100644 index 25df4254a..000000000 --- a/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/PathUtil.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.maven.archiva.common.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -/** - * PathUtil - simple utility methods for path manipulation. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class PathUtil -{ - public static String getRelative( String basedir, File file ) - { - return getRelative( basedir, file.getAbsolutePath() ); - } - - public static String getRelative( String basedir, String child ) - { - if ( child.startsWith( basedir ) ) - { - // simple solution. - return child.substring( basedir.length() + 1 ); - } - - String absoluteBasedir = new File( basedir ).getAbsolutePath(); - if ( child.startsWith( absoluteBasedir ) ) - { - // resolved basedir solution. - return child.substring( absoluteBasedir.length() + 1 ); - } - - // File is not within basedir. - throw new IllegalStateException( "Unable to obtain relative path of file " + child - + ", it is not within basedir " + basedir + "." ); - } -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java deleted file mode 100644 index 4ee9785d0..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/AbstractArchivaCommonTestCase.java +++ /dev/null @@ -1,146 +0,0 @@ -package org.apache.maven.archiva.common; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.codehaus.plexus.PlexusTestCase; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * AbstractArchivaCommonTestCase - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public abstract class AbstractArchivaCommonTestCase - extends PlexusTestCase -{ - protected ArtifactRepository createRepository( File basedir, String layout ) - throws Exception - { - ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); - - ArtifactRepositoryLayout repoLayout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, layout ); - - return factory.createArtifactRepository( "discoveryRepo", "file://" + basedir, repoLayout, null, null ); - } - - public List getLegacyLayoutArtifactPaths() - { - List files = new ArrayList(); - - files.add( "invalid/jars/1.0/invalid-1.0.jar" ); - files.add( "invalid/jars/invalid-1.0.rar" ); - files.add( "invalid/jars/invalid.jar" ); - files.add( "invalid/invalid-1.0.jar" ); - files.add( "javax.sql/jars/jdbc-2.0.jar" ); - files.add( "org.apache.maven/jars/some-ejb-1.0-client.jar" ); - files.add( "org.apache.maven/jars/testing-1.0.jar" ); - files.add( "org.apache.maven/jars/testing-1.0-sources.jar" ); - files.add( "org.apache.maven/jars/testing-UNKNOWN.jar" ); - files.add( "org.apache.maven/jars/testing-1.0.zip" ); - files.add( "org.apache.maven/jars/testing-1.0-20050611.112233-1.jar" ); - files.add( "org.apache.maven/jars/testing-1.0.tar.gz" ); - files.add( "org.apache.maven.update/jars/test-not-updated-1.0.jar" ); - files.add( "org.apache.maven.update/jars/test-updated-1.0.jar" ); - - return files; - } - - public List getDefaultLayoutArtifactPaths() - { - List files = new ArrayList(); - - files.add( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" ); - files.add( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" ); - files.add( "invalid/invalid/1.0/invalid-1.0b.jar" ); - files.add( "invalid/invalid/1.0/invalid-2.0.jar" ); - files.add( "invalid/invalid-1.0.jar" ); - files.add( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" ); - files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" ); - files.add( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" ); - files.add( "org/apache/maven/A/1.0/A-1.0.war" ); - files.add( "org/apache/maven/A/1.0/A-1.0.pom" ); - files.add( "org/apache/maven/B/2.0/B-2.0.pom" ); - files.add( "org/apache/maven/B/1.0/B-1.0.pom" ); - files.add( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" ); - files.add( "org/apache/maven/C/1.0/C-1.0.war" ); - files.add( "org/apache/maven/C/1.0/C-1.0.pom" ); - files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" ); - files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar" ); - files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" ); - files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar" ); - files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0-test-sources.jar" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0.jar" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0.zip" ); - files.add( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" ); - files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" ); - files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.jar" ); - files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ); - files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ); - files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" ); - files.add( "javax/sql/jdbc/2.0/jdbc-2.0.jar" ); - - return files; - } - - public List getDefaultLayoutMetadataPaths() - { - List files = new ArrayList(); - - files.add( "org/apache/maven/some-ejb/1.0/maven-metadata.xml" ); - files.add( "org/apache/maven/update/test-not-updated/maven-metadata.xml" ); - files.add( "org/apache/maven/update/test-updated/maven-metadata.xml" ); - files.add( "org/apache/maven/maven-metadata.xml" ); - files.add( "org/apache/testgroup/discovery/1.0/maven-metadata.xml" ); - files.add( "org/apache/testgroup/discovery/maven-metadata.xml" ); - files.add( "javax/sql/jdbc/2.0/maven-metadata-repository.xml" ); - files.add( "javax/sql/jdbc/maven-metadata-repository.xml" ); - files.add( "javax/sql/maven-metadata-repository.xml" ); - files.add( "javax/maven-metadata.xml" ); - - return files; - } - - public List getDefaultLayoutModelPaths() - { - List files = new ArrayList(); - - files.add( "org/apache/maven/A/1.0/A-1.0.pom" ); - files.add( "org/apache/maven/B/2.0/B-2.0.pom" ); - files.add( "org/apache/maven/B/1.0/B-1.0.pom" ); - files.add( "org/apache/maven/C/1.0/C-1.0.pom" ); - files.add( "org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom" ); - files.add( "org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom" ); - files.add( "org/apache/maven/discovery/1.0/discovery-1.0.pom" ); - files.add( "org/apache/maven/samplejar/2.0/samplejar-2.0.pom" ); - files.add( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ); - files.add( "org/apache/testgroup/discovery/1.0/discovery-1.0.pom" ); - - return files; - } -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java deleted file mode 100644 index b6bde475a..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/AllTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.archiva.common; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllTests - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AllTests -{ - - public static Test suite() - { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.common" ); - //$JUnit-BEGIN$ - suite.addTest( org.apache.maven.archiva.common.artifact.builder.AllTests.suite() ); - suite.addTest( org.apache.maven.archiva.common.utils.AllTests.suite() ); - //$JUnit-END$ - return suite; - } - -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java deleted file mode 100644 index 9d9b55df0..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AbstractLayoutArtifactBuilderTestCase.java +++ /dev/null @@ -1,51 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.artifact.Artifact; -import org.codehaus.plexus.PlexusTestCase; - -/** - * AbstractLayoutArtifactBuilderTestCase - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public abstract class AbstractLayoutArtifactBuilderTestCase -extends PlexusTestCase -{ - - protected void assertArtifact( String groupId, String artifactId, String version, String type, String classifier, Artifact artifact ) - { - assertNotNull( "Artifact cannot be null.", artifact ); - - assertEquals( "Artifact groupId", groupId, artifact.getGroupId() ); - assertEquals( "Artifact artifactId", artifactId, artifact.getArtifactId() ); - assertEquals( "Artifact version", version, artifact.getVersion() ); - assertEquals( "Artifact type", type, artifact.getType() ); - - if ( StringUtils.isNotBlank( classifier ) ) - { - assertEquals( "Artifact classifier", classifier, artifact.getClassifier() ); - } - } - -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java deleted file mode 100644 index 45511c374..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/AllTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllTests - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AllTests -{ - - public static Test suite() - { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.discoverer.builders" ); - //$JUnit-BEGIN$ - suite.addTestSuite( LegacyLayoutArtifactBuilderTest.class ); - suite.addTestSuite( DefaultLayoutArtifactBuilderTest.class ); - //$JUnit-END$ - return suite; - } - -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java deleted file mode 100644 index 954a5bb68..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/DefaultLayoutArtifactBuilderTest.java +++ /dev/null @@ -1,206 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * DefaultLayoutArtifactBuilderTest - * - * @author Brett Porter - * @author Joakim Erdfelt - * @version $Id$ - */ -public class DefaultLayoutArtifactBuilderTest - extends AbstractLayoutArtifactBuilderTestCase -{ - LayoutArtifactBuilder builder; - - protected void setUp() - throws Exception - { - super.setUp(); - - builder = (LayoutArtifactBuilder) lookup( LayoutArtifactBuilder.class.getName(), "default" ); - assertNotNull( builder ); - } - - protected void tearDown() - throws Exception - { - if ( builder != null ) - { - release( builder ); - } - super.tearDown(); - } - - public void testPathDistributionArtifacts() - throws BuilderException - { - assertArtifact( "org.apache.maven", "testing", "1.0", "distribution-tgz", null, builder - .build( "org/apache/maven/testing/1.0/testing-1.0.tar.gz" ) ); - - assertArtifact( "org.apache.maven", "testing", "1.0", "distribution-zip", null, builder - .build( "org/apache/maven/testing/1.0/testing-1.0.zip" ) ); - } - - public void testPathNormal() - throws BuilderException - { - assertArtifact( "org.apache.maven.wagon", "wagon", "1.0", "jar", null, builder - .build( "/org/apache/maven/wagon/wagon/1.0/wagon-1.0.jar" ) ); - - assertArtifact( "org.apache.maven.wagon", "wagon", "1.0", "jar", null, builder - .build( "org/apache/maven/wagon/wagon/1.0/wagon-1.0.jar" ) ); - - assertArtifact( "javax.sql", "jdbc", "2.0", "jar", null, builder.build( "javax/sql/jdbc/2.0/jdbc-2.0.jar" ) ); - - } - - public void testPathSnapshots() - throws BuilderException - { - assertArtifact( "org.apache.maven", "test", "1.0-SNAPSHOT", "jar", null, builder - .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-SNAPSHOT.jar" ) ); - - assertArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", null, builder - .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar" ) ); - } - - public void testPathSnapshotWithClassifier() - throws BuilderException - { - assertArtifact( "org.apache.maven", "test", "1.0-20050611.112233-1", "jar", "javadoc", builder - .build( "org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar" ) ); - } - - public void testPathWithClassifier() - throws BuilderException - { - assertArtifact( "org.apache.maven", "some-ejb", "1.0", "jar", "client", builder - .build( "org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar" ) ); - } - - public void testPathWithJavaSourceInclusion() - throws BuilderException - { - assertArtifact( "org.apache.maven", "testing", "1.0", "java-source", "sources", builder - .build( "org/apache/maven/testing/1.0/testing-1.0-sources.jar" ) ); - } - - public void testProblemMissingType() - { - try - { - builder.build( "invalid/invalid/1/invalid-1" ); - fail( "Should have detected missing type." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path filename does not have an extension.", e.getMessage() ); - } - } - - public void testProblemNonSnapshotInSnapshotDir() - { - try - { - builder.build( "invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar" ); - fail( "Non Snapshot artifact inside of an Snapshot dir is invalid." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Failed to create a snapshot artifact: invalid:invalid:jar:1.0:runtime", e.getMessage() ); - } - } - - public void testProblemPathTooShort() - { - try - { - builder.build( "invalid/invalid-1.0.jar" ); - fail( "Should have detected that path is too short." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path is too short to build an artifact from.", e.getMessage() ); - } - } - - public void testProblemTimestampSnapshotNotInSnapshotDir() - { - try - { - builder.build( "invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar" ); - fail( "Timestamped Snapshot artifact not inside of an Snapshot dir is invalid." ); - } - catch ( BuilderException e ) - { - /* expected path */ - // TODO: Is this really the right thing to do for this kind of artifact?? - assertEquals( "Built snapshot artifact base version does not match path version: 1.0-SNAPSHOT; " - + "should have been version: 1.0-20050611.123456-1", e.getMessage() ); - } - } - - public void testProblemVersionPathMismatch() - { - try - { - builder.build( "invalid/invalid/1.0/invalid-2.0.jar" ); - fail( "Should have detected version mismatch between path and artifact." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Built artifact version does not match path version", e.getMessage() ); - } - } - - public void testProblemVersionPathMismatchAlt() - { - try - { - builder.build( "invalid/invalid/1.0/invalid-1.0b.jar" ); - fail( "Should have version mismatch between directory and artifact." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path version does not corresspond to an artifact version", e.getMessage() ); - } - } - - public void testProblemWrongArtifactId() - { - try - { - builder.build( "org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar" ); - fail( "Should have detected wrong artifact Id." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path filename does not correspond to an artifact.", e.getMessage() ); - } - } -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java deleted file mode 100644 index 2fdae4a14..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/artifact/builder/LegacyLayoutArtifactBuilderTest.java +++ /dev/null @@ -1,160 +0,0 @@ -package org.apache.maven.archiva.common.artifact.builder; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; - -/** - * LegacyLayoutArtifactBuilderTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class LegacyLayoutArtifactBuilderTest - extends AbstractLayoutArtifactBuilderTestCase -{ - LayoutArtifactBuilder builder; - - protected void setUp() - throws Exception - { - super.setUp(); - - builder = (LayoutArtifactBuilder) lookup( LayoutArtifactBuilder.class.getName(), "legacy" ); - assertNotNull( builder ); - } - - protected void tearDown() - throws Exception - { - if ( builder != null ) - { - release( builder ); - } - super.tearDown(); - } - - public void testPathNormal() - throws BuilderException - { - Artifact artifact = builder.build( "javax.sql/jars/jdbc-2.0.jar" ); - - assertArtifact( "javax.sql", "jdbc", "2.0", "jar", null, artifact ); - } - - public void testPathFinal() - throws BuilderException - { - Artifact artifact = builder.build( "org.apache.maven.test/jars/maven-model-1.0-final-20060606.jar" ); - - assertArtifact( "org.apache.maven.test", "maven-model", "1.0-final-20060606", "jar", null, artifact ); - } - - public void testPathSnapshot() - throws BuilderException - { - Artifact artifact = builder.build( "org.apache.maven.test/jars/maven-model-1.0-SNAPSHOT.jar" ); - - assertArtifact( "org.apache.maven.test", "maven-model", "1.0-SNAPSHOT", "jar", null, artifact ); - } - - public void testPathJavadoc() - throws BuilderException - { - Artifact artifact = builder.build( "javax.sql/javadoc.jars/jdbc-2.0-javadoc.jar" ); - - assertArtifact( "javax.sql", "jdbc", "2.0", "javadoc.jar", "javadoc", artifact ); - } - - public void testPathSources() - throws BuilderException - { - Artifact artifact = builder.build( "javax.sql/java-sources/jdbc-2.0-sources.jar" ); - - assertArtifact( "javax.sql", "jdbc", "2.0", "java-source", "sources", artifact ); - } - - public void testPathPlugin() - throws BuilderException - { - Artifact artifact = builder.build( "maven/plugins/maven-test-plugin-1.8.jar" ); - - assertArtifact( "maven", "maven-test-plugin", "1.8", "plugin", null, artifact ); - } - - public void testProblemNoType() - { - try - { - builder.build( "invalid/invalid/1/invalid-1" ); - - fail( "Should have detected no type." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path does not match a legacy repository path for an artifact", e.getMessage() ); - } - } - - public void testProblemWrongArtifactPackaging() - throws ComponentLookupException - { - try - { - builder.build( "org.apache.maven.test/jars/artifactId-1.0.jar.md5" ); - - fail( "Should have detected wrong package extension." ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path type does not match the extension", e.getMessage() ); - } - } - - public void testProblemNoArtifactId() - { - try - { - builder.build( "groupId/jars/-1.0.jar" ); - - fail( "Should have detected artifactId is missing" ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path filename artifactId is empty", e.getMessage() ); - } - - try - { - builder.build( "groupId/jars/1.0.jar" ); - - fail( "Should have detected artifactId is missing" ); - } - catch ( BuilderException e ) - { - /* expected path */ - assertEquals( "Path filename artifactId is empty", e.getMessage() ); - } - } -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/AllTests.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/AllTests.java deleted file mode 100644 index db0ec4f38..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/AllTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.archiva.common.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllTests - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AllTests -{ - - public static Test suite() - { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.common.utils" ); - //$JUnit-BEGIN$ - suite.addTestSuite( PathUtilTest.class ); - suite.addTestSuite( BaseFileTest.class ); - //$JUnit-END$ - return suite; - } - -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java deleted file mode 100644 index ab8c6718c..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/BaseFileTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.apache.maven.archiva.common.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.TestCase; -import org.codehaus.plexus.util.StringUtils; - -import java.io.File; - -/** - * BaseFileTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class BaseFileTest - extends TestCase -{ - public void testFileString() - { - File repoDir = new File( "/home/user/foo/repository" ); - String pathFile = "path/to/resource.xml"; - BaseFile file = new BaseFile( repoDir, pathFile ); - - assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); - assertRelativePath( "path/to/resource.xml", file ); - assertBasedir( "/home/user/foo/repository", file ); - } - - public void testFileFile() - { - File repoDir = new File( "/home/user/foo/repository" ); - File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" ); - BaseFile file = new BaseFile( repoDir, pathFile ); - - assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); - assertRelativePath( "path/to/resource.xml", file ); - assertBasedir( "/home/user/foo/repository", file ); - } - - public void testStringFile() - { - String repoDir = "/home/user/foo/repository"; - File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" ); - BaseFile file = new BaseFile( repoDir, pathFile ); - - assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); - assertRelativePath( "path/to/resource.xml", file ); - assertBasedir( "/home/user/foo/repository", file ); - } - - public void testFileThenSetBaseString() - { - String repoDir = "/home/user/foo/repository"; - File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" ); - BaseFile file = new BaseFile( pathFile ); - file.setBaseDir( repoDir ); - - assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); - assertRelativePath( "path/to/resource.xml", file ); - assertBasedir( "/home/user/foo/repository", file ); - } - - public void testFileThenSetBaseFile() - { - File repoDir = new File( "/home/user/foo/repository" ); - File pathFile = new File( "/home/user/foo/repository/path/to/resource.xml" ); - BaseFile file = new BaseFile( pathFile ); - file.setBaseDir( repoDir ); - - assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); - assertRelativePath( "path/to/resource.xml", file ); - assertBasedir( "/home/user/foo/repository", file ); - } - - public void testStringThenSetBaseString() - { - String repoDir = "/home/user/foo/repository"; - String pathFile = "/home/user/foo/repository/path/to/resource.xml"; - BaseFile file = new BaseFile( pathFile ); - file.setBaseDir( repoDir ); - - assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); - assertRelativePath( "path/to/resource.xml", file ); - assertBasedir( "/home/user/foo/repository", file ); - } - - public void testStringThenSetBaseFile() - { - File repoDir = new File( "/home/user/foo/repository" ); - String pathFile = "/home/user/foo/repository/path/to/resource.xml"; - BaseFile file = new BaseFile( pathFile ); - file.setBaseDir( repoDir ); - - assertAbsolutePath( "/home/user/foo/repository/path/to/resource.xml", file ); - assertRelativePath( "path/to/resource.xml", file ); - assertBasedir( "/home/user/foo/repository", file ); - } - - private void assertAbsolutePath( String expectedPath, BaseFile actualFile ) - { - assertEquals( new File( expectedPath ).getAbsolutePath(), actualFile.getAbsolutePath() ); - } - - private void assertRelativePath( String expectedPath, BaseFile actualFile ) - { - assertEquals( expectedPath, StringUtils.replace( actualFile.getRelativePath(), "\\", "/" ) ); - } - - private void assertBasedir( String expectedPath, BaseFile actualFile ) - { - assertEquals( new File( expectedPath ), actualFile.getBaseDir() ); - } -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java deleted file mode 100644 index 09785b6e5..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/DateUtilTest.java +++ /dev/null @@ -1,69 +0,0 @@ -package org.apache.maven.archiva.common.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; - -import junit.framework.TestCase; - -/** - * DateUtilTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class DateUtilTest extends TestCase -{ - private void assertDuration( String expectedDuration, String startTimestamp, String endTimestamp ) - throws ParseException - { - SimpleDateFormat sdf = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss SSS" ); - Date startDate = sdf.parse( startTimestamp ); - Date endDate = sdf.parse( endTimestamp ); - -// System.out.println( "Date: " + endTimestamp + " - " + startTimestamp + " = " -// + ( endDate.getTime() - startDate.getTime() ) + " ms" ); - - assertEquals( expectedDuration, DateUtil.getDuration( startDate, endDate ) ); - } - - public void testGetDurationDifference() throws ParseException - { - assertDuration( "2 Seconds", "2006-08-22 13:00:02 0000", - "2006-08-22 13:00:04 0000" ); - - assertDuration( "12 Minutes 12 Seconds 234 Milliseconds", "2006-08-22 13:12:02 0000", - "2006-08-22 13:24:14 0234" ); - - assertDuration( "12 Minutes 501 Milliseconds", "2006-08-22 13:12:01 0500", - "2006-08-22 13:24:02 0001" ); - } - - public void testGetDurationDirect() throws ParseException - { - assertEquals( "2 Seconds", DateUtil.getDuration( 2000 ) ); - - assertEquals( "12 Minutes 12 Seconds 234 Milliseconds", DateUtil.getDuration( 732234 ) ); - - assertEquals( "12 Minutes 501 Milliseconds", DateUtil.getDuration( 720501 ) ); - } -} diff --git a/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java b/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java deleted file mode 100644 index 58abbd2bf..000000000 --- a/archiva-common/src/test/java/org/apache/maven/archiva/common/utils/PathUtilTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.archiva.common.utils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.utils.PathUtil; - -import junit.framework.TestCase; - -/** - * PathUtilTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class PathUtilTest - extends TestCase -{ - public void testToRelative() - { - assertEquals( "path/to/resource.xml", PathUtil.getRelative( "/home/user/foo/repository", - "/home/user/foo/repository/path/to/resource.xml" ) ); - } -} diff --git a/archiva-common/src/test/legacy-repository/CVS/Root b/archiva-common/src/test/legacy-repository/CVS/Root deleted file mode 100644 index 2e65f24a6..000000000 --- a/archiva-common/src/test/legacy-repository/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -not a real CVS root - for testing exclusions diff --git a/archiva-common/src/test/legacy-repository/KEYS b/archiva-common/src/test/legacy-repository/KEYS deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/invalid/foo/invalid-1.0.foo b/archiva-common/src/test/legacy-repository/invalid/foo/invalid-1.0.foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/invalid/invalid-1.0.jar b/archiva-common/src/test/legacy-repository/invalid/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar b/archiva-common/src/test/legacy-repository/invalid/jars/1.0/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/invalid/jars/invalid-1.0.rar b/archiva-common/src/test/legacy-repository/invalid/jars/invalid-1.0.rar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/invalid/jars/invalid.jar b/archiva-common/src/test/legacy-repository/invalid/jars/invalid.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/invalid/jars/no-extension b/archiva-common/src/test/legacy-repository/invalid/jars/no-extension deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar b/archiva-common/src/test/legacy-repository/javax.sql/jars/jdbc-2.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar b/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar b/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-common/src/test/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar b/archiva-common/src/test/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar b/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar b/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar b/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz b/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip b/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-1.0.zip deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar b/archiva-common/src/test/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/CVS/Root b/archiva-common/src/test/repository/CVS/Root deleted file mode 100644 index 2e65f24a6..000000000 --- a/archiva-common/src/test/repository/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -not a real CVS root - for testing exclusions diff --git a/archiva-common/src/test/repository/KEYS b/archiva-common/src/test/repository/KEYS deleted file mode 100644 index d3b34d5ad..000000000 --- a/archiva-common/src/test/repository/KEYS +++ /dev/null @@ -1 +0,0 @@ -test KEYS file \ No newline at end of file diff --git a/archiva-common/src/test/repository/invalid/invalid-1.0.jar b/archiva-common/src/test/repository/invalid/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar b/archiva-common/src/test/repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar b/archiva-common/src/test/repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar b/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-1.0b.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar b/archiva-common/src/test/repository/invalid/invalid/1.0/invalid-2.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/invalid/invalid/1/invalid-1 b/archiva-common/src/test/repository/invalid/invalid/1/invalid-1 deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/javax/maven-metadata.xml b/archiva-common/src/test/repository/javax/maven-metadata.xml deleted file mode 100644 index b3baf545d..000000000 --- a/archiva-common/src/test/repository/javax/maven-metadata.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - javax.sql - jdbc - 2.0 - diff --git a/archiva-common/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar b/archiva-common/src/test/repository/javax/sql/jdbc/2.0/jdbc-2.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml deleted file mode 100644 index caf5b6697..000000000 --- a/archiva-common/src/test/repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - javax.sql - jdbc - 2.0 - diff --git a/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml deleted file mode 100644 index bb7570891..000000000 --- a/archiva-common/src/test/repository/javax/sql/jdbc/maven-metadata-repository.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - javax.sql - jdbc - 2.0 - - - 2.0 - - - diff --git a/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml b/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml deleted file mode 100644 index caf5b6697..000000000 --- a/archiva-common/src/test/repository/javax/sql/maven-metadata-repository.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - javax.sql - jdbc - 2.0 - diff --git a/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom b/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom deleted file mode 100644 index 202a0a448..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - A - 1.0 - Maven Test Repository Artifact Discovery - war - diff --git a/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war b/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/A/1.0/A-1.0.war +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom deleted file mode 100644 index fa5f8f6c8..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/B/1.0/B-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - B - 1.0 - Maven Test Repository Artifact Discovery - pom - diff --git a/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom deleted file mode 100644 index c3034e820..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/B/2.0/B-2.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - B - 2.0 - Maven Test Repository Artifact Discovery - pom - diff --git a/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom deleted file mode 100644 index ae14cd7eb..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - C - 1.0 - Maven Test Repository Artifact Discovery - war - diff --git a/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war b/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/C/1.0/C-1.0.war +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom b/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom deleted file mode 100644 index 5a29f6117..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/discovery/1.0/discovery-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - discovery - 1.0 - Maven Test Repository Artifact Discovery - pom - diff --git a/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml b/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml deleted file mode 100644 index 8ce7fc7bb..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/maven-metadata.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - org.apache.maven - \ No newline at end of file diff --git a/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar b/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom b/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom deleted file mode 100644 index 6ab57d162..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - org.apache.maven - C - 1.0 - Maven Test Repository Artifact Discovery - - - diff --git a/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar b/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom b/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom deleted file mode 100644 index a959980df..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - org.apache.maven - C - 1.0 - Maven Test Repository Artifact Discovery - - jar - diff --git a/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml b/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar b/archiva-common/src/test/repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar b/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar b/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar b/archiva-common/src/test/repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar b/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar b/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar b/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz b/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip b/archiva-common/src/test/repository/org/apache/maven/testing/1.0/testing-1.0.zip deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar b/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom b/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom deleted file mode 100644 index 452727f28..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - org.apache.maven.update - test-not-updated - 1.0 - Maven Test Repository Artifact Discovery - - - diff --git a/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml b/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml deleted file mode 100644 index bd56a21c1..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/update/test-not-updated/maven-metadata.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.apache.maven.update - test-not-updated - \ No newline at end of file diff --git a/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar b/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom b/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom deleted file mode 100644 index edd7b6479..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - org.apache.maven.update - test-updated - 1.0 - Maven Test Repository Artifact Discovery - - - diff --git a/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml b/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml deleted file mode 100644 index 86e063ca8..000000000 --- a/archiva-common/src/test/repository/org/apache/maven/update/test-updated/maven-metadata.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.apache.maven.update - test-updated - \ No newline at end of file diff --git a/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom deleted file mode 100644 index 12538e81a..000000000 --- a/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.testgroup - discovery - 1.0 - Maven Test Repository Artifact Discovery - pom - diff --git a/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml deleted file mode 100644 index 8ee18048c..000000000 --- a/archiva-common/src/test/repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - org.apache.testgroup - discovery - 1.0 - \ No newline at end of file diff --git a/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml deleted file mode 100644 index b024ef7ef..000000000 --- a/archiva-common/src/test/repository/org/apache/testgroup/discovery/maven-metadata.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.apache.testgroup - discovery - \ No newline at end of file diff --git a/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml b/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml deleted file mode 100644 index 5760e8918..000000000 --- a/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericArtifactConsumerTest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - org.apache.maven.archiva.common.consumers.Consumer - mock-artifact - org.apache.maven.archiva.common.consumers.MockArtifactConsumer - - - org.apache.maven.artifact.factory.ArtifactFactory - - - - - \ No newline at end of file diff --git a/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml b/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml deleted file mode 100644 index 2ded1b62d..000000000 --- a/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericModelConsumerTest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - org.apache.maven.archiva.discoverer.DiscovererConsumer - mock-model - org.apache.maven.archiva.discoverer.consumers.MockModelConsumer - - - org.apache.maven.artifact.factory.ArtifactFactory - - - - - \ No newline at end of file diff --git a/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml b/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml deleted file mode 100644 index da9864d00..000000000 --- a/archiva-common/src/test/resources/org/apache/maven/archiva/common/consumers/GenericRepositoryMetadataConsumerTest.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - org.apache.maven.archiva.discoverer.DiscovererConsumer - mock-metadata - org.apache.maven.archiva.discoverer.consumers.MockRepositoryMetadataConsumer - - - org.apache.maven.artifact.factory.ArtifactFactory - - - - - \ No newline at end of file diff --git a/archiva-configuration/pom.xml b/archiva-configuration/pom.xml deleted file mode 100644 index 4a502130b..000000000 --- a/archiva-configuration/pom.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - archiva - org.apache.maven.archiva - 1.0-SNAPSHOT - - 4.0.0 - archiva-configuration - Archiva Configuration - - - org.codehaus.plexus - plexus-component-api - - - org.codehaus.plexus - plexus-utils - - - commons-lang - commons-lang - - - commons-io - commons-io - - - org.codehaus.plexus.registry - plexus-registry-api - 1.0-alpha-2-SNAPSHOT - - - org.codehaus.plexus.registry - plexus-registry-commons - 1.0-alpha-2-SNAPSHOT - test - - - - easymock - easymock - 1.2_Java1.3 - test - - - org.codehaus.plexus - plexus-container-default - test - - - - - - org.codehaus.modello - modello-maven-plugin - 1.0-alpha-15-SNAPSHOT - - - - java - registry-reader - registry-writer - - - - - 1.0.0 - src/main/mdo/configuration.mdo - - - - org.codehaus.mojo - cobertura-maven-plugin - - - - - org/apache/maven/archiva/configuration/io/** - org/apache/maven/archiva/configuration/*RepositoryConfiguration.* - org/apache/maven/archiva/configuration/Configuration.* - org/apache/maven/archiva/configuration/Proxy.* - - - - - - - diff --git a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java deleted file mode 100644 index a914ce712..000000000 --- a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/ArchivaConfiguration.java +++ /dev/null @@ -1,53 +0,0 @@ -package org.apache.maven.archiva.configuration; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.plexus.registry.RegistryListener; - -/** - * Configuration holder for the model read from the registry. - */ -public interface ArchivaConfiguration -{ - /** - * Get the configuration. - * - * @return the configuration - */ - Configuration getConfiguration(); - - /** - * Save any updated configuration. - * - * @param configuration the configuration to save - * @throws org.codehaus.plexus.registry.RegistryException - * if there is a problem saving the registry data - */ - void save( Configuration configuration ) - throws RegistryException; - - /** - * Add a change listener so that registry changes are propogated. - * - * @param listener the listener - */ - void addChangeListener( RegistryListener listener ); -} diff --git a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java deleted file mode 100644 index ab64a661d..000000000 --- a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/DefaultArchivaConfiguration.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.apache.maven.archiva.configuration; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryReader; -import org.apache.maven.archiva.configuration.io.registry.ConfigurationRegistryWriter; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.codehaus.plexus.registry.Registry; -import org.codehaus.plexus.registry.RegistryException; -import org.codehaus.plexus.registry.RegistryListener; -import org.codehaus.plexus.util.StringUtils; - -import java.util.Iterator; - -/** - * Implementation of configuration holder that retrieves it from the registry. - * - * @plexus.component - */ -public class DefaultArchivaConfiguration - implements ArchivaConfiguration, RegistryListener, Initializable -{ - /** - * Plexus registry to read the configuration from. - * - * @plexus.requirement role-hint="commons-configuration" - */ - private Registry registry; - - /** - * The configuration that has been converted. - */ - private Configuration configuration; - - private static final String KEY = "org.apache.maven.archiva"; - - public synchronized Configuration getConfiguration() - { - if ( configuration == null ) - { - // TODO: should this be the same as section? make sure unnamed sections still work (eg, sys properties) - configuration = new ConfigurationRegistryReader().read( registry.getSubset( KEY ) ); - - // TODO: for commons-configuration 1.3 only - for ( Iterator i = configuration.getRepositories().iterator(); i.hasNext(); ) - { - RepositoryConfiguration c = (RepositoryConfiguration) i.next(); - c.setUrl( removeExpressions( c.getUrl() ) ); - } - } - return configuration; - } - - public void save( Configuration configuration ) - throws RegistryException - { - Registry section = registry.getSection( KEY + ".user" ); - if ( section == null ) - { - section = registry.getSection( KEY + ".base" ); - } - new ConfigurationRegistryWriter().write( configuration, section ); - section.save(); - - this.configuration = configuration; - } - - public void addChangeListener( RegistryListener listener ) - { - Registry section = registry.getSection( KEY + ".user" ); - if ( section != null ) - { - section.addChangeListener( listener ); - } - section = registry.getSection( KEY + ".base" ); - if ( section != null ) - { - section.addChangeListener( listener ); - } - } - - public void initialize() - throws InitializationException - { - registry.addChangeListener( this ); - } - - public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - // nothing to do here - } - - public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue ) - { - configuration = null; - } - - private String removeExpressions( String directory ) - { - String value = StringUtils.replace( directory, "${appserver.base}", - registry.getString( "appserver.base", "${appserver.base}" ) ); - value = StringUtils.replace( value, "${appserver.home}", - registry.getString( "appserver.home", "${appserver.home}" ) ); - return value; - } - -} diff --git a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java deleted file mode 100644 index 0efcde250..000000000 --- a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/InvalidConfigurationException.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.maven.archiva.configuration; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * An error in the configuration. - * - * @author Brett Porter - */ -public class InvalidConfigurationException - extends Exception -{ - private final String name; - - public InvalidConfigurationException( String name, String message ) - { - super( message ); - this.name = name; - } - - public InvalidConfigurationException( String name, String message, Throwable cause ) - { - super( message, cause ); - - this.name = name; - } - - public String getName() - { - return name; - } -} diff --git a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java b/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java deleted file mode 100644 index 070ed0539..000000000 --- a/archiva-configuration/src/main/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoader.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.apache.maven.archiva.configuration; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.util.Enumeration; -import java.util.Properties; -import java.util.StringTokenizer; - -/** - * @author Ben Walding - * @author Brett Porter - */ -public class MavenProxyPropertyLoader -{ - private static final String REPO_LOCAL_STORE = "repo.local.store"; - - private static final String PROXY_LIST = "proxy.list"; - - private static final String REPO_LIST = "repo.list"; - - public void load( Properties props, Configuration configuration ) throws InvalidConfigurationException - { - // set up the managed repository - String localCachePath = getMandatoryProperty( props, REPO_LOCAL_STORE ); - - RepositoryConfiguration config = new RepositoryConfiguration(); - config.setUrl( toURL( localCachePath ) ); - config.setName( "Imported Maven-Proxy Cache" ); - config.setId( "maven-proxy" ); - configuration.addRepository( config ); - - // Add the network proxies. - String propertyList = props.getProperty( PROXY_LIST ); - if ( propertyList != null ) - { - StringTokenizer tok = new StringTokenizer( propertyList, "," ); - while ( tok.hasMoreTokens() ) - { - String key = tok.nextToken(); - if ( StringUtils.isNotEmpty( key ) ) - { - ProxyConfiguration proxy = new ProxyConfiguration(); - proxy.setHost( getMandatoryProperty( props, "proxy." + key + ".host" ) ); - proxy.setPort( Integer.parseInt( getMandatoryProperty( props, "proxy." + key + ".port" ) ) ); - - // the username and password isn't required - proxy.setUsername( props.getProperty( "proxy." + key + ".username" ) ); - proxy.setPassword( props.getProperty( "proxy." + key + ".password" ) ); - - configuration.addNetworkProxy( proxy ); - } - } - } - - // Add the remote repository list - String repoList = getMandatoryProperty( props, REPO_LIST ); - - StringTokenizer tok = new StringTokenizer( repoList, "," ); - while ( tok.hasMoreTokens() ) - { - String key = tok.nextToken(); - - Properties repoProps = getSubset( props, "repo." + key + "." ); - String url = getMandatoryProperty( props, "repo." + key + ".url" ); - String proxyKey = repoProps.getProperty( "proxy" ); - - int cachePeriod = Integer.parseInt( repoProps.getProperty( "cache.period", "60" ) ); - - RepositoryConfiguration repository = new RepositoryConfiguration(); - repository.setId( key ); - repository.setName( "Imported Maven-Proxy Remote Proxy" ); - repository.setUrl( url ); - repository.setLayout( "legacy" ); - repository.setIndexed( false ); - repository.setReleases( true ); - repository.setSnapshots( false ); - - configuration.addRepository( repository ); - - RepositoryProxyConnectorConfiguration proxyConnector = new RepositoryProxyConnectorConfiguration(); - proxyConnector.setSourceRepoId( "maven-proxy" ); - proxyConnector.setTargetRepoId( key ); - proxyConnector.setProxyId( proxyKey ); - proxyConnector.setFailurePolicy( RepositoryProxyConnectorConfiguration.NOT_FOUND ); - proxyConnector.setSnapshotsPolicy( String.valueOf( cachePeriod ) ); - proxyConnector.setReleasesPolicy( RepositoryProxyConnectorConfiguration.NEVER ); - - configuration.addProxyConnector( proxyConnector ); - } - } - - private String toURL( String path ) - { - File file = new File( path ); - try - { - return file.toURL().toExternalForm(); - } - catch ( MalformedURLException e ) - { - return "file://" + StringUtils.replaceChars( file.getAbsolutePath(), '\\', '/' ); - } - } - - private Properties getSubset( Properties props, String prefix ) - { - Enumeration keys = props.keys(); - Properties result = new Properties(); - while ( keys.hasMoreElements() ) - { - String key = (String) keys.nextElement(); - String value = props.getProperty( key ); - if ( key.startsWith( prefix ) ) - { - String newKey = key.substring( prefix.length() ); - result.setProperty( newKey, value ); - } - } - return result; - } - - public void load( InputStream is, Configuration configuration ) throws IOException, InvalidConfigurationException - { - Properties props = new Properties(); - props.load( is ); - load( props, configuration ); - } - - private String getMandatoryProperty( Properties props, String key ) throws InvalidConfigurationException - { - String value = props.getProperty( key ); - - if ( value == null ) - { - throw new InvalidConfigurationException( key, "Missing required field: " + key ); - } - - return value; - } -} \ No newline at end of file diff --git a/archiva-configuration/src/main/mdo/configuration.mdo b/archiva-configuration/src/main/mdo/configuration.mdo deleted file mode 100644 index 75ba48c53..000000000 --- a/archiva-configuration/src/main/mdo/configuration.mdo +++ /dev/null @@ -1,479 +0,0 @@ - - - - configuration - Configuration - - Configuration for the Maven Repository Manager. - - - - package - org.apache.maven.archiva.configuration - - - - - Configuration - 1.0.0+ - - - repositories - 1.0.0+ - - RepositoryConfiguration - * - - The list of repositories that this archiva instance uses. - - - proxyConnectors - 1.0.0+ - - RepositoryProxyConnectorConfiguration - * - - The list of proxy connectors for this archiva instance. - - - - networkProxies - 1.0.0+ - - ProxyConfiguration - * - - - The list of network proxies to use for outgoing requests. - - - - fileProcessors - 1.0.0+ - - FileProcessor - * - - - The file processors setup. - - - - - - - - - RepositoryConfiguration - 1.0.0+ - - - id - 1.0.0+ - String - true - - The repository identifier. - - - - name - 1.0.0+ - String - true - - The descriptive name of the repository. - - - - url - 1.0.0+ - String - true - - The URL for this repository. - - - - layout - 1.0.0+ - String - true - - The layout of the repository. Valid values are "default" and "legacy". - - - default - - - releases - 1.0.0+ - boolean - True if this repository contains release versioned artifacts. - true - - - snapshots - 1.0.0+ - boolean - True if this repository contains snapshot versioned artifacts. - false - - - indexed - 1.0.0+ - boolean - True if this repository should be indexed. - true - - - refreshCronExpression - 1.0.0+ - String - - When to run the refresh task. - Default is every 30 minutes (translated as every 0 and 30 minute reading of every hour) - - 0 0,30 * * * ? - - - - - - - - AbstractRepositoryConnectorConfiguration - true - 1.0.0+ - - - sourceRepoId - 1.0.0+ - String - true - - The Repository Source for this connector. - - - - targetRepoId - 1.0.0+ - String - true - - The Repository Target for this connector. - - - - proxyId - 1.0.0+ - String - - The network proxy ID to use for this connector. - - - - blackListPatterns - 1.0.0+ - - String - * - - - The list of blacklisted patterns for this connector. - - - - whiteListPatterns - 1.0.0+ - - String - * - - - The list of whitelisted patterns for this connector. - - - - - - - AbstractRepositoryConnectorConfiguration - RepositoryProxyConnectorConfiguration - 1.0.0+ - - - snapshotsPolicy - 1.0.0+ - String - disabled - - The policy for snapshots: - Can be one of the following keywords: - "disabled" - means retrieval isn't even attempted. - "daily" - means snapshot is fetched, but only updated on - a daily basis. (equivalent to "1440" minutes) - "hourly" - means snapshot is fetched, but only updated on - an hourly basis. (equivalent to "60" minutes) - "never" - means snapshot is fetched once, but never updated. - (equivalent to "-1" minutes) - Or it can be a number of minutes before updating of the snapshot. - - - - releasesPolicy - 1.0.0+ - String - never - - The policy for releases: - Can be one of the following keywords: - "disabled" - means retrieval isn't even attempted. - "daily" - means release is fetched, but only updated on - a daily basis. (equivalent to "1440" minutes) - "hourly" - means release is fetched, but only updated on - an hourly basis. (equivalent to "60" minutes) - "never" - means release is fetched once, but never updated. - (equivalent to "-1" minutes) - Or it can be a number of minutes before updating of the release. - - - - failurePolicy - 1.0.0+ - String - not-found - - The policy for dealing with proxy failures. - Can be one of the following keywords: - "not-found" - means if the retrieval has a failure, an HTTP 404 - (not found) is returned to the client of this - archiva instance. - This policy setting will allow other proxies - to be checked for content. - "failure" - means if the retrieval has a failure, an HTTP 500 - (server error) is returned to the client of this - archiva instance. - This policy setting will return immediately to the - client of the archiva instance and not allow - furthor attempts on other proxies for this content. - - - - - - 1.0.0+ - - - - - - - AbstractRepositoryConnectorConfiguration - RepositorySynchConnectorConfiguration - true - 1.0.0+ - - - cronExpression - 1.0.0+ - String - When to run the sync mechanism. Default is every hour on the hour. - 0 0 * * * ? - - - method - 1.0.0+ - String - The type of synchronization to use. - rsync - - - properties - 1.0.0+ - Properties - Configuration for the repository synchronization. - - String - * - - - - - - - - - ProxyConfiguration - 1.0.0+ - - - id - 1.0.0+ - String - - The ID for this proxy. - - - - protocol - 1.0.0+ - - The network protocol to use with this proxy. - - String - true - http - - - host - 1.0.0+ - - The proxy host. - - String - true - - - port - 1.0.0+ - - The proxy port. - - int - 8080 - - - username - 1.0.0+ - - The proxy user. - - String - - - password - 1.0.0+ - - The proxy password. - - String - - - - - - - FileProcessor - 1.0.0+ - - - id - 1.0.0+ - true - String - - The ID for this file processor - - - - patterns - 1.0.0+ - true - - String - * - - - The list of patterns for this processor. - - - - consumers - 1.0.0+ - true - - String - * - - - The list of consumer IDs for this file processor. - - - - - - - - - diff --git a/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties b/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties deleted file mode 100644 index 2beeea469..000000000 --- a/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/SyncedRepositoryConfiguration-conversion.properties +++ /dev/null @@ -1,21 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -Key_properties=java.lang.String -Element_properties=java.lang.String diff --git a/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml b/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml deleted file mode 100644 index 4c48beb5d..000000000 --- a/archiva-configuration/src/main/resources/org/apache/maven/archiva/configuration/default-archiva.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - internal - Archiva Managed Internal Repository - file://${appserver.home}/repositories/internal - default - true - false - true - 0 0 * * ? - - - snapshots - Archiva Managed Snapshot Repository - file://${appserver.home}/repositories/internal - default - false - true - true - 0 0,30 * * ? - - - central - Central Repository - http://repo1.maven.org/maven2 - default - 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 - - - - - internal - central - - disabled - never - not-found - - - internal - maven2-repository.dev.java.net - - disabled - never - not-found - - javax/** - - - - - - - - artifacts - - **/*.pom - **/*.jar - **/*.ear - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - **/*.dtd - **/*.tld - **/*.tar.gz - **/*.tar.bz2 - **/*.zip - - - artifact-to-db - artifact-to-lucene - artifact-create-missing-checksums - - - - projects - - **/*.pom - - - project-to-db - - - - repository-metadata - - **/maven-metadata.xml - - - repository-metadata-to-db - repository-metadata-version-mismatch - - - - checksums - - **/*.sha1 - **/*.md5 - - - checksum-validate - - - - signatures - - **/*.asc - - - signature-validate - - - - archives - - **/*.jar - **/*.ear - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - **/*.tar.gz - **/*.tar.bz2 - **/*.zip - **/*.nbm - - - archive-toc-to-lucene - - - - bytecode - - **/*.jar - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - - - bytecode-to-db - bytecode-to-lucene - - - - xmls - - **/*.pom - **/*.xml - **/*.xsd - - - xml-to-lucene - - - - text - - **/*.txt - **/*.TXT - **/*.block - **/*.config - - - - ignored - - **/.htaccess - **/KEYS - **/*.rb - **/*.sh - **/.svn/** - **/.DAV/** - - - ignored - - - - auto-remove - - **/*.bak - **/*~ - **/*- - - - auto-remove - - - - auto-rename - - **/*.distribution-tgz - **/*.distribution-zip - **/*.plugin - - - auto-rename - - - - diff --git a/archiva-configuration/src/test/conf/corrupt.xml b/archiva-configuration/src/test/conf/corrupt.xml deleted file mode 100644 index b4469289a..000000000 --- a/archiva-configuration/src/test/conf/corrupt.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - diff --git a/archiva-configuration/src/test/conf/maven-proxy-complete.conf b/archiva-configuration/src/test/conf/maven-proxy-complete.conf deleted file mode 100644 index 7908a9ad9..000000000 --- a/archiva-configuration/src/test/conf/maven-proxy-complete.conf +++ /dev/null @@ -1,144 +0,0 @@ -################ GLOBAL SETTINGS -# This is where maven-proxy stores files it has downloaded -repo.local.store=target - -#The port to listen on - not used if loaded as a webapp -port=9999 - -#This is the base area that all files are loaded from. While it is possible to leave this blank, this behaviour -#is deprecated and will be disabled in version 2.0. There are too many namespace conflicts caused by not using -#a prefix. -#The repository will be shown at http://localhost:9999/repository/ -#for the .war loaded into a webapp server, the default prefix is "repository" (edit the web.xml to change) -# As maven doesn't like a trailing slash, this address shouldn't have one either. -prefix=repository - -#This is the simple date format used to display the last modified date while browsing the repository. -lastModifiedDateFormat=yyyy/MM/dd HH:mm:ss - -################ SNAPSHOT HANDLING -#If you want the proxy to look for newer snapshots, set to true -snapshot.update=true - -################ M2 METADATA HANDLING -#If you want the proxy to prevent looking for newer metadata, set to false (default is true) -#metadata.update=false - -################ M2 POM HANDLING -#If you want the proxy to look for newer POMs, set to true (default is false) -pom.update=true - -################ PROMOTION HANDLING -# ***** NOT CURRENTLY IMPLEMENTED ***** -#Promotion describes the process by which new artifacts are loaded to global maven-proxy repository. It -# is designed to be used by "higher security installations" that do not want to acquire artifacts from -# remote repositories without approval. -# -#If promotion handling is enabled, then the proxy will not download remote artifacts without permission -# (local repositories with copy=false are considered to be local) -# -#Permission to download is granted via the Promotion menu which will be enabled -# when promotion handling is enabled. -# -#If promotion is false, artifacts are sourced from any repository as per normal. -# -#Promotion and snapshots: If promotion is enabled, snapshots are not downloadable. The concept of using -# a snapshot in a production build (which is primarily what promotion is for) is counterintuitive. -## -promotion=false - -################ WEB INTERFACE -# This defines the absolute URL the server should use to identify itself. -# This can often be determined automatically, but we recommend you specify -# it explicitly to prevent problems during startup. -# The prefix will be added to this for the actual repository -# i.e. proxy available at http://localhost:9999/, repository at http://localhost:9999/repository -serverName=http://localhost:9999 - -#If true, the repository can be browsed -browsable=true - -#If true, the repository can be searched -searchable=true - -#Not currently implemented. Will allow webdav access to the repository at some point. -webdav=true - -#Stylesheet - if configured, will override the default stylesheet shipped with maven-proxy - absolute URLs only -#eg. /maven-proxy/style.css, http://www.example.com/style.css -stylesheet=/maven-proxy/style.css - -#bgColor / bgColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. -#If a stylesheet is set, these are not used. -bgColor=#14B -bgColorHighlight=#94B - -#rowColor / rowColorHighlight are replaced in the built in stylesheet to produce a simple color scheme. -#If a stylesheet is set, these are not used. -rowColor=#CCF -rowColorHighlight=#DDF - - -################ PROXIES -#This is just a hack, it should auto discover them -proxy.list=one,two,three - -#Unauthenticated proxy -proxy.one.host=proxy1.example.com -proxy.one.port=3128 - -#Authenticated proxy -proxy.two.host=proxy2.example.org -proxy.two.port=80 -proxy.two.username=username2 -proxy.two.password=password2 - -#Authenticated proxy -proxy.three.host=proxy3.example.net -proxy.three.port=3129 -proxy.three.username=username3 -proxy.three.password=password3 - - -################# REPOSITORIES -#This is not just a hack, it specifies the order repositories should be checked -#Note that the proxy adds a "/" which is why the urls aren't suffixed with a "/" -repo.list=local-repo,www-ibiblio-org,dist-codehaus-org,private-example-com - -#local-store -# The local store represents a location that local jars you host can be located. -# This could also be achieved by having a local http repository, but this is less cumbersome -repo.local-repo.url=file://target -repo.local-repo.description=Super Secret Custom Repository -#If copy is true, jars are copied from the store to the proxy-repo. Only configurable for file:/// repos -repo.local-repo.copy=false -#If hardfail is true, any unexpected errors from the repository will cause -#the client download to fail (typically with a 500 error) -repo.local-repo.hardfail=true -#Don't cache a file repository -repo.local-repo.cache.period=0 - - -#www.ibiblio.org -repo.www-ibiblio-org.url=http://www.ibiblio.org/maven2 -repo.www-ibiblio-org.description=www.ibiblio.org -repo.www-ibiblio-org.proxy=one -repo.www-ibiblio-org.hardfail=true -#Cache this repository for 1 hour -repo.www-ibiblio-org.cache.period=3600 -repo.www-ibiblio-org.cache.failures=true - -#dist.codehaus.org -repo.dist-codehaus-org.url=http://dist.codehaus.org -repo.dist-codehaus-org.proxy=two -repo.dist-codehaus-org.hardfail=false -repo.dist-codehaus-org.cache.period=3600 -repo.dist-codehaus-org.cache.failures=true - -#private.example.com -repo.private-example-com.url=http://private.example.com/internal -repo.private-example-com.description=Commercial In Confidence Repository -repo.private-example-com.username=username1 -repo.private-example-com.password=password1 -repo.private-example-com.proxy=three -repo.private-example-com.cache.period=3600 diff --git a/archiva-configuration/src/test/conf/repository-manager.xml b/archiva-configuration/src/test/conf/repository-manager.xml deleted file mode 100644 index 44e7fc155..000000000 --- a/archiva-configuration/src/test/conf/repository-manager.xml +++ /dev/null @@ -1,238 +0,0 @@ - - - - - - - internal - Archiva Managed Internal Repository - file://${appserver.home}/repositories/internal - default - true - false - true - 0 0 * * ? - - - snapshots - Archiva Managed Snapshot Repository - file://${appserver.home}/repositories/internal - default - false - true - true - 0 0,30 * * ? - - - central - Central Repository - http://repo1.maven.org/maven2 - default - 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 - - - - - internal - central - - disabled - never - not-found - - - internal - maven2-repository.dev.java.net - - disabled - never - not-found - - javax/** - - - - - - - - artifacts - - **/*.pom - **/*.jar - **/*.ear - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - **/*.dtd - **/*.tld - **/*.tar.gz - **/*.tar.bz2 - **/*.zip - - - artifact-to-db - artifact-to-lucene - artifact-create-missing-checksums - - - - projects - - **/*.pom - - - project-to-db - - - - repository-metadata - - **/maven-metadata.xml - - - repository-metadata-to-db - repository-metadata-version-mismatch - - - - checksums - - **/*.sha1 - **/*.md5 - - - checksum-validate - - - - signatures - - **/*.asc - - - signature-validate - - - - archives - - **/*.jar - **/*.ear - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - **/*.tar.gz - **/*.tar.bz2 - **/*.zip - **/*.nbm - - - archive-toc-to-lucene - - - - bytecode - - **/*.jar - **/*.war - **/*.car - **/*.sar - **/*.mar - **/*.rar - - - bytecode-to-db - bytecode-to-lucene - - - - xmls - - **/*.pom - **/*.xml - **/*.xsd - - - xml-to-lucene - - - - text - - **/*.txt - **/*.TXT - **/*.block - **/*.config - - - - ignored - - **/.htaccess - **/KEYS - **/*.rb - **/*.sh - **/.svn/** - **/.DAV/** - - - ignored - - - - auto-remove - - **/*.bak - **/*~ - **/*- - - - auto-remove - - - - auto-rename - - **/*.distribution-tgz - **/*.distribution-zip - **/*.plugin - - - auto-rename - - - - diff --git a/archiva-configuration/src/test/conf/with-proxied-repos.xml b/archiva-configuration/src/test/conf/with-proxied-repos.xml deleted file mode 100644 index c8032436a..000000000 --- a/archiva-configuration/src/test/conf/with-proxied-repos.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - managed-repository - local - local - - - - - http://www.ibiblio.org/maven2/ - local - true - ibiblio - Ibiblio - - - http://repository.codehaus.org/ - local - codehaus - Codehaus - - - diff --git a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java deleted file mode 100644 index 8f4243c27..000000000 --- a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.java +++ /dev/null @@ -1,200 +0,0 @@ -package org.apache.maven.archiva.configuration; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.io.FileUtils; -import org.codehaus.plexus.PlexusTestCase; - -import java.io.File; -import java.util.Properties; - -/** - * Test the configuration store. - * - * @author Brett Porter - */ -public class ArchivaConfigurationTest extends PlexusTestCase -{ - public void testDefaults() throws Exception - { - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "test-defaults" ); - - Configuration configuration = archivaConfiguration.getConfiguration(); - - // check default configuration - assertNotNull( "check configuration returned", configuration ); - assertTrue( "check configuration has default elements", configuration.getRepositories().isEmpty() ); - } - - public void testGetConfiguration() throws Exception - { - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); - - Configuration configuration = archivaConfiguration.getConfiguration(); - - assertEquals( "check repositories", 4, configuration.getRepositories().size() ); - assertEquals( "check proxy connectors", 2, configuration.getProxyConnectors().size() ); - assertEquals( "check network proxies", 0, configuration.getNetworkProxies().size() ); - assertEquals( "check file processors", 12, configuration.getFileProcessors().size() ); - - RepositoryConfiguration repository = - (RepositoryConfiguration) configuration.getRepositories().iterator().next(); - - assertEquals( "check managed repositories", "file://${appserver.home}/repositories/internal", repository.getUrl() ); - 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.isIndexed() ); - } - - public void testGetConfigurationSystemOverride() throws Exception - { - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-configuration" ); - - System.setProperty( "org.apache.maven.archiva.localRepository", "system-repository" ); - - Configuration configuration = archivaConfiguration.getConfiguration(); - - // assertEquals( "check localRepository", "system-repository", configuration.getLocalRepository() ); - // assertEquals( "check indexPath", ".index", configuration.getIndexPath() ); - } - - public void testStoreConfiguration() throws Exception - { - File file = getTestFile( "target/test/test-file.xml" ); - file.delete(); - assertFalse( file.exists() ); - - // TODO: remove with commons-configuration 1.4 - file.getParentFile().mkdirs(); - org.codehaus.plexus.util.FileUtils.fileWrite( file.getAbsolutePath(), "" ); - - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save" ); - - Configuration configuration = new Configuration(); - // configuration.setIndexPath( "index-path" ); - - archivaConfiguration.save( configuration ); - - assertTrue( "Check file exists", file.exists() ); - - // check it - configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check value", "index-path", configuration.getIndexPath() ); - - // read it back - archivaConfiguration = (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-saved" ); - configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check value", "index-path", configuration.getIndexPath() ); - } - - public void testStoreConfigurationUser() throws Exception - { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); - - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); - - // TODO: remove with commons-configuration 1.4 - userFile.getParentFile().mkdirs(); - org.codehaus.plexus.util.FileUtils.fileWrite( userFile.getAbsolutePath(), "" ); - - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); - - Configuration configuration = new Configuration(); - // configuration.setIndexPath( "index-path" ); - - archivaConfiguration.save( configuration ); - - assertTrue( "Check file exists", userFile.exists() ); - assertFalse( "Check file not created", baseFile.exists() ); - - // check it - configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check value", "index-path", configuration.getIndexPath() ); - } - - public void testStoreConfigurationFallback() throws Exception - { - File baseFile = getTestFile( "target/test/test-file.xml" ); - baseFile.delete(); - assertFalse( baseFile.exists() ); - - File userFile = getTestFile( "target/test/test-file-user.xml" ); - userFile.delete(); - assertFalse( userFile.exists() ); - - // TODO: remove with commons-configuration 1.4 - baseFile.getParentFile().mkdirs(); - org.codehaus.plexus.util.FileUtils.fileWrite( baseFile.getAbsolutePath(), "" ); - - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-save-user" ); - - Configuration configuration = new Configuration(); - // configuration.setIndexPath( "index-path" ); - - archivaConfiguration.save( configuration ); - - assertTrue( "Check file exists", baseFile.exists() ); - assertFalse( "Check file not created", userFile.exists() ); - - // check it - configuration = archivaConfiguration.getConfiguration(); - // assertEquals( "check value", "index-path", configuration.getIndexPath() ); - } - - public void testRemoveProxiedRepositoryAndStoreConfiguration() throws Exception - { - // MRM-300 - - File src = getTestFile( "src/test/conf/with-proxied-repos.xml" ); - File dest = getTestFile( "target/test/with-proxied-repos.xml" ); - FileUtils.copyFile( src, dest ); - - ArchivaConfiguration archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-remove-proxied-repo" ); - - Configuration configuration = archivaConfiguration.getConfiguration(); - // configuration.getProxiedRepositories().remove( 0 ); - - archivaConfiguration.save( configuration ); - - // check it - configuration = archivaConfiguration.getConfiguration(); - // assertEquals( 1, configuration.getProxiedRepositories().size() ); - - release( archivaConfiguration ); - - // read it back - archivaConfiguration = - (ArchivaConfiguration) lookup( ArchivaConfiguration.class.getName(), "test-read-back-remove-proxied-repo" ); - configuration = archivaConfiguration.getConfiguration(); - // assertEquals( 1, configuration.getProxiedRepositories().size() ); - } -} diff --git a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java b/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java deleted file mode 100644 index 091126087..000000000 --- a/archiva-configuration/src/test/java/org/apache/maven/archiva/configuration/MavenProxyPropertyLoaderTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.archiva.configuration; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.codehaus.plexus.PlexusTestCase; - -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * @author Edwin Punzalan - */ -public class MavenProxyPropertyLoaderTest extends PlexusTestCase -{ - private MavenProxyPropertyLoader loader; - - public void testLoadValidMavenProxyConfiguration() throws IOException, InvalidConfigurationException - { - File confFile = getTestFile( "src/test/conf/maven-proxy-complete.conf" ); - - Configuration configuration = new Configuration(); - ProxyConfiguration proxy = new ProxyConfiguration(); - proxy.setHost( "original-host" ); - configuration.addNetworkProxy( proxy ); // overwritten - - loader.load( new FileInputStream( confFile ), configuration ); - - List repos = configuration.getRepositories(); - assertEquals( "Count repositories", 5, repos.size() ); - - Map repositoryIdMap = new HashMap(); - - for ( Iterator itRepo = repos.iterator(); itRepo.hasNext(); ) - { - RepositoryConfiguration repo = (RepositoryConfiguration) itRepo.next(); - repositoryIdMap.put( repo.getId(), repo ); - } - - assertRepositoryExists( repositoryIdMap, "local-repo", "file://target" ); - - assertRepositoryExists( repositoryIdMap, "www-ibiblio-org", "http://www.ibiblio.org/maven2" ); - assertRepositoryExists( repositoryIdMap, "dist-codehaus-org", "http://dist.codehaus.org" ); - assertRepositoryExists( repositoryIdMap, "private-example-com", "http://private.example.com/internal" ); - } - - private void assertRepositoryExists( Map repoMap, String id, String expectedUrl ) - { - RepositoryConfiguration repo = (RepositoryConfiguration) repoMap.get( id ); - assertNotNull( "Repository id [" + id + "] should not be null", repo ); - assertEquals( "Repository id", id, repo.getId() ); - assertEquals( "Repository url", expectedUrl, repo.getUrl() ); - } - - public void testInvalidConfiguration() - { - Configuration configuration = new Configuration(); - try - { - loader.load( new Properties(), configuration ); - fail( "Incomplete config should have failed" ); - } - catch ( InvalidConfigurationException e ) - { - assertTrue( true ); - } - } - - protected void setUp() throws Exception - { - super.setUp(); - loader = new MavenProxyPropertyLoader(); - } -} diff --git a/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml b/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml deleted file mode 100644 index 00c6fceb1..000000000 --- a/archiva-configuration/src/test/resources/org/apache/maven/archiva/configuration/ArchivaConfigurationTest.xml +++ /dev/null @@ -1,182 +0,0 @@ - - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-defaults - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - empty - - - - - org.codehaus.plexus.registry.Registry - empty - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-configuration - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - configured - - - - - org.codehaus.plexus.registry.Registry - configured - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-save - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - save - - - - - org.codehaus.plexus.registry.Registry - save - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-save-user - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - save-user - - - - - org.codehaus.plexus.registry.Registry - save-user - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-read-saved - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - read-saved - - - - - org.codehaus.plexus.registry.Registry - read-saved - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-remove-proxied-repo - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - read-remove-proxied-repo - - - - - org.codehaus.plexus.registry.Registry - read-remove-proxied-repo - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - org.apache.maven.archiva.configuration.ArchivaConfiguration - test-read-back-remove-proxied-repo - org.apache.maven.archiva.configuration.DefaultArchivaConfiguration - - - org.codehaus.plexus.registry.Registry - read-back-remove-proxied-repo - - - - - org.codehaus.plexus.registry.Registry - read-back-remove-proxied-repo - org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry - - - - - - - - diff --git a/archiva-converter/pom.xml b/archiva-converter/pom.xml deleted file mode 100644 index a8fefa798..000000000 --- a/archiva-converter/pom.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - org.apache.maven.archiva - archiva - 1.0-SNAPSHOT - - 4.0.0 - archiva-converter - Archiva Repository Converter - - - org.apache.maven.archiva - archiva-consumer-api - - - org.apache.maven.archiva - archiva-discoverer - - - org.codehaus.plexus - plexus-utils - - - org.codehaus.plexus - plexus-component-api - - - org.apache.maven - maven-artifact - - - org.apache.maven.shared - maven-model-converter - - - org.codehaus.plexus - plexus-digest - - - org.codehaus.plexus - plexus-i18n - 1.0-beta-6 - - - commons-io - commons-io - - - - hsqldb - hsqldb - 1.7.3.3 - test - - - - org.codehaus.plexus - plexus-container-default - test - - - diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionEvent.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionEvent.java deleted file mode 100644 index bd5ef5854..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionEvent.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.apache.maven.archiva.converter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.converter.legacy.LegacyRepositoryConverter; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * ConversionEvent - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ConversionEvent -{ - public static final int STARTED = 0; - - public static final int PROCESSED = 1; - - public static final int WARNING = 2; - - public static final int ERROR = 3; - - public static final int FINISHED = 4; - - private int type; - - private String message; - - private Artifact artifact; - - private ArtifactRepository repository; - - private Exception exception; - - public ConversionEvent( ArtifactRepository repository, int type ) - { - this.repository = repository; - this.type = type; - } - - public ConversionEvent( ArtifactRepository repository, int type, Artifact artifact ) - { - this( repository, type ); - this.artifact = artifact; - } - - public ConversionEvent( ArtifactRepository repository, int type, Artifact artifact, String message ) - { - this( repository, type ); - this.artifact = artifact; - this.message = message; - } - - public ConversionEvent( ArtifactRepository repository, int type, Artifact artifact, Exception exception ) - { - this( repository, type ); - this.artifact = artifact; - this.exception = exception; - } - - public Artifact getArtifact() - { - return artifact; - } - - public Exception getException() - { - return exception; - } - - public String getMessage() - { - return message; - } - - public ArtifactRepository getRepository() - { - return repository; - } - - /** - *

- * The type of event. - *

- * - *

- * Can be one of the following ... - *

- * - *
    - *
  • {@link #STARTED} - the whole repository conversion process has started. - * only seen when using the whole repository conversion technique with the - * {@link LegacyRepositoryConverter#convertLegacyRepository(java.io.File, java.io.File, java.util.List, boolean)} - * method.
  • - *
  • {@link #PROCESSED} - a specific artifact has been processed.
  • - *
  • {@link #WARNING} - a warning has been detected for a specific artifact during the conversion process.
  • - *
  • {@link #ERROR} - an error in the processing of an artifact has been detected.
  • - *
  • {@link #FINISHED} - the whole repository conversion process has finished. - * only seen when using the whole repository conversion technique with the - * {@link LegacyRepositoryConverter#convertLegacyRepository(java.io.File, java.io.File, java.util.List, boolean)} - * method.
  • - *
- * @return - */ - public int getType() - { - return type; - } -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionListener.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionListener.java deleted file mode 100644 index 3193bd475..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/ConversionListener.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.maven.archiva.converter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * ConversionListener - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public interface ConversionListener -{ - public void conversionEvent( ConversionEvent event ); -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java deleted file mode 100644 index 5b03d6f48..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/DefaultRepositoryConverter.java +++ /dev/null @@ -1,741 +0,0 @@ -package org.apache.maven.archiva.converter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.maven.archiva.converter.transaction.FileTransaction; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.Metadata; -import org.apache.maven.artifact.repository.metadata.RepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.Snapshot; -import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.Versioning; -import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; -import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Writer; -import org.apache.maven.model.DistributionManagement; -import org.apache.maven.model.Model; -import org.apache.maven.model.Relocation; -import org.apache.maven.model.converter.ModelConverter; -import org.apache.maven.model.converter.PomTranslationException; -import org.apache.maven.model.io.xpp3.MavenXpp3Writer; -import org.apache.maven.model.v3_0_0.io.xpp3.MavenXpp3Reader; -import org.codehaus.plexus.digest.Digester; -import org.codehaus.plexus.digest.DigesterException; -import org.codehaus.plexus.i18n.I18N; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Properties; -import java.util.regex.Matcher; - -/** - * Implementation of repository conversion class. - * - * @author Brett Porter - * @plexus.component role="org.apache.maven.archiva.converter.RepositoryConverter" role-hint="default" - */ -public class DefaultRepositoryConverter - extends AbstractLogEnabled - implements RepositoryConverter -{ - /** - * {@link List}<{@link Digester}> - * - * @plexus.requirement role="org.codehaus.plexus.digest.Digester" - */ - private List digesters; - - /** - * @plexus.requirement - */ - private ArtifactFactory artifactFactory; - - /** - * @plexus.requirement - */ - private ModelConverter translator; - - /** - * @plexus.requirement - */ - private ArtifactHandlerManager artifactHandlerManager; - - /** - * @plexus.configuration default-value="false" - */ - private boolean force; - - /** - * @plexus.configuration default-value="false" - */ - private boolean dryrun; - - /** - * @plexus.requirement - */ - private I18N i18n; - - private List listeners = new ArrayList(); - - public void convert( Artifact artifact, ArtifactRepository targetRepository ) - throws RepositoryConversionException - { - if ( artifact.getRepository().getUrl().equals( targetRepository.getUrl() ) ) - { - throw new RepositoryConversionException( getI18NString( "exception.repositories.match" ) ); - } - - if ( validateMetadata( artifact ) ) - { - FileTransaction transaction = new FileTransaction(); - - if ( copyPom( artifact, targetRepository, transaction ) ) - { - if ( copyArtifact( artifact, targetRepository, transaction ) ) - { - Metadata metadata = createBaseMetadata( artifact ); - Versioning versioning = new Versioning(); - versioning.addVersion( artifact.getBaseVersion() ); - metadata.setVersioning( versioning ); - updateMetadata( new ArtifactRepositoryMetadata( artifact ), targetRepository, metadata, transaction ); - - metadata = createBaseMetadata( artifact ); - metadata.setVersion( artifact.getBaseVersion() ); - versioning = new Versioning(); - - Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( artifact.getVersion() ); - if ( matcher.matches() ) - { - Snapshot snapshot = new Snapshot(); - snapshot.setBuildNumber( Integer.valueOf( matcher.group( 3 ) ).intValue() ); - snapshot.setTimestamp( matcher.group( 2 ) ); - versioning.setSnapshot( snapshot ); - } - - // TODO: merge latest/release/snapshot from source instead - metadata.setVersioning( versioning ); - updateMetadata( new SnapshotArtifactRepositoryMetadata( artifact ), targetRepository, metadata, - transaction ); - - if ( !dryrun ) - { - transaction.commit(); - } - } - } - } - } - - private static Metadata createBaseMetadata( Artifact artifact ) - { - Metadata metadata = new Metadata(); - metadata.setArtifactId( artifact.getArtifactId() ); - metadata.setGroupId( artifact.getGroupId() ); - return metadata; - } - - private void updateMetadata( RepositoryMetadata artifactMetadata, ArtifactRepository targetRepository, - Metadata newMetadata, FileTransaction transaction ) - throws RepositoryConversionException - { - File file = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - - Metadata metadata; - boolean changed; - - if ( file.exists() ) - { - metadata = readMetadata( file ); - changed = metadata.merge( newMetadata ); - } - else - { - changed = true; - metadata = newMetadata; - } - - if ( changed ) - { - StringWriter writer = null; - try - { - writer = new StringWriter(); - - MetadataXpp3Writer mappingWriter = new MetadataXpp3Writer(); - - mappingWriter.write( writer, metadata ); - - transaction.createFile( writer.toString(), file, digesters ); - } - catch ( IOException e ) - { - throw new RepositoryConversionException( "Error writing target metadata", e ); - } - finally - { - IOUtils.closeQuietly( writer ); - } - } - } - - private Metadata readMetadata( File file ) - throws RepositoryConversionException - { - Metadata metadata; - MetadataXpp3Reader reader = new MetadataXpp3Reader(); - FileReader fileReader = null; - try - { - fileReader = new FileReader( file ); - metadata = reader.read( fileReader ); - } - catch ( FileNotFoundException e ) - { - throw new RepositoryConversionException( "Error reading target metadata", e ); - } - catch ( IOException e ) - { - throw new RepositoryConversionException( "Error reading target metadata", e ); - } - catch ( XmlPullParserException e ) - { - throw new RepositoryConversionException( "Error reading target metadata", e ); - } - finally - { - IOUtils.closeQuietly( fileReader ); - } - return metadata; - } - - private boolean validateMetadata( Artifact artifact ) - throws RepositoryConversionException - { - ArtifactRepository repository = artifact.getRepository(); - - boolean result = true; - - RepositoryMetadata repositoryMetadata = new ArtifactRepositoryMetadata( artifact ); - File file = new File( repository.getBasedir(), repository.pathOfRemoteRepositoryMetadata( repositoryMetadata ) ); - if ( file.exists() ) - { - Metadata metadata = readMetadata( file ); - result = validateMetadata( metadata, repositoryMetadata, artifact ); - } - - repositoryMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - file = new File( repository.getBasedir(), repository.pathOfRemoteRepositoryMetadata( repositoryMetadata ) ); - if ( file.exists() ) - { - Metadata metadata = readMetadata( file ); - result = result && validateMetadata( metadata, repositoryMetadata, artifact ); - } - - return result; - } - - private boolean validateMetadata( Metadata metadata, RepositoryMetadata repositoryMetadata, Artifact artifact ) - { - String groupIdKey; - String artifactIdKey = null; - String snapshotKey = null; - String versionKey = null; - String versionsKey = null; - - if ( repositoryMetadata.storedInGroupDirectory() ) - { - groupIdKey = "failure.incorrect.groupMetadata.groupId"; - } - else if ( repositoryMetadata.storedInArtifactVersionDirectory() ) - { - groupIdKey = "failure.incorrect.snapshotMetadata.groupId"; - artifactIdKey = "failure.incorrect.snapshotMetadata.artifactId"; - versionKey = "failure.incorrect.snapshotMetadata.version"; - snapshotKey = "failure.incorrect.snapshotMetadata.snapshot"; - } - else - { - groupIdKey = "failure.incorrect.artifactMetadata.groupId"; - artifactIdKey = "failure.incorrect.artifactMetadata.artifactId"; - versionsKey = "failure.incorrect.artifactMetadata.versions"; - } - - boolean result = true; - - if ( metadata.getGroupId() == null || !metadata.getGroupId().equals( artifact.getGroupId() ) ) - { - addFailure( artifact, groupIdKey ); - result = false; - } - if ( !repositoryMetadata.storedInGroupDirectory() ) - { - if ( metadata.getGroupId() == null || !metadata.getArtifactId().equals( artifact.getArtifactId() ) ) - { - addFailure( artifact, artifactIdKey ); - result = false; - } - if ( !repositoryMetadata.storedInArtifactVersionDirectory() ) - { - // artifact metadata - - boolean foundVersion = false; - if ( metadata.getVersioning() != null ) - { - for ( Iterator i = metadata.getVersioning().getVersions().iterator(); i.hasNext() && !foundVersion; ) - { - String version = (String) i.next(); - if ( version.equals( artifact.getBaseVersion() ) ) - { - foundVersion = true; - } - } - } - - if ( !foundVersion ) - { - addFailure( artifact, versionsKey ); - result = false; - } - } - else - { - // snapshot metadata - if ( !artifact.getBaseVersion().equals( metadata.getVersion() ) ) - { - addFailure( artifact, versionKey ); - result = false; - } - - if ( artifact.isSnapshot() ) - { - Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( artifact.getVersion() ); - if ( matcher.matches() ) - { - boolean correct = false; - if ( metadata.getVersioning() != null && metadata.getVersioning().getSnapshot() != null ) - { - Snapshot snapshot = metadata.getVersioning().getSnapshot(); - int build = Integer.valueOf( matcher.group( 3 ) ).intValue(); - String ts = matcher.group( 2 ); - if ( build == snapshot.getBuildNumber() && ts.equals( snapshot.getTimestamp() ) ) - { - correct = true; - } - } - - if ( !correct ) - { - addFailure( artifact, snapshotKey ); - result = false; - } - } - } - } - } - return result; - } - - private void addFailure( Artifact artifact, String key ) - { - addFailureWithReason( artifact, getI18NString( key ) ); - } - - private void addWarning( Artifact artifact, String message ) - { - // TODO: should we be able to identify/fix these? - // TODO: write archiva-artifact-repair module - triggerConversionEvent( new ConversionEvent( artifact.getRepository(), ConversionEvent.WARNING, artifact, - message ) ); - } - - private void addFailureWithReason( Artifact artifact, String reason ) - { - // TODO: should we be able to identify/fix these? - triggerConversionEvent( new ConversionEvent( artifact.getRepository(), ConversionEvent.ERROR, artifact, reason ) ); - } - - private boolean copyPom( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction ) - throws RepositoryConversionException - { - Artifact pom = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact - .getVersion() ); - pom.setBaseVersion( artifact.getBaseVersion() ); - ArtifactRepository repository = artifact.getRepository(); - File file = new File( repository.getBasedir(), repository.pathOf( pom ) ); - - boolean result = true; - if ( file.exists() ) - { - File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pom ) ); - - String contents = null; - boolean checksumsValid = false; - try - { - if ( testChecksums( artifact, file ) ) - { - checksumsValid = true; - } - - // Even if the checksums for the POM are invalid we should still convert the POM - contents = FileUtils.readFileToString( file, null ); - } - catch ( IOException e ) - { - throw new RepositoryConversionException( "Unable to read source POM: " + e.getMessage(), e ); - } - - if ( checksumsValid && contents.indexOf( "modelVersion" ) >= 0 ) - { - // v4 POM - try - { - boolean matching = false; - if ( !force && targetFile.exists() ) - { - String targetContents = FileUtils.readFileToString( targetFile, null ); - matching = targetContents.equals( contents ); - } - if ( force || !matching ) - { - transaction.createFile( contents, targetFile, digesters ); - } - } - catch ( IOException e ) - { - throw new RepositoryConversionException( "Unable to write target POM: " + e.getMessage(), e ); - } - } - else - { - // v3 POM - StringReader stringReader = new StringReader( contents ); - StringWriter writer = null; - try - { - MavenXpp3Reader v3Reader = new MavenXpp3Reader(); - org.apache.maven.model.v3_0_0.Model v3Model = v3Reader.read( stringReader ); - - if ( doRelocation( artifact, v3Model, targetRepository, transaction ) ) - { - Artifact relocatedPom = artifactFactory.createProjectArtifact( artifact.getGroupId(), artifact - .getArtifactId(), artifact.getVersion() ); - targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( relocatedPom ) ); - } - - Model v4Model = translator.translate( v3Model ); - - translator.validateV4Basics( v4Model, v3Model.getGroupId(), v3Model.getArtifactId(), v3Model - .getVersion(), v3Model.getPackage() ); - - writer = new StringWriter(); - MavenXpp3Writer Xpp3Writer = new MavenXpp3Writer(); - Xpp3Writer.write( writer, v4Model ); - - transaction.createFile( writer.toString(), targetFile, digesters ); - - List warnings = translator.getWarnings(); - - for ( Iterator i = warnings.iterator(); i.hasNext(); ) - { - String message = (String) i.next(); - addWarning( artifact, message ); - } - } - catch ( XmlPullParserException e ) - { - addFailureWithReason( artifact, getI18NString( "failure.invalid.source.pom", e.getMessage() ) ); - result = false; - } - catch ( IOException e ) - { - throw new RepositoryConversionException( "Unable to write converted POM", e ); - } - catch ( PomTranslationException e ) - { - addFailureWithReason( artifact, getI18NString( "failure.invalid.source.pom", e.getMessage() ) ); - result = false; - } - finally - { - IOUtils.closeQuietly( writer ); - } - } - } - else - { - addWarning( artifact, getI18NString( "warning.missing.pom" ) ); - } - return result; - } - - private boolean doRelocation( Artifact artifact, org.apache.maven.model.v3_0_0.Model v3Model, - ArtifactRepository repository, FileTransaction transaction ) - throws IOException - { - Properties properties = v3Model.getProperties(); - if ( properties.containsKey( "relocated.groupId" ) || properties.containsKey( "relocated.artifactId" ) - || properties.containsKey( "relocated.version" ) ) - { - String newGroupId = properties.getProperty( "relocated.groupId", v3Model.getGroupId() ); - properties.remove( "relocated.groupId" ); - - String newArtifactId = properties.getProperty( "relocated.artifactId", v3Model.getArtifactId() ); - properties.remove( "relocated.artifactId" ); - - String newVersion = properties.getProperty( "relocated.version", v3Model.getVersion() ); - properties.remove( "relocated.version" ); - - String message = properties.getProperty( "relocated.message", "" ); - properties.remove( "relocated.message" ); - - if ( properties.isEmpty() ) - { - v3Model.setProperties( null ); - } - - writeRelocationPom( v3Model.getGroupId(), v3Model.getArtifactId(), v3Model.getVersion(), newGroupId, - newArtifactId, newVersion, message, repository, transaction ); - - v3Model.setGroupId( newGroupId ); - v3Model.setArtifactId( newArtifactId ); - v3Model.setVersion( newVersion ); - - artifact.setGroupId( newGroupId ); - artifact.setArtifactId( newArtifactId ); - artifact.setVersion( newVersion ); - - return true; - } - else - { - return false; - } - } - - private void writeRelocationPom( String groupId, String artifactId, String version, String newGroupId, - String newArtifactId, String newVersion, String message, - ArtifactRepository repository, FileTransaction transaction ) - throws IOException - { - Model pom = new Model(); - pom.setGroupId( groupId ); - pom.setArtifactId( artifactId ); - pom.setVersion( version ); - - DistributionManagement dMngt = new DistributionManagement(); - - Relocation relocation = new Relocation(); - relocation.setGroupId( newGroupId ); - relocation.setArtifactId( newArtifactId ); - relocation.setVersion( newVersion ); - if ( message != null && message.length() > 0 ) - { - relocation.setMessage( message ); - } - - dMngt.setRelocation( relocation ); - - pom.setDistributionManagement( dMngt ); - - Artifact artifact = artifactFactory.createBuildArtifact( groupId, artifactId, version, "pom" ); - File pomFile = new File( repository.getBasedir(), repository.pathOf( artifact ) ); - - StringWriter strWriter = new StringWriter(); - MavenXpp3Writer pomWriter = new MavenXpp3Writer(); - pomWriter.write( strWriter, pom ); - - transaction.createFile( strWriter.toString(), pomFile, digesters ); - } - - private String getI18NString( String key, String arg0 ) - { - return i18n.format( getClass().getName(), Locale.getDefault(), key, arg0 ); - } - - private String getI18NString( String key ) - { - return i18n.getString( getClass().getName(), Locale.getDefault(), key ); - } - - private boolean testChecksums( Artifact artifact, File file ) - throws IOException - { - boolean result = true; - Iterator it = digesters.iterator(); - while ( it.hasNext() ) - { - Digester digester = (Digester) it.next(); - result &= verifyChecksum( file, file.getName() + "." + getDigesterFileExtension( digester ), digester, - artifact, "failure.incorrect." + getDigesterFileExtension( digester ) ); - } - return result; - } - - /** - * File extension for checksums - * TODO should be moved to plexus-digester ? - */ - private String getDigesterFileExtension( Digester digester ) - { - return digester.getAlgorithm().toLowerCase().replaceAll( "-", "" ); - } - - private boolean verifyChecksum( File file, String fileName, Digester digester, Artifact artifact, String key ) - throws IOException - { - boolean result = true; - - File checksumFile = new File( file.getParentFile(), fileName ); - if ( checksumFile.exists() ) - { - String checksum = FileUtils.readFileToString( checksumFile, null ); - try - { - digester.verify( file, checksum ); - } - catch ( DigesterException e ) - { - addFailure( artifact, key ); - result = false; - } - } - return result; - } - - private boolean copyArtifact( Artifact artifact, ArtifactRepository targetRepository, FileTransaction transaction ) - throws RepositoryConversionException - { - File sourceFile = artifact.getFile(); - - if ( sourceFile.getAbsolutePath().indexOf( "/plugins/" ) > -1 ) - { - artifact.setArtifactHandler( artifactHandlerManager.getArtifactHandler( "maven-plugin" ) ); - } - - File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - - boolean result = true; - try - { - boolean matching = false; - if ( !force && targetFile.exists() ) - { - matching = FileUtils.contentEquals( sourceFile, targetFile ); - if ( !matching ) - { - addFailure( artifact, "failure.target.already.exists" ); - result = false; - } - } - if ( result ) - { - if ( force || !matching ) - { - if ( testChecksums( artifact, sourceFile ) ) - { - transaction.copyFile( sourceFile, targetFile, digesters ); - } - else - { - result = false; - } - } - } - } - catch ( IOException e ) - { - throw new RepositoryConversionException( "Error copying artifact", e ); - } - return result; - } - - public void convert( List artifacts, ArtifactRepository targetRepository ) - throws RepositoryConversionException - { - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) - { - Artifact artifact = (Artifact) i.next(); - - try - { - convert( artifact, targetRepository ); - } - catch ( RepositoryConversionException e ) - { - triggerConversionEvent( new ConversionEvent( targetRepository, ConversionEvent.ERROR, artifact, e ) ); - } - } - } - - /** - * Add a listener to the conversion process. - * - * @param listener the listener to add. - */ - public void addConversionListener( ConversionListener listener ) - { - listeners.add( listener ); - } - - /** - * Remove a listener from the conversion process. - * - * @param listener the listener to remove. - */ - public void removeConversionListener( ConversionListener listener ) - { - listeners.remove( listener ); - } - - private void triggerConversionEvent( ConversionEvent event ) - { - Iterator it = listeners.iterator(); - while ( it.hasNext() ) - { - ConversionListener listener = (ConversionListener) it.next(); - - try - { - listener.conversionEvent( event ); - } - catch ( Throwable t ) - { - getLogger().warn( "ConversionEvent resulted in exception from listener: " + t.getMessage(), t ); - } - } - } -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConversionException.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConversionException.java deleted file mode 100644 index cbc622d64..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConversionException.java +++ /dev/null @@ -1,39 +0,0 @@ -package org.apache.maven.archiva.converter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * Exception occuring during repository conversion. - * - * @author Brett Porter - */ -public class RepositoryConversionException - extends Exception -{ - public RepositoryConversionException( String message ) - { - super( message ); - } - - public RepositoryConversionException( String message, Throwable cause ) - { - super( message, cause ); - } -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java deleted file mode 100644 index 37c21fcce..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/RepositoryConverter.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.archiva.converter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; - -import java.util.List; - -/** - * Copy a set of artifacts from one repository to the other, converting if necessary. - * - * @author Brett Porter - */ -public interface RepositoryConverter -{ - String ROLE = RepositoryConverter.class.getName(); - - /** - * Convert a single artifact, writing it into the target repository. - * - * @param artifact the artifact to convert - * @param targetRepository the target repository - */ - void convert( Artifact artifact, ArtifactRepository targetRepository ) - throws RepositoryConversionException; - - /** - * Convert a set of artifacts, writing them into the target repository. - * - * @param artifacts the set of artifacts to convert - * @param targetRepository the target repository - */ - void convert( List artifacts, ArtifactRepository targetRepository ) - throws RepositoryConversionException; - - /** - * Add a listener to the conversion process. - * - * @param listener the listener to add. - */ - void addConversionListener( ConversionListener listener ); - - /** - * Remove a listener from the conversion process. - * - * @param listener the listener to remove. - */ - void removeConversionListener( ConversionListener listener ); -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java deleted file mode 100644 index abf303bcb..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/DefaultLegacyRepositoryConverter.java +++ /dev/null @@ -1,139 +0,0 @@ -package org.apache.maven.archiva.converter.legacy; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.converter.ConversionListener; -import org.apache.maven.archiva.converter.RepositoryConversionException; -import org.apache.maven.archiva.discoverer.Discoverer; -import org.apache.maven.archiva.discoverer.DiscovererException; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; - -import java.io.File; -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Jason van Zyl - * @plexus.component - * @todo turn this into a general conversion component and hide all this crap here. - * @todo it should be possible to move this to the converter module without causing it to gain additional dependencies - */ -public class DefaultLegacyRepositoryConverter - implements LegacyRepositoryConverter -{ - /** - * @plexus.requirement role-hint="legacy" - */ - private ArtifactRepositoryLayout legacyLayout; - - /** - * @plexus.requirement role-hint="default" - */ - private ArtifactRepositoryLayout defaultLayout; - - /** - * @plexus.requirement - */ - private ArtifactRepositoryFactory artifactRepositoryFactory; - - /** - * @plexus.requirement role-hint="default" - */ - private Discoverer discoverer; - - /** - * @plexus.requirement role="org.apache.maven.archiva.common.consumers.Consumer" role-hint="legacy-converter" - */ - private LegacyConverterArtifactConsumer legacyConverterConsumer; - - public void convertLegacyRepository( File legacyRepositoryDirectory, File repositoryDirectory, - List fileExclusionPatterns, boolean includeSnapshots ) - throws RepositoryConversionException - { - ArtifactRepository legacyRepository; - - ArtifactRepository repository; - - try - { - String legacyRepositoryDir = legacyRepositoryDirectory.toURI().toURL().toString(); - String repositoryDir = repositoryDirectory.toURI().toURL().toString(); - - //workaround for spaces non converted by PathUtils in wagon - //TODO: remove it when PathUtils will be fixed - if ( legacyRepositoryDir.indexOf( "%20" ) >= 0 ) - { - legacyRepositoryDir = StringUtils.replace( legacyRepositoryDir, "%20", " " ); - } - if ( repositoryDir.indexOf( "%20" ) >= 0 ) - { - repositoryDir = StringUtils.replace( repositoryDir, "%20", " " ); - } - - legacyRepository = artifactRepositoryFactory.createArtifactRepository( "legacy", legacyRepositoryDir, - legacyLayout, null, null ); - - repository = artifactRepositoryFactory.createArtifactRepository( "default", repositoryDir, defaultLayout, - null, null ); - } - catch ( MalformedURLException e ) - { - throw new RepositoryConversionException( "Error convering legacy repository.", e ); - } - - try - { - List consumers = new ArrayList(); - legacyConverterConsumer.setDestinationRepository( repository ); - consumers.add( legacyConverterConsumer ); - - discoverer.walkRepository( legacyRepository, consumers, includeSnapshots ); - } - catch ( DiscovererException e ) - { - throw new RepositoryConversionException( - "Unable to convert repository due to discoverer error:" + e.getMessage(), e ); - } - } - - /** - * Add a listener to the conversion process. - * - * @param listener the listener to add. - */ - public void addConversionListener( ConversionListener listener ) - { - legacyConverterConsumer.addConversionListener( listener ); - } - - /** - * Remove a listener from the conversion process. - * - * @param listener the listener to remove. - */ - public void removeConversionListener( ConversionListener listener ) - { - legacyConverterConsumer.removeConversionListener( listener ); - } -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java deleted file mode 100644 index 03e9d47d0..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyConverterArtifactConsumer.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.apache.maven.archiva.converter.legacy; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.utils.BaseFile; -import org.apache.maven.archiva.consumers.GenericArtifactConsumer; -import org.apache.maven.archiva.converter.ConversionListener; -import org.apache.maven.archiva.converter.RepositoryConversionException; -import org.apache.maven.archiva.converter.RepositoryConverter; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * LegacyConverterArtifactConsumer - convert artifacts as they are found - * into the destination repository. - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.common.consumers.Consumers" - * role-hint="legacy-converter" - * instantiation-strategy="per-lookup" - */ -public class LegacyConverterArtifactConsumer - extends GenericArtifactConsumer -{ - /** - * @plexus.requirement - */ - private RepositoryConverter repositoryConverter; - - private ArtifactRepository destinationRepository; - - public void processArtifact( Artifact artifact, BaseFile file ) - { - try - { - repositoryConverter.convert( artifact, destinationRepository ); - } - catch ( RepositoryConversionException e ) - { - getLogger().error( - "Unable to convert artifact " + artifact + " to destination repository " - + destinationRepository, e ); - } - } - - public void processFileProblem( BaseFile path, String message ) - { - getLogger().error( "Artifact Build Failure on " + path + " : " + message ); - // TODO: report this to the ConversionListener? - } - - public ArtifactRepository getDestinationRepository() - { - return destinationRepository; - } - - public void setDestinationRepository( ArtifactRepository destinationRepository ) - { - this.destinationRepository = destinationRepository; - } - - public String getName() - { - return "Legacy Artifact Converter Consumer"; - } - - /** - * Add a listener to the conversion process. - * - * @param listener the listener to add. - */ - public void addConversionListener( ConversionListener listener ) - { - repositoryConverter.addConversionListener( listener ); - } - - /** - * Remove a listener from the conversion process. - * - * @param listener the listener to remove. - */ - public void removeConversionListener( ConversionListener listener ) - { - repositoryConverter.removeConversionListener( listener ); - } -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyRepositoryConverter.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyRepositoryConverter.java deleted file mode 100644 index 60d3d5599..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/legacy/LegacyRepositoryConverter.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.apache.maven.archiva.converter.legacy; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.converter.ConversionListener; -import org.apache.maven.archiva.converter.RepositoryConversionException; - -import java.io.File; -import java.util.List; - -/** - * Convert an entire repository. - * - * @author Jason van Zyl - */ -public interface LegacyRepositoryConverter -{ - String ROLE = LegacyRepositoryConverter.class.getName(); - - /** - * Convert a legacy repository to a modern repository. This means a Maven 1.x repository - * using v3 POMs to a Maven 2.x repository using v4.0.0 POMs. - * - * @param legacyRepositoryDirectory the directory of the legacy repository. - * @param destinationRepositoryDirectory the directory of the modern repository. - * @param fileExclusionPatterns the list of patterns to exclude from the conversion. - * @param includeSnapshots true to include snapshots in conversion or not. - * @throws RepositoryConversionException - */ - void convertLegacyRepository( File legacyRepositoryDirectory, File destinationRepositoryDirectory, - List fileExclusionPatterns, boolean includeSnapshots ) - throws RepositoryConversionException; - - /** - * Add a listener to the conversion process. - * - * @param listener the listener to add. - */ - void addConversionListener( ConversionListener listener ); - - /** - * Remove a listener from the conversion process. - * - * @param listener the listener to remove. - */ - void removeConversionListener( ConversionListener listener ); -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/AbstractTransactionEvent.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/AbstractTransactionEvent.java deleted file mode 100644 index 10479ec62..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/AbstractTransactionEvent.java +++ /dev/null @@ -1,225 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.apache.commons.io.FileUtils; -import org.codehaus.plexus.digest.Digester; -import org.codehaus.plexus.digest.DigesterException; -import org.codehaus.plexus.logging.AbstractLogEnabled; - -/** - * Abstract class for the TransactionEvents - * - * @author Edwin Punzalan - * @author Carlos Sanchez - * @version $Id$ - */ -public abstract class AbstractTransactionEvent - extends AbstractLogEnabled - implements TransactionEvent -{ - private Map backups = new HashMap();; - - private List createdDirs = new ArrayList(); - - private List createdFiles = new ArrayList(); - - /** {@link List}<{@link Digester}> */ - private List digesters; - - protected AbstractTransactionEvent() - { - this( new ArrayList( 0 ) ); - } - - protected AbstractTransactionEvent( List digesters ) - { - this.digesters = digesters; - } - - protected List getDigesters() - { - return digesters; - } - - /** - * Method that creates a directory as well as all the parent directories needed - * - * @param dir The File directory to be created - * @throws IOException when an unrecoverable error occurred - */ - protected void mkDirs( File dir ) - throws IOException - { - List createDirs = new ArrayList(); - - File parent = dir; - while ( !parent.exists() || !parent.isDirectory() ) - { - createDirs.add( parent ); - - parent = parent.getParentFile(); - } - - while ( !createDirs.isEmpty() ) - { - File directory = (File) createDirs.remove( createDirs.size() - 1 ); - - if ( directory.mkdir() ) - { - createdDirs.add( directory ); - } - else - { - throw new IOException( "Failed to create directory: " + directory.getAbsolutePath() ); - } - } - } - - protected void revertMkDirs() - throws IOException - { - if ( createdDirs != null ) - { - Collections.reverse( createdDirs ); - - while ( !createdDirs.isEmpty() ) - { - File dir = (File) createdDirs.remove( 0 ); - - if ( dir.isDirectory() && dir.list().length == 0 ) - { - FileUtils.deleteDirectory( dir ); - } - else - { - //cannot rollback created directory if it still contains files - break; - } - } - } - } - - protected void revertFilesCreated() - throws IOException - { - Iterator it = createdFiles.iterator(); - while ( it.hasNext() ) - { - File file = (File) it.next(); - file.delete(); - it.remove(); - } - } - - protected void createBackup( File file ) - throws IOException - { - if ( file.exists() && file.isFile() ) - { - File backup = File.createTempFile( "temp-", ".backup" ); - - FileUtils.copyFile( file, backup ); - - backup.deleteOnExit(); - - backups.put( file, backup ); - } - } - - protected void restoreBackups() - throws IOException - { - Iterator it = backups.entrySet().iterator(); - while ( it.hasNext() ) - { - Map.Entry entry = (Map.Entry) it.next(); - FileUtils.copyFile( (File) entry.getValue(), (File) entry.getKey() ); - } - } - - protected void restoreBackup( File file ) - throws IOException - { - File backup = (File) backups.get( file ); - if ( backup != null ) - { - FileUtils.copyFile( backup, file ); - } - } - - /** - * Create checksums of file using all digesters defined at construction time. - * - * @param file - * @param force whether existing checksums should be overwritten or not - * @throws IOException - */ - protected void createChecksums( File file, boolean force ) - throws IOException - { - Iterator it = getDigesters().iterator(); - while ( it.hasNext() ) - { - Digester digester = (Digester) it.next(); - File checksumFile = new File( file.getAbsolutePath() + "." + getDigesterFileExtension( digester ) ); - if ( checksumFile.exists() ) - { - if ( !force ) - { - continue; - } - createBackup( checksumFile ); - } - else - { - createdFiles.add( checksumFile ); - } - try - { - FileUtils.writeStringToFile( checksumFile, digester.calc( file ), null ); - } - catch ( DigesterException e ) - { - // the Digester API just wraps IOException and should be fixed - throw (IOException) e.getCause(); - } - } - } - - /** - * File extension for checksums - * TODO should be moved to plexus-digester ? - */ - protected String getDigesterFileExtension( Digester digester ) - { - return digester.getAlgorithm().toLowerCase().replaceAll( "-", "" ); - } - -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CopyFileEvent.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CopyFileEvent.java deleted file mode 100644 index 96cc72d07..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CopyFileEvent.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.io.FileUtils; -import org.codehaus.plexus.digest.Digester; - -/** - * Event to copy a file. - * - * @author Brett Porter - * @author Carlos Sanchez - * @version $Id$ - */ -public class CopyFileEvent - extends AbstractTransactionEvent -{ - private final File source; - - private final File destination; - - /** - * Creates a copy file event with no digesters - * - * @deprecated use other constructors - * - * @param source - * @param destination - */ - public CopyFileEvent( File source, File destination ) - { - this( source, destination, new ArrayList( 0 ) ); - } - - /** - * - * @param source - * @param destination - * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming - */ - public CopyFileEvent( File source, File destination, List digesters ) - { - super( digesters ); - this.source = source; - this.destination = destination; - } - - public void commit() - throws IOException - { - createBackup( destination ); - - mkDirs( destination.getParentFile() ); - - FileUtils.copyFile( source, destination ); - - createChecksums( destination, true ); - copyChecksums(); - - copyChecksum( "asc" ); - } - - /** - * Copy checksums of source file with all digesters if exist - * - * @throws IOException - */ - private void copyChecksums() - throws IOException - { - Iterator it = getDigesters().iterator(); - while ( it.hasNext() ) - { - Digester digester = (Digester) it.next(); - copyChecksum( getDigesterFileExtension( digester ) ); - } - } - - /** - * Copy checksum of source file with extension provided if exists - * - * @param extension - * @return whether the checksum exists or not - * @throws IOException - */ - private boolean copyChecksum( String extension ) - throws IOException - { - File checksumSource = new File( source.getAbsolutePath() + "." + extension ); - if ( checksumSource.exists() ) - { - File checksumDestination = new File( destination.getAbsolutePath() + "." + extension ); - FileUtils.copyFile( checksumSource, checksumDestination ); - return true; - } - return false; - } - - public void rollback() - throws IOException - { - destination.delete(); - - revertFilesCreated(); - - revertMkDirs(); - - restoreBackups(); - } -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CreateFileEvent.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CreateFileEvent.java deleted file mode 100644 index d8c567997..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/CreateFileEvent.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.io.FileUtils; -import org.codehaus.plexus.digest.Digester; - -/** - * Event for creating a file from a string content. - * - * @author Brett Porter - * @author Carlos Sanchez - * @version $Id$ - */ -public class CreateFileEvent - extends AbstractTransactionEvent -{ - private final File destination; - - private final String content; - - /** - * Creates a create file event with no digesters - * - * @deprecated use other constructors - * - * @param content - * @param destination - */ - public CreateFileEvent( String content, File destination ) - { - this( content, destination, new ArrayList( 0 ) ); - } - - /** - * - * @param content - * @param destination - * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming - */ - public CreateFileEvent( String content, File destination, List digesters ) - { - super( digesters ); - this.content = content; - this.destination = destination; - } - - public void commit() - throws IOException - { - createBackup( destination ); - - mkDirs( destination.getParentFile() ); - - if ( !destination.exists() && !destination.createNewFile() ) - { - throw new IOException( "Unable to create new file" ); - } - - FileUtils.writeStringToFile( destination, content, null ); - - createChecksums( destination, true ); - } - - public void rollback() - throws IOException - { - destination.delete(); - - revertFilesCreated(); - - revertMkDirs(); - - restoreBackups(); - } -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/FileTransaction.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/FileTransaction.java deleted file mode 100644 index f1c668ab5..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/FileTransaction.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.converter.RepositoryConversionException; -import org.codehaus.plexus.digest.Digester; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; - -/** - * Implement commit/rollback semantics for a set of files. - * - * @author Brett Porter - */ -public class FileTransaction -{ - private List events = new ArrayList(); - - public void commit() - throws RepositoryConversionException - { - List toRollback = new ArrayList( events.size() ); - - for ( Iterator i = events.iterator(); i.hasNext(); ) - { - TransactionEvent event = (TransactionEvent) i.next(); - - try - { - event.commit(); - - toRollback.add( event ); - } - catch ( IOException e ) - { - try - { - rollback( toRollback ); - - throw new RepositoryConversionException( "Unable to commit file transaction", e ); - } - catch ( IOException ioe ) - { - throw new RepositoryConversionException( - "Unable to commit file transaction, and rollback failed with error: '" + ioe.getMessage() + "'", - e ); - } - } - } - } - - private void rollback( List toRollback ) - throws IOException - { - for ( Iterator i = toRollback.iterator(); i.hasNext(); ) - { - TransactionEvent event = (TransactionEvent) i.next(); - - event.rollback(); - } - } - - /** - * @deprecated use {@link #copyFile(File, File, List)} - * @param source - * @param destination - */ - public void copyFile( File source, File destination ) - { - copyFile( source, destination, Collections.EMPTY_LIST ); - } - - /** - * - * @param source - * @param destination - * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming - */ - public void copyFile( File source, File destination, List digesters ) - { - events.add( new CopyFileEvent( source, destination, digesters ) ); - } - - /** - * @deprecated use {@link #createFile(String, File, List)} - * @param content - * @param destination - */ - public void createFile( String content, File destination ) - { - createFile( content, destination, Collections.EMPTY_LIST ); - } - - /** - * - * @param content - * @param destination - * @param digesters {@link List}<{@link Digester}> digesters to use for checksumming - */ - public void createFile( String content, File destination, List digesters ) - { - events.add( new CreateFileEvent( content, destination, digesters ) ); - } -} diff --git a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/TransactionEvent.java b/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/TransactionEvent.java deleted file mode 100644 index eda17fc04..000000000 --- a/archiva-converter/src/main/java/org/apache/maven/archiva/converter/transaction/TransactionEvent.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.IOException; - -/** - * Interface for individual events in a transaction. - * - * @author Brett Porter - */ -public interface TransactionEvent -{ - /** - * Commit this event. - * - * @throws IOException if an error occurred committing the change - */ - void commit() - throws IOException; - - /** - * Rollback the even already committed. - * - * @throws IOException if an error occurred reverting the change - */ - void rollback() - throws IOException; -} diff --git a/archiva-converter/src/main/resources/org/apache/maven/archiva/converter/DefaultRepositoryConverter.properties b/archiva-converter/src/main/resources/org/apache/maven/archiva/converter/DefaultRepositoryConverter.properties deleted file mode 100644 index 8589df468..000000000 --- a/archiva-converter/src/main/resources/org/apache/maven/archiva/converter/DefaultRepositoryConverter.properties +++ /dev/null @@ -1,38 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# - -failure.incorrect.md5=The MD5 checksum value was incorrect. -failure.incorrect.sha1=The SHA1 checksum value was incorrect. -failure.target.already.exists=The artifact could not be converted because it already exists. -failure.invalid.source.pom=The source POM was invalid: {0}. - -warning.missing.pom=The artifact had no POM in the source repository. - -exception.repositories.match=Source and target repositories are identical. - -failure.incorrect.groupMetadata.groupId=The group ID in the source group metadata is incorrect. - -failure.incorrect.artifactMetadata.artifactId=The artifact ID in the source artifact metadata is incorrect. -failure.incorrect.artifactMetadata.groupId=The group ID in the source artifact metadata is incorrect. -failure.incorrect.artifactMetadata.versions=The version list in the source artifact metadata is incorrect. - -failure.incorrect.snapshotMetadata.artifactId=The artifact ID in the source artifact version metadata is incorrect. -failure.incorrect.snapshotMetadata.groupId=The group ID in the source artifact version metadata is incorrect. -failure.incorrect.snapshotMetadata.version=The version in the source artifact version metadata is incorrect. -failure.incorrect.snapshotMetadata.snapshot=The snapshot information in the source artifact version metadata is incorrect. diff --git a/archiva-converter/src/test/expected-files/converted-artifact-one.pom b/archiva-converter/src/test/expected-files/converted-artifact-one.pom deleted file mode 100644 index cd3862d35..000000000 --- a/archiva-converter/src/test/expected-files/converted-artifact-one.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - test - artifact-one - 1.0.0 - diff --git a/archiva-converter/src/test/expected-files/converted-artifact-three.pom b/archiva-converter/src/test/expected-files/converted-artifact-three.pom deleted file mode 100644 index 343291037..000000000 --- a/archiva-converter/src/test/expected-files/converted-artifact-three.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - test - artifact-three - 1.0.0 - diff --git a/archiva-converter/src/test/expected-files/converted-artifact-two.pom b/archiva-converter/src/test/expected-files/converted-artifact-two.pom deleted file mode 100644 index 227470167..000000000 --- a/archiva-converter/src/test/expected-files/converted-artifact-two.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - test - artifact-two - 1.0.0 - diff --git a/archiva-converter/src/test/expected-files/converted-v3-snapshot.pom b/archiva-converter/src/test/expected-files/converted-v3-snapshot.pom deleted file mode 100644 index 1615b6663..000000000 --- a/archiva-converter/src/test/expected-files/converted-v3-snapshot.pom +++ /dev/null @@ -1,28 +0,0 @@ - - 4.0.0 - test - v3artifact - 1.0.0-SNAPSHOT - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - - - groupId - artifactId - version - - - groupId - test-artifactId - version - test - - - junit - junit - 3.8.2 - test - - - diff --git a/archiva-converter/src/test/expected-files/converted-v3-timestamped-snapshot.pom b/archiva-converter/src/test/expected-files/converted-v3-timestamped-snapshot.pom deleted file mode 100644 index 94307d863..000000000 --- a/archiva-converter/src/test/expected-files/converted-v3-timestamped-snapshot.pom +++ /dev/null @@ -1,28 +0,0 @@ - - 4.0.0 - test - v3artifact - 1.0.0-20060105.130101-3 - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - - - groupId - artifactId - version - - - groupId - test-artifactId - version - test - - - junit - junit - 3.8.2 - test - - - diff --git a/archiva-converter/src/test/expected-files/converted-v3-warnings.pom b/archiva-converter/src/test/expected-files/converted-v3-warnings.pom deleted file mode 100644 index 25f4e76d0..000000000 --- a/archiva-converter/src/test/expected-files/converted-v3-warnings.pom +++ /dev/null @@ -1,28 +0,0 @@ - - 4.0.0 - test - v3-warnings-artifact - 1.0.0 - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - - - groupId - artifactId - version - - - groupId - test-artifactId - version - test - - - junit - junit - 3.8.2 - test - - - diff --git a/archiva-converter/src/test/expected-files/converted-v3.pom b/archiva-converter/src/test/expected-files/converted-v3.pom deleted file mode 100644 index 9f8b63e16..000000000 --- a/archiva-converter/src/test/expected-files/converted-v3.pom +++ /dev/null @@ -1,28 +0,0 @@ - - 4.0.0 - test - v3artifact - 1.0.0 - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - - - groupId - artifactId - version - - - groupId - test-artifactId - version - test - - - junit - junit - 3.8.2 - test - - - diff --git a/archiva-converter/src/test/expected-files/maven-foo-plugin-1.0.pom b/archiva-converter/src/test/expected-files/maven-foo-plugin-1.0.pom deleted file mode 100644 index 17095cc57..000000000 --- a/archiva-converter/src/test/expected-files/maven-foo-plugin-1.0.pom +++ /dev/null @@ -1,7 +0,0 @@ - - 4.0.0 - org.apache.maven.plugins - maven-foo-plugin - 1.0.0 - maven-plugin - diff --git a/archiva-converter/src/test/expected-files/newversion-artifact-metadata.xml b/archiva-converter/src/test/expected-files/newversion-artifact-metadata.xml deleted file mode 100644 index ecc7f09a0..000000000 --- a/archiva-converter/src/test/expected-files/newversion-artifact-metadata.xml +++ /dev/null @@ -1,10 +0,0 @@ - - test - newversion-artifact - - - 1.0.0 - 1.0.1 - - - diff --git a/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/maven-metadata.xml b/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/maven-metadata.xml deleted file mode 100644 index ebd9be970..000000000 --- a/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/maven-metadata.xml +++ /dev/null @@ -1,6 +0,0 @@ - - relocated-test - relocated-v3artifact - 1.0.0 - - \ No newline at end of file diff --git a/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.jar b/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom b/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom deleted file mode 100644 index 0180549f0..000000000 --- a/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - 4.0.0 - relocated-test - relocated-v3artifact - 1.0.0 - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - - - groupId - artifactId - version - - - groupId - test-artifactId - version - test - - - junit - junit - 3.8.2 - test - - - diff --git a/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/maven-metadata.xml b/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/maven-metadata.xml deleted file mode 100644 index b4b1a864a..000000000 --- a/archiva-converter/src/test/expected-files/relocated-test/relocated-v3artifact/maven-metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ - - relocated-test - relocated-v3artifact - - - 1.0.0 - - - \ No newline at end of file diff --git a/archiva-converter/src/test/expected-files/test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom b/archiva-converter/src/test/expected-files/test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom deleted file mode 100644 index b20f62f9e..000000000 --- a/archiva-converter/src/test/expected-files/test/relocated-v3artifact/1.0.0/relocated-v3artifact-1.0.0.pom +++ /dev/null @@ -1,12 +0,0 @@ - - test - relocated-v3artifact - 1.0.0 - - - relocated-test - relocated-v3artifact - 1.0.0 - - - \ No newline at end of file diff --git a/archiva-converter/src/test/expected-files/v3-artifact-metadata.xml b/archiva-converter/src/test/expected-files/v3-artifact-metadata.xml deleted file mode 100644 index a8a7f3748..000000000 --- a/archiva-converter/src/test/expected-files/v3-artifact-metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ - - test - v3artifact - - - 1.0.0 - - - diff --git a/archiva-converter/src/test/expected-files/v3-snapshot-artifact-metadata.xml b/archiva-converter/src/test/expected-files/v3-snapshot-artifact-metadata.xml deleted file mode 100644 index 24d25a0e0..000000000 --- a/archiva-converter/src/test/expected-files/v3-snapshot-artifact-metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ - - test - v3artifact - - - 1.0.0-SNAPSHOT - - - diff --git a/archiva-converter/src/test/expected-files/v3-snapshot-metadata.xml b/archiva-converter/src/test/expected-files/v3-snapshot-metadata.xml deleted file mode 100644 index b19c537b5..000000000 --- a/archiva-converter/src/test/expected-files/v3-snapshot-metadata.xml +++ /dev/null @@ -1,6 +0,0 @@ - - test - v3artifact - 1.0.0-SNAPSHOT - - diff --git a/archiva-converter/src/test/expected-files/v3-timestamped-snapshot-metadata.xml b/archiva-converter/src/test/expected-files/v3-timestamped-snapshot-metadata.xml deleted file mode 100644 index 602c38ec8..000000000 --- a/archiva-converter/src/test/expected-files/v3-timestamped-snapshot-metadata.xml +++ /dev/null @@ -1,11 +0,0 @@ - - test - v3artifact - 1.0.0-SNAPSHOT - - - 20060105.130101 - 3 - - - diff --git a/archiva-converter/src/test/expected-files/v3-version-metadata.xml b/archiva-converter/src/test/expected-files/v3-version-metadata.xml deleted file mode 100644 index 3c8938984..000000000 --- a/archiva-converter/src/test/expected-files/v3-version-metadata.xml +++ /dev/null @@ -1,6 +0,0 @@ - - test - v3artifact - 1.0.0 - - diff --git a/archiva-converter/src/test/expected-files/v4-artifact-metadata.xml b/archiva-converter/src/test/expected-files/v4-artifact-metadata.xml deleted file mode 100644 index c0cdbfdb4..000000000 --- a/archiva-converter/src/test/expected-files/v4-artifact-metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ - - test - v4artifact - - - 1.0.0 - - - diff --git a/archiva-converter/src/test/expected-files/v4-snapshot-artifact-metadata.xml b/archiva-converter/src/test/expected-files/v4-snapshot-artifact-metadata.xml deleted file mode 100644 index f8072b0df..000000000 --- a/archiva-converter/src/test/expected-files/v4-snapshot-artifact-metadata.xml +++ /dev/null @@ -1,9 +0,0 @@ - - test - v4artifact - - - 1.0.0-SNAPSHOT - - - diff --git a/archiva-converter/src/test/expected-files/v4-snapshot-metadata.xml b/archiva-converter/src/test/expected-files/v4-snapshot-metadata.xml deleted file mode 100644 index d5ecb7d47..000000000 --- a/archiva-converter/src/test/expected-files/v4-snapshot-metadata.xml +++ /dev/null @@ -1,6 +0,0 @@ - - test - v4artifact - 1.0.0-SNAPSHOT - - diff --git a/archiva-converter/src/test/expected-files/v4-timestamped-snapshot-metadata.xml b/archiva-converter/src/test/expected-files/v4-timestamped-snapshot-metadata.xml deleted file mode 100644 index 060a79cdd..000000000 --- a/archiva-converter/src/test/expected-files/v4-timestamped-snapshot-metadata.xml +++ /dev/null @@ -1,11 +0,0 @@ - - test - v4artifact - 1.0.0-SNAPSHOT - - - 20060111.120115 - 1 - - - diff --git a/archiva-converter/src/test/expected-files/v4-version-metadata.xml b/archiva-converter/src/test/expected-files/v4-version-metadata.xml deleted file mode 100644 index 7cbd8ad3d..000000000 --- a/archiva-converter/src/test/expected-files/v4-version-metadata.xml +++ /dev/null @@ -1,6 +0,0 @@ - - test - v4artifact - 1.0.0 - - diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/AllTests.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/AllTests.java deleted file mode 100644 index dbd54f604..000000000 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/AllTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.archiva.converter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllTests - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AllTests -{ - - public static Test suite() - { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.converter" ); - //$JUnit-BEGIN$ - suite.addTest( org.apache.maven.archiva.converter.transaction.AllTests.suite() ); - suite.addTestSuite( RepositoryConverterTest.class ); - //$JUnit-END$ - return suite; - } - -} diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/MockConversionListener.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/MockConversionListener.java deleted file mode 100644 index 92b70069b..000000000 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/MockConversionListener.java +++ /dev/null @@ -1,163 +0,0 @@ -package org.apache.maven.archiva.converter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.artifact.Artifact; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -/** - * MockConversionListener - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class MockConversionListener - implements ConversionListener -{ - private Map warnings = new HashMap(); - - private Map errors = new HashMap(); - - private Map exceptions = new HashMap(); - - private List processed = new ArrayList(); - - private List repositories = new ArrayList(); - - public void conversionEvent( ConversionEvent event ) - { - switch ( event.getType() ) - { - case ConversionEvent.STARTED: - addUnique( repositories, event.getRepository() ); - break; - case ConversionEvent.PROCESSED: - addUnique( processed, event.getArtifact() ); - break; - case ConversionEvent.WARNING: - if ( event.getException() != null ) - { - addObjectList( exceptions, toKey( event.getArtifact() ), event.getException() ); - } - - if ( event.getMessage() != null ) - { - addObjectList( warnings, toKey( event.getArtifact() ), event.getMessage() ); - } - break; - case ConversionEvent.ERROR: - if ( event.getException() != null ) - { - addObjectList( exceptions, toKey( event.getArtifact() ), event.getException() ); - } - - if ( event.getMessage() != null ) - { - addObjectList( errors, toKey( event.getArtifact() ), event.getMessage() ); - } - break; - case ConversionEvent.FINISHED: - addUnique( repositories, event.getRepository() ); - break; - } - } - - public String toKey( Artifact artifact ) - { - return StringUtils.defaultString( artifact.getGroupId() ) + ":" - + StringUtils.defaultString( artifact.getArtifactId() ) + ":" - + StringUtils.defaultString( artifact.getVersion() ) + ":" + StringUtils.defaultString( artifact.getType() ) - + ":" + StringUtils.defaultString( artifact.getClassifier() ); - } - - private void addObjectList( Map map, String key, Object value ) - { - List objlist = (List) map.get( key ); - if ( objlist == null ) - { - objlist = new ArrayList(); - } - - objlist.add( value ); - - map.put( key, objlist ); - } - - private void addUnique( Collection collection, Object obj ) - { - if ( !collection.contains( obj ) ) - { - collection.add( obj ); - } - } - - public Map getErrors() - { - return errors; - } - - public Map getExceptions() - { - return exceptions; - } - - public List getProcessed() - { - return processed; - } - - public List getRepositories() - { - return repositories; - } - - public Map getWarnings() - { - return warnings; - } - - private int getObjectListCount( Map map ) - { - int count = 0; - for ( Iterator it = map.values().iterator(); it.hasNext(); ) - { - List objList = (List) it.next(); - count += objList.size(); - } - return count; - } - - public int getWarningMessageCount() - { - return getObjectListCount( warnings ); - } - - public int getErrorMessageCount() - { - return getObjectListCount( errors ); - } -} diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java deleted file mode 100644 index 8e0c676e3..000000000 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/RepositoryConverterTest.java +++ /dev/null @@ -1,1088 +0,0 @@ -package org.apache.maven.archiva.converter; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.io.FileUtils; -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.metadata.ArtifactMetadata; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata; -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.i18n.I18N; - -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Map; -import java.util.Map.Entry; -import java.util.regex.Matcher; - -/** - * Test the repository converter. - * - * @author Brett Porter - * @todo what about deletions from the source repository? - * @todo use artifact-test instead - * @todo should reject if dependencies are missing - rely on reporting? - * @todo group metadata - */ -public class RepositoryConverterTest - extends PlexusTestCase -{ - private ArtifactRepository sourceRepository; - - private ArtifactRepository targetRepository; - - private RepositoryConverter repositoryConverter; - - private ArtifactFactory artifactFactory; - - private static final int SLEEP_MILLIS = 100; - - private I18N i18n; - - protected void setUp() - throws Exception - { - super.setUp(); - - ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); - - ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "legacy" ); - - File sourceBase = getTestFile( "src/test/source-repository" ); - sourceRepository = factory.createArtifactRepository( "source", sourceBase.toURL().toString(), layout, null, - null ); - - layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); - - File targetBase = getTestFile( "target/test-target-repository" ); - copyDirectoryStructure( getTestFile( "src/test/target-repository" ), targetBase ); - - targetRepository = factory.createArtifactRepository( "target", targetBase.toURL().toString(), layout, null, - null ); - - repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "default" ); - - artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - - i18n = (I18N) lookup( I18N.ROLE ); - } - - protected void tearDown() - throws Exception - { - super.tearDown(); - } - - private void copyDirectoryStructure( File sourceDirectory, File destinationDirectory ) - throws IOException - { - if ( !sourceDirectory.exists() ) - { - throw new IOException( "Source directory doesn't exists (" + sourceDirectory.getAbsolutePath() + ")." ); - } - - File[] files = sourceDirectory.listFiles(); - - String sourcePath = sourceDirectory.getAbsolutePath(); - - for ( int i = 0; i < files.length; i++ ) - { - File file = files[i]; - - String dest = file.getAbsolutePath(); - - dest = dest.substring( sourcePath.length() + 1 ); - - File destination = new File( destinationDirectory, dest ); - - if ( file.isFile() ) - { - destination = destination.getParentFile(); - - FileUtils.copyFileToDirectory( file, destination ); - } - else if ( file.isDirectory() ) - { - if ( !".svn".equals( file.getName() ) ) - { - if ( !destination.exists() && !destination.mkdirs() ) - { - throw new IOException( "Could not create destination directory '" - + destination.getAbsolutePath() + "'." ); - } - copyDirectoryStructure( file, destination ); - } - } - else - { - throw new IOException( "Unknown file type: " + file.getAbsolutePath() ); - } - } - } - - public void testV4PomConvert() - throws IOException, RepositoryConversionException - { - // test that it is copied as is - - Artifact artifact = createArtifact( "test", "v4artifact", "1.0.0" ); - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - artifactMetadataFile.delete(); - - ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( versionMetadata ) ); - versionMetadataFile.delete(); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - artifactFile.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkSuccess(listener); - - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - assertTrue( "Check POM created", pomFile.exists() ); - - compareFiles( sourcePomFile, pomFile ); - - assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); - - File expectedMetadataFile = getTestFile( "src/test/expected-files/v4-artifact-metadata.xml" ); - - compareFiles( expectedMetadataFile, artifactMetadataFile ); - - assertTrue( "Check snapshot metadata created", versionMetadataFile.exists() ); - - expectedMetadataFile = getTestFile( "src/test/expected-files/v4-version-metadata.xml" ); - - compareFiles( expectedMetadataFile, versionMetadataFile ); - } - - public void testV3PomConvert() - throws IOException, RepositoryConversionException - { - // test that the pom is coverted - - Artifact artifact = createArtifact( "test", "v3artifact", "1.0.0" ); - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - artifactMetadataFile.delete(); - - ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( versionMetadata ) ); - versionMetadataFile.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkSuccess(listener); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3.pom" ); - assertTrue( "Check POM created", pomFile.exists() ); - - compareFiles( expectedPomFile, pomFile ); - - assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); - - File expectedMetadataFile = getTestFile( "src/test/expected-files/v3-artifact-metadata.xml" ); - - compareFiles( expectedMetadataFile, artifactMetadataFile ); - - assertTrue( "Check snapshot metadata created", versionMetadataFile.exists() ); - - expectedMetadataFile = getTestFile( "src/test/expected-files/v3-version-metadata.xml" ); - - compareFiles( expectedMetadataFile, versionMetadataFile ); - } - - public void testV3PomConvertWithRelocation() - throws RepositoryConversionException, IOException - { - Artifact artifact = createArtifact( "test", "relocated-v3artifact", "1.0.0" ); - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - artifactMetadataFile.delete(); - - ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( versionMetadata ) ); - versionMetadataFile.delete(); - - repositoryConverter.convert( artifact, targetRepository ); - //checkSuccess(); --> commented until MNG-2100 is fixed - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check if relocated artifact created", artifactFile.exists() ); - assertTrue( "Check if relocated artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - Artifact pomArtifact = createArtifact( "relocated-test", "relocated-v3artifact", "1.0.0", "1.0.0", "pom" ); - File pomFile = getTestFile( "src/test/expected-files/" + targetRepository.pathOf( pomArtifact ) ); - File testFile = getTestFile( "target/test-target-repository/" + targetRepository.pathOf( pomArtifact ) ); - compareFiles( pomFile, testFile ); - - Artifact orig = createArtifact( "test", "relocated-v3artifact", "1.0.0", "1.0.0", "pom" ); - artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( orig ) ); - assertTrue( "Check if relocation artifact pom is created", artifactFile.exists() ); - testFile = getTestFile( "src/test/expected-files/" + targetRepository.pathOf( orig ) ); - compareFiles( artifactFile, testFile ); - } - - public void testV3PomWarningsOnConvert() - throws RepositoryConversionException, IOException - { - // test that the pom is converted but that warnings are reported - - Artifact artifact = createArtifact( "test", "v3-warnings-artifact", "1.0.0" ); - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - artifactMetadataFile.delete(); - - ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( versionMetadata ) ); - versionMetadataFile.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 0, 2 ); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3-warnings.pom" ); - assertTrue( "Check POM created", pomFile.exists() ); - - compareFiles( expectedPomFile, pomFile ); - - // TODO: check 2 warnings (extend and versions) matched on i18n key - } - - private void doTestV4SnapshotPomConvert( String version, String expectedMetadataFileName ) - throws RepositoryConversionException, IOException - { - // test that it is copied as is - - Artifact artifact = createArtifact( "test", "v4artifact", version ); - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - artifactMetadataFile.delete(); - - ArtifactMetadata snapshotMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - File snapshotMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( snapshotMetadata ) ); - snapshotMetadataFile.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 0, 0 ); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - assertTrue( "Check POM created", pomFile.exists() ); - - compareFiles( sourcePomFile, pomFile ); - - assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); - - File expectedMetadataFile = getTestFile( "src/test/expected-files/v4-snapshot-artifact-metadata.xml" ); - - compareFiles( expectedMetadataFile, artifactMetadataFile ); - - assertTrue( "Check snapshot metadata created", snapshotMetadataFile.exists() ); - - expectedMetadataFile = getTestFile( expectedMetadataFileName ); - - compareFiles( expectedMetadataFile, snapshotMetadataFile ); - } - - public void testV3SnapshotPomConvert() - throws IOException, RepositoryConversionException - { - // test that the pom is coverted - - Artifact artifact = createArtifact( "test", "v3artifact", "1.0.0-SNAPSHOT" ); - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - artifactMetadataFile.delete(); - - ArtifactMetadata snapshotMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - File snapshotMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( snapshotMetadata ) ); - snapshotMetadataFile.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 0, 0 ); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3-snapshot.pom" ); - assertTrue( "Check POM created", pomFile.exists() ); - - compareFiles( expectedPomFile, pomFile ); - - assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); - - File expectedMetadataFile = getTestFile( "src/test/expected-files/v3-snapshot-artifact-metadata.xml" ); - - compareFiles( expectedMetadataFile, artifactMetadataFile ); - - assertTrue( "Check snapshot metadata created", snapshotMetadataFile.exists() ); - - expectedMetadataFile = getTestFile( "src/test/expected-files/v3-snapshot-metadata.xml" ); - - compareFiles( expectedMetadataFile, snapshotMetadataFile ); - } - - public void testV4SnapshotPomConvert() - throws IOException, RepositoryConversionException - { - doTestV4SnapshotPomConvert( "1.0.0-SNAPSHOT", "src/test/expected-files/v4-snapshot-metadata.xml" ); - - assertTrue( true ); - } - - public void testV4TimestampedSnapshotPomConvert() - throws IOException, RepositoryConversionException - { - doTestV4SnapshotPomConvert( "1.0.0-20060111.120115-1", - "src/test/expected-files/v4-timestamped-snapshot-metadata.xml" ); - - assertTrue( true ); - } - - public void testMavenOnePluginConversion() - throws Exception - { - Artifact artifact = createArtifact( "org.apache.maven.plugins", "maven-foo-plugin", "1.0", "1.0", - "maven-plugin" ); - artifact.setFile( new File( getBasedir(), "src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar" ) ); - repositoryConverter.convert( artifact, targetRepository ); - // There is a warning but I can't figure out how to look at it. Eyeballing the results it appears - // the plugin is being coverted correctly. - //checkSuccess(); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - /* - The POM isn't needed for Maven 1.x plugins but the raw conversion for - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File expectedPomFile = getTestFile( "src/test/expected-files/maven-foo-plugin-1.0.pom" ); - assertTrue( "Check POM created", pomFile.exists() ); - compareFiles( expectedPomFile, pomFile ); - */ - } - - public void testV3TimestampedSnapshotPomConvert() - throws IOException, RepositoryConversionException - { - // test that the pom is coverted - - Artifact artifact = createArtifact( "test", "v3artifact", "1.0.0-20060105.130101-3" ); - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - artifactMetadataFile.delete(); - - ArtifactMetadata snapshotMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - File snapshotMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( snapshotMetadata ) ); - snapshotMetadataFile.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 0, 0 ); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File expectedPomFile = getTestFile( "src/test/expected-files/converted-v3-timestamped-snapshot.pom" ); - assertTrue( "Check POM created", pomFile.exists() ); - - compareFiles( expectedPomFile, pomFile ); - - assertTrue( "Check artifact snapshotMetadata created", artifactMetadataFile.exists() ); - - File expectedMetadataFile = getTestFile( "src/test/expected-files/v3-snapshot-artifact-metadata.xml" ); - - compareFiles( expectedMetadataFile, artifactMetadataFile ); - - assertTrue( "Check snapshot snapshotMetadata created", snapshotMetadataFile.exists() ); - - expectedMetadataFile = getTestFile( "src/test/expected-files/v3-timestamped-snapshot-metadata.xml" ); - - compareFiles( expectedMetadataFile, snapshotMetadataFile ); - } - - public void testNoPomConvert() - throws IOException, RepositoryConversionException - { - // test that a POM is not created when there was none at the source - - Artifact artifact = createArtifact( "test", "noPomArtifact", "1.0.0" ); - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 0, 1 ); - - assertHasWarningReason( listener, getI18nString( "warning.missing.pom" ) ); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - - assertFalse( "Check no POM created", pomFile.exists() ); - assertFalse( "No source POM", sourcePomFile.exists() ); - } - - public void testIncorrectSourceChecksumMd5() - throws RepositoryConversionException - { - // test that it fails when the source md5 is wrong - - Artifact artifact = createArtifact( "test", "incorrectMd5Artifact", "1.0.0" ); - File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - file.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 1, 0 ); - - assertHasErrorReason( listener, getI18nString( "failure.incorrect.md5" ) ); - - assertFalse( "Check artifact not created", file.exists() ); - - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - File metadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( metadata ) ); - assertFalse( "Check metadata not created", metadataFile.exists() ); - } - - public void testIncorrectSourceChecksumSha1() - throws RepositoryConversionException - { - // test that it fails when the source sha1 is wrong - - Artifact artifact = createArtifact( "test", "incorrectSha1Artifact", "1.0.0" ); - File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - file.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 1, 0 ); - - assertHasErrorReason( listener, getI18nString( "failure.incorrect.sha1" ) ); - - assertFalse( "Check artifact not created", file.exists() ); - - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - File metadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( metadata ) ); - assertFalse( "Check metadata not created", metadataFile.exists() ); - } - - public void testUnmodifiedArtifact() - throws RepositoryConversionException, IOException, InterruptedException - { - // test the unmodified artifact is untouched - - Artifact artifact = createArtifact( "test", "unmodified-artifact", "1.0.0" ); - Artifact pomArtifact = createPomArtifact( artifact ); - - File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); - File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); - - assertTrue( "Check target file exists", targetFile.exists() ); - assertTrue( "Check target POM exists", targetPomFile.exists() ); - - sourceFile.setLastModified( System.currentTimeMillis() ); - sourcePomFile.setLastModified( System.currentTimeMillis() ); - - long origTime = targetFile.lastModified(); - long origPomTime = targetPomFile.lastModified(); - - // Need to guarantee last modified is not equal - Thread.sleep( SLEEP_MILLIS ); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 0, 0 ); - - compareFiles( sourceFile, targetFile ); - compareFiles( sourcePomFile, targetPomFile ); - - assertEquals( "Check artifact unmodified", origTime, targetFile.lastModified() ); - assertEquals( "Check POM unmodified", origPomTime, targetPomFile.lastModified() ); - } - - public void testModifedArtifactFails() - throws InterruptedException, RepositoryConversionException, IOException - { - // test that it fails when the source artifact has changed and is different to the existing artifact in the - // target repository - - Artifact artifact = createArtifact( "test", "modified-artifact", "1.0.0" ); - Artifact pomArtifact = createPomArtifact( artifact ); - - File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); - File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); - - assertTrue( "Check target file exists", targetFile.exists() ); - assertTrue( "Check target POM exists", targetPomFile.exists() ); - - sourceFile.setLastModified( System.currentTimeMillis() ); - sourcePomFile.setLastModified( System.currentTimeMillis() ); - - long origTime = targetFile.lastModified(); - long origPomTime = targetPomFile.lastModified(); - - // Need to guarantee last modified is not equal - Thread.sleep( SLEEP_MILLIS ); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 1, 0 ); - - assertHasErrorReason( listener, getI18nString( "failure.target.already.exists" ) ); - - assertEquals( "Check unmodified", origTime, targetFile.lastModified() ); - assertEquals( "Check unmodified", origPomTime, targetPomFile.lastModified() ); - - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - File metadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( metadata ) ); - assertFalse( "Check metadata not created", metadataFile.exists() ); - } - - public void testForcedUnmodifiedArtifact() - throws Exception - { - // test unmodified artifact is still converted when set to force - - repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "force-repository-converter" ); - - Artifact artifact = createArtifact( "test", "unmodified-artifact", "1.0.0" ); - Artifact pomArtifact = createPomArtifact( artifact ); - - File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); - File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); - - SimpleDateFormat dateFormat = new SimpleDateFormat( "yyyy-MM-dd", Locale.getDefault() ); - long origTime = dateFormat.parse( "2006-03-03" ).getTime(); - targetFile.setLastModified( origTime ); - targetPomFile.setLastModified( origTime ); - - sourceFile.setLastModified( dateFormat.parse( "2006-01-01" ).getTime() ); - sourcePomFile.setLastModified( dateFormat.parse( "2006-02-02" ).getTime() ); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 0, 0 ); - - compareFiles( sourceFile, targetFile ); - compareFiles( sourcePomFile, targetPomFile ); - - assertFalse( "Check modified", origTime == targetFile.lastModified() ); - assertFalse( "Check modified", origTime == targetPomFile.lastModified() ); - - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - File metadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( metadata ) ); - assertTrue( "Check metadata created", metadataFile.exists() ); - } - - public void testDryRunSuccess() - throws Exception - { - // test dry run does nothing on a run that will be successful, and returns success - - repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "dryrun-repository-converter" ); - - Artifact artifact = createArtifact( "test", "dryrun-artifact", "1.0.0" ); - Artifact pomArtifact = createPomArtifact( artifact ); - - File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); - File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 0, 0 ); - - assertTrue( "Check source file exists", sourceFile.exists() ); - assertTrue( "Check source POM exists", sourcePomFile.exists() ); - - assertFalse( "Check target file doesn't exist", targetFile.exists() ); - assertFalse( "Check target POM doesn't exist", targetPomFile.exists() ); - - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - File metadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( metadata ) ); - assertFalse( "Check metadata not created", metadataFile.exists() ); - } - - public void testDryRunFailure() - throws Exception - { - // test dry run does nothing on a run that will fail, and returns failure - - repositoryConverter = (RepositoryConverter) lookup( RepositoryConverter.ROLE, "dryrun-repository-converter" ); - - Artifact artifact = createArtifact( "test", "modified-artifact", "1.0.0" ); - Artifact pomArtifact = createPomArtifact( artifact ); - - File sourceFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( pomArtifact ) ); - File targetFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File targetPomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( pomArtifact ) ); - - assertTrue( "Check target file exists", targetFile.exists() ); - assertTrue( "Check target POM exists", targetPomFile.exists() ); - - sourceFile.setLastModified( System.currentTimeMillis() ); - sourcePomFile.setLastModified( System.currentTimeMillis() ); - - long origTime = targetFile.lastModified(); - long origPomTime = targetPomFile.lastModified(); - - // Need to guarantee last modified is not equal - Thread.sleep( SLEEP_MILLIS ); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkFailure(listener); - - assertHasErrorReason( listener, getI18nString( "failure.target.already.exists" ) ); - - assertEquals( "Check unmodified", origTime, targetFile.lastModified() ); - assertEquals( "Check unmodified", origPomTime, targetPomFile.lastModified() ); - - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - File metadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( metadata ) ); - assertFalse( "Check metadata not created", metadataFile.exists() ); - } - - public void testRollbackArtifactCreated() - throws RepositoryConversionException, IOException - { - // test rollback can remove a created artifact, including checksums - - Artifact artifact = createArtifact( "test", "rollback-created-artifact", "1.0.0" ); - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - FileUtils.deleteDirectory( artifactMetadataFile.getParentFile() ); - - ArtifactMetadata versionMetadata = new SnapshotArtifactRepositoryMetadata( artifact ); - File versionMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( versionMetadata ) ); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkCounts( listener, 1, 0 ); - - List messages = (List) listener.getErrors().get( listener.toKey( artifact )); - assertNotNull("Should have error messages."); - - boolean found = false; - String pattern = "^" + getI18nString( "failure.invalid.source.pom" ).replaceFirst( "\\{0\\}", ".*" ) + "$"; - for ( Iterator it = messages.iterator(); it.hasNext(); ) - { - String reason = (String) it.next(); - if( reason.matches( pattern ) ) - { - found = true; - break; - } - } - - assertTrue( "Check failure message.", found ); - - assertFalse( "check artifact rolled back", artifactFile.exists() ); - assertFalse( "check metadata rolled back", artifactMetadataFile.exists() ); - assertFalse( "check metadata rolled back", versionMetadataFile.exists() ); - } - - public void testMultipleArtifacts() - throws RepositoryConversionException, IOException - { - // test multiple artifacts are converted - - List artifacts = new ArrayList(); - artifacts.add( createArtifact( "test", "artifact-one", "1.0.0" ) ); - artifacts.add( createArtifact( "test", "artifact-two", "1.0.0" ) ); - artifacts.add( createArtifact( "test", "artifact-three", "1.0.0" ) ); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifacts, targetRepository ); - checkCounts( listener, 0, 0 ); - - for ( Iterator i = artifacts.iterator(); i.hasNext(); ) - { - Artifact artifact = (Artifact) i.next(); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File expectedPomFile = getTestFile( "src/test/expected-files/converted-" + artifact.getArtifactId() - + ".pom" ); - assertTrue( "Check POM created", pomFile.exists() ); - - compareFiles( expectedPomFile, pomFile ); - } - } - - public void testInvalidSourceArtifactMetadata() - throws Exception - { - // test artifact is not converted when source metadata is invalid, and returns failure - - createModernSourceRepository(); - - Artifact artifact = createArtifact( "test", "incorrectArtifactMetadata", "1.0.0" ); - File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - file.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkFailure(listener); - - assertHasErrorReason( listener, getI18nString( "failure.incorrect.artifactMetadata.versions" ) ); - - assertFalse( "Check artifact not created", file.exists() ); - - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - File metadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( metadata ) ); - assertFalse( "Check metadata not created", metadataFile.exists() ); - } - - public void testInvalidSourceSnapshotMetadata() - throws Exception - { - // test artifact is not converted when source snapshot metadata is invalid and returns failure - - createModernSourceRepository(); - - Artifact artifact = createArtifact( "test", "incorrectSnapshotMetadata", "1.0.0-20060102.030405-6" ); - File file = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - file.delete(); - - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkFailure(listener); - - assertHasErrorReason( listener, getI18nString( "failure.incorrect.snapshotMetadata.snapshot" ) ); - - assertFalse( "Check artifact not created", file.exists() ); - - ArtifactRepositoryMetadata metadata = new ArtifactRepositoryMetadata( artifact ); - File metadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( metadata ) ); - assertFalse( "Check metadata not created", metadataFile.exists() ); - } - - public void testMergeArtifactMetadata() - throws RepositoryConversionException, IOException - { - // test artifact level metadata is merged when it already exists on successful conversion - - Artifact artifact = createArtifact( "test", "newversion-artifact", "1.0.1" ); - MockConversionListener listener = new MockConversionListener(); - - repositoryConverter.addConversionListener( listener ); - repositoryConverter.convert( artifact, targetRepository ); - checkSuccess(listener); - - File artifactFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - assertTrue( "Check artifact created", artifactFile.exists() ); - assertTrue( "Check artifact matches", FileUtils.contentEquals( artifactFile, artifact.getFile() ) ); - - artifact = createPomArtifact( artifact ); - File pomFile = new File( targetRepository.getBasedir(), targetRepository.pathOf( artifact ) ); - File sourcePomFile = new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ); - assertTrue( "Check POM created", pomFile.exists() ); - - compareFiles( sourcePomFile, pomFile ); - - ArtifactMetadata artifactMetadata = new ArtifactRepositoryMetadata( artifact ); - File artifactMetadataFile = new File( targetRepository.getBasedir(), targetRepository - .pathOfRemoteRepositoryMetadata( artifactMetadata ) ); - assertTrue( "Check artifact metadata created", artifactMetadataFile.exists() ); - - File expectedMetadataFile = getTestFile( "src/test/expected-files/newversion-artifact-metadata.xml" ); - - compareFiles( expectedMetadataFile, artifactMetadataFile ); - } - - public void testSourceAndTargetRepositoriesMatch() - throws Exception - { - // test that it fails if the same - - ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); - - sourceRepository = factory.createArtifactRepository( "source", targetRepository.getUrl(), targetRepository - .getLayout(), null, null ); - - Artifact artifact = createArtifact( "test", "repository-artifact", "1.0" ); - - try - { - repositoryConverter.convert( artifact, targetRepository ); - fail( "Should have failed trying to convert within the same repository" ); - } - catch ( RepositoryConversionException e ) - { - // expected - assertEquals( "check message", getI18nString( "exception.repositories.match" ), e.getMessage() ); - assertNull( "Check no additional cause", e.getCause() ); - } - } - - private Artifact createArtifact( String groupId, String artifactId, String version ) - { - Matcher matcher = Artifact.VERSION_FILE_PATTERN.matcher( version ); - String baseVersion; - if ( matcher.matches() ) - { - baseVersion = matcher.group( 1 ) + "-SNAPSHOT"; - } - else - { - baseVersion = version; - } - return createArtifact( groupId, artifactId, baseVersion, version, "jar" ); - } - - private Artifact createArtifact( String groupId, String artifactId, String baseVersion, String version, String type ) - { - Artifact artifact = artifactFactory.createArtifact( groupId, artifactId, version, null, type ); - artifact.setBaseVersion( baseVersion ); - artifact.setRepository( sourceRepository ); - artifact.setFile( new File( sourceRepository.getBasedir(), sourceRepository.pathOf( artifact ) ) ); - return artifact; - } - - private Artifact createPomArtifact( Artifact artifact ) - { - return createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion(), artifact - .getVersion(), "pom" ); - } - - private static void compareFiles( File expectedPomFile, File pomFile ) - throws IOException - { - String expectedContent = normalizeString( FileUtils.readFileToString( expectedPomFile, null ) ); - String targetContent = normalizeString( FileUtils.readFileToString( pomFile, null ) ); - assertEquals( "Check file match between " + expectedPomFile + " and " + pomFile, expectedContent, targetContent ); - } - - private static String normalizeString( String path ) - { - return path.trim().replaceAll( "\r\n", "\n" ).replace( '\r', '\n' ).replaceAll( "<\\?xml .+\\?>", "" ); - } - - private void checkSuccess(MockConversionListener listener) - { - checkCounts( listener, 0, 0 ); - } - - private void checkFailure(MockConversionListener listener) - { - checkCounts( listener, 1, 0 ); - } - - private void checkCounts( MockConversionListener listener, int failures, int warnings ) - { - int actualFailures = listener.getErrorMessageCount(); - int actualWarnings = listener.getWarningMessageCount(); - - if ( ( failures != actualFailures ) || ( warnings != actualWarnings ) ) - { - fail( "Check Results Counts expected:<" + failures + "," + warnings + "> but was:<" + actualFailures + "," - + actualWarnings + ">" ); - } - } - - private String getI18nString( String key ) - { - return i18n.getString( repositoryConverter.getClass().getName(), Locale.getDefault(), key ); - } - - private void assertHasWarningReason( MockConversionListener listener, String reason ) - { - assertHasMessage( listener.getWarnings(), "warning", reason ); - } - - private void assertHasErrorReason( MockConversionListener listener, String reason ) - { - assertHasMessage( listener.getErrors(), "error", reason ); - } - - private void assertHasMessage( Map map, String type, String message ) - { - if ( ( map == null ) || ( map.isEmpty() ) ) - { - fail( "No " + type + "s captured, expected " + type + " <" + message + ">" ); - } - - // Attempt to find the message ... - for ( Iterator it = map.values().iterator(); it.hasNext(); ) - { - List msgList = (List) it.next(); - - if ( msgList.contains( message ) ) - { - // Found it! - return; - } - } - - // Didn't find it! whoops ... - for ( Iterator it = map.entrySet().iterator(); it.hasNext(); ) - { - Map.Entry entry = (Entry) it.next(); - String key = (String) entry.getKey(); - List msgList = (List) entry.getValue(); - - System.err.println( " Artifact: " + key ); - - for ( Iterator itMsgs = msgList.iterator(); itMsgs.hasNext(); ) - { - String msg = (String) itMsgs.next(); - System.err.println( " " + msg ); - } - } - - fail( "Unable to find " + type + " reason <" + message + "> in any artifact." ); - } - - private void createModernSourceRepository() - throws Exception - { - ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); - - ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); - - File sourceBase = getTestFile( "src/test/source-modern-repository" ); - sourceRepository = factory.createArtifactRepository( "source", sourceBase.toURL().toString(), layout, null, - null ); - } -} diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AbstractFileEventTest.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AbstractFileEventTest.java deleted file mode 100644 index f768e1e72..000000000 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AbstractFileEventTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.IOException; -import java.util.List; - -import org.codehaus.plexus.PlexusTestCase; -import org.codehaus.plexus.digest.Digester; - -/** - * - * @author Carlos Sanchez - * @version $Id$ - */ -public abstract class AbstractFileEventTest - extends PlexusTestCase -{ - protected List digesters; - - public void setUp() - throws Exception - { - super.setUp(); - - digesters = getContainer().lookupList( Digester.class.getName() ); - } - - protected void assertChecksumExists( File file, String algorithm ) - { - assertChecksum( file, algorithm, true ); - } - - protected void assertChecksumDoesNotExist( File file, String algorithm ) - { - assertChecksum( file, algorithm, false ); - } - - private void assertChecksum( File file, String algorithm, boolean exist ) - { - String msg = exist ? "exists" : "does not exist"; - File checksumFile = new File( file.getPath() + "." + algorithm ); - assertEquals( "Test file " + algorithm + " checksum " + msg, exist, checksumFile.exists() ); - } - - protected void assertChecksumCommit( File file ) - throws IOException - { - assertChecksumExists( file, "md5" ); - assertChecksumExists( file, "sha1" ); - } - - protected void assertChecksumRollback( File file ) - throws IOException - { - assertChecksumDoesNotExist( file, "md5" ); - assertChecksumDoesNotExist( file, "sha1" ); - } -} \ No newline at end of file diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AllTests.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AllTests.java deleted file mode 100644 index 9274035d8..000000000 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/AllTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllTests - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AllTests -{ - - public static Test suite() - { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.converter.transaction" ); - //$JUnit-BEGIN$ - suite.addTestSuite( CreateFileEventTest.class ); - suite.addTestSuite( CopyFileEventTest.class ); - //$JUnit-END$ - return suite; - } - -} diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CopyFileEventTest.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CopyFileEventTest.java deleted file mode 100644 index acb6a3fdc..000000000 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CopyFileEventTest.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; -import java.io.IOException; - -import org.apache.commons.io.FileUtils; -import org.codehaus.plexus.PlexusTestCase; - -/** - * @author Edwin Punzalan - */ -public class CopyFileEventTest - extends AbstractFileEventTest -{ - private File testDir = new File( PlexusTestCase.getBasedir(), "target/transaction-tests/copy-file" ); - - private File testDest = new File( testDir, "test-file.txt" ); - - private File testSource = new File( PlexusTestCase.getBasedir(), "target/transaction-tests/test-file.txt" ); - - private File testDestChecksum; - - private String source, oldChecksum; - - public void setUp() - throws Exception - { - super.setUp(); - - testSource.getParentFile().mkdirs(); - - testSource.createNewFile(); - - FileUtils.writeStringToFile( testSource, "source contents", null ); - - testDestChecksum = new File( testDest.getPath() + ".sha1" ); - - testDestChecksum.getParentFile().mkdirs(); - - testDestChecksum.createNewFile(); - - FileUtils.writeStringToFile( testDestChecksum, "this is the checksum", null ); - - assertTrue( "Test if the source exists", testSource.exists() ); - - assertTrue( "Test if the destination checksum exists", testDestChecksum.exists() ); - - source = FileUtils.readFileToString( testSource, null ); - - oldChecksum = FileUtils.readFileToString( testDestChecksum, null ); - } - - public void testCopyCommitRollback() - throws Exception - { - CopyFileEvent event = new CopyFileEvent( testSource, testDest, digesters ); - - assertFalse( "Test that the destination is not yet created", testDest.exists() ); - - event.commit(); - - assertTrue( "Test that the destination is created", testDest.exists() ); - - assertChecksumCommit( testDest ); - - String target = FileUtils.readFileToString( testDest, null ); - - assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) ); - - event.rollback(); - - assertFalse( "Test that the destination file has been deleted", testDest.exists() ); - - assertChecksumRollback( testDest ); - } - - public void testCopyCommitRollbackWithBackup() - throws Exception - { - testDest.getParentFile().mkdirs(); - - testDest.createNewFile(); - - FileUtils.writeStringToFile( testDest, "overwritten contents", null ); - - assertTrue( "Test that the destination exists", testDest.exists() ); - - CopyFileEvent event = new CopyFileEvent( testSource, testDest, digesters ); - - String target = FileUtils.readFileToString( testDest, null ); - - assertTrue( "Test that the destination contents have not changed", target.equals( "overwritten contents" ) ); - - event.commit(); - - target = FileUtils.readFileToString( testDest, null ); - - assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) ); - - assertChecksumCommit( testDest ); - - event.rollback(); - - target = FileUtils.readFileToString( testDest, null ); - - assertTrue( "Test the destination file contents have been restored", target.equals( "overwritten contents" ) ); - - assertChecksumRollback( testDest ); - } - - public void testCreateRollbackCommit() - throws Exception - { - CopyFileEvent event = new CopyFileEvent( testSource, testDest, digesters ); - - assertFalse( "Test that the destination is not yet created", testDest.exists() ); - - event.rollback(); - - assertFalse( "Test that the destination file is not yet created", testDest.exists() ); - - event.commit(); - - assertTrue( "Test that the destination is created", testDest.exists() ); - - assertChecksumCommit( testDest ); - - String target = FileUtils.readFileToString( testDest, null ); - - assertTrue( "Test that the destination contents are copied correctly", source.equals( target ) ); - } - - protected void tearDown() - throws Exception - { - super.tearDown(); - - FileUtils.deleteDirectory( new File( PlexusTestCase.getBasedir(), "target/transaction-tests" ) ); - } - - protected void assertChecksumCommit( File file ) - throws IOException - { - super.assertChecksumCommit( file ); - - String target = FileUtils.readFileToString( testDestChecksum, null ); - - assertFalse( "Test that the destination checksum contents are created correctly", oldChecksum.equals( target ) ); - } - - protected void assertChecksumRollback( File file ) - throws IOException - { - assertChecksumDoesNotExist( file, "md5" ); - assertChecksumExists( file, "sha1" ); - - String target = FileUtils.readFileToString( testDestChecksum, null ); - - assertEquals( "Test that the destination checksum contents are reverted correctly", oldChecksum, target ); - } -} diff --git a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CreateFileEventTest.java b/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CreateFileEventTest.java deleted file mode 100644 index d27701e20..000000000 --- a/archiva-converter/src/test/java/org/apache/maven/archiva/converter/transaction/CreateFileEventTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package org.apache.maven.archiva.converter.transaction; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.io.File; - -import org.apache.commons.io.FileUtils; -import org.codehaus.plexus.PlexusTestCase; - -/** - * @author Edwin Punzalan - */ -public class CreateFileEventTest - extends AbstractFileEventTest -{ - private File testDir = new File( PlexusTestCase.getBasedir(), "target/transaction-tests/create-file" ); - - public void testCreateCommitRollback() - throws Exception - { - File testFile = new File( testDir, "test-file.txt" ); - - CreateFileEvent event = new CreateFileEvent( "file contents", testFile, digesters ); - - assertFalse( "Test file is not yet created", testFile.exists() ); - - event.commit(); - - assertTrue( "Test file has been created", testFile.exists() ); - - assertChecksumCommit( testFile ); - - event.rollback(); - - assertFalse( "Test file is has been deleted after rollback", testFile.exists() ); - - assertChecksumRollback( testFile ); - - assertFalse( "Test file parent directories has been rolledback too", testDir.exists() ); - assertTrue( "target directory still exists", new File( PlexusTestCase.getBasedir(), "target" ).exists() ); - } - - public void testCreateCommitRollbackWithBackup() - throws Exception - { - File testFile = new File( testDir, "test-file.txt" ); - - testFile.getParentFile().mkdirs(); - - testFile.createNewFile(); - - FileUtils.writeStringToFile( testFile, "original contents", null ); - - CreateFileEvent event = new CreateFileEvent( "modified contents", testFile, digesters ); - - String contents = FileUtils.readFileToString( testFile, null ); - - assertEquals( "Test contents have not changed", "original contents", contents ); - - event.commit(); - - contents = FileUtils.readFileToString( testFile, null ); - - assertEquals( "Test contents have not changed", "modified contents", contents ); - - assertChecksumCommit( testFile ); - - event.rollback(); - - contents = FileUtils.readFileToString( testFile, null ); - - assertEquals( "Test contents have not changed", "original contents", contents ); - - assertChecksumRollback( testFile ); - } - - public void testCreateRollbackCommit() - throws Exception - { - File testFile = new File( testDir, "test-file.txt" ); - - CreateFileEvent event = new CreateFileEvent( "file contents", testFile, digesters ); - - assertFalse( "Test file is not yet created", testFile.exists() ); - - event.rollback(); - - assertFalse( "Test file is not yet created", testFile.exists() ); - - event.commit(); - - assertTrue( "Test file is not yet created", testFile.exists() ); - - assertChecksumCommit( testFile ); - } - - protected void tearDown() - throws Exception - { - super.tearDown(); - - FileUtils.deleteDirectory( new File( PlexusTestCase.getBasedir(), "target/transaction-tests" ) ); - } -} diff --git a/archiva-converter/src/test/resources/log4j.properties b/archiva-converter/src/test/resources/log4j.properties deleted file mode 100644 index 9b2c26ade..000000000 --- a/archiva-converter/src/test/resources/log4j.properties +++ /dev/null @@ -1,10 +0,0 @@ -# Set root logger level to DEBUG and its only appender to A1. -log4j.rootLogger=WARN, A1 - -# A1 is set to be a ConsoleAppender. -log4j.appender.A1=org.apache.log4j.ConsoleAppender - -# A1 uses PatternLayout. -log4j.appender.A1.layout=org.apache.log4j.PatternLayout -log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n - diff --git a/archiva-converter/src/test/resources/org/apache/maven/archiva/converter/RepositoryConverterTest.xml b/archiva-converter/src/test/resources/org/apache/maven/archiva/converter/RepositoryConverterTest.xml deleted file mode 100644 index b1cf9640a..000000000 --- a/archiva-converter/src/test/resources/org/apache/maven/archiva/converter/RepositoryConverterTest.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - org.apache.maven.archiva.converter.RepositoryConverter - org.apache.maven.archiva.converter.DefaultRepositoryConverter - force-repository-converter - - true - - - - org.codehaus.plexus.digest.Digester - digesters - - - org.apache.maven.artifact.factory.ArtifactFactory - artifactFactory - - - org.codehaus.plexus.i18n.I18N - i18n - - - - - org.apache.maven.archiva.converter.RepositoryConverter - org.apache.maven.archiva.converter.DefaultRepositoryConverter - dryrun-repository-converter - - true - - - - org.codehaus.plexus.digest.Digester - digesters - - - org.apache.maven.artifact.factory.ArtifactFactory - artifactFactory - - - org.codehaus.plexus.i18n.I18N - i18n - - - - - - - org.codehaus.plexus.jdo.JdoFactory - archiva - org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory - - - - org.hsqldb.jdbcDriver - jdbc:hsqldb:mem:TESTDB - sa - - - - org.jpox.PersistenceManagerFactoryImpl - - - javax.jdo.PersistenceManagerFactoryClass - org.jpox.PersistenceManagerFactoryImpl - - - org.jpox.autoCreateSchema - true - - - org.jpox.validateTables - false - - - org.jpox.validateConstraints - false - - - org.jpox.validateColumns - false - - - org.jpox.autoStartMechanism - None - - - org.jpox.transactionIsolation - READ_UNCOMMITTED - - - org.jpox.poid.transactionIsolation - READ_UNCOMMITTED - - - org.jpox.rdbms.dateTimezone - JDK_DEFAULT_TIMEZONE - - - - - - diff --git a/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.jar b/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.jar deleted file mode 100644 index 72af4bc10..000000000 --- a/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -incorrectMd5 diff --git a/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.pom b/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.pom deleted file mode 100644 index b64e1d0f0..000000000 --- a/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/1.0.0/incorrectArtifactMetadata-1.0.0.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - 3 - incorrectArtifactMetadata - test - 1.0.0 - diff --git a/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/maven-metadata.xml b/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/maven-metadata.xml deleted file mode 100644 index b393bcd3d..000000000 --- a/archiva-converter/src/test/source-modern-repository/test/incorrectArtifactMetadata/maven-metadata.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - test - incorrectArtifactMetadata - - - 0.9 - - - \ No newline at end of file diff --git a/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.jar b/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.jar deleted file mode 100644 index 72af4bc10..000000000 --- a/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.jar +++ /dev/null @@ -1 +0,0 @@ -incorrectMd5 diff --git a/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.pom b/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.pom deleted file mode 100644 index 929190af2..000000000 --- a/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/incorrectSnapshotMetadata-1.0.0-20060102.030405-6.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - 3 - incorrectSnapshotMetadata - test - 1.0.0-20060102.030405-6 - diff --git a/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml b/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml deleted file mode 100644 index 5980278b3..000000000 --- a/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/1.0.0-SNAPSHOT/maven-metadata.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - test - incorrectSnapshotMetadata - 1.0.0-SNAPSHOT - - - 10 - 20060102.040506 - - - \ No newline at end of file diff --git a/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml b/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml deleted file mode 100644 index 3f9a0cef2..000000000 --- a/archiva-converter/src/test/source-modern-repository/test/incorrectSnapshotMetadata/maven-metadata.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - test - incorrectSnapshotMetadata - - - 1.0.0-SNAPSHOT - - - \ No newline at end of file diff --git a/archiva-converter/src/test/source-repository/test/jars/artifact-one-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/artifact-one-1.0.0.jar deleted file mode 100644 index 5626abf0f..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/artifact-one-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/archiva-converter/src/test/source-repository/test/jars/artifact-three-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/artifact-three-1.0.0.jar deleted file mode 100644 index 2bdf67abb..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/artifact-three-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -three diff --git a/archiva-converter/src/test/source-repository/test/jars/artifact-two-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/artifact-two-1.0.0.jar deleted file mode 100644 index f719efd43..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/artifact-two-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -two diff --git a/archiva-converter/src/test/source-repository/test/jars/dryrun-artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/dryrun-artifact-1.0.0.jar deleted file mode 100644 index cbaf024e5..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/dryrun-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -existing diff --git a/archiva-converter/src/test/source-repository/test/jars/existing-artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/existing-artifact-1.0.0.jar deleted file mode 100644 index cbaf024e5..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/existing-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -existing diff --git a/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar deleted file mode 100644 index 72af4bc10..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -incorrectMd5 diff --git a/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar.md5 b/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar.md5 deleted file mode 100644 index 316d9a4eb..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/incorrectMd5Artifact-1.0.0.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -379dcfcd1e6312cc859111f696047eb4 diff --git a/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar deleted file mode 100644 index f5812f3e5..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -incorrectSha1 diff --git a/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 b/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 deleted file mode 100644 index cce322eb2..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/incorrectSha1Artifact-1.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -52e07b82d944741f66bba5896d4cd74e9879e289 diff --git a/archiva-converter/src/test/source-repository/test/jars/modified-artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/modified-artifact-1.0.0.jar deleted file mode 100644 index 2e0996000..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/modified-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -modified diff --git a/archiva-converter/src/test/source-repository/test/jars/newversion-artifact-1.0.1.jar b/archiva-converter/src/test/source-repository/test/jars/newversion-artifact-1.0.1.jar deleted file mode 100644 index c694117fd..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/newversion-artifact-1.0.1.jar +++ /dev/null @@ -1 +0,0 @@ -v4 diff --git a/archiva-converter/src/test/source-repository/test/jars/noPomArtifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/noPomArtifact-1.0.0.jar deleted file mode 100644 index 3d27acdcc..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/noPomArtifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -noPom diff --git a/archiva-converter/src/test/source-repository/test/jars/relocated-v3artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/relocated-v3artifact-1.0.0.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/relocated-v3artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/source-repository/test/jars/rollback-created-artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/rollback-created-artifact-1.0.0.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/rollback-created-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/source-repository/test/jars/unmodified-artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/unmodified-artifact-1.0.0.jar deleted file mode 100644 index 27597bc21..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/unmodified-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -unmodified diff --git a/archiva-converter/src/test/source-repository/test/jars/v3-warnings-artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/v3-warnings-artifact-1.0.0.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v3-warnings-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-20060105.130101-3.jar b/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-20060105.130101-3.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-20060105.130101-3.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-SNAPSHOT.jar b/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-SNAPSHOT.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0-SNAPSHOT.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v3artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-20060111.120115-1.jar b/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-20060111.120115-1.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-20060111.120115-1.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-SNAPSHOT.jar b/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-SNAPSHOT.jar deleted file mode 100644 index 29ef827e8..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0-SNAPSHOT.jar +++ /dev/null @@ -1 +0,0 @@ -v3 diff --git a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar b/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar deleted file mode 100644 index c694117fd..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -v4 diff --git a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.md5 b/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.md5 deleted file mode 100644 index 1930bc6d3..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.md5 +++ /dev/null @@ -1 +0,0 @@ -4289bbdd6fba75013b317b2f9a540736 *v4artifact-1.0.0.jar diff --git a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.sha1 b/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.sha1 deleted file mode 100644 index 466f209a7..000000000 --- a/archiva-converter/src/test/source-repository/test/jars/v4artifact-1.0.0.jar.sha1 +++ /dev/null @@ -1 +0,0 @@ -e3e4159da65a4257f0bffb7cac8e3e78241a4dca *v4artifact-1.0.0.jar diff --git a/archiva-converter/src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar b/archiva-converter/src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar deleted file mode 100644 index 5626abf0f..000000000 --- a/archiva-converter/src/test/source-repository/test/plugins/maven-foo-plugin-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -one diff --git a/archiva-converter/src/test/source-repository/test/poms/artifact-one-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/artifact-one-1.0.0.pom deleted file mode 100644 index cd3862d35..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/artifact-one-1.0.0.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - test - artifact-one - 1.0.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/artifact-three-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/artifact-three-1.0.0.pom deleted file mode 100644 index 343291037..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/artifact-three-1.0.0.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - test - artifact-three - 1.0.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/artifact-two-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/artifact-two-1.0.0.pom deleted file mode 100644 index 227470167..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/artifact-two-1.0.0.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - test - artifact-two - 1.0.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/dryrun-artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/dryrun-artifact-1.0.0.pom deleted file mode 100644 index 1953c5523..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/dryrun-artifact-1.0.0.pom +++ /dev/null @@ -1,22 +0,0 @@ - - - - 4.0.0 - dryrun-artifact - test - 1.0.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/incorrectMd5Artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/incorrectMd5Artifact-1.0.0.pom deleted file mode 100644 index 74d5e12b4..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/incorrectMd5Artifact-1.0.0.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 3 - incorrectMd5Artifact - test - 1.0.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/incorrectSha1Artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/incorrectSha1Artifact-1.0.0.pom deleted file mode 100644 index fe3c7fd91..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/incorrectSha1Artifact-1.0.0.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 3 - incorrectSha1Artifact - test - 1.0.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/maven-foo-plugin-1.0.pom b/archiva-converter/src/test/source-repository/test/poms/maven-foo-plugin-1.0.pom deleted file mode 100644 index a5a02c42d..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/maven-foo-plugin-1.0.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 3 - maven-foo-plugin - org.apache.maven.plugins - 1.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/modified-artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/modified-artifact-1.0.0.pom deleted file mode 100644 index fcfdaacb4..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/modified-artifact-1.0.0.pom +++ /dev/null @@ -1,22 +0,0 @@ - - - - 4.0.0 - modified-artifact - test - 1.0.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom b/archiva-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom deleted file mode 100644 index f441c9a46..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/newversion-artifact-1.0.1.pom +++ /dev/null @@ -1,22 +0,0 @@ - - - - 4.0.0 - test - newversoin-artifact - 1.0.1 - diff --git a/archiva-converter/src/test/source-repository/test/poms/relocated-v3artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/relocated-v3artifact-1.0.0.pom deleted file mode 100644 index ab112a296..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/relocated-v3artifact-1.0.0.pom +++ /dev/null @@ -1,27 +0,0 @@ - - 3 - relocated-v3artifact - test - 1.0.0 - - - groupId - artifactId - version - - - groupId - test-artifactId - version - - test - - - - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - - relocated-test - - \ No newline at end of file diff --git a/archiva-converter/src/test/source-repository/test/poms/rollback-created-artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/rollback-created-artifact-1.0.0.pom deleted file mode 100644 index 00692be72..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/rollback-created-artifact-1.0.0.pom +++ /dev/null @@ -1,39 +0,0 @@ - - - - 3 - v3artifact - test - 1.0.0 - - - groupId - artifactId - version - - - groupId - test-artifactId - version - - test - - - - - - diff --git a/archiva-converter/src/test/source-repository/test/poms/unmodified-artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/unmodified-artifact-1.0.0.pom deleted file mode 100644 index a8428a8a4..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/unmodified-artifact-1.0.0.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - unmodified-artifact - test - 1.0.0 - diff --git a/archiva-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom deleted file mode 100644 index 5f347f371..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/v3-warnings-artifact-1.0.0.pom +++ /dev/null @@ -1,48 +0,0 @@ - - - - 3 - ../project.xml - v3-warnings-artifact - test - 1.0.0 - - - 1.0 - 1.0 - 1_0 - - - - - groupId - artifactId - version - - - groupId - test-artifactId - version - - test - - - - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - diff --git a/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-20060105.130101-3.pom b/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-20060105.130101-3.pom deleted file mode 100644 index d7ae8953b..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-20060105.130101-3.pom +++ /dev/null @@ -1,40 +0,0 @@ - - - - 3 - v3artifact - test - 1.0.0-20060105.130101-3 - - - groupId - artifactId - version - - - groupId - test-artifactId - version - - test - - - - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - diff --git a/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-SNAPSHOT.pom b/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-SNAPSHOT.pom deleted file mode 100644 index 3958a3358..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0-SNAPSHOT.pom +++ /dev/null @@ -1,40 +0,0 @@ - - - - 3 - v3artifact - test - 1.0.0-SNAPSHOT - - - groupId - artifactId - version - - - groupId - test-artifactId - version - - test - - - - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - diff --git a/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0.pom deleted file mode 100644 index 5aed3437a..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/v3artifact-1.0.0.pom +++ /dev/null @@ -1,24 +0,0 @@ - - 3 - v3artifact - test - 1.0.0 - - - groupId - artifactId - version - - - groupId - test-artifactId - version - - test - - - - - scm:cvs:ext:${maven.username}@localhost:/home/cvs - - diff --git a/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-20060111.120115-1.pom b/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-20060111.120115-1.pom deleted file mode 100644 index e4f36566a..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-20060111.120115-1.pom +++ /dev/null @@ -1,22 +0,0 @@ - - - - 4.0.0 - test - v4artifact - 1.0.0-20060111.120115-1 - diff --git a/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-SNAPSHOT.pom b/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-SNAPSHOT.pom deleted file mode 100644 index be5b8b7e2..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0-SNAPSHOT.pom +++ /dev/null @@ -1,22 +0,0 @@ - - - - 4.0.0 - test - v4artifact - 1.0.0-SNAPSHOT - diff --git a/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0.pom b/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0.pom deleted file mode 100644 index fa6e82b1e..000000000 --- a/archiva-converter/src/test/source-repository/test/poms/v4artifact-1.0.0.pom +++ /dev/null @@ -1,6 +0,0 @@ - - 4.0.0 - test - v4artifact - 1.0.0 - diff --git a/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.jar b/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.jar deleted file mode 100644 index 27597bc21..000000000 --- a/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -unmodified diff --git a/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.pom b/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.pom deleted file mode 100644 index d23afd027..000000000 --- a/archiva-converter/src/test/target-repository/test/modified-artifact/1.0.0/modified-artifact-1.0.0.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - modified-artifact - test - 1.0.0 - diff --git a/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.jar b/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.jar deleted file mode 100644 index 27597bc21..000000000 --- a/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -unmodified diff --git a/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom b/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom deleted file mode 100644 index e21492ebf..000000000 --- a/archiva-converter/src/test/target-repository/test/newversion-artifact/1.0.0/newversion-artifact-1.0.0.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - newversion-artifact - test - 1.0.0 - diff --git a/archiva-converter/src/test/target-repository/test/newversion-artifact/maven-metadata.xml b/archiva-converter/src/test/target-repository/test/newversion-artifact/maven-metadata.xml deleted file mode 100644 index 42537e4c5..000000000 --- a/archiva-converter/src/test/target-repository/test/newversion-artifact/maven-metadata.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - test - newversion-artifact - - - 1.0.0 - - - \ No newline at end of file diff --git a/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.jar b/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.jar deleted file mode 100644 index 27597bc21..000000000 --- a/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.jar +++ /dev/null @@ -1 +0,0 @@ -unmodified diff --git a/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.pom b/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.pom deleted file mode 100644 index a8428a8a4..000000000 --- a/archiva-converter/src/test/target-repository/test/unmodified-artifact/1.0.0/unmodified-artifact-1.0.0.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - unmodified-artifact - test - 1.0.0 - diff --git a/archiva-repository-layer/pom.xml b/archiva-repository-layer/pom.xml deleted file mode 100644 index 210563124..000000000 --- a/archiva-repository-layer/pom.xml +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - archiva - org.apache.maven.archiva - 1.0-SNAPSHOT - - 4.0.0 - org.apache.maven.archiva - archiva-repository-layer - Archiva Repository Interface Layer - - - org.apache.maven.archiva - archiva-common - - - org.apache.maven.archiva - archiva-model - 1.0-SNAPSHOT - - - org.codehaus.plexus - plexus-utils - - - org.codehaus.plexus.cache - plexus-cache-api - 1.0-alpha-2-SNAPSHOT - compile - - - org.codehaus.plexus.cache - plexus-cache-ehcache - 1.0-alpha-2-SNAPSHOT - compile - - - org.apache.maven - maven-artifact - - - org.apache.maven - maven-artifact-manager - - - org.apache.maven - maven-repository-metadata - - - org.slf4j - slf4j-log4j12 - - - - - - org.codehaus.plexus - plexus-maven-plugin - - - merge - - merge-descriptors - - - - ${basedir}/src/main/resources/META-INF/plexus/components.xml - ${project.build.directory}/generated-resources/plexus/META-INF/plexus/components.xml - - - - - - - - diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java deleted file mode 100644 index 2f7f35fe9..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayer.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.codehaus.plexus.cache.Cache; -import org.codehaus.plexus.cache.CacheException; -import org.codehaus.plexus.cache.CacheHints; -import org.codehaus.plexus.cache.factory.CacheFactory; - -import java.util.List; - -/** - * CachedRepositoryQueryLayer - simple wrapper around another non-cached Repository Query Layer. - * - * @version $Id$ - */ -public class CachedRepositoryQueryLayer - implements RepositoryQueryLayer -{ - private Cache cache; - - private RepositoryQueryLayer layer; - - public CachedRepositoryQueryLayer( RepositoryQueryLayer layer ) - throws RepositoryQueryLayerException - { - this.layer = layer; - String repoId = layer.getRepository().getId(); - - CacheHints hints = new CacheHints(); - hints.setName( repoId ); - hints.setOverflowToDisk( false ); - try - { - this.cache = CacheFactory.getInstance().getCache( repoId, hints ); - } - catch ( CacheException e ) - { - throw new RepositoryQueryLayerException( "Unable to initialize cache: " + e.getMessage(), e ); - } - } - - public boolean containsArtifact( Artifact artifact ) - { - boolean artifactFound = true; - - String artifactPath = layer.getRepository().pathOf( artifact ); - - if ( cache.get( artifactPath ) == null ) - { - artifactFound = layer.containsArtifact( artifact ); - if ( artifactFound ) - { - cache.put( artifactPath, artifactPath ); - } - } - - return artifactFound; - } - - public List getVersions( Artifact artifact ) - throws RepositoryQueryLayerException - { - List list = (List) cache.get( artifact.getId() ); - - if ( list == null ) - { - list = layer.getVersions( artifact ); - cache.put( artifact.getId(), list ); - } - - return list; - } - - public ArtifactRepository getRepository() - { - return layer.getRepository(); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayer.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayer.java deleted file mode 100644 index d664dad1b..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayer.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.metadata.ArtifactRepositoryMetadata; -import org.apache.maven.artifact.repository.metadata.Metadata; -import org.apache.maven.artifact.repository.metadata.io.xpp3.MetadataXpp3Reader; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.List; - -/** - * DefaultRepositoryQueryLayer - * - * @version $Id$ - * @plexus.component role="org.apache.maven.archiva.layer.RepositoryQueryLayer" role-hint="default" - */ -public class DefaultRepositoryQueryLayer - implements RepositoryQueryLayer -{ - protected ArtifactRepository repository; - - public DefaultRepositoryQueryLayer( ArtifactRepository repository ) - { - this.repository = repository; - } - - public boolean containsArtifact( Artifact artifact ) - { - File f = new File( repository.getBasedir(), repository.pathOf( artifact ) ); - return f.exists(); - } - - public List getVersions( Artifact artifact ) - throws RepositoryQueryLayerException - { - Metadata metadata = getMetadata( artifact ); - - return metadata.getVersioning().getVersions(); - } - - public ArtifactRepository getRepository() - { - return repository; - } - - private Metadata getMetadata( Artifact artifact ) - throws RepositoryQueryLayerException - { - Metadata metadata; - - ArtifactRepositoryMetadata repositoryMetadata = new ArtifactRepositoryMetadata( artifact ); - String path = repository.pathOfRemoteRepositoryMetadata( repositoryMetadata ); - File metadataFile = new File( repository.getBasedir(), path ); - if ( metadataFile.exists() ) - { - MetadataXpp3Reader reader = new MetadataXpp3Reader(); - try - { - metadata = reader.read( new FileReader( metadataFile ) ); - } - catch ( FileNotFoundException e ) - { - throw new RepositoryQueryLayerException( "Error occurred while attempting to read metadata file", e ); - } - catch ( IOException e ) - { - throw new RepositoryQueryLayerException( "Error occurred while attempting to read metadata file", e ); - } - catch ( XmlPullParserException e ) - { - throw new RepositoryQueryLayerException( "Error occurred while attempting to read metadata file", e ); - } - } - else - { - throw new RepositoryQueryLayerException( "Metadata not found: " + metadataFile.getAbsolutePath() ); - } - - return metadata; - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerFactory.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerFactory.java deleted file mode 100644 index a7e794b19..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerFactory.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * Gets the default implementation of a repository query layer for the given repository. - * - * @author Brett Porter - * @version $Id:DefaultRepositoryQueryLayerFactory.java 437105 2006-08-26 17:22:22 +1000 (Sat, 26 Aug 2006) brett $ - * @plexus.component role="org.apache.maven.archiva.layer.RepositoryQueryLayerFactory" - */ -public class DefaultRepositoryQueryLayerFactory - implements RepositoryQueryLayerFactory -{ - public RepositoryQueryLayer createRepositoryQueryLayer( ArtifactRepository repository ) - { - return new DefaultRepositoryQueryLayer( repository ); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayer.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayer.java deleted file mode 100644 index 16ee0b378..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayer.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.repository.ArtifactRepository; - -import java.util.List; - -/** - * The transitive and metadata validation reports will need to query the repository for artifacts. - */ -public interface RepositoryQueryLayer -{ - String ROLE = RepositoryQueryLayer.class.getName(); - - boolean containsArtifact( Artifact artifact ); - - List getVersions( Artifact artifact ) - throws RepositoryQueryLayerException; - - ArtifactRepository getRepository(); -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerException.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerException.java deleted file mode 100644 index 08ef9d932..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerException.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * - */ -public class RepositoryQueryLayerException - extends Exception -{ - public RepositoryQueryLayerException( String message, Throwable cause ) - { - super( message, cause ); - } - - public RepositoryQueryLayerException( String message ) - { - super( message ); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerFactory.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerFactory.java deleted file mode 100644 index 2aad42224..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/layer/RepositoryQueryLayerFactory.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.repository.ArtifactRepository; - -/** - * Gets the preferred implementation of a repository query layer for the given repository. - * - * @author Brett Porter - * @version $Id:RepositoryQueryLayerFactory.java 437105 2006-08-26 17:22:22 +1000 (Sat, 26 Aug 2006) brett $ - */ -public interface RepositoryQueryLayerFactory -{ - String ROLE = RepositoryQueryLayerFactory.class.getName(); - - /** - * Create or obtain a query interface. - * - * @param repository the repository to query - * @return the obtained query layer - */ - RepositoryQueryLayer createRepositoryQueryLayer( ArtifactRepository repository ); -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaArtifact.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaArtifact.java deleted file mode 100644 index 2456f29f3..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaArtifact.java +++ /dev/null @@ -1,161 +0,0 @@ -package org.apache.maven.archiva.repository; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.model.ArchivaArtifactModel; -import org.apache.maven.archiva.model.RepositoryContent; -import org.apache.maven.archiva.repository.version.VersionUtil; -import org.codehaus.plexus.util.StringUtils; - -/** - * ArchivaArtifact - Mutable artifact object. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ArchivaArtifact -{ - private ArchivaArtifactModel model; - - private String baseVersion; - - private boolean snapshot = false; - - public ArchivaArtifact( String groupId, String artifactId, String version, String classifier, String type ) - { - this( null, groupId, artifactId, version, classifier, type ); - } - - public ArchivaArtifact( ArchivaRepository repository, String groupId, String artifactId, String version, - String classifier, String type ) - { - if ( empty( groupId ) ) - { - throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty groupId." ); - } - - if ( empty( artifactId ) ) - { - throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty artifactId." ); - } - - if ( empty( version ) ) - { - throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty version." ); - } - - if ( empty( type ) ) - { - throw new IllegalArgumentException( "Unable to create ArchivaArtifact with empty type." ); - } - - model = new ArchivaArtifactModel(); - - if( repository == null ) - { - model.setContentKey( new RepositoryContent( groupId, artifactId, version ) ); - } - else - { - model.setContentKey( new RepositoryContent( repository.getModel(), groupId, artifactId, version ) ); - } - model.setClassifier( StringUtils.defaultString( classifier ) ); - model.setType( type ); - - this.snapshot = VersionUtil.isSnapshot( version ); - this.baseVersion = VersionUtil.getBaseVersion( version ); - } - - public String getGroupId() - { - return model.getContentKey().getGroupId(); - } - - public String getArtifactId() - { - return model.getContentKey().getArtifactId(); - } - - public String getVersion() - { - return model.getContentKey().getVersion(); - } - - public String getBaseVersion() - { - return baseVersion; - } - - public boolean isSnapshot() - { - return snapshot; - } - - public String getClassifier() - { - return model.getClassifier(); - } - - public String getType() - { - return model.getType(); - } - - public boolean hasClassifier() - { - return StringUtils.isNotEmpty( model.getClassifier() ); - } - - public String toString() - { - StringBuffer sb = new StringBuffer(); - if ( model.getContentKey().getGroupId() != null ) - { - sb.append( model.getContentKey().getGroupId() ); - sb.append( ":" ); - } - appendArtifactTypeClassifierString( sb ); - sb.append( ":" ); - if ( model.getContentKey().getVersion() != null ) - { - sb.append( model.getContentKey().getVersion() ); - } - - return sb.toString(); - } - - private void appendArtifactTypeClassifierString( StringBuffer sb ) - { - sb.append( model.getContentKey().getArtifactId() ); - sb.append( ":" ); - sb.append( getType() ); - if ( hasClassifier() ) - { - sb.append( ":" ); - sb.append( getClassifier() ); - } - } - - private boolean empty( String value ) - { - return value == null || value.trim().length() < 1; - } - -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaRepository.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaRepository.java deleted file mode 100644 index c1fb4f0fe..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/ArchivaRepository.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.apache.maven.archiva.repository; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.model.ArchivaRepositoryModel; -import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy; - -/** - * ArchivaRepository - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ArchivaRepository -{ - protected ArtifactRepositoryPolicy releases; - - protected ArtifactRepositoryPolicy snapshots; - - private ArchivaRepositoryModel model; - - private RepositoryURL url; - - protected boolean blacklisted; - - /** - * Construct a Repository. - * - * @param id the unique identifier for this repository. - * @param name the name for this repository. - * @param url the base URL for this repository (this should point to the top level URL for the entire repository) - * @param layout the layout technique for this repository. - */ - public ArchivaRepository( String id, String name, String url ) - { - model = new ArchivaRepositoryModel(); - - model.setId( id ); - model.setName( name ); - setUrl( new RepositoryURL( url ) ); - } - - /** - * Construct a Repository. - * - * @param id the unique identifier for this repository. - * @param name the name for this repository. - * @param url the base URL for this repository (this should point to the top level URL for the entire repository) - * @param layout the layout technique for this repository. - */ - public ArchivaRepository( ArchivaRepositoryModel model ) - { - this.model = model; - - this.url = new RepositoryURL( model.getUrl() ); - } - - public String getId() - { - return model.getId(); - } - - public void setUrl( RepositoryURL url ) - { - this.url = url; - model.setUrl( url.getUrl() ); - } - - public RepositoryURL getUrl() - { - return this.url; - } - - public ArchivaRepositoryModel getModel() - { - return this.model; - } - - public boolean isBlacklisted() - { - return blacklisted; - } - - public void setBlacklisted( boolean blacklisted ) - { - this.blacklisted = blacklisted; - } - - public ArtifactRepositoryPolicy getReleases() - { - return releases; - } - - public void setReleases( ArtifactRepositoryPolicy releases ) - { - this.releases = releases; - } - - public ArtifactRepositoryPolicy getSnapshots() - { - return snapshots; - } - - public void setSnapshots( ArtifactRepositoryPolicy snapshots ) - { - this.snapshots = snapshots; - } - - public boolean isRemote() - { - return this.url.getProtocol().equals( "file" ); - } - - public boolean isManaged() - { - return this.url.getProtocol().equals( "file" ); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryException.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryException.java deleted file mode 100644 index 0cafdc92d..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryException.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.maven.archiva.repository; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * RepositoryException - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryException - extends Exception -{ - - public RepositoryException() - { - super(); - } - - public RepositoryException( String message, Throwable cause ) - { - super( message, cause ); - } - - public RepositoryException( String message ) - { - super( message ); - } - - public RepositoryException( Throwable cause ) - { - super( cause ); - } - -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryURL.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryURL.java deleted file mode 100644 index 13ed57fc9..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/RepositoryURL.java +++ /dev/null @@ -1,156 +0,0 @@ -package org.apache.maven.archiva.repository; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -/** - * RepositoryURL - Mutable (and protocol forgiving) URL object. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryURL -{ - private String url; - - private String protocol; - - private String host; - - private String port; - - private String username; - - private String password; - - private String path; - - public RepositoryURL( String url ) - { - this.url = url; - - // .\ Parse the URL \.____________________________________________ - - int pos; - - pos = url.indexOf( "://" ); - if ( pos == ( -1 ) ) - { - throw new IllegalArgumentException( "Invalid URL, unable to parse protocol:// from " + url ); - } - - protocol = url.substring( 0, pos ); - - // attempt to find the start of the 'path' - pos = url.indexOf( "/", protocol.length() + 3 ); - - // no path specified - ex "http://localhost" - if ( pos == ( -1 ) ) - { - // set pos to end of string. (needed for 'middle section') - pos = url.length(); - // default path - path = "/"; - } - else - { - // get actual path. - path = url.substring( pos ); - } - - // get the middle section ( username : password @ hostname : port ) - String middle = url.substring( protocol.length() + 3, pos ); - - pos = middle.indexOf( '@' ); - - // we have an authentication section. - if ( pos > 0 ) - { - String authentication = middle.substring( 0, pos ); - middle = middle.substring( pos + 1 ); // lop off authentication for host:port search - - pos = authentication.indexOf( ':' ); - - // we have a password. - if ( pos > 0 ) - { - username = authentication.substring( 0, pos ); - password = authentication.substring( pos + 1 ); - } - else - { - username = authentication; - } - } - - pos = middle.indexOf( ':' ); - - // we have a defined port - if ( pos > 0 ) - { - host = middle.substring( 0, pos ); - port = middle.substring( pos + 1 ); - } - else - { - host = middle; - } - } - - public String toString() - { - return url; - } - - public String getUsername() - { - return username; - } - - public String getPassword() - { - return password; - } - - public String getHost() - { - return host; - } - - public String getPath() - { - return path; - } - - public String getPort() - { - return port; - } - - public String getProtocol() - { - return protocol; - } - - public String getUrl() - { - return url; - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java deleted file mode 100644 index f7adfedac..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/connector/RepositoryConnector.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.archiva.repository.connector; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.repository.ArchivaRepository; - -import java.util.List; - -/** - * RepositoryConnector - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public interface RepositoryConnector -{ - public ArchivaRepository getSourceRepository(); - - public ArchivaRepository getTargetRepository(); - - public List getBlacklist(); - - public List getWhitelist(); -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/Consumer.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/Consumer.java deleted file mode 100644 index 66b35a232..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/Consumer.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.apache.maven.archiva.repository.consumer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.utils.BaseFile; -import org.apache.maven.archiva.repository.ArchivaRepository; -import org.apache.maven.artifact.repository.ArtifactRepository; - -import java.util.List; - -/** - * DiscovererConsumer - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public interface Consumer -{ - public static final String ROLE = Consumer.class.getName(); - - /** - * This is the human readable name for the discoverer. - * - * @return the human readable discoverer name. - */ - public String getName(); - - /** - * This is used to initialize any internals in the consumer before it is used. - * - * This method is called by the internals of archiva and is not meant to be used by other developers. - * This method is called once per repository. - * - * @param repository the repository to initialize the consumer against. - * @return true if the repository is valid for this consumer. false will result in consumer being disabled - * for the provided repository. - */ - public boolean init( ArchivaRepository repository ); - - /** - * Get the List of excluded file patterns for this consumer. - * - * @return the list of excluded file patterns for this consumer. - */ - public List getExcludePatterns(); - - /** - * Get the List of included file patterns for this consumer. - * - * @return the list of included file patterns for this consumer. - */ - public List getIncludePatterns(); - - /** - * Called by archiva framework to indicate that there is a file suitable for consuming, - * This method will only be called if the {@link #init(ArtifactRepository)} and {@link #getExcludePatterns()} - * and {@link #getIncludePatterns()} all pass for this consumer. - * - * @param file the file to process. - * @throws ConsumerException if there was a problem processing this file. - */ - public void processFile( BaseFile file ) throws ConsumerException; - - /** - * Called by archiva framework to indicate that there has been a problem detected - * on a specific file. - * - * NOTE: It is very possible for 1 file to have more than 1 problem associated with it. - * - * @param file the file to process. - * @param message the message describing the problem. - */ - public void processFileProblem( BaseFile file, String message ); -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java deleted file mode 100644 index 709be8e6d..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerException.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.apache.maven.archiva.repository.consumer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.ArchivaException; -import org.apache.maven.archiva.common.utils.BaseFile; - -/** - * ConsumerException - details about the failure of a consumer. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ConsumerException - extends ArchivaException -{ - private BaseFile file; - - public ConsumerException( BaseFile file, String message, Throwable cause ) - { - super( message, cause ); - this.file = file; - } - - public ConsumerException( BaseFile file, String message ) - { - super( message ); - this.file = file; - } - - public BaseFile getFile() - { - return file; - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerFactory.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerFactory.java deleted file mode 100644 index 00c88064d..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/consumer/ConsumerFactory.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.apache.maven.archiva.repository.consumer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.context.Context; -import org.codehaus.plexus.context.ContextException; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; - -/** - * DiscovererConsumerFactory - factory for consumers. - * - * @author Joakim Erdfelt - * @version $Id$ - * @plexus.component role="org.apache.maven.archiva.common.consumers.ConsumerFactory" - */ -public class ConsumerFactory - extends AbstractLogEnabled - implements Contextualizable -{ - public static final String ROLE = ConsumerFactory.class.getName(); - - private PlexusContainer container; - - public Consumer createConsumer( String name ) - throws ConsumerException - { - getLogger().info( "Attempting to create consumer [" + name + "]" ); - - Consumer consumer; - try - { - consumer = (Consumer) container.lookup( Consumer.ROLE, name, container.getLookupRealm() ); - } - catch ( Throwable t ) - { - String emsg = "Unable to create consumer [" + name + "]: " + t.getMessage(); - getLogger().warn( t.getMessage(), t ); - throw new ConsumerException( null, emsg, t ); - } - - getLogger().info( "Created consumer [" + name + "|" + consumer.getName() + "]" ); - return consumer; - } - - public void contextualize( Context context ) - throws ContextException - { - container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY ); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractArtifactExtensionMapping.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractArtifactExtensionMapping.java deleted file mode 100644 index 3b1ab31c1..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/AbstractArtifactExtensionMapping.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.apache.maven.archiva.repository.content; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.repository.ArchivaArtifact; - -import java.util.HashMap; -import java.util.Map; - -/** - * AbstractArtifactExtensionMapping - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public abstract class AbstractArtifactExtensionMapping implements ArtifactExtensionMapping -{ - protected final Map typeToExtensionMap; - - public AbstractArtifactExtensionMapping() - { - typeToExtensionMap = new HashMap(); - typeToExtensionMap.put( "ejb-client", "jar" ); - typeToExtensionMap.put( "ejb", "jar" ); - typeToExtensionMap.put( "distribution-tgz", "tar.gz" ); - typeToExtensionMap.put( "distribution-zip", "zip" ); - typeToExtensionMap.put( "java-source", "jar" ); - typeToExtensionMap.put( "aspect", "jar" ); - typeToExtensionMap.put( "uberjar", "jar" ); - } - - public String getExtension( ArchivaArtifact artifact ) - { - // Try specialized types first. - if ( typeToExtensionMap.containsKey( artifact.getType() ) ) - { - return (String) typeToExtensionMap.get( artifact.getType() ); - } - - // Return type - return artifact.getType(); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java deleted file mode 100644 index 0f6c990e7..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/ArtifactExtensionMapping.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.apache.maven.archiva.repository.content; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.repository.ArchivaArtifact; - -/** - * ArtifactExtensionMapping - Utility to provide the mapping between an Artifact's extension and it's type and - * vice versa. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public interface ArtifactExtensionMapping -{ - public String getExtension( ArchivaArtifact artifact ); - - public String getType( String filename ); -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultArtifactExtensionMapping.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultArtifactExtensionMapping.java deleted file mode 100644 index 70f036259..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/DefaultArtifactExtensionMapping.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.apache.maven.archiva.repository.content; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; - -/** - * DefaultArtifactExtensionMapping - extension mapping for Maven 2.x projects. - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.repository.content.ArtifactExtensionMapping" - * role-hint="default" - */ -public class DefaultArtifactExtensionMapping extends AbstractArtifactExtensionMapping - implements ArtifactExtensionMapping -{ - public DefaultArtifactExtensionMapping() - { - super(); - } - - public String getType( String filename ) - { - if ( StringUtils.isBlank( filename ) ) - { - return null; - } - - String normalizedName = filename.toLowerCase().trim(); - - if ( normalizedName.endsWith( ".tar.gz" ) ) - { - return "distribution-tgz"; - } - else if ( normalizedName.endsWith( ".zip" ) ) - { - return "distribution-zip"; - } - else if ( normalizedName.endsWith( "-sources.jar" ) ) - { - return "java-source"; - } - // TODO: handle type for -javadoc.jar ? - else - { - int index = normalizedName.lastIndexOf( '.' ); - if ( index >= 0 ) - { - return normalizedName.substring( index + 1 ); - } - else - { - throw new IllegalArgumentException( "Filename " + filename + " does not have an extension." ); - } - } - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyArtifactExtensionMapping.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyArtifactExtensionMapping.java deleted file mode 100644 index 10fd815c8..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/content/LegacyArtifactExtensionMapping.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.apache.maven.archiva.repository.content; - -import org.apache.commons.lang.StringUtils; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * LegacyArtifactExtensionMapping - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.repository.content.ArtifactExtensionMapping" - * role-hint="legacy" - */ -public class LegacyArtifactExtensionMapping extends AbstractArtifactExtensionMapping - implements ArtifactExtensionMapping -{ - public LegacyArtifactExtensionMapping() - { - super(); - } - - public String getType( String filename ) - { - if ( StringUtils.isBlank( filename ) ) - { - return null; - } - - String normalizedName = filename.toLowerCase().trim(); - - if ( normalizedName.endsWith( ".tar.gz" ) ) - { - return "distribution-tgz"; - } - else if ( normalizedName.endsWith( ".zip" ) ) - { - return "distribution-zip"; - } - else if ( normalizedName.endsWith( "-sources.jar" ) ) - { - return "java-source"; - } - // TODO: handle type for -javadoc.jar ? - else - { - int index = normalizedName.lastIndexOf( '.' ); - if ( index >= 0 ) - { - return normalizedName.substring( index + 1 ); - } - else - { - throw new IllegalArgumentException( "Filename " + filename + " does not have an extension." ); - } - } - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/BidirectionalRepositoryLayout.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/BidirectionalRepositoryLayout.java deleted file mode 100644 index 29770dffc..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/BidirectionalRepositoryLayout.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.repository.ArchivaArtifact; - -/** - * BidirectionalRepositoryLayout - Similar in scope to ArtifactRepositoryLayout, but does - * the both the Path to Artifact, and Artifact to Path conversions. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public interface BidirectionalRepositoryLayout -{ - /** - * Get the identifier for this layout. - * - * @return the identifier for this layout. - */ - public String getId(); - - /** - * Given an ArchivaArtifact, return the relative path to the artifact. - * - * @param artifact the artifact to compute the path of. - * @return the relative path to the artifact. - */ - public String pathOf( ArchivaArtifact artifact ); - - /** - * Given a repository relative path to a filename, return the ArchivaArtifact object suitable for the path. - * - * @param path the path relative to the repository base dir for the artifact. - * @return the ArchivaArtifact representing the path. (or null if path cannot be converted to an ArchivaArtifact) - * @throws LayoutException if there was a problem converting the path to an artifact. - */ - public ArchivaArtifact toArtifact( String path ) throws LayoutException; -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayout.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayout.java deleted file mode 100644 index 35406aa07..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayout.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.repository.ArchivaArtifact; -import org.apache.maven.archiva.repository.content.ArtifactExtensionMapping; -import org.apache.maven.archiva.repository.content.DefaultArtifactExtensionMapping; - -/** - * DefaultBidirectionalRepositoryLayout - the layout mechanism for use by Maven 2.x repositories. - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role-hint="default" - */ -public class DefaultBidirectionalRepositoryLayout - implements BidirectionalRepositoryLayout -{ - private static final char PATH_SEPARATOR = '/'; - - private static final char GROUP_SEPARATOR = '.'; - - private static final char ARTIFACT_SEPARATOR = '-'; - - private ArtifactExtensionMapping extensionMapper = new DefaultArtifactExtensionMapping(); - - public String getId() - { - return "default"; - } - - public String pathOf( ArchivaArtifact artifact ) - { - StringBuffer path = new StringBuffer(); - - path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR ); - path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR ); - path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR ); - path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); - - if ( artifact.hasClassifier() ) - { - path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() ); - } - - path.append( GROUP_SEPARATOR ).append( extensionMapper.getExtension( artifact ) ); - - return path.toString(); - } - - private String formatAsDirectory( String directory ) - { - return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR ); - } - - public ArchivaArtifact toArtifact( String path ) throws LayoutException - { - String normalizedPath = StringUtils.replace( path, "\\", "/" ); - - String pathParts[] = StringUtils.split( normalizedPath, '/' ); - - /* Minimum parts. - * - * path = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar" - * path[0] = "commons-lang"; // The Group ID - * path[1] = "commons-lang"; // The Artifact ID - * path[2] = "2.1"; // The Version - * path[3] = "commons-lang-2.1.jar" // The filename. - */ - - if ( pathParts.length < 4 ) - { - // Illegal Path Parts Length. - throw new LayoutException( "Not enough parts to the path [" + path - + "] to construct an ArchivaArtifact from. (Requires at least 4 parts)" ); - } - - // Maven 2.x path. - int partCount = pathParts.length; - - // Last part is the filename - String filename = pathParts[partCount - 1]; - - // Second to last is the baseVersion (the directory version) - // (Don't need it) String baseVersion = pathParts[partCount - 2]; - - // Third to last is the artifact Id. - String artifactId = pathParts[partCount - 3]; - - // Remaining pieces are the groupId. - String groupId = ""; - for ( int i = 0; i <= partCount - 4; i++ ) - { - if ( groupId.length() > 0 ) - { - groupId += "."; - } - groupId += pathParts[i]; - } - - // Now we need to parse the filename to get the artifact version Id. - String fileParts[] = RepositoryLayoutUtils.splitFilename( filename, artifactId ); - String version = fileParts[1]; - String classifier = fileParts[2]; - - String type = extensionMapper.getType( filename ); - - return new ArchivaArtifact( groupId, artifactId, version, classifier, type ); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LayoutException.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LayoutException.java deleted file mode 100644 index 0fc833689..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LayoutException.java +++ /dev/null @@ -1,41 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.ArchivaException; - -/** - * LayoutException - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class LayoutException extends ArchivaException -{ - public LayoutException( String message, Throwable cause ) - { - super( message, cause ); - } - - public LayoutException( String message ) - { - super( message ); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayout.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayout.java deleted file mode 100644 index 0344a5245..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayout.java +++ /dev/null @@ -1,135 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.repository.ArchivaArtifact; -import org.apache.maven.archiva.repository.content.ArtifactExtensionMapping; -import org.apache.maven.archiva.repository.content.LegacyArtifactExtensionMapping; - -import java.util.HashMap; -import java.util.Map; - -/** - * LegacyBidirectionalRepositoryLayout - the layout mechanism for use by Maven 1.x repositories. - * - * @author Joakim Erdfelt - * @version $Id$ - * - * @plexus.component role-hint="legacy" - */ -public class LegacyBidirectionalRepositoryLayout implements BidirectionalRepositoryLayout -{ - private static final String PATH_SEPARATOR = "/"; - - private ArtifactExtensionMapping extensionMapper = new LegacyArtifactExtensionMapping(); - - private Map typeToDirectoryMap; - - public LegacyBidirectionalRepositoryLayout() - { - typeToDirectoryMap = new HashMap(); - typeToDirectoryMap.put( "ejb-client", "ejb" ); - typeToDirectoryMap.put( "distribution-tgz", "distribution" ); - typeToDirectoryMap.put( "distribution-zip", "distribution" ); - } - - public String getId() - { - return "legacy"; - } - - public String pathOf( ArchivaArtifact artifact ) - { - StringBuffer path = new StringBuffer(); - - path.append( artifact.getGroupId() ).append( PATH_SEPARATOR ); - path.append( getDirectory( artifact ) ).append( PATH_SEPARATOR ); - path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() ); - - if ( artifact.hasClassifier() ) - { - path.append( '-' ).append( artifact.getClassifier() ); - } - - path.append( '.' ).append( extensionMapper.getExtension( artifact ) ); - - return path.toString(); - } - - private String getDirectory( ArchivaArtifact artifact ) - { - // Special Cases involving classifiers and type. - if ( "jar".equals( artifact.getType() ) && "sources".equals( artifact.getClassifier() ) ) - { - return "javadoc.jars"; - } - - // Special Cases involving only type. - String dirname = (String) typeToDirectoryMap.get( artifact.getType() ); - - if ( dirname != null ) - { - return dirname + "s"; - } - - // Default process. - return artifact.getType() + "s"; - } - - public ArchivaArtifact toArtifact( String path ) throws LayoutException - { - String normalizedPath = StringUtils.replace( path, "\\", "/" ); - - String pathParts[] = StringUtils.split( normalizedPath, '/' ); - - /* Always 3 parts. (Never more or less) - * - * path = "commons-lang/jars/commons-lang-2.1.jar" - * path[0] = "commons-lang"; // The Group ID - * path[1] = "jars"; // The Directory Type - * path[2] = "commons-lang-2.1.jar"; // The Filename. - */ - - if ( pathParts.length != 3 ) - { - // Illegal Path Parts Length. - throw new LayoutException( "Invalid number of parts to the path [" + path - + "] to construct an ArchivaArtifact from. (Required to be 3 parts)" ); - } - - // The Group ID. - String groupId = pathParts[0]; - - // The Filename. - String filename = pathParts[2]; - - String fileParts[] = RepositoryLayoutUtils.splitFilename( filename, null ); - - String artifactId = fileParts[0]; - String version = fileParts[1]; - String classifier = fileParts[2]; - - String type = extensionMapper.getType( filename ); - - return new ArchivaArtifact( groupId, artifactId, version, classifier, type ); - } - -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtils.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtils.java deleted file mode 100644 index 8e2c144c9..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtils.java +++ /dev/null @@ -1,219 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * RepositoryLayoutUtils - utility methods common for most BidirectionalRepositoryLayout implementation. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryLayoutUtils -{ - /** - * Complex 2+ part extensions. - * Do not include initial "." character in extension names here. - */ - private static final String ComplexExtensions[] = new String[] { "tar.gz", "tar.bz2" }; - - /** - * These are the version patterns found in the filenames of the various artifact's versions IDs. - * These patterns are all tackling lowercase version IDs. - */ - private static final String VersionPatterns[] = - new String[] { "(snapshot)", "([0-9][_.0-9a-z]*)", "(g?[_.0-9ab]*(pre|rc|g|m)[_.0-9]*)", "(dev[_.0-9]*)", - "(alpha[_.0-9]*)", "(beta[_.0-9]*)", "(rc[_.0-9]*)", "(test[_.0-9]*)", "(debug[_.0-9]*)", - "(unofficial[_.0-9]*)", "(current)", "(latest)", "(fcs)", "(release[_.0-9]*)", "(nightly)", "(final)", - "(incubating)", "(incubator)", "([ab][_.0-9]*)" }; - - private static final String VersionMegaPattern = StringUtils.join( VersionPatterns, '|' ); - - /** - * Filename Parsing Mode - Artifact Id. - */ - private static final int ARTIFACTID = 1; - - /** - * Filename Parsing Mode - Version. - */ - private static final int VERSION = 2; - - /** - * Filename Parsing Mode - Classifier. - */ - private static final int CLASSIFIER = 3; - - /** - * Split the provided filename into 4 String parts. - * - *
-     * String part[] = splitFilename( filename );
-     * artifactId = part[0];
-     * version    = part[1];
-     * classifier = part[2];
-     * extension  = part[3];
-     * 
- * - * @param filename the filename to split. - * @param possibleArtifactId the optional artifactId to aide in splitting the filename. - * (null to allow algorithm to calculate one) - * @return the parts of the filename. - * @throws LayoutException - */ - public static String[] splitFilename( String filename, String possibleArtifactId ) throws LayoutException - { - if ( StringUtils.isBlank( filename ) ) - { - throw new IllegalArgumentException( "Unable to split blank filename." ); - } - - String filestring = filename.trim(); - - String artifactId = ""; - String version = ""; - String classifier = ""; - String extension = ""; - - // I like working backwards. - - // Find the extension. - - // Work on multipart extensions first. - boolean found = false; - - String lowercaseFilename = filestring.toLowerCase(); - for ( int i = 0; i < ComplexExtensions.length && !found; i++ ) - { - if ( lowercaseFilename.endsWith( "." + ComplexExtensions[i] ) ) - { - extension = ComplexExtensions[i]; - filestring = filestring.substring( 0, filestring.length() - ComplexExtensions[i].length() - 1 ); - found = true; - } - } - - if ( !found ) - { - // Default to 1 part extension. - - int index = filestring.lastIndexOf( '.' ); - if ( index <= 0 ) - { - // Bad Filename - No Extension - throw new LayoutException( "Unable to determine extension from filename " + filename ); - } - extension = filestring.substring( index + 1 ); - filestring = filestring.substring( 0, index ); - } - - // Work on version string. - - if ( ( possibleArtifactId != null ) && filename.startsWith( possibleArtifactId ) ) - { - artifactId = possibleArtifactId; - filestring = filestring.substring( possibleArtifactId.length() + 1 ); - } - - String fileParts[] = StringUtils.split( filestring, '-' ); - - int versionStart = -1; - int versionEnd = -1; - - Pattern pat = Pattern.compile( VersionMegaPattern, Pattern.CASE_INSENSITIVE ); - Matcher mat; - - for ( int i = 0; i < fileParts.length; i++ ) - { - String part = fileParts[i]; - mat = pat.matcher( part ); - - if ( mat.matches() ) - { - // It is a potential verion part. - if ( versionStart < 0 ) - { - versionStart = i; - } - - versionEnd = i; - } - } - - if ( versionStart < 0 ) - { - throw new LayoutException( "Unable to determine version from filename " + filename ); - } - - // Gather up the ArtifactID - Version - Classifier pieces found. - - int mode = ARTIFACTID; - for ( int i = 0; i < fileParts.length; i++ ) - { - String part = fileParts[i]; - - if ( ( mode == ARTIFACTID ) && ( i >= versionStart ) ) - { - if ( StringUtils.isBlank( artifactId ) ) - { - throw new LayoutException( "No Artifact Id detected." ); - } - mode = VERSION; - } - - switch ( mode ) - { - case ARTIFACTID: - if ( artifactId.length() > 0 ) - { - artifactId += "-"; - } - artifactId += part; - break; - case VERSION: - if ( version.length() > 0 ) - { - version += "-"; - } - version += part; - break; - case CLASSIFIER: - if ( classifier.length() > 0 ) - { - classifier += "-"; - } - classifier += part; - break; - } - - if ( i >= versionEnd ) - { - mode = CLASSIFIER; - } - } - - return new String[] { artifactId, version, classifier, extension }; - } - -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java deleted file mode 100644 index 568c07c9c..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScanner.java +++ /dev/null @@ -1,197 +0,0 @@ -package org.apache.maven.archiva.repository.scanner; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.model.RepositoryContentStatistics; -import org.apache.maven.archiva.repository.ArchivaRepository; -import org.apache.maven.archiva.repository.RepositoryException; -import org.apache.maven.archiva.repository.consumer.Consumer; -import org.codehaus.plexus.util.DirectoryWalker; -import org.codehaus.plexus.util.FileUtils; - -import java.io.File; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; - -/** - * RepositoryScanner - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryScanner -{ - /** - * Standard patterns to exclude from discovery as they are usually noise. - */ - private static final String[] STANDARD_SCANNER_EXCLUDES = { - "bin/**", - "reports/**", - ".index", - ".reports/**", - ".maven/**", - "**/*snapshot-version", - "*/website/**", - "*/licences/**", - "**/.htaccess", - "**/*.html", - "**/*.txt", - "**/README*", - "**/CHANGELOG*", - "**/KEYS*" }; - - /** - * Walk the repository, and report to the consumers the files found. - * - * Report changes to the appropriate Consumer. - * - * This is just a convenience method to {@link #scan(ArtifactRepository, List, boolean, long, List, List)} - * equivalent to calling scan( repository, consumers, includeSnapshots, 0, null, null ); - * - * @param repository the repository to change. - * @param consumers use the provided list of consumers. - * @param includeSnapshots true to include snapshots in the walking of this repository. - * @return the statistics for this scan. - * @throws RepositoryException if there was a fundamental problem with getting the discoverer started. - */ - public RepositoryContentStatistics scan( ArchivaRepository repository, List consumers, boolean includeSnapshots ) - throws RepositoryException - { - return scan( repository, consumers, includeSnapshots, 0, null, null ); - } - - /** - * Walk the repository, and report to the consumers the files found. - * - * Report changes to the appropriate Consumer. - * - * @param repository the repository to change. - * @param consumers use the provided list of consumers. - * @param includeSnapshots true to include snapshots in the scanning of this repository. - * @param onlyModifiedAfterTimestamp Only report to the consumers, files that have a {@link File#lastModified()}) - * after the provided timestamp. - * @param extraFileExclusions an optional list of file exclusions on the walk. - * @param extraFileInclusions an optional list of file inclusions on the walk. - * @return the statistics for this scan. - * @throws RepositoryException if there was a fundamental problem with getting the discoverer started. - */ - public RepositoryContentStatistics scan( ArchivaRepository repository, List consumers, boolean includeSnapshots, - long onlyModifiedAfterTimestamp, List extraFileExclusions, List extraFileInclusions ) - throws RepositoryException - { - if ( repository == null ) - { - throw new IllegalArgumentException( "Unable to operate on a null repository." ); - } - - if ( !"file".equals( repository.getUrl().getProtocol() ) ) - { - throw new UnsupportedOperationException( "Only filesystem repositories are supported." ); - } - - File repositoryBase = new File( repository.getUrl().getPath() ); - - if ( !repositoryBase.exists() ) - { - throw new UnsupportedOperationException( "Unable to scan a repository, directory " - + repositoryBase.getAbsolutePath() + " does not exist." ); - } - - if ( !repositoryBase.isDirectory() ) - { - throw new UnsupportedOperationException( "Unable to scan a repository, path " - + repositoryBase.getAbsolutePath() + " is not a directory." ); - } - - // Setup Includes / Excludes. - - List allExcludes = new ArrayList(); - List allIncludes = new ArrayList(); - - // Exclude all of the SCM patterns. - allExcludes.addAll( FileUtils.getDefaultExcludesAsList() ); - - // Exclude all of the archiva noise patterns. - allExcludes.addAll( Arrays.asList( STANDARD_SCANNER_EXCLUDES ) ); - - if ( !includeSnapshots ) - { - allExcludes.add( "**/*-SNAPSHOT*" ); - } - - if ( extraFileExclusions != null ) - { - allExcludes.addAll( extraFileExclusions ); - } - - Iterator it = consumers.iterator(); - while ( it.hasNext() ) - { - Consumer consumer = (Consumer) it.next(); - - /* NOTE: Do not insert the consumer exclusion patterns here. - * Exclusion patterns are handled by RepositoryScanner.wantsFile(Consumer, String) - * - * addUniqueElements( consumer.getExcludePatterns(), allExcludes ); - */ - addUniqueElements( consumer.getIncludePatterns(), allIncludes ); - } - - if ( extraFileInclusions != null ) - { - allIncludes.addAll( extraFileInclusions ); - } - - // Setup Directory Walker - - DirectoryWalker dirWalker = new DirectoryWalker(); - - dirWalker.setBaseDir( repositoryBase ); - - dirWalker.setIncludes( allIncludes ); - dirWalker.setExcludes( allExcludes ); - - // Setup the Scan Instance - RepositoryScannerInstance scannerInstance = new RepositoryScannerInstance( repository, consumers ); - scannerInstance.setOnlyModifiedAfterTimestamp( onlyModifiedAfterTimestamp ); - - dirWalker.addDirectoryWalkListener( scannerInstance ); - - // Execute scan. - dirWalker.scan(); - - return scannerInstance.getStatistics(); - } - - private void addUniqueElements( List fromList, List toList ) - { - Iterator itFrom = fromList.iterator(); - while ( itFrom.hasNext() ) - { - Object o = itFrom.next(); - if ( !toList.contains( o ) ) - { - toList.add( o ); - } - } - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java deleted file mode 100644 index 349618273..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerInstance.java +++ /dev/null @@ -1,199 +0,0 @@ -package org.apache.maven.archiva.repository.scanner; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.SystemUtils; -import org.apache.maven.archiva.common.utils.BaseFile; -import org.apache.maven.archiva.model.RepositoryContentStatistics; -import org.apache.maven.archiva.repository.ArchivaRepository; -import org.apache.maven.archiva.repository.consumer.Consumer; -import org.codehaus.plexus.util.DirectoryWalkListener; -import org.codehaus.plexus.util.SelectorUtils; -import org.codehaus.plexus.util.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.util.Iterator; -import java.util.List; - -/** - * RepositoryScannerInstance - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryScannerInstance implements DirectoryWalkListener -{ - private static Logger log = LoggerFactory.getLogger( RepositoryScannerInstance.class ); - - private List consumers; - - private ArchivaRepository repository; - - private boolean isCaseSensitive = true; - - private RepositoryContentStatistics stats; - - private long onlyModifiedAfterTimestamp = 0; - - public RepositoryScannerInstance( ArchivaRepository repository, List consumerList ) - { - this.repository = repository; - this.consumers = consumerList; - stats = new RepositoryContentStatistics(); - stats.setRepositoryId( repository.getId() ); - - - Iterator it = this.consumers.iterator(); - while ( it.hasNext() ) - { - Consumer consumer = (Consumer) it.next(); - - if ( !consumer.init( this.repository ) ) - { - throw new IllegalStateException( "Consumer [" + consumer.getName() + - "] is reporting that it is incompatible with the [" + repository.getId() + "] repository." ); - } - } - - if ( SystemUtils.IS_OS_WINDOWS ) - { - isCaseSensitive = false; - } - } - - public RepositoryContentStatistics getStatistics() - { - return stats; - } - - public void directoryWalkStarting( File basedir ) - { - log.info( "Walk Started: [" + this.repository.getId() + "] " + this.repository.getUrl() ); - stats.triggerStart(); - } - - public void directoryWalkStep( int percentage, File file ) - { - log.debug( "Walk Step: " + percentage + ", " + file ); - - stats.increaseFileCount(); - - // Timestamp finished points to the last successful scan, not this current one. - if ( file.lastModified() < onlyModifiedAfterTimestamp ) - { - // Skip file as no change has occured. - log.debug( "Skipping, No Change: " + file.getAbsolutePath() ); - return; - } - - synchronized ( consumers ) - { - stats.increaseNewFileCount(); - - BaseFile basefile = new BaseFile( repository.getUrl().getPath(), file ); - - Iterator itConsumers = this.consumers.iterator(); - while ( itConsumers.hasNext() ) - { - Consumer consumer = (Consumer) itConsumers.next(); - - if ( wantsFile( consumer, StringUtils.replace( basefile.getRelativePath(), "\\", "/" ) ) ) - { - try - { - log.debug( "Sending to consumer: " + consumer.getName() ); - consumer.processFile( basefile ); - } - catch ( Exception e ) - { - /* Intentionally Catch all exceptions. - * So that the discoverer processing can continue. - */ - log.error( "Consumer [" + consumer.getName() + "] had an error when processing file [" + - basefile.getAbsolutePath() + "]: " + e.getMessage(), e ); - } - } - else - { - log.debug( - "Skipping consumer " + consumer.getName() + " for file " + basefile.getRelativePath() ); - } - } - } - } - - public void directoryWalkFinished() - { - log.info( "Walk Finished: [" + this.repository.getId() + "] " + this.repository.getUrl() ); - stats.triggerFinished(); - } - - private boolean wantsFile( Consumer consumer, String relativePath ) - { - Iterator it; - - // Test excludes first. - it = consumer.getExcludePatterns().iterator(); - while ( it.hasNext() ) - { - String pattern = (String) it.next(); - if ( SelectorUtils.matchPath( pattern, relativePath, isCaseSensitive ) ) - { - // Definately does NOT WANT FILE. - return false; - } - } - - // Now test includes. - it = consumer.getIncludePatterns().iterator(); - while ( it.hasNext() ) - { - String pattern = (String) it.next(); - if ( SelectorUtils.matchPath( pattern, relativePath, isCaseSensitive ) ) - { - // Specifically WANTS FILE. - return true; - } - } - - // Not included, and Not excluded? Default to EXCLUDE. - return false; - } - - public long getOnlyModifiedAfterTimestamp() - { - return onlyModifiedAfterTimestamp; - } - - public void setOnlyModifiedAfterTimestamp( long onlyModifiedAfterTimestamp ) - { - this.onlyModifiedAfterTimestamp = onlyModifiedAfterTimestamp; - } - - /** - * Debug method from DirectoryWalker. - */ - public void debug( String message ) - { - log.debug( "Repository Scanner: " + message ); - } -} diff --git a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/version/VersionUtil.java b/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/version/VersionUtil.java deleted file mode 100644 index c8ce3716f..000000000 --- a/archiva-repository-layer/src/main/java/org/apache/maven/archiva/repository/version/VersionUtil.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.apache.maven.archiva.repository.version; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * VersionConstants - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class VersionUtil -{ - public static final String SNAPSHOT = "SNAPSHOT"; - - public static final Pattern UNIQUE_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-([0-9]{8}\\.[0-9]{6})-([0-9]+)$" ); - - public static boolean isSnapshot( String version ) - { - Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version ); - if ( m.matches() ) - { - return true; - } - else - { - return version.endsWith( SNAPSHOT ); - } - } - - public static String getBaseVersion( String version ) - { - Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( version ); - if ( m.matches() ) - { - return m.group( 1 ) + "-" + SNAPSHOT; - } - else - { - return version; - } - } -} diff --git a/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml b/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml deleted file mode 100644 index c2ee003f5..000000000 --- a/archiva-repository-layer/src/main/resources/META-INF/plexus/components.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - org.codehaus.plexus.cache.Cache - repository-query - org.codehaus.plexus.cache.ehcache.EhcacheCache - EhcacheCache - - 600 - true - ${java.io.tmpdir}/ehcache/repo-query - false - 1000 - LRU - repository-query - false - 600 - 300 - - - - diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java deleted file mode 100644 index e23eb09f7..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/AllTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.archiva; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllTests - conveinence test suite for IDE users. - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AllTests -{ - - public static Test suite() - { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva" ); - //$JUnit-BEGIN$ - suite.addTest( org.apache.maven.archiva.repository.AllTests.suite() ); - suite.addTest( org.apache.maven.archiva.layer.AllTests.suite() ); - //$JUnit-END$ - return suite; - } - -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AbstractRepositoryQueryLayerTestCase.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AbstractRepositoryQueryLayerTestCase.java deleted file mode 100644 index 55f509457..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AbstractRepositoryQueryLayerTestCase.java +++ /dev/null @@ -1,116 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.artifact.Artifact; -import org.apache.maven.artifact.factory.ArtifactFactory; -import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.repository.ArtifactRepositoryFactory; -import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; -import org.codehaus.plexus.PlexusTestCase; - -import java.io.File; -import java.util.List; - -/** - * - */ -public abstract class AbstractRepositoryQueryLayerTestCase - extends PlexusTestCase -{ - private ArtifactFactory artifactFactory; - - protected ArtifactRepository repository; - - protected RepositoryQueryLayer queryLayer; - - protected void setUp() - throws Exception - { - super.setUp(); - File repositoryDirectory = getTestFile( "src/test/repositories/simple-repository" ); - - artifactFactory = (ArtifactFactory) lookup( ArtifactFactory.ROLE ); - ArtifactRepositoryFactory factory = (ArtifactRepositoryFactory) lookup( ArtifactRepositoryFactory.ROLE ); - ArtifactRepositoryLayout layout = (ArtifactRepositoryLayout) lookup( ArtifactRepositoryLayout.ROLE, "default" ); - - repository = - factory.createArtifactRepository( "test", repositoryDirectory.toURL().toString(), layout, null, null ); - } - - public void testContainsArtifactTrue() - { - Artifact artifact = getArtifact( "groupId", "artifactId", "1.0-alpha-1" ); - - assertTrue( "check artifact", queryLayer.containsArtifact( artifact ) ); - } - - public void testContainsArtifactFalse() - { - Artifact artifact = getArtifact( "groupId", "artifactId", "1.0-beta-1" ); - - assertFalse( "check non-existent artifact", queryLayer.containsArtifact( artifact ) ); - } - - public void testContainsSnapshotArtifactTrue() - { - Artifact artifact = getArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-20050611.202024-1" ); - assertTrue( "check for snapshot artifact", queryLayer.containsArtifact( artifact ) ); - } - - public void testContainsSnapshotArtifactFalse() - { - Artifact artifact = getArtifact( "groupId", "snapshot-artifact", "1.0-alpha-1-20050611.202024-2" ); - assertFalse( "check for non-existent snapshot artifact", queryLayer.containsArtifact( artifact ) ); - } - - public void testArtifactVersions() - throws Exception - { - Artifact artifact = getArtifact( "groupId", "artifactId", "ignored" ); - - List versions = queryLayer.getVersions( artifact ); - - assertTrue( "check version 1.0-alpha-1", versions.contains( "1.0-alpha-1" ) ); - assertFalse( "check version 1.0-alpha-2", versions.contains( "1.0-alpha-2" ) ); - } - - public void testArtifactVersionsError() - { - Artifact artifact = getArtifact( "groupId", "none", "ignored" ); - - try - { - queryLayer.getVersions( artifact ); - fail( "expected error not thrown" ); - } - catch ( RepositoryQueryLayerException e ) - { - //expected - } - } - - private Artifact getArtifact( String groupId, String artifactId, String version ) - { - Artifact projectArtifact = artifactFactory.createProjectArtifact( groupId, artifactId, version ); - projectArtifact.isSnapshot(); - return projectArtifact; - } -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java deleted file mode 100644 index c87f2710e..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/AllTests.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllTests - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AllTests -{ - - public static Test suite() - { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.layer" ); - //$JUnit-BEGIN$ - suite.addTestSuite( CachedRepositoryQueryLayerTest.class ); - suite.addTestSuite( DefaultRepositoryQueryLayerTest.class ); - //$JUnit-END$ - return suite; - } - -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java deleted file mode 100644 index 1451e380c..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/CachedRepositoryQueryLayerTest.java +++ /dev/null @@ -1,56 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -/** - * CachedRepositoryQueryLayerTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class CachedRepositoryQueryLayerTest - extends AbstractRepositoryQueryLayerTestCase -{ - protected void setUp() - throws Exception - { - super.setUp(); - - RepositoryQueryLayer defaultLayer = new DefaultRepositoryQueryLayer( repository ); - - queryLayer = new CachedRepositoryQueryLayer( defaultLayer ); - } - - public void testUseFileCache() - { - testContainsArtifactTrue(); - } - - public void testUseMetadataCache() - throws Exception - { - testArtifactVersions(); - } - - public void testUseFileCacheOnSnapshot() - { - testContainsSnapshotArtifactTrue(); - } -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerTest.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerTest.java deleted file mode 100644 index 4a50f8c66..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/layer/DefaultRepositoryQueryLayerTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.apache.maven.archiva.layer; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -public class DefaultRepositoryQueryLayerTest - extends AbstractRepositoryQueryLayerTestCase -{ - protected void setUp() - throws Exception - { - super.setUp(); - - queryLayer = new DefaultRepositoryQueryLayer( repository ); - } -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java deleted file mode 100644 index e25a55e80..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/AllTests.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.apache.maven.archiva.repository; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.Test; -import junit.framework.TestSuite; - -/** - * AllTests - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AllTests -{ - - public static Test suite() - { - TestSuite suite = new TestSuite( "Test for org.apache.maven.archiva.repository" ); - //$JUnit-BEGIN$ - suite.addTestSuite( RepositoryURLTest.class ); - //$JUnit-END$ - return suite; - } - -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/RepositoryURLTest.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/RepositoryURLTest.java deleted file mode 100644 index c91eef8c8..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/RepositoryURLTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.apache.maven.archiva.repository; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - - -import java.net.MalformedURLException; - -import junit.framework.TestCase; - -/** - * RepositoryURLTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryURLTest - extends TestCase -{ - private void assertURL( String actualURL, String protocol, String username, String password, String hostname, - String port, String path ) - { - RepositoryURL url = new RepositoryURL( actualURL ); - - assertEquals( protocol, url.getProtocol() ); - assertEquals( username, url.getUsername() ); - assertEquals( password, url.getPassword() ); - assertEquals( hostname, url.getHost() ); - assertEquals( port, url.getPort() ); - assertEquals( path, url.getPath() ); - } - - public void testProtocolHttp() - throws MalformedURLException - { - assertURL( "http://localhost/path/to/resource.txt", "http", null, null, "localhost", null, - "/path/to/resource.txt" ); - } - - public void testProtocolWagonWebdav() - throws MalformedURLException - { - assertURL( "dav:http://localhost/path/to/resource.txt", "dav:http", null, null, "localhost", null, - "/path/to/resource.txt" ); - } - - public void testProtocolHttpWithPort() - throws MalformedURLException - { - assertURL( "http://localhost:9090/path/to/resource.txt", "http", null, null, "localhost", "9090", - "/path/to/resource.txt" ); - } - - public void testProtocolHttpWithUsername() - throws MalformedURLException - { - assertURL( "http://user@localhost/path/to/resource.txt", "http", "user", null, "localhost", null, - "/path/to/resource.txt" ); - } - - public void testProtocolHttpWithUsernamePassword() - throws MalformedURLException - { - assertURL( "http://user:pass@localhost/path/to/resource.txt", "http", "user", "pass", "localhost", null, - "/path/to/resource.txt" ); - } - - public void testProtocolHttpWithUsernamePasswordPort() - throws MalformedURLException - { - assertURL( "http://user:pass@localhost:9090/path/to/resource.txt", "http", "user", "pass", "localhost", "9090", - "/path/to/resource.txt" ); - } -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/AbstractBidirectionalRepositoryLayoutTestCase.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/AbstractBidirectionalRepositoryLayoutTestCase.java deleted file mode 100644 index b15685a3b..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/AbstractBidirectionalRepositoryLayoutTestCase.java +++ /dev/null @@ -1,100 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.repository.ArchivaArtifact; -import org.apache.maven.archiva.repository.ArchivaRepository; -import org.codehaus.plexus.PlexusTestCase; - -import java.io.File; - -/** - * AbstractBidirectionalRepositoryLayoutTestCase - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class AbstractBidirectionalRepositoryLayoutTestCase extends PlexusTestCase -{ - protected ArchivaRepository repository; - - protected void setUp() throws Exception - { - super.setUp(); - - repository = createTestRepository(); - } - - protected ArchivaRepository createTestRepository() - { - File targetDir = new File( getBasedir(), "target" ); - File testRepo = new File( targetDir, "test-repo" ); - - if ( !testRepo.exists() ) - { - testRepo.mkdirs(); - } - - String repoUri = "file://" + StringUtils.replace( testRepo.getAbsolutePath(), "\\", "/" ); - - ArchivaRepository repo = new ArchivaRepository( "testRepo", "Test Repository", repoUri ); - - return repo; - } - - protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String classifier, - String type ) - { - ArchivaArtifact artifact = new ArchivaArtifact( repository, groupId, artifactId, version, classifier, type ); - assertNotNull( artifact ); - return artifact; - } - - protected void assertArtifact( ArchivaArtifact actualArtifact, String groupId, String artifactId, String version, - String classifier, String type ) - { - String expectedId = groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type; - - assertNotNull( expectedId + " - Should not be null.", actualArtifact ); - - assertEquals( expectedId + " - Group ID", actualArtifact.getGroupId(), groupId ); - assertEquals( expectedId + " - Artifact ID", actualArtifact.getArtifactId(), artifactId ); - assertEquals( expectedId + " - Version ID", actualArtifact.getVersion(), version ); - assertEquals( expectedId + " - Classifier", actualArtifact.getClassifier(), classifier ); - assertEquals( expectedId + " - Type", actualArtifact.getType(), type ); - } - - protected void assertSnapshotArtifact( ArchivaArtifact actualArtifact, String groupId, String artifactId, - String version, String classifier, String type ) - { - String expectedId = groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type; - - assertNotNull( expectedId + " - Should not be null.", actualArtifact ); - - assertEquals( expectedId + " - Group ID", actualArtifact.getGroupId(), groupId ); - assertEquals( expectedId + " - Artifact ID", actualArtifact.getArtifactId(), artifactId ); - assertEquals( expectedId + " - Version ID", actualArtifact.getVersion(), version ); - assertEquals( expectedId + " - Classifier", actualArtifact.getClassifier(), classifier ); - assertEquals( expectedId + " - Type", actualArtifact.getType(), type ); - assertTrue( expectedId + " - Snapshot", actualArtifact.isSnapshot() ); - } - -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java deleted file mode 100644 index 249104a7f..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/DefaultBidirectionalRepositoryLayoutTest.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.repository.ArchivaArtifact; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; -import org.apache.maven.archiva.repository.layout.LayoutException; - -/** - * DefaultBidirectionalRepositoryLayoutTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class DefaultBidirectionalRepositoryLayoutTest extends AbstractBidirectionalRepositoryLayoutTestCase -{ - private BidirectionalRepositoryLayout layout; - - protected void setUp() throws Exception - { - super.setUp(); - - layout = (BidirectionalRepositoryLayout) lookup( BidirectionalRepositoryLayout.class.getName(), "default" ); - } - - public void testToPathBasic() - { - ArchivaArtifact artifact = createArtifact( "com.foo", "foo-tool", "1.0", "", "jar" ); - - assertEquals( "com/foo/foo-tool/1.0/foo-tool-1.0.jar", layout.pathOf( artifact ) ); - } - - public void testToPathEjbClient() - { - ArchivaArtifact artifact = createArtifact( "com.foo", "foo-client", "1.0", "", "ejb-client" ); - - assertEquals( "com/foo/foo-client/1.0/foo-client-1.0.jar", layout.pathOf( artifact ) ); - } - - public void testToPathWithClassifier() - { - ArchivaArtifact artifact = createArtifact( "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "java-source" ); - - assertEquals( "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar", layout.pathOf( artifact ) ); - } - - public void testToPathUsingUniqueSnapshot() - { - ArchivaArtifact artifact = createArtifact( "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" ); - - assertEquals( "com/foo/foo-connector/2.1-SNAPSHOT/foo-connector-2.1-20060822.123456-35.jar", - layout.pathOf( artifact ) ); - } - - public void testToArtifactBasicSimpleGroupId() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "commons-lang/commons-lang/2.1/commons-lang-2.1.jar" ); - assertArtifact( artifact, "commons-lang", "commons-lang", "2.1", "", "jar" ); - } - - public void testToArtifactBasicLongGroupId() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "com/foo/foo-tool/1.0/foo-tool-1.0.jar" ); - assertArtifact( artifact, "com.foo", "foo-tool", "1.0", "", "jar" ); - } - - public void testToArtifactEjbClient() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "com/foo/foo-client/1.0/foo-client-1.0.jar" ); - // The type is correct. as we cannot possibly know this is an ejb client without parsing the pom - assertArtifact( artifact, "com.foo", "foo-client", "1.0", "", "jar" ); - } - - public void testToArtifactWithClassifier() throws LayoutException - { - ArchivaArtifact artifact = - layout.toArtifact( "com/foo/lib/foo-lib/2.1-alpha-1/foo-lib-2.1-alpha-1-sources.jar" ); - // The 'java-source' type is correct. You might be thinking of extension, which we are not testing here. - assertArtifact( artifact, "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "java-source" ); - } - - public void testToArtifactUsingUniqueSnapshot() throws LayoutException - { - ArchivaArtifact artifact = - layout.toArtifact( "com/foo/foo-connector/2.1-SNAPSHOT/foo-connector-2.1-20060822.123456-35.jar" ); - assertSnapshotArtifact( artifact, "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" ); - } -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayoutTest.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayoutTest.java deleted file mode 100644 index c90f3b56f..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/LegacyBidirectionalRepositoryLayoutTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.repository.ArchivaArtifact; -import org.apache.maven.archiva.repository.layout.BidirectionalRepositoryLayout; - -/** - * LegacyBidirectionalRepositoryLayoutTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class LegacyBidirectionalRepositoryLayoutTest extends AbstractBidirectionalRepositoryLayoutTestCase -{ - private BidirectionalRepositoryLayout layout; - - protected void setUp() throws Exception - { - super.setUp(); - - layout = (BidirectionalRepositoryLayout) lookup( BidirectionalRepositoryLayout.class.getName(), "legacy" ); - } - - public void testToPathBasic() - { - ArchivaArtifact artifact = createArtifact( "com.foo", "foo-tool", "1.0", "", "jar" ); - - assertEquals( "com.foo/jars/foo-tool-1.0.jar", layout.pathOf( artifact ) ); - } - - public void testToPathEjbClient() - { - ArchivaArtifact artifact = createArtifact( "com.foo", "foo-client", "1.0", "", "ejb-client" ); - - assertEquals( "com.foo/ejbs/foo-client-1.0.jar", layout.pathOf( artifact ) ); - } - - public void testToPathWithClassifier() - { - ArchivaArtifact artifact = createArtifact( "com.foo.lib", "foo-lib", "2.1-alpha-1", "sources", "jar" ); - - assertEquals( "com.foo.lib/javadoc.jars/foo-lib-2.1-alpha-1-sources.jar", layout.pathOf( artifact ) ); - } - - public void testToPathUsingUniqueSnapshot() - { - ArchivaArtifact artifact = createArtifact( "com.foo", "foo-connector", "2.1-20060822.123456-35", "", "jar" ); - - assertEquals( "com.foo/jars/foo-connector-2.1-20060822.123456-35.jar", layout.pathOf( artifact ) ); - } - - public void testToArtifactBasicSimpleGroupId() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "commons-lang/jars/commons-lang-2.1.jar" ); - assertArtifact( artifact, "commons-lang", "commons-lang", "2.1", "", "jar" ); - } - - public void testToArtifactBasicLongGroupId() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "org.apache.derby/jars/derby-10.2.2.0.jar" ); - assertArtifact( artifact, "org.apache.derby", "derby", "10.2.2.0", "", "jar" ); - } - - public void testToArtifactLongGroupId() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "org.apache.geronimo.specs/jars/geronimo-ejb_2.1_spec-1.0.1.jar" ); - assertArtifact( artifact, "org.apache.geronimo.specs", "geronimo-ejb_2.1_spec", "1.0.1", "", "jar" ); - } - - public void testToArtifactEjbClient() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "org.apache.beehive/jars/beehive-ejb-control-1.0.1.jar" ); - // The type is correct. as we cannot possibly know this is an ejb client without parsing the pom - assertArtifact( artifact, "org.apache.beehive", "beehive-ejb-control", "1.0.1", "", "jar" ); - } - - public void testToArtifactWithClassifier() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "commons-lang/jars/commons-lang-2.3-sources.jar" ); - // The 'java-source' type is correct. You might be thinking of extension, which we are not testing here. - assertArtifact( artifact, "commons-lang", "commons-lang", "2.3", "sources", "java-source" ); - } - - public void testToArtifactSnapshot() throws LayoutException - { - ArchivaArtifact artifact = layout.toArtifact( "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom" ); - assertSnapshotArtifact( artifact, "directory-clients", "ldap-clients", "0.9.1-SNAPSHOT", "", "pom" ); - } -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtilsTest.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtilsTest.java deleted file mode 100644 index 5a4e7049e..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/layout/RepositoryLayoutUtilsTest.java +++ /dev/null @@ -1,206 +0,0 @@ -package org.apache.maven.archiva.repository.layout; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import junit.framework.TestCase; - -/** - * RepositoryLayoutUtilsTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryLayoutUtilsTest extends TestCase -{ - public void testSplitFilenameBasic() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.1.jar", "commons-lang" ), "commons-lang", - "2.1", "", "jar" ); - } - - public void testSplitFilenameAlphaVersion() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.0-alpha-1.jar", "commons-lang" ), - "commons-lang", "2.0-alpha-1", "", "jar" ); - } - - public void testSplitFilenameSnapshot() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "foo-2.0-SNAPSHOT.jar", "foo" ), "foo", "2.0-SNAPSHOT", "", - "jar" ); - } - - public void testSplitFilenameUniqueSnapshot() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "fletch-2.0-20060822-123456-35.tar.gz", "fletch" ), "fletch", - "2.0-20060822-123456-35", "", "tar.gz" ); - } - - public void testSplitFilenameBasicClassifier() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.1-sources.jar", "commons-lang" ), - "commons-lang", "2.1", "sources", "jar" ); - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.1-javadoc.jar", "commons-lang" ), - "commons-lang", "2.1", "javadoc", "jar" ); - } - - public void testSplitFilenameAlphaClassifier() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.0-alpha-1-sources.jar", "commons-lang" ), - "commons-lang", "2.0-alpha-1", "sources", "jar" ); - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-2.0-alpha-1-javadoc.jar", "commons-lang" ), - "commons-lang", "2.0-alpha-1", "javadoc", "jar" ); - } - - public void testSplitFilenameSnapshotClassifier() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-3.1-SNAPSHOT-sources.jar", "commons-lang" ), - "commons-lang", "3.1-SNAPSHOT", "sources", "jar" ); - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-3.1-SNAPSHOT-javadoc.jar", "commons-lang" ), - "commons-lang", "3.1-SNAPSHOT", "javadoc", "jar" ); - } - - public void testSplitFilenameUniqueSnapshotClassifier() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-3.1-SNAPSHOT-sources.jar", "commons-lang" ), - "commons-lang", "3.1-SNAPSHOT", "sources", "jar" ); - assertSplit( RepositoryLayoutUtils.splitFilename( "commons-lang-3.1-SNAPSHOT-javadoc.jar", "commons-lang" ), - "commons-lang", "3.1-SNAPSHOT", "javadoc", "jar" ); - } - - public void testSplitFilenameApacheIncubator() throws LayoutException - { - assertSplit( RepositoryLayoutUtils.splitFilename( "cxf-common-2.0-incubator-M1.pom", null ), "cxf-common", - "2.0-incubator-M1", "", "pom" ); - assertSplit( RepositoryLayoutUtils.splitFilename( "commonj-api_r1.1-1.0-incubator-M2.jar", null ), - "commonj-api_r1.1", "1.0-incubator-M2", "", "jar" ); - } - - public void testSplitFilenameBlankInputs() - { - try - { - RepositoryLayoutUtils.splitFilename( null, null ); - fail( "Should have thrown an IllegalArgumentException." ); - } - catch ( IllegalArgumentException e ) - { - /* expected path */ - } - catch ( LayoutException e ) - { - fail( "Should have thrown an IllegalArgumentException." ); - } - - try - { - RepositoryLayoutUtils.splitFilename( "", null ); - fail( "Should have thrown an IllegalArgumentException." ); - } - catch ( IllegalArgumentException e ) - { - /* expected path */ - } - catch ( LayoutException e ) - { - fail( "Should have thrown an IllegalArgumentException." ); - } - - try - { - RepositoryLayoutUtils.splitFilename( " ", null ); - fail( "Should have thrown an IllegalArgumentException." ); - } - catch ( IllegalArgumentException e ) - { - /* expected path */ - } - catch ( LayoutException e ) - { - fail( "Should have thrown an IllegalArgumentException." ); - } - - try - { - RepositoryLayoutUtils.splitFilename( " \t \n ", null ); - fail( "Should have thrown an IllegalArgumentException." ); - } - catch ( IllegalArgumentException e ) - { - /* expected path */ - } - catch ( LayoutException e ) - { - fail( "Should have thrown an IllegalArgumentException." ); - } - } - - public void testSplitFilenameBadInputs() - { - try - { - RepositoryLayoutUtils.splitFilename( "commons-lang.jar", null ); - fail( "Should have thrown a LayoutException (No Version)." ); - } - catch ( LayoutException e ) - { - /* Expected Path */ - } - - try - { - RepositoryLayoutUtils.splitFilename( "geronimo-store", null ); - fail( "Should have thrown a LayoutException (No Extension)." ); - } - catch ( LayoutException e ) - { - /* Expected Path */ - } - - try - { - RepositoryLayoutUtils.splitFilename( "The Sixth Sick Sheiks Sixth Sheep is Sick.", null ); - fail( "Should have thrown a LayoutException (No Extension)." ); - } - catch ( LayoutException e ) - { - /* Expected Path */ - } - - try - { - RepositoryLayoutUtils.splitFilename( "1.0.jar", null ); - fail( "Should have thrown a LayoutException (No Artifact ID)." ); - } - catch ( LayoutException e ) - { - /* Expected Path */ - } - } - - private void assertSplit( String[] actualSplit, String artifactId, String version, String classifier, - String extension ) - { - assertEquals( "Split - artifactId", artifactId, actualSplit[0] ); - assertEquals( "Split - version", version, actualSplit[1] ); - assertEquals( "Split - classifier", classifier, actualSplit[2] ); - assertEquals( "Split - extension", extension, actualSplit[3] ); - } -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/CentralScannerTiming.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/CentralScannerTiming.java deleted file mode 100644 index 3c2c3a2aa..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/CentralScannerTiming.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.apache.maven.archiva.repository.scanner; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.utils.BaseFile; -import org.apache.maven.archiva.common.utils.DateUtil; -import org.apache.maven.archiva.model.RepositoryContentStatistics; -import org.apache.maven.archiva.repository.ArchivaRepository; -import org.apache.maven.archiva.repository.RepositoryException; -import org.apache.maven.archiva.repository.consumer.Consumer; -import org.apache.maven.archiva.repository.consumer.ConsumerException; - -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * CentralScannerTiming - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class CentralScannerTiming -{ - public static void main( String[] args ) - { - String pathToCentral = "/home/repo1/ibiblio"; - - ( new CentralScannerTiming() ).scanIt( pathToCentral ); - } - - public void scanIt( String path ) - { - ArchivaRepository centralRepo = new ArchivaRepository( "central", "Central Mirror", "file://" + path ); - - RepositoryScanner scanner = new RepositoryScanner(); - - List consumerList = new ArrayList(); - BasicConsumer consumer = new BasicConsumer(); - consumerList.add( consumer ); - - try - { - RepositoryContentStatistics stats = scanner.scan( centralRepo, consumerList, true ); - - SimpleDateFormat df = new SimpleDateFormat(); - System.out.println( "-------" ); - System.out.println( " Repository ID : " + stats.getRepositoryId() ); - System.out.println( " Duration : " + DateUtil.getDuration( stats.getDuration() ) ); - System.out.println( " When Gathered : " + df.format( stats.getWhenGathered() ) ); - System.out.println( " Total File Count: " + stats.getTotalFileCount() ); - System.out.println( " New File Count : " + stats.getNewFileCount() ); - } - catch ( RepositoryException e ) - { - e.printStackTrace( System.err ); - } - } - - class BasicConsumer implements Consumer - { - int count = 0; - - public List getExcludePatterns() - { - return Collections.EMPTY_LIST; - } - - public List getIncludePatterns() - { - List includes = new ArrayList(); - includes.add( "**/*.pom" ); - includes.add( "**/*.jar" ); - includes.add( "**/*.war" ); - includes.add( "**/*.ear" ); - includes.add( "**/*.sar" ); - includes.add( "**/*.car" ); - includes.add( "**/*.mar" ); -// includes.add( "**/*.sha1" ); -// includes.add( "**/*.md5" ); -// includes.add( "**/*.asc" ); - includes.add( "**/*.dtd" ); - includes.add( "**/*.tld" ); - includes.add( "**/*.gz" ); - includes.add( "**/*.bz2" ); - includes.add( "**/*.zip" ); - return includes; - } - - public String getName() - { - return "Basic No-op Consumer"; - } - - public boolean init( ArchivaRepository repository ) - { - return true; - } - - public void processFile( BaseFile file ) throws ConsumerException - { - count++; - if ( ( count % 1000 ) == 0 ) - { - System.out.println( "Files Processed: " + count ); - } - } - - public void processFileProblem( BaseFile file, String message ) - { - /* no-op */ - } - } -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java deleted file mode 100644 index 4907819f0..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/RepositoryScannerTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.apache.maven.archiva.repository.scanner; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.model.RepositoryContentStatistics; -import org.apache.maven.archiva.repository.ArchivaRepository; -import org.apache.maven.archiva.repository.RepositoryException; -import org.codehaus.plexus.PlexusTestCase; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -/** - * RepositoryScannerTest - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class RepositoryScannerTest extends PlexusTestCase -{ - private ArchivaRepository createDefaultRepository() - { - File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" ); - - assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() ); - - String repoUri = "file://" + StringUtils.replace( repoDir.getAbsolutePath(), "\\", "/" ); - - ArchivaRepository repo = new ArchivaRepository( "testDefaultRepo", "Test Default Repository", repoUri ); - - return repo; - } - - public void testDefaultRepositoryScanner() throws RepositoryException - { - ArchivaRepository repository = createDefaultRepository(); - - List consumers = new ArrayList(); - ScanConsumer consumer = new ScanConsumer(); - consumers.add( consumer ); - - RepositoryScanner scanner = new RepositoryScanner(); - boolean includeSnapshots = true; - RepositoryContentStatistics stats = scanner.scan( repository, consumers, includeSnapshots ); - - assertNotNull( "Stats should not be null.", stats ); - assertEquals( "Stats.totalFileCount", 17, stats.getTotalFileCount() ); - assertEquals( "Processed Count", 17, consumer.getProcessCount() ); - } - -} diff --git a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/ScanConsumer.java b/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/ScanConsumer.java deleted file mode 100644 index d1c8e0a10..000000000 --- a/archiva-repository-layer/src/test/java/org/apache/maven/archiva/repository/scanner/ScanConsumer.java +++ /dev/null @@ -1,82 +0,0 @@ -package org.apache.maven.archiva.repository.scanner; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.common.utils.BaseFile; -import org.apache.maven.archiva.repository.ArchivaRepository; -import org.apache.maven.archiva.repository.consumer.Consumer; -import org.apache.maven.archiva.repository.consumer.ConsumerException; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -/** - * ScanConsumer - * - * @author Joakim Erdfelt - * @version $Id$ - */ -public class ScanConsumer implements Consumer -{ - private int processCount = 0; - - public List getExcludePatterns() - { - return Collections.EMPTY_LIST; - } - - public List getIncludePatterns() - { - List includes = new ArrayList(); - includes.add( "**/*.jar" ); - return includes; - } - - public String getName() - { - return "Scan Consumer"; - } - - public boolean init( ArchivaRepository repository ) - { - return true; - } - - public void processFile( BaseFile file ) throws ConsumerException - { - this.processCount++; - } - - public void processFileProblem( BaseFile file, String message ) - { - /* do nothing */ - } - - public int getProcessCount() - { - return processCount; - } - - public void setProcessCount( int processCount ) - { - this.processCount = processCount; - } -} diff --git a/archiva-repository-layer/src/test/repositories/default-repository/CVS/Root b/archiva-repository-layer/src/test/repositories/default-repository/CVS/Root deleted file mode 100644 index 2e65f24a6..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -not a real CVS root - for testing exclusions diff --git a/archiva-repository-layer/src/test/repositories/default-repository/KEYS b/archiva-repository-layer/src/test/repositories/default-repository/KEYS deleted file mode 100644 index d3b34d5ad..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/KEYS +++ /dev/null @@ -1 +0,0 @@ -test KEYS file \ No newline at end of file diff --git a/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid-1.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar b/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-20050611.123456-1/invalid-1.0-20050611.123456-1.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0-SNAPSHOT/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-1.0b.jar b/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-1.0b.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-2.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1.0/invalid-2.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1/invalid-1 b/archiva-repository-layer/src/test/repositories/default-repository/invalid/invalid/1/invalid-1 deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/javax/maven-metadata.xml b/archiva-repository-layer/src/test/repositories/default-repository/javax/maven-metadata.xml deleted file mode 100644 index b3baf545d..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/javax/maven-metadata.xml +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - javax.sql - jdbc - 2.0 - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/jdbc-2.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml b/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml deleted file mode 100644 index caf5b6697..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/2.0/maven-metadata-repository.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - javax.sql - jdbc - 2.0 - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml b/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml deleted file mode 100644 index bb7570891..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/jdbc/maven-metadata-repository.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - javax.sql - jdbc - 2.0 - - - 2.0 - - - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml b/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml deleted file mode 100644 index caf5b6697..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/javax/sql/maven-metadata-repository.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - javax.sql - jdbc - 2.0 - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom deleted file mode 100644 index 202a0a448..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - A - 1.0 - Maven Test Repository Artifact Discovery - war - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/A/1.0/A-1.0.war +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom deleted file mode 100644 index fa5f8f6c8..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/1.0/B-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - B - 1.0 - Maven Test Repository Artifact Discovery - pom - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom deleted file mode 100644 index c3034e820..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/B/2.0/B-2.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - B - 2.0 - Maven Test Repository Artifact Discovery - pom - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom deleted file mode 100644 index ae14cd7eb..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - C - 1.0 - Maven Test Repository Artifact Discovery - war - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/C/1.0/C-1.0.war +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/discovery/1.0/discovery-1.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/discovery/1.0/discovery-1.0.pom deleted file mode 100644 index 5a29f6117..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/discovery/1.0/discovery-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.maven - discovery - 1.0 - Maven Test Repository Artifact Discovery - pom - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml deleted file mode 100644 index 8ce7fc7bb..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/maven-metadata.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - org.apache.maven - \ No newline at end of file diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom deleted file mode 100644 index 6ab57d162..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/1.0/samplejar-1.0.pom +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - org.apache.maven - C - 1.0 - Maven Test Repository Artifact Discovery - - - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom deleted file mode 100644 index a959980df..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/samplejar/2.0/samplejar-2.0.pom +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - org.apache.maven - C - 1.0 - Maven Test Repository Artifact Discovery - - jar - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/maven-metadata.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/some-ejb/1.0/some-ejb-1.0-client.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1-javadoc.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/test-1.0-20050611.112233-1.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/test/1.0-SNAPSHOT/wrong-artifactId-1.0-20050611.112233-1.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-sources.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0-test-sources.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.tar.gz deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.zip b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/testing/1.0/testing-1.0.zip deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom deleted file mode 100644 index 452727f28..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/1.0/test-not-updated-1.0.pom +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - org.apache.maven.update - test-not-updated - 1.0 - Maven Test Repository Artifact Discovery - - - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/maven-metadata.xml b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/maven-metadata.xml deleted file mode 100644 index bd56a21c1..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-not-updated/maven-metadata.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.apache.maven.update - test-not-updated - \ No newline at end of file diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom deleted file mode 100644 index edd7b6479..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/1.0/test-updated-1.0.pom +++ /dev/null @@ -1,29 +0,0 @@ - - - - 4.0.0 - org.apache.maven.update - test-updated - 1.0 - Maven Test Repository Artifact Discovery - - - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/maven-metadata.xml b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/maven-metadata.xml deleted file mode 100644 index 86e063ca8..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/maven/update/test-updated/maven-metadata.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.apache.maven.update - test-updated - \ No newline at end of file diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom deleted file mode 100644 index 12538e81a..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/discovery-1.0.pom +++ /dev/null @@ -1,28 +0,0 @@ - - - - 4.0.0 - org.apache.testgroup - discovery - 1.0 - Maven Test Repository Artifact Discovery - pom - diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml deleted file mode 100644 index 8ee18048c..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/1.0/maven-metadata.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - org.apache.testgroup - discovery - 1.0 - \ No newline at end of file diff --git a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml b/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml deleted file mode 100644 index b024ef7ef..000000000 --- a/archiva-repository-layer/src/test/repositories/default-repository/org/apache/testgroup/discovery/maven-metadata.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - org.apache.testgroup - discovery - \ No newline at end of file diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/CVS/Root b/archiva-repository-layer/src/test/repositories/legacy-repository/CVS/Root deleted file mode 100644 index 2e65f24a6..000000000 --- a/archiva-repository-layer/src/test/repositories/legacy-repository/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -not a real CVS root - for testing exclusions diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/KEYS b/archiva-repository-layer/src/test/repositories/legacy-repository/KEYS deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo b/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar b/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/invalid.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/no-extension b/archiva-repository-layer/src/test/repositories/legacy-repository/invalid/jars/no-extension deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar +++ /dev/null @@ -1 +0,0 @@ -dummy content. sample file only. diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-sources.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar b/archiva-repository-layer/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.jar b/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.jar deleted file mode 100644 index c2ea777c1..000000000 Binary files a/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.jar and /dev/null differ diff --git a/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.pom b/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.pom deleted file mode 100644 index a987f03ec..000000000 --- a/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/1.0-alpha-1/artifactId-1.0-alpha-1.pom +++ /dev/null @@ -1,25 +0,0 @@ - - - - 4.0.0 - groupId - artifactId - 1.0-alpha-1 - diff --git a/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/maven-metadata.xml b/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/maven-metadata.xml deleted file mode 100644 index 526cc825a..000000000 --- a/archiva-repository-layer/src/test/repositories/simple-repository/groupId/artifactId/maven-metadata.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - groupId - artifactId - 1.0-alpha-1 - - - 1.0-alpha-1 - - - diff --git a/archiva-repository-layer/src/test/repositories/simple-repository/groupId/snapshot-artifact/1.0-alpha-1-SNAPSHOT/snapshot-artifact-1.0-alpha-1-20050611.202024-1.pom b/archiva-repository-layer/src/test/repositories/simple-repository/groupId/snapshot-artifact/1.0-alpha-1-SNAPSHOT/snapshot-artifact-1.0-alpha-1-20050611.202024-1.pom deleted file mode 100644 index cf613e847..000000000 --- a/archiva-repository-layer/src/test/repositories/simple-repository/groupId/snapshot-artifact/1.0-alpha-1-SNAPSHOT/snapshot-artifact-1.0-alpha-1-20050611.202024-1.pom +++ /dev/null @@ -1,19 +0,0 @@ - - diff --git a/archiva-repository-layer/src/test/resources/log4j.xml b/archiva-repository-layer/src/test/resources/log4j.xml deleted file mode 100644 index 23d4d08d6..000000000 --- a/archiva-repository-layer/src/test/resources/log4j.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- cgit v1.2.3