diff options
author | Martin Stockhammer <martin_s@apache.org> | 2020-06-03 14:21:08 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2020-06-03 14:21:08 +0200 |
commit | d8f55d0c99feccb781d0b02954023bb0af4fb35b (patch) | |
tree | f88d4fcef260732f519576747e569de7d351cc78 /archiva-modules/archiva-maven | |
parent | b9dd7edf9eac052e4400fd37e12b3e123b8b9f55 (diff) | |
download | archiva-d8f55d0c99feccb781d0b02954023bb0af4fb35b.tar.gz archiva-d8f55d0c99feccb781d0b02954023bb0af4fb35b.zip |
Removing old API methods for layout
Diffstat (limited to 'archiva-modules/archiva-maven')
3 files changed, 0 insertions, 366 deletions
diff --git a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java index ae4a88950..63a037277 100644 --- a/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java +++ b/archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java @@ -24,8 +24,6 @@ import org.apache.archiva.common.utils.VersionUtil; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.maven.model.MavenArtifactFacet; import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.model.ProjectReference; -import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.*; import org.apache.archiva.repository.content.Artifact; import org.apache.archiva.repository.content.BaseDataItemTypes; @@ -79,18 +77,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout } @Override - public VersionedReference toVersion( String groupId, String artifactId, String version ) - { - return null; - } - - @Override - public VersionedReference toVersion( ArtifactReference artifactReference ) - { - return null; - } - - @Override public <T extends ContentItem> T adaptItem( Class<T> clazz, ContentItem item ) throws LayoutException { if (clazz.isAssignableFrom( Version.class )) @@ -329,30 +315,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout } @Override - public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException, ContentAccessException - { - - } - - @Override - public void deleteGroupId( String groupId ) throws ContentNotFoundException, ContentAccessException - { - - } - - @Override - public void deleteProject( String namespace, String projectId ) throws ContentNotFoundException, ContentAccessException - { - - } - - @Override - public void deleteProject( ProjectReference reference ) throws ContentNotFoundException, ContentAccessException - { - - } - - @Override public String toPath( ContentItem item ) { return item.getAsset( ).getPath( ); @@ -365,18 +327,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout } @Override - public List<ArtifactReference> getRelatedArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException - { - return null; - } - - @Override - public List<ArtifactReference> getArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException - { - return null; - } - - @Override public String getRepoRoot( ) { return getRepoRootAsset().getFilePath().toString(); @@ -405,12 +355,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout this.repository = repo; } - @Override - public StorageAsset toFile( VersionedReference reference ) - { - return null; - } - private Map<ArtifactReference, String> refs = new HashMap<>(); @Override diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java index 3e195c226..f63d83a76 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java @@ -24,7 +24,6 @@ import org.apache.archiva.configuration.FileTypes; import org.apache.archiva.metadata.maven.MavenMetadataReader; import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; import org.apache.archiva.model.ArtifactReference; -import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; import org.apache.archiva.repository.ContentAccessException; import org.apache.archiva.repository.ContentNotFoundException; @@ -69,7 +68,6 @@ import java.nio.file.Paths; import java.util.Arrays; import java.util.Collections; import java.util.List; -import java.util.Objects; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.regex.Matcher; @@ -1298,31 +1296,6 @@ public class ManagedDefaultRepositoryContent /// ************* End of new generation interface ****************** - /** - * Returns a version reference from the coordinates - * - * @param groupId the group id - * @param artifactId the artifact id - * @param version the version - * @return the versioned reference object - */ - @Override - public VersionedReference toVersion( String groupId, String artifactId, String version ) - { - return new VersionedReference( ).groupId( groupId ).artifactId( artifactId ).version( version ); - } - - /** - * Return the version the artifact is part of - * - * @param artifactReference - * @return - */ - public VersionedReference toVersion( ArtifactReference artifactReference ) - { - return toVersion( artifactReference.getGroupId( ), artifactReference.getArtifactId( ), artifactReference.getVersion( ) ); - } - @Override public String toPath( ContentItem item ) { return item.getAsset( ).getPath( ); @@ -1343,175 +1316,11 @@ public class ManagedDefaultRepositoryContent @Override - public void deleteProject( ProjectReference ref ) - throws ContentNotFoundException, ContentAccessException - { - final String path = toPath( ref ); - final Path deleteTarget = getRepoDir( ).resolve( path ); - if ( !Files.exists( deleteTarget ) ) - { - log.warn( "Project path for repository {} does not exist: {}", getId( ), deleteTarget ); - throw new ContentNotFoundException( "Project not found for repository " + getId( ) + ": " + path ); - } - if ( Files.isDirectory( deleteTarget ) ) - { - try - { - org.apache.archiva.common.utils.FileUtils.deleteDirectory( deleteTarget ); - } - catch ( IOException e ) - { - log.error( "Could not delete file path {}: {}", deleteTarget, e.getMessage( ), e ); - throw new ContentAccessException( "Error while trying to delete path " + path + " from repository " + getId( ) + ": " + e.getMessage( ), e ); - } - } - else - { - log.warn( "Project path for repository {} is not a directory {}", getId( ), deleteTarget ); - throw new ContentNotFoundException( "Project path for repository " + getId( ) + " is not directory: " + path ); - } - - } - - @Override - public void deleteProject( String namespace, String projectId ) throws ContentNotFoundException, ContentAccessException - { - this.deleteProject( new ProjectReference( ).groupId( namespace ).artifactId( projectId ) ); - } - - @Override - public void deleteArtifact( ArtifactReference ref ) throws ContentNotFoundException, ContentAccessException - { - final String path = toPath( ref ); - final Path repoDir = getRepoDir( ); - Path deleteTarget = repoDir.resolve( path ); - if ( Files.exists( deleteTarget ) ) - { - try - { - if ( Files.isDirectory( deleteTarget ) ) - { - org.apache.archiva.common.utils.FileUtils.deleteDirectory( deleteTarget ); - } - else - { - Files.delete( deleteTarget ); - } - } - catch ( IOException e ) - { - log.error( "Could not delete file path {}: {}", deleteTarget, e.getMessage( ), e ); - throw new ContentAccessException( "Error while trying to delete path " + path + " from repository " + getId( ) + ": " + e.getMessage( ), e ); - } - } - else - { - log.warn( "Artifact path for repository {} does not exist: {}", getId( ), deleteTarget ); - throw new ContentNotFoundException( "Artifact not found for repository " + getId( ) + ": " + path ); - } - - } - - @Override - public void deleteGroupId( String groupId ) - throws ContentNotFoundException, ContentAccessException - { - final String path = toPath( groupId ); - final Path deleteTarget = getRepoDir( ).resolve( path ); - if ( !Files.exists( deleteTarget ) ) - { - log.warn( "Namespace path for repository {} does not exist: {}", getId( ), deleteTarget ); - throw new ContentNotFoundException( "Namespace not found for repository " + getId( ) + ": " + path ); - } - if ( Files.isDirectory( deleteTarget ) ) - { - try - { - org.apache.archiva.common.utils.FileUtils.deleteDirectory( deleteTarget ); - } - catch ( IOException e ) - { - log.error( "Could not delete file path {}: {}", deleteTarget, e.getMessage( ), e ); - throw new ContentAccessException( "Error while trying to delete path " + path + " from repository " + getId( ) + ": " + e.getMessage( ), e ); - } - } - else - { - log.warn( "Namespace path for repository {} is not a directory {}", getId( ), deleteTarget ); - throw new ContentNotFoundException( "Namespace path for repository " + getId( ) + " is not directory: " + path ); - - } - } - - @Override public String getId( ) { return repository.getId( ); } - @Override - public List<ArtifactReference> getRelatedArtifacts( VersionedReference reference ) - throws ContentNotFoundException, LayoutException, ContentAccessException - { - StorageAsset artifactDir = toFile( reference ); - if ( !artifactDir.exists( ) ) - { - throw new ContentNotFoundException( - "Unable to get related artifacts using a non-existant directory: " + artifactDir.getPath( ) ); - } - - if ( !artifactDir.isContainer( ) ) - { - throw new ContentNotFoundException( - "Unable to get related artifacts using a non-directory: " + artifactDir.getPath( ) ); - } - - // First gather up the versions found as artifacts in the managed repository. - - try ( Stream<? extends StorageAsset> stream = artifactDir.list( ).stream( ) ) - { - return stream.filter( asset -> !asset.isContainer( ) ).map( path -> { - try - { - ArtifactReference artifact = toArtifactReference( path.getPath( ) ); - if ( artifact.getGroupId( ).equals( reference.getGroupId( ) ) && artifact.getArtifactId( ).equals( - reference.getArtifactId( ) ) && artifact.getVersion( ).equals( reference.getVersion( ) ) ) - { - return artifact; - } - else - { - return null; - } - } - catch ( LayoutException e ) - { - log.debug( "Not processing file that is not an artifact: {}", e.getMessage( ) ); - return null; - } - } ).filter( Objects::nonNull ).collect( Collectors.toList( ) ); - } - catch ( RuntimeException e ) - { - Throwable cause = e.getCause( ); - if ( cause != null ) - { - if ( cause instanceof LayoutException ) - { - throw (LayoutException) cause; - } - else - { - throw new ContentAccessException( cause.getMessage( ), cause ); - } - } - else - { - throw new ContentAccessException( e.getMessage( ), e ); - } - } - } - /* * Create the filter for various combinations of classifier and type */ @@ -1660,12 +1469,6 @@ public class ManagedDefaultRepositoryContent } - @Override - public StorageAsset toFile( VersionedReference reference ) - { - return repository.getAsset( toPath( reference ) ); - } - /** * Get the first Artifact found in the provided VersionedReference location. * @@ -1711,21 +1514,6 @@ public class ManagedDefaultRepositoryContent .map( this::toArtifactRef ); } - public List<ArtifactReference> getArtifacts( VersionedReference reference ) throws ContentNotFoundException, LayoutException, ContentAccessException - { - try ( Stream<ArtifactReference> stream = newArtifactStream( reference ) ) - { - return stream.collect( Collectors.toList( ) ); - } - catch ( IOException e ) - { - String path = toPath( reference ); - log.error( "Could not read directory from repository {} - {}: ", getId( ), path, e.getMessage( ), e ); - throw new ContentAccessException( "Could not read path from repository " + getId( ) + ": " + path, e ); - - } - } - private boolean hasArtifact( VersionedReference reference ) { diff --git a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java index 746bbb8d7..5b13edf88 100644 --- a/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java +++ b/archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java @@ -440,104 +440,6 @@ public class ManagedDefaultRepositoryContentTest } - @Test - public void testDeleteArtifactWithType() throws IOException, org.apache.archiva.repository.ContentNotFoundException, org.apache.archiva.repository.ContentAccessException - { - Path deleteRepo = setupRepoCopy( "delete-repository", "delete-repository-2" ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) ); - - ArtifactReference ref = new ArtifactReference( ); - ref.setGroupId( "org.apache.maven" ); - ref.setArtifactId( "samplejar" ); - ref.setVersion( "1.0" ); - ref.setType( "jar" ); - - repoContent.deleteArtifact( ref ); - - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) ); - assertFalse( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) ); - - - } - - - @Test - public void testDeleteArtifactWithClassifier() throws IOException, org.apache.archiva.repository.ContentNotFoundException, org.apache.archiva.repository.ContentAccessException - { - Path deleteRepo = setupRepoCopy( "default-repository", "default-repository-2" ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) ); - - ArtifactReference ref = new ArtifactReference( ); - ref.setGroupId( "org.apache.maven" ); - ref.setArtifactId( "samplejar" ); - ref.setVersion( "1.0" ); - ref.setClassifier( "source" ); - ref.setType( "jar" ); - - repoContent.deleteArtifact( ref ); - - assertFalse( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) ); - - } - - @Test - public void testDeleteArtifactWithoutType() throws IOException, org.apache.archiva.repository.ContentNotFoundException, org.apache.archiva.repository.ContentAccessException - { - Path deleteRepo = setupRepoCopy( "default-repository", "default-repository-2" ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) ); - - ArtifactReference ref = new ArtifactReference( ); - ref.setGroupId( "org.apache.maven" ); - ref.setArtifactId( "samplejar" ); - ref.setVersion( "1.0" ); - - repoContent.deleteArtifact( ref ); - - assertFalse( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar" ) ) ); - - } - - - @Test - public void testDeleteProject() throws IOException, org.apache.archiva.repository.ContentNotFoundException, org.apache.archiva.repository.ContentAccessException - { - Path deleteRepo = setupRepoCopy( "delete-repository", "delete-repository-2" ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0-source.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.md5" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.jar.sha1" ) ) ); - assertTrue( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0/samplejar-1.0.pom" ) ) ); - - ProjectReference ref = new ProjectReference( ).groupId( "org.apache.maven" ).artifactId( "samplejar" ); - - repoContent.deleteProject( ref ); - - assertFalse( Files.exists( deleteRepo.resolve( "org/apache/maven/samplejar/1.0" ) ) ); - - } @Test public void testGetArtifactStreamWithVersionSelector() { |