From edbc2b762e27cee9f22a34eb25803f46dff77ab1 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 12 Feb 2015 22:27:49 +1100 Subject: [PATCH] [MRM-1359] remove maven1 code --- .../AbstractLegacyRepositoryContent.java | 129 ----- .../content/legacy/LegacyPathParser.java | 216 -------- .../ManagedLegacyRepositoryContent.java | 498 ------------------ .../legacy/RemoteLegacyRepositoryContent.java | 93 ---- .../AbstractRepositoryLayerTestCase.java | 99 ---- .../content/legacy/LegacyPathParserTest.java | 497 ----------------- .../repositories/legacy-repository/CVS/Root | 1 - .../test/repositories/legacy-repository/KEYS | 0 .../invalid/foo/invalid-1.0.foo | 0 .../legacy-repository/invalid/invalid-1.0.jar | 0 .../invalid/jars/1.0/invalid-1.0.jar | 0 .../invalid/jars/invalid-1.0.rar | 0 .../invalid/jars/invalid.jar | 0 .../invalid/jars/no-extension | 0 .../javax.sql/jars/jdbc-2.0.jar | 0 .../maven/poms/wagon-ssh-1.0.pom | 52 -- .../jars/test-not-updated-1.0.jar | 1 - .../jars/test-updated-1.0.jar | 1 - .../jars/some-ejb-1.0-client.jar | 0 .../jars/testing-1.0-20050611.112233-1.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 .../java-sources/testing-1.0-sources.jar | 0 .../javadoc.jars/testing-1.0-javadoc.jar | 0 .../poms/maven-model-v3-2.0.pom | 15 - .../org.apache.maven/poms/testing-1.0.pom | 0 28 files changed, 1602 deletions(-) delete mode 100644 archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/AbstractLegacyRepositoryContent.java delete mode 100644 archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/LegacyPathParser.java delete mode 100644 archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/ManagedLegacyRepositoryContent.java delete mode 100644 archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/RemoteLegacyRepositoryContent.java delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/legacy/LegacyPathParserTest.java delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/CVS/Root delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/KEYS delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/invalid.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/no-extension delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/maven/poms/wagon-ssh-1.0.pom delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/java-sources/testing-1.0-sources.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/javadoc.jars/testing-1.0-javadoc.jar delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/poms/maven-model-v3-2.0.pom delete mode 100644 archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/poms/testing-1.0.pom diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/AbstractLegacyRepositoryContent.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/AbstractLegacyRepositoryContent.java deleted file mode 100644 index 6c7f239c8..000000000 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/AbstractLegacyRepositoryContent.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.apache.archiva.repository.content.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.archiva.model.ArchivaArtifact; -import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.repository.content.PathParser; -import org.apache.archiva.repository.content.maven2.ArtifactExtensionMapping; -import org.apache.archiva.repository.layout.LayoutException; -import org.apache.commons.lang.StringUtils; - -import javax.inject.Inject; -import javax.inject.Named; -import java.util.HashMap; -import java.util.Map; - -/** - * AbstractLegacyRepositoryContent - * - * - */ -public abstract class AbstractLegacyRepositoryContent -{ - private static final String PATH_SEPARATOR = "/"; - - private static final Map typeToDirectoryMap; - - static - { - typeToDirectoryMap = new HashMap<>( 5 ); - typeToDirectoryMap.put( "ejb-client", "ejb" ); - typeToDirectoryMap.put( ArtifactExtensionMapping.MAVEN_ONE_PLUGIN, "plugin" ); - typeToDirectoryMap.put( "distribution-tgz", "distribution" ); - typeToDirectoryMap.put( "distribution-zip", "distribution" ); - typeToDirectoryMap.put( "javadoc", "javadoc.jar" ); - } - - /** - * - */ - @Inject - @Named( "pathParser#legacy" ) - private PathParser legacyPathParser; - - public ArtifactReference toArtifactReference( String path ) - throws LayoutException - { - return legacyPathParser.toArtifactReference( path ); - } - - public String toPath( ArchivaArtifact reference ) - { - if ( reference == null ) - { - throw new IllegalArgumentException( "Artifact reference cannot be null" ); - } - - return toPath( reference.getGroupId(), reference.getArtifactId(), reference.getVersion(), - reference.getClassifier(), reference.getType() ); - } - - public String toPath( ArtifactReference reference ) - { - if ( reference == null ) - { - throw new IllegalArgumentException( "Artifact reference cannot be null" ); - } - - return toPath( reference.getGroupId(), reference.getArtifactId(), reference.getVersion(), - reference.getClassifier(), reference.getType() ); - } - - private String toPath( String groupId, String artifactId, String version, String classifier, String type ) - { - StringBuilder path = new StringBuilder(); - - path.append( groupId ).append( PATH_SEPARATOR ); - path.append( getDirectory( type ) ).append( PATH_SEPARATOR ); - - if ( version != null ) - { - path.append( artifactId ).append( '-' ).append( version ); - - if ( StringUtils.isNotBlank( classifier ) ) - { - path.append( '-' ).append( classifier ); - } - - path.append( '.' ).append( ArtifactExtensionMapping.getExtension( type ) ); - } - - return path.toString(); - } - - private String getDirectory( String type ) - { - String dirname = typeToDirectoryMap.get( type ); - - if ( dirname != null ) - { - return dirname + "s"; - } - - // Default process. - return type + "s"; - } - - public void setLegacyPathParser( PathParser parser ) - { - this.legacyPathParser = parser; - } -} diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/LegacyPathParser.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/LegacyPathParser.java deleted file mode 100644 index dc580c8dd..000000000 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/LegacyPathParser.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.apache.archiva.repository.content.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.archiva.configuration.ArchivaConfiguration; -import org.apache.archiva.configuration.LegacyArtifactPath; -import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.repository.content.ArtifactClassifierMapping; -import org.apache.archiva.repository.content.PathParser; -import org.apache.archiva.repository.content.maven2.ArtifactExtensionMapping; -import org.apache.archiva.repository.content.maven2.FilenameParser; -import org.apache.archiva.repository.layout.LayoutException; -import org.apache.commons.lang.StringUtils; - -import java.util.Collection; - -/** - * LegacyPathParser is a parser for maven 1 (legacy layout) paths to - * ArtifactReference. - * - * - */ -public class LegacyPathParser - implements PathParser -{ - private static final String INVALID_ARTIFACT_PATH = "Invalid path to Artifact: "; - - protected ArchivaConfiguration configuration; - - public LegacyPathParser( ArchivaConfiguration configuration ) - { - this.configuration = configuration; - } - - - /** - * {@inheritDoc} - * - * @see org.apache.archiva.repository.content.PathParser#toArtifactReference(String) - */ - @Override - public ArtifactReference toArtifactReference( String path ) - throws LayoutException - { - ArtifactReference artifact = new ArtifactReference(); - - // First, look if a custom resolution rule has been set for this artifact - Collection legacy = configuration.getConfiguration().getLegacyArtifactPaths(); - for ( LegacyArtifactPath legacyPath : legacy ) - { - if ( legacyPath.match( path ) ) - { - artifact.setGroupId( legacyPath.getGroupId() ); - artifact.setArtifactId( legacyPath.getArtifactId() ); - artifact.setClassifier( legacyPath.getClassifier() ); - artifact.setVersion( legacyPath.getVersion() ); - artifact.setType( legacyPath.getType() ); - return artifact; - } - } - - 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_ARTIFACT_PATH - + "legacy paths should only have 3 parts [groupId]/[type]s/[artifactId]-[version].[type], found " - + pathParts.length + " instead." ); - } - - // The Group ID. - artifact.setGroupId( pathParts[0] ); - - // The Expected Type. - String expectedType = pathParts[1]; - - // Sanity Check: expectedType should end in "s". - if ( !expectedType.endsWith( "s" ) ) - { - throw new LayoutException( INVALID_ARTIFACT_PATH - + "legacy paths should have an expected type ending in [s] in the second part of the path." ); - } - - // The Filename. - String filename = pathParts[2]; - - FilenameParser parser = new FilenameParser( filename ); - - artifact.setArtifactId( parser.nextNonVersion() ); - - // Sanity Check: does it have an artifact id? - if ( StringUtils.isEmpty( artifact.getArtifactId() ) ) - { - // Special Case: The filename might start with a version id (like "test-arch-1.0.jar"). - int idx = filename.indexOf( '-' ); - if ( idx > 0 ) - { - parser.reset(); - // Take the first section regardless of content. - String artifactId = parser.next(); - - // Is there anything more that is considered not a version id? - String moreArtifactId = parser.nextNonVersion(); - if ( StringUtils.isNotBlank( moreArtifactId ) ) - { - artifact.setArtifactId( artifactId + "-" + moreArtifactId ); - } - else - { - artifact.setArtifactId( artifactId ); - } - } - - // Sanity Check: still no artifact id? - if ( StringUtils.isEmpty( artifact.getArtifactId() ) ) - { - throw new LayoutException( INVALID_ARTIFACT_PATH + "no artifact id present." ); - } - } - - artifact.setVersion( parser.remaining() ); - - // Sanity Check: does it have a version? - if ( StringUtils.isEmpty( artifact.getVersion() ) ) - { - // Special Case: use last section of artifactId as version. - String artifactId = artifact.getArtifactId(); - int idx = artifactId.lastIndexOf( '-' ); - if ( idx > 0 ) - { - artifact.setVersion( artifactId.substring( idx + 1 ) ); - artifact.setArtifactId( artifactId.substring( 0, idx ) ); - } - else - { - throw new LayoutException( INVALID_ARTIFACT_PATH + "no version found." ); - } - } - - String classifier = ArtifactClassifierMapping.getClassifier( expectedType ); - if ( classifier != null ) - { - String version = artifact.getVersion(); - if ( !version.endsWith( "-" + classifier ) ) - { - throw new LayoutException( - INVALID_ARTIFACT_PATH + expectedType + " artifacts must use the classifier " + classifier ); - } - version = version.substring( 0, version.length() - classifier.length() - 1 ); - artifact.setVersion( version ); - artifact.setClassifier( classifier ); - } - - String extension = parser.getExtension(); - - // Set Type - String defaultExtension = expectedType.substring( 0, expectedType.length() - 1 ); - artifact.setType( - ArtifactExtensionMapping.mapExtensionAndClassifierToType( classifier, extension, defaultExtension ) ); - - // Sanity Check: does it have an extension? - if ( StringUtils.isEmpty( artifact.getType() ) ) - { - throw new LayoutException( INVALID_ARTIFACT_PATH + "no extension found." ); - } - - // Special Case with Maven Plugins - if ( StringUtils.equals( "jar", extension ) && StringUtils.equals( "plugins", expectedType ) ) - { - artifact.setType( ArtifactExtensionMapping.MAVEN_ONE_PLUGIN ); - } - else - { - // Sanity Check: does extension match pathType on path? - String expectedExtension = ArtifactExtensionMapping.getExtension( artifact.getType() ); - - if ( !expectedExtension.equals( extension ) ) - { - throw new LayoutException( - INVALID_ARTIFACT_PATH + "mismatch on extension [" + extension + "] and layout specified type [" - + artifact.getType() + "] (which maps to extension: [" + expectedExtension + "]) on path [" - + path + "]" ); - } - } - - return artifact; - } -} diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/ManagedLegacyRepositoryContent.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/ManagedLegacyRepositoryContent.java deleted file mode 100644 index b6a06be95..000000000 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/ManagedLegacyRepositoryContent.java +++ /dev/null @@ -1,498 +0,0 @@ -package org.apache.archiva.repository.content.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.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.common.utils.PathUtil; -import org.apache.archiva.configuration.FileTypes; -import org.apache.archiva.model.ArchivaArtifact; -import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.model.ProjectReference; -import org.apache.archiva.model.VersionedReference; -import org.apache.archiva.repository.ContentNotFoundException; -import org.apache.archiva.repository.ManagedRepositoryContent; -import org.apache.archiva.repository.RepositoryException; -import org.apache.archiva.repository.layout.LayoutException; -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.lang.StringUtils; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Service; - -import javax.inject.Inject; -import java.io.File; -import java.util.HashSet; -import java.util.Set; - -/** - * ManagedLegacyRepositoryContent - * - * - * TODO no need to be a component when filetypes, legacy path parser is not - */ -@Service( "managedRepositoryContent#legacy" ) -@Scope( "prototype" ) -public class ManagedLegacyRepositoryContent - extends AbstractLegacyRepositoryContent - implements ManagedRepositoryContent -{ - /** - * - */ - @Inject - private FileTypes filetypes; - - private ManagedRepository repository; - - @Override - public void deleteVersion( VersionedReference reference ) - throws ContentNotFoundException - { - File groupDir = new File( repository.getLocation(), reference.getGroupId() ); - - if ( !groupDir.exists() ) - { - throw new ContentNotFoundException( - "Unable to get versions using a non-existant groupId directory: " + groupDir.getAbsolutePath() ); - } - - if ( !groupDir.isDirectory() ) - { - throw new ContentNotFoundException( - "Unable to get versions using a non-directory: " + groupDir.getAbsolutePath() ); - } - - // First gather up the versions found as artifacts in the managed repository. - File typeDirs[] = groupDir.listFiles(); - for ( File typeDir : typeDirs ) - { - if ( !typeDir.isDirectory() ) - { - // Skip it, we only care about directories. - continue; - } - - if ( !typeDir.getName().endsWith( "s" ) ) - { - // Skip it, we only care about directories that end in "s". - } - - deleteVersions( typeDir, reference ); - } - } - - private void deleteVersions( File typeDir, VersionedReference reference ) - { - File repoFiles[] = typeDir.listFiles(); - for ( File repoFile : repoFiles ) - { - if ( repoFile.isDirectory() ) - { - // Skip it. it's a directory. - continue; - } - - String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile ); - - if ( filetypes.matchesArtifactPattern( relativePath ) ) - { - try - { - ArtifactReference artifact = toArtifactReference( relativePath ); - if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) - && StringUtils.equals( artifact.getVersion(), reference.getVersion() ) ) - { - repoFile.delete(); - deleteSupportFiles( repoFile ); - } - } - catch ( LayoutException e ) - { - /* don't fail the process if there is a bad artifact within the directory. */ - } - } - } - } - - @Override - public void deleteProject( String namespace, String projectId ) - throws RepositoryException - { - // TODO implements ?? - } - - private void deleteSupportFiles( File repoFile ) - { - deleteSupportFile( repoFile, ".sha1" ); - deleteSupportFile( repoFile, ".md5" ); - deleteSupportFile( repoFile, ".asc" ); - deleteSupportFile( repoFile, ".gpg" ); - } - - private void deleteSupportFile( File repoFile, String supportExtension ) - { - File supportFile = new File( repoFile.getAbsolutePath() + supportExtension ); - if ( supportFile.exists() && supportFile.isFile() ) - { - supportFile.delete(); - } - } - - @Override - public String getId() - { - return repository.getId(); - } - - @Override - public Set getRelatedArtifacts( ArtifactReference reference ) - throws ContentNotFoundException - { - File artifactFile = toFile( reference ); - File repoDir = artifactFile.getParentFile(); - - if ( !repoDir.exists() ) - { - throw new ContentNotFoundException( - "Unable to get related artifacts using a non-existant directory: " + repoDir.getAbsolutePath() ); - } - - if ( !repoDir.isDirectory() ) - { - throw new ContentNotFoundException( - "Unable to get related artifacts using a non-directory: " + repoDir.getAbsolutePath() ); - } - - Set foundArtifacts = new HashSet(); - - // First gather up the versions found as artifacts in the managed repository. - File projectParentDir = repoDir.getParentFile(); - File typeDirs[] = projectParentDir.listFiles(); - for ( File typeDir : typeDirs ) - { - if ( !typeDir.isDirectory() ) - { - // Skip it, we only care about directories. - continue; - } - - if ( !typeDir.getName().endsWith( "s" ) ) - { - // Skip it, we only care about directories that end in "s". - } - - getRelatedArtifacts( typeDir, reference, foundArtifacts ); - } - - return foundArtifacts; - } - - @Override - public String getRepoRoot() - { - return repository.getLocation(); - } - - @Override - public ManagedRepository getRepository() - { - return repository; - } - - @Override - public Set getVersions( ProjectReference reference ) - throws ContentNotFoundException - { - File groupDir = new File( repository.getLocation(), reference.getGroupId() ); - - if ( !groupDir.exists() ) - { - throw new ContentNotFoundException( - "Unable to get versions using a non-existant groupId directory: " + groupDir.getAbsolutePath() ); - } - - if ( !groupDir.isDirectory() ) - { - throw new ContentNotFoundException( - "Unable to get versions using a non-directory: " + groupDir.getAbsolutePath() ); - } - - Set foundVersions = new HashSet(); - - // First gather up the versions found as artifacts in the managed repository. - File typeDirs[] = groupDir.listFiles(); - for ( File typeDir : typeDirs ) - { - if ( !typeDir.isDirectory() ) - { - // Skip it, we only care about directories. - continue; - } - - if ( !typeDir.getName().endsWith( "s" ) ) - { - // Skip it, we only care about directories that end in "s". - } - - getProjectVersions( typeDir, reference, foundVersions ); - } - - return foundVersions; - } - - @Override - public Set getVersions( VersionedReference reference ) - throws ContentNotFoundException - { - File groupDir = new File( repository.getLocation(), reference.getGroupId() ); - - if ( !groupDir.exists() ) - { - throw new ContentNotFoundException( - "Unable to get versions using a non-existant groupId directory: " + groupDir.getAbsolutePath() ); - } - - if ( !groupDir.isDirectory() ) - { - throw new ContentNotFoundException( - "Unable to get versions using a non-directory: " + groupDir.getAbsolutePath() ); - } - - Set foundVersions = new HashSet(); - - // First gather up the versions found as artifacts in the managed repository. - File typeDirs[] = groupDir.listFiles(); - for ( File typeDir : typeDirs ) - { - if ( !typeDir.isDirectory() ) - { - // Skip it, we only care about directories. - continue; - } - - if ( !typeDir.getName().endsWith( "s" ) ) - { - // Skip it, we only care about directories that end in "s". - } - - getVersionedVersions( typeDir, reference, foundVersions ); - } - - return foundVersions; - } - - @Override - public boolean hasContent( ArtifactReference reference ) - { - File artifactFile = toFile( reference ); - return artifactFile.exists() && artifactFile.isFile(); - } - - @Override - public boolean hasContent( ProjectReference reference ) - { - try - { - Set versions = getVersions( reference ); - return CollectionUtils.isNotEmpty( versions ); - } - catch ( ContentNotFoundException e ) - { - return false; - } - } - - @Override - public boolean hasContent( VersionedReference reference ) - { - try - { - Set versions = getVersions( reference ); - return CollectionUtils.isNotEmpty( versions ); - } - catch ( ContentNotFoundException e ) - { - return false; - } - } - - @Override - public void setRepository( ManagedRepository repository ) - { - this.repository = repository; - } - - /** - * Convert a path to an artifact reference. - * - * @param path the path to convert. (relative or full location path) - * @throws org.apache.archiva.repository.layout.LayoutException if the path cannot be converted to an artifact reference. - */ - @Override - public ArtifactReference toArtifactReference( String path ) - throws LayoutException - { - if ( ( path != null ) && path.startsWith( repository.getLocation() ) ) - { - return super.toArtifactReference( path.substring( repository.getLocation().length() ) ); - } - - return super.toArtifactReference( path ); - } - - @Override - public File toFile( ArchivaArtifact reference ) - { - return new File( repository.getLocation(), toPath( reference ) ); - } - - @Override - public File toFile( ArtifactReference reference ) - { - return new File( repository.getLocation(), toPath( reference ) ); - } - - @Override - public String toMetadataPath( ProjectReference reference ) - { - // No metadata present in legacy repository. - return null; - } - - @Override - public String toMetadataPath( VersionedReference reference ) - { - // No metadata present in legacy repository. - return null; - } - - private void getProjectVersions( File typeDir, ProjectReference reference, Set foundVersions ) - { - File repoFiles[] = typeDir.listFiles(); - for ( File repoFile : repoFiles ) - { - if ( repoFile.isDirectory() ) - { - // Skip it. it's a directory. - continue; - } - - String relativePath = PathUtil.getRelative( repository.getLocation(), repoFile ); - - if ( filetypes.matchesArtifactPattern( relativePath ) ) - { - try - { - ArtifactReference artifact = toArtifactReference( relativePath ); - if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) ) - { - foundVersions.add( artifact.getVersion() ); - } - } - catch ( LayoutException e ) - { - /* don't fail the process if there is a bad artifact within the directory. */ - } - } - } - } - - private void getRelatedArtifacts( File typeDir, ArtifactReference reference, Set foundArtifacts ) - { - File repoFiles[] = typeDir.listFiles(); - for ( int i = 0; i < repoFiles.length; i++ ) - { - if ( repoFiles[i].isDirectory() ) - { - // Skip it. it's a directory. - continue; - } - - String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] ); - - if ( filetypes.matchesArtifactPattern( relativePath ) ) - { - try - { - ArtifactReference artifact = toArtifactReference( relativePath ); - if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) - && artifact.getVersion().startsWith( reference.getVersion() ) ) - { - foundArtifacts.add( artifact ); - } - } - catch ( LayoutException e ) - { - /* don't fail the process if there is a bad artifact within the directory. */ - } - } - } - } - - private void getVersionedVersions( File typeDir, VersionedReference reference, Set foundVersions ) - { - File repoFiles[] = typeDir.listFiles(); - for ( int i = 0; i < repoFiles.length; i++ ) - { - if ( repoFiles[i].isDirectory() ) - { - // Skip it. it's a directory. - continue; - } - - String relativePath = PathUtil.getRelative( repository.getLocation(), repoFiles[i] ); - - if ( filetypes.matchesArtifactPattern( relativePath ) ) - { - try - { - ArtifactReference artifact = toArtifactReference( relativePath ); - if ( StringUtils.equals( artifact.getArtifactId(), reference.getArtifactId() ) - && artifact.getVersion().startsWith( reference.getVersion() ) ) - { - foundVersions.add( artifact.getVersion() ); - } - } - catch ( LayoutException e ) - { - /* don't fail the process if there is a bad artifact within the directory. */ - } - } - } - } - - public void setFileTypes( FileTypes fileTypes ) - { - this.filetypes = fileTypes; - } - - @Override - public void deleteArtifact( ArtifactReference artifactReference ) - throws ContentNotFoundException - { - // TODO implements for legacy ?? - } - - @Override - public void deleteGroupId( String groupId ) - throws ContentNotFoundException - { - // TODO implements for legacy ?? - } -} diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/RemoteLegacyRepositoryContent.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/RemoteLegacyRepositoryContent.java deleted file mode 100644 index 7a7d3f3eb..000000000 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/repository/content/legacy/RemoteLegacyRepositoryContent.java +++ /dev/null @@ -1,93 +0,0 @@ -package org.apache.archiva.repository.content.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.archiva.admin.model.beans.RemoteRepository; -import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.model.RepositoryURL; -import org.apache.archiva.repository.RemoteRepositoryContent; -import org.apache.archiva.repository.content.legacy.AbstractLegacyRepositoryContent; -import org.apache.archiva.repository.layout.LayoutException; -import org.springframework.context.annotation.Scope; -import org.springframework.stereotype.Service; - -/** - * RemoteLegacyRepositoryContent - * - * - * TODO no need to be a component once legacy path parser is not - */ -@Service( "remoteRepositoryContent#legacy" ) -@Scope( "prototype" ) -public class RemoteLegacyRepositoryContent - extends AbstractLegacyRepositoryContent - implements RemoteRepositoryContent -{ - private RemoteRepository repository; - - @Override - public String getId() - { - return repository.getId(); - } - - @Override - public RemoteRepository getRepository() - { - return repository; - } - - @Override - public RepositoryURL getURL() - { - return new RepositoryURL( repository.getUrl() ); - } - - @Override - public void setRepository( RemoteRepository repository ) - { - this.repository = repository; - } - - /** - * Convert a path to an artifact reference. - * - * @param path the path to convert. (relative or full url path) - * @throws org.apache.archiva.repository.layout.LayoutException if the path cannot be converted to an artifact reference. - */ - @Override - public ArtifactReference toArtifactReference( String path ) - throws LayoutException - { - if ( path.startsWith( repository.getUrl() ) ) - { - return super.toArtifactReference( path.substring( repository.getUrl().length() ) ); - } - - return super.toArtifactReference( path ); - } - - @Override - public RepositoryURL toURL( ArtifactReference reference ) - { - String url = repository.getUrl() + toPath( reference ); - return new RepositoryURL( url ); - } -} diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java deleted file mode 100644 index 94bfe47a0..000000000 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/AbstractRepositoryLayerTestCase.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.apache.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.archiva.admin.model.beans.ManagedRepository; -import org.apache.archiva.admin.model.beans.RemoteRepository; -import org.junit.Rule; -import org.junit.rules.TestName; -import org.junit.runner.RunWith; -import org.springframework.context.ApplicationContext; -import org.springframework.test.context.ContextConfiguration; - -import java.io.File; -import javax.inject.Inject; -import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; - -/** - * AbstractRepositoryLayerTestCase - * - * - */ -@RunWith( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) -public abstract class AbstractRepositoryLayerTestCase -{ - @Rule - public TestName name = new TestName(); - - @Inject - protected ApplicationContext applicationContext; - - protected ManagedRepository createRepository( String id, String name, File location ) - { - ManagedRepository repo = new ManagedRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setLocation( location.getAbsolutePath() ); - return repo; - } - - protected RemoteRepository createRemoteRepository( String id, String name, String url ) - { - RemoteRepository repo = new RemoteRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setUrl( url ); - return repo; - } - - protected ManagedRepositoryContent createManagedRepositoryContent( String id, String name, File location, - String layout ) - throws Exception - { - ManagedRepository repo = new ManagedRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setLocation( location.getAbsolutePath() ); - repo.setLayout( layout ); - - ManagedRepositoryContent repoContent = - applicationContext.getBean( "managedRepositoryContent#" + layout, ManagedRepositoryContent.class ); - repoContent.setRepository( repo ); - - return repoContent; - } - - protected RemoteRepositoryContent createRemoteRepositoryContent( String id, String name, String url, String layout ) - throws Exception - { - RemoteRepository repo = new RemoteRepository(); - repo.setId( id ); - repo.setName( name ); - repo.setUrl( url ); - repo.setLayout( layout ); - - RemoteRepositoryContent repoContent = - applicationContext.getBean( "remoteRepositoryContent#" + layout, RemoteRepositoryContent.class ); - repoContent.setRepository( repo ); - - return repoContent; - } -} diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/legacy/LegacyPathParserTest.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/legacy/LegacyPathParserTest.java deleted file mode 100644 index 4b3eb5da1..000000000 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/repository/content/legacy/LegacyPathParserTest.java +++ /dev/null @@ -1,497 +0,0 @@ -package org.apache.archiva.repository.content.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.archiva.configuration.ArchivaConfiguration; -import org.apache.archiva.configuration.LegacyArtifactPath; -import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.repository.layout.LayoutException; -import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.test.context.ContextConfiguration; - -import javax.inject.Inject; -import javax.inject.Named; - -import static org.junit.Assert.*; - -/** - * LegacyPathParserTest - * - * - */ -@RunWith ( ArchivaSpringJUnit4ClassRunner.class ) -@ContextConfiguration ( { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context-no-mock-conf.xml" } ) -public class LegacyPathParserTest -{ - private LegacyPathParser parser; - - @Inject - @Named( "archivaConfiguration#default" ) - ArchivaConfiguration config; - - /** - * Configure the ArchivaConfiguration - * {@inheritDoc} - */ - @Before - public void setUp() - throws Exception - { - parser = new LegacyPathParser( config ); - LegacyArtifactPath jaxen = new LegacyArtifactPath(); - jaxen.setPath( "jaxen/jars/jaxen-1.0-FCS-full.jar" ); - jaxen.setArtifact( "jaxen:jaxen:1.0-FCS:full:jar" ); - config.getConfiguration().addLegacyArtifactPath( jaxen ); - parser.configuration = config; - } - - @Test - public void testBadPathArtifactIdMissingA() - { - assertBadPath( "groupId/jars/-1.0.jar", "artifactId is missing" ); - } - - @Test - public void testBadPathArtifactIdMissingB() - { - assertBadPath( "groupId/jars/1.0.jar", "artifactId is missing" ); - } - - @Test - public void testBadPathMissingType() - { - assertBadPath( "invalid/invalid/1/invalid-1", "missing type" ); - } - - @Test - public void testBadPathTooShort() - { - // NEW - assertBadPath( "invalid/invalid-1.0.jar", "path is too short" ); - } - - @Test - public void testBadPathWrongPackageExtension() - { - assertBadPath( "org.apache.maven.test/jars/artifactId-1.0.war", "wrong package extension" ); - } - - /** - * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error - */ - @Test - public void testGoodButDualExtensions() - throws LayoutException - { - String groupId = "org.project"; - String artifactId = "example-presentation"; - String version = "3.2.xml"; - String type = "distribution-zip"; - String path = "org.project/zips/example-presentation-3.2.xml.zip"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-432] Oddball version spec. - * Example of an oddball / unusual version spec. - * - * @throws org.apache.archiva.repository.layout.LayoutException - */ - @Test - public void testGoodButOddVersionSpecGanymedSsh2() - throws LayoutException - { - String groupId = "ch.ethz.ganymed"; - String artifactId = "ganymed-ssh2"; - String version = "build210"; - String type = "jar"; - String path = "ch.ethz.ganymed/jars/ganymed-ssh2-build210.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-432] Oddball version spec. - * Example of an oddball / unusual version spec. - * - * @throws org.apache.archiva.repository.layout.LayoutException - */ - @Test - public void testGoodButOddVersionSpecJavaxComm() - throws LayoutException - { - String groupId = "javax"; - String artifactId = "comm"; - String version = "3.0-u1"; - String type = "jar"; - String path = "javax/jars/comm-3.0-u1.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-432] Oddball version spec. - * Example of an oddball / unusual version spec. - * - * @throws org.apache.archiva.repository.layout.LayoutException - */ - @Test - public void testGoodButOddVersionSpecJavaxPersistence() - throws LayoutException - { - String groupId = "javax.persistence"; - String artifactId = "ejb"; - String version = "3.0-public_review"; - String type = "jar"; - String path = "javax.persistence/jars/ejb-3.0-public_review.jar"; - - /* - * The version id of "public_review" can cause problems. is it part of - * the version spec? or the classifier? - */ - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - @Test - public void testGoodCommonsLang() - throws LayoutException - { - String groupId = "commons-lang"; - String artifactId = "commons-lang"; - String version = "2.1"; - String type = "jar"; - String path = "commons-lang/jars/commons-lang-2.1.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - @Test - public void testGoodDerby() - throws LayoutException - { - String groupId = "org.apache.derby"; - String artifactId = "derby"; - String version = "10.2.2.0"; - String type = "jar"; - String path = "org.apache.derby/jars/derby-10.2.2.0.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * Test the ejb-client type spec. - * Type specs are not a 1 to 1 map to the extension. - * This tests that effect. - * @throws org.apache.archiva.repository.layout.LayoutException - */ - /* TODO: Re-enabled in the future. - public void testGoodFooEjbClient() - throws LayoutException - { - String groupId = "com.foo"; - String artifactId = "foo-client"; - String version = "1.0"; - String type = "ejb"; // oddball type-spec (should result in jar extension) - String path = "com.foo/ejbs/foo-client-1.0.jar"; - - assertLayout( path, groupId, artifactId, version, classifier, type ); - } - */ - - /** - * Test the classifier. - * - * @throws org.apache.archiva.repository.layout.LayoutException - */ - @Test - public void testGoodFooLibJavadoc() - throws LayoutException - { - String groupId = "com.foo.lib"; - String artifactId = "foo-lib"; - String version = "2.1-alpha-1"; - String type = "javadoc"; - String classifier = "javadoc"; - String path = "com.foo.lib/javadoc.jars/foo-lib-2.1-alpha-1-javadoc.jar"; - - assertLayout( path, groupId, artifactId, version, classifier, type ); - - assertLayout( "com.foo.lib/javadocs/foo-lib-2.1-alpha-1-javadoc.jar", "com.foo.lib", "foo-lib", "2.1-alpha-1", - "javadoc", "javadoc" ); - } - - /** - * Test the classifier, and java-source type spec. - * - * @throws org.apache.archiva.repository.layout.LayoutException - */ - @Test - public void testGoodFooLibSources() - throws LayoutException - { - String groupId = "com.foo.lib"; - String artifactId = "foo-lib"; - String version = "2.1-alpha-1"; - String type = "java-source"; // oddball type-spec (should result in jar extension) - String classifier = "sources"; - String path = "com.foo.lib/java-sources/foo-lib-2.1-alpha-1-sources.jar"; - - assertLayout( path, groupId, artifactId, version, classifier, type ); - } - - /** - * Test the classifier, and java-source type spec. - * - * @throws org.apache.archiva.repository.layout.LayoutException - */ - @Test - public void testBadClassifierFooLibSources() - throws LayoutException - { - assertBadPath( "com.foo.lib/java-sources/foo-lib-2.1-alpha-1.jar", "missing required classifier" ); - assertBadPath( "com.foo.lib/java-sources/foo-lib-2.1-alpha-1-javadoc.jar", "incorrect classifier" ); - assertBadPath( "com.foo.lib/java-sources/foo-lib-2.1-alpha-1-other.jar", "incorrect classifier" ); - } - - /** - * Test the classifier, and java-source type spec. - * - * @throws org.apache.archiva.repository.layout.LayoutException - */ - @Test - public void testGoodFooLibTestSources() - throws LayoutException - { - String groupId = "com.foo.lib"; - String artifactId = "foo-lib"; - String version = "2.1-alpha-1-test-sources"; - String type = "jar"; - String classifier = null; // we can't parse this type of classifier in legacy format - String path = "com.foo.lib/jars/foo-lib-2.1-alpha-1-test-sources.jar"; - - assertLayout( path, groupId, artifactId, version, classifier, type ); - } - - @Test - public void testGoodFooTool() - throws LayoutException - { - String groupId = "com.foo"; - String artifactId = "foo-tool"; - String version = "1.0"; - String type = "jar"; - String path = "com.foo/jars/foo-tool-1.0.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - @Test - public void testGoodGeronimoEjbSpec() - throws LayoutException - { - String groupId = "org.apache.geronimo.specs"; - String artifactId = "geronimo-ejb_2.1_spec"; - String version = "1.0.1"; - String type = "jar"; - String path = "org.apache.geronimo.specs/jars/geronimo-ejb_2.1_spec-1.0.1.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - @Test - public void testGoodLdapClientsPom() - throws LayoutException - { - String groupId = "directory-clients"; - String artifactId = "ldap-clients"; - String version = "0.9.1-SNAPSHOT"; - String type = "pom"; - String path = "directory-clients/poms/ldap-clients-0.9.1-SNAPSHOT.pom"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * A timestamped versioned artifact, should reside in a SNAPSHOT baseversion directory. - * - * @throws org.apache.archiva.repository.layout.LayoutException - */ - @Test - public void testGoodSnapshotMavenTest() - throws LayoutException - { - String groupId = "org.apache.archiva.test"; - String artifactId = "redonkulous"; - String version = "3.1-beta-1-20050831.101112-42"; - String type = "jar"; - String path = "org.apache.archiva.test/jars/redonkulous-3.1-beta-1-20050831.101112-42.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-519] version identifiers within filename cause misidentification of version. - * Example uses "test" in artifact Id, which is also part of the versionKeyword list. - */ - @Test - public void testGoodVersionKeywordInArtifactId() - throws LayoutException - { - String groupId = "maven"; - String artifactId = "maven-test-plugin"; - String version = "1.8.2"; - String type = "pom"; - - String path = "maven/poms/maven-test-plugin-1.8.2.pom"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. - * Example uses "test" in artifact Id, which is also part of the versionKeyword list. - */ - @Test - public void testGoodDetectPluginMavenTest() - throws LayoutException - { - String groupId = "maven"; - String artifactId = "maven-test-plugin"; - String version = "1.8.2"; - String type = "maven-one-plugin"; - String path = "maven/plugins/maven-test-plugin-1.8.2.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. - */ - @Test - public void testGoodDetectPluginAvalonMeta() - throws LayoutException - { - String groupId = "avalon-meta"; - String artifactId = "avalon-meta-plugin"; - String version = "1.1"; - String type = "maven-one-plugin"; - String path = "avalon-meta/plugins/avalon-meta-plugin-1.1.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. - */ - @Test - public void testGoodDetectPluginCactusMaven() - throws LayoutException - { - String groupId = "cactus"; - String artifactId = "cactus-maven"; - String version = "1.7dev-20040815"; - String type = "maven-one-plugin"; - String path = "cactus/plugins/cactus-maven-1.7dev-20040815.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-562] Artifact type "maven-plugin" is not detected correctly in .toArtifactReference() methods. - */ - @Test - public void testGoodDetectPluginGeronimoPackaging() - throws LayoutException - { - String groupId = "geronimo"; - String artifactId = "geronimo-packaging-plugin"; - String version = "1.0.1"; - String type = "maven-one-plugin"; - String path = "geronimo/plugins/geronimo-packaging-plugin-1.0.1.jar"; - - assertLayout( path, groupId, artifactId, version, null, type ); - } - - /** - * [MRM-594] add some hook in LegacyPathParser to allow exceptions in artifact resolution - * - * @since 1.1 - */ - @Test - public void testCustomExceptionsInArtifactResolution() - throws LayoutException - { - String groupId = "jaxen"; - String artifactId = "jaxen"; - String version = "1.0-FCS"; - String type = "jar"; - String classifier = "full"; - String path = "jaxen/jars/jaxen-1.0-FCS-full.jar"; - - assertLayout( path, groupId, artifactId, version, classifier, type ); - } - - /** - * Perform a path to artifact reference lookup, and verify the results. - */ - private void assertLayout( String path, String groupId, String artifactId, String version, String classifier, - String type ) - throws LayoutException - { - // Path to Artifact Reference. - ArtifactReference testReference = parser.toArtifactReference( path ); - assertArtifactReference( testReference, groupId, artifactId, version, classifier, type ); - } - - private void assertArtifactReference( ArtifactReference actualReference, String groupId, String artifactId, - String version, String classifier, String type ) - { - String expectedId = - "ArtifactReference - " + groupId + ":" + artifactId + ":" + version + ":" + classifier + ":" + type; - - assertNotNull( expectedId + " - Should not be null.", actualReference ); - - assertEquals( expectedId + " - Group ID", groupId, actualReference.getGroupId() ); - assertEquals( expectedId + " - Artifact ID", artifactId, actualReference.getArtifactId() ); - assertEquals( expectedId + " - Version ID", version, actualReference.getVersion() ); - assertEquals( expectedId + " - classifier", classifier, actualReference.getClassifier() ); - assertEquals( expectedId + " - Type", type, actualReference.getType() ); - } - - protected void assertBadPath( String path, String reason ) - { - try - { - parser.toArtifactReference( path ); - fail( - "Should have thrown a LayoutException on the invalid path [" + path + "] because of [" + reason + "]" ); - } - catch ( LayoutException e ) - { - /* expected path */ - } - } -} diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/CVS/Root b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/CVS/Root deleted file mode 100644 index 2e65f24a6..000000000 --- a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/CVS/Root +++ /dev/null @@ -1 +0,0 @@ -not a real CVS root - for testing exclusions diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/KEYS b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/KEYS deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/foo/invalid-1.0.foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/1.0/invalid-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/invalid-1.0.rar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/invalid.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/invalid.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/no-extension b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/invalid/jars/no-extension deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/javax.sql/jars/jdbc-2.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/maven/poms/wagon-ssh-1.0.pom b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/maven/poms/wagon-ssh-1.0.pom deleted file mode 100644 index e6a72b9d6..000000000 --- a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/maven/poms/wagon-ssh-1.0.pom +++ /dev/null @@ -1,52 +0,0 @@ - - - - ../../project.xml - 3 - maven - wagon-ssh - wagon-ssh - Wagon SSH provider - 1.0-SNAPSHOT - - Wagon Provider for protocols from SSH2 family based on JSCH - org.apache.maven.wagon.providers.ssh - 2003 - http://maven.apache.org/wagon/wagon-providers/ssh - http://jira.codehaus.org/BrowseProject.jspa?id=10319 - /www/maven.apache.org/wagon/wagon-providers/ssh - - scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:maven-wagon/wagon-providers/ssh - http://cvs.apache.org/viewcvs/maven-wagon/wagon-providers/ssh/ - - - - - Michal Maczka - michal - michal.maczka@dimatics.com - Dimatics - - Creator - Developer - Release Manager - - - - - - - maven - wagon-api - 0.9-SNAPSHOT - jar - - - jsch - jsch - 0.1.14 - jar - - - - diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-not-updated-1.0.jar b/archiva-modules/plugins/maven2-repository/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-modules/plugins/maven2-repository/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-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven.update/jars/test-updated-1.0.jar deleted file mode 100644 index 54d190b23..000000000 --- a/archiva-modules/plugins/maven2-repository/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-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/some-ejb-1.0-client.jar b/archiva-modules/plugins/maven2-repository/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-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0-20050611.112233-1.jar b/archiva-modules/plugins/maven2-repository/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-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.tar.gz b/archiva-modules/plugins/maven2-repository/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-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-1.0.zip deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/jars/testing-UNKNOWN.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/java-sources/testing-1.0-sources.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/java-sources/testing-1.0-sources.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/javadoc.jars/testing-1.0-javadoc.jar b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/javadoc.jars/testing-1.0-javadoc.jar deleted file mode 100644 index e69de29bb..000000000 diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/poms/maven-model-v3-2.0.pom b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/poms/maven-model-v3-2.0.pom deleted file mode 100644 index 509552ef9..000000000 --- a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/poms/maven-model-v3-2.0.pom +++ /dev/null @@ -1,15 +0,0 @@ - - 3 - org.apache.maven - maven-model-v3 - Maven Model v3 - 2.0 - Maven Model v3 - - - org.codehaus.plexus - plexus-utils - 1.0.4 - - - \ No newline at end of file diff --git a/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/poms/testing-1.0.pom b/archiva-modules/plugins/maven2-repository/src/test/repositories/legacy-repository/org.apache.maven/poms/testing-1.0.pom deleted file mode 100644 index e69de29bb..000000000