]> source.dussan.org Git - archiva.git/commitdiff
Removing old API methods for layout
authorMartin Stockhammer <martin_s@apache.org>
Wed, 3 Jun 2020 12:21:08 +0000 (14:21 +0200)
committerMartin Stockhammer <martin_s@apache.org>
Wed, 3 Jun 2020 12:21:08 +0000 (14:21 +0200)
archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java
archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java
archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java
archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java

index 2fc7aee975d56957178d0baa54811e0be5cf2374..3cb7b153c2d28c11670e29b0c50af7adb4cbaea2 100644 (file)
@@ -270,98 +270,6 @@ public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLay
     /// *****************   End of new generation interface **********************
 
 
-
-    /**
-     * Returns the version reference for the given coordinates.
-     * @param groupId the group id
-     * @param artifactId the artifact id
-     * @param version the version number
-     * @return a version reference
-     */
-    VersionedReference toVersion( String groupId, String artifactId, String version );
-
-
-    /**
-     * Return the version reference that matches exactly the version string of the artifact
-     *
-     * @param artifactReference The artifact reference
-     * @return the version reference
-     */
-    VersionedReference toVersion( ArtifactReference artifactReference);
-
-
-    /**
-     * delete a specified artifact from the repository
-     *
-     * @param artifactReference
-     * @throws ContentNotFoundException
-     */
-    void deleteArtifact( ArtifactReference artifactReference )
-        throws ContentNotFoundException, ContentAccessException;
-
-
-
-    /**
-     * @param groupId
-     * @throws ContentNotFoundException
-     * @since 1.4-M3
-     */
-    void deleteGroupId( String groupId )
-        throws ContentNotFoundException, ContentAccessException;
-
-
-
-
-    /**
-     *
-     * @param namespace groupId for maven
-     * @param projectId artifactId for maven
-     * @throws ContentNotFoundException
-     */
-    void deleteProject( String namespace, String projectId )
-        throws ContentNotFoundException, ContentAccessException;
-
-
-    /**
-     * Deletes a project
-     * @param reference
-     */
-    void deleteProject(ProjectReference reference) throws ContentNotFoundException, ContentAccessException;
-
-
-
-
-
-
-    /**
-     * <p>
-     * Gather up the list of related artifacts to the ArtifactReference provided.
-     * This typically includes the pom files, and those things with
-     * classifiers (such as doc, source code, test libs, etc...). Even if the classifier
-     * is set in the artifact reference, it may return artifacts with different classifiers.
-     * </p>
-     * <p>
-     * <strong>NOTE:</strong> Some layouts (such as maven 1 "legacy") are not compatible with this query.
-     * </p>
-     *
-     * @param reference the reference to work off of.
-     * @return the list of ArtifactReferences for related artifacts, if
-     * @throws ContentNotFoundException if the initial artifact reference does not exist within the repository.
-     */
-    List<ArtifactReference> getRelatedArtifacts( VersionedReference reference )
-        throws ContentNotFoundException, LayoutException, ContentAccessException;
-
-
-    /**
-     * Returns all artifacts that belong to a given version
-     * @param reference the version reference
-     * @return the list of artifacts or a empty list
-     */
-    List<ArtifactReference> getArtifacts(VersionedReference reference) throws ContentNotFoundException, LayoutException, ContentAccessException;
-
-
-
-
     /**
      * <p>
      * Convenience method to get the repository (on disk) root directory.
@@ -375,13 +283,4 @@ public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLay
     String getRepoRoot();
 
 
-    /**
-     * Given an {@link ArtifactReference}, return the file reference to the artifact.
-     *
-     * @param reference the artifact reference to use.
-     * @return the relative path to the artifact.
-     */
-    StorageAsset toFile( VersionedReference reference );
-
-
 }
index c10c6c319a7606a047987c59c9e33eec472799fc..60e8fd35fbd1d20d9daee41bf7926ecadc02deaf 100644 (file)
@@ -20,10 +20,7 @@ package org.apache.archiva.repository.mock;
  */
 
 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;
 import org.apache.archiva.repository.ManagedRepositoryContent;
 import org.apache.archiva.repository.ItemDeleteStatus;
 import org.apache.archiva.repository.LayoutException;
@@ -60,18 +57,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
 {
     private ManagedRepository repository;
 
-    @Override
-    public VersionedReference toVersion( String groupId, String artifactId, String version )
-    {
-        return null;
-    }
-
-    @Override
-    public VersionedReference toVersion( ArtifactReference artifactReference )
-    {
-        return null;
-    }
-
     @Override
     public void deleteAllItems( ItemSelector selector, Consumer<ItemDeleteStatus> consumer ) throws ContentAccessException, IllegalArgumentException
     {
@@ -155,12 +140,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
         return null;
     }
 
-    @Override
-    public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException, ContentAccessException
-    {
-
-    }
-
 
     @Override
     public Artifact getArtifact( ItemSelector selector ) throws ContentAccessException
@@ -312,25 +291,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
     }
 
 
-    @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 )
     {
@@ -343,18 +303,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
         return null;
     }
 
-    @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( )
     {
@@ -373,12 +321,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
         this.repository = repo;
     }
 
-    @Override
-    public StorageAsset toFile( VersionedReference reference )
-    {
-        return null;
-    }
-
     @Override
     public ArtifactReference toArtifactReference( String path ) throws LayoutException
     {
index d7d9ab46b100fbf6fbdd15426a32d3134fc0c5f2..ecc6430ebcbf855a8be59d5a87b370b10b2ea092 100644 (file)
@@ -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;
@@ -72,18 +70,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
         this.repository = repo;
     }
 
-    @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
     {
@@ -307,30 +293,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
         return null;
     }
 
-    @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 )
     {
@@ -343,18 +305,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
         return repository.getId();
     }
 
-    @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( )
     {
@@ -384,12 +334,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
index ae4a88950295e6bf8b0607c788d2ac745d136efc..63a03727751a2f1b56eeb50b442ac627b0d53bb8 100644 (file)
@@ -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;
@@ -78,18 +76,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
         this.fsStorage = repo;
     }
 
-    @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
     {
@@ -328,30 +314,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 )
     {
@@ -364,18 +326,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
         return repository.getId();
     }
 
-    @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( )
     {
@@ -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
index 3e195c22691da1636c7e5019b80f26ddf1602a16..f63d83a764f3fe24eea695bd4a0d57bd43ef7c92 100644 (file)
@@ -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( );
@@ -1342,176 +1315,12 @@ 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 )
 
     {
index 746bbb8d7b7e1ae77343e3620ca518f575a6480d..5b13edf88fdcf5b33173cd973dcedb030ac15040 100644 (file)
@@ -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() {
index cfb5dfc30ede2809d843e30b51bf1825de209e38..60467bcc777ae6df01dec21fcb9ceea877a18373 100644 (file)
@@ -750,6 +750,7 @@ public class DefaultRepositoriesService
 
         boolean snapshotVersion =
             VersionUtil.isSnapshot( artifact.getVersion() ) | VersionUtil.isGenericSnapshot( artifact.getVersion() );
+        String baseVersion = VersionUtil.getBaseVersion( artifact.getVersion( ) );
 
         RepositorySession repositorySession = null;
         try
@@ -774,7 +775,7 @@ public class DefaultRepositoriesService
 
             ArchivaItemSelector versionSelector = ArchivaItemSelector.builder( ).withNamespace( artifact.getGroupId( ) )
                 .withProjectId( artifact.getArtifactId( ) )
-                .withVersion( artifact.getVersion( ) ).build( );
+                .withVersion( baseVersion ).build( );
 
             Version version1 = layout.getVersion( versionSelector );
             String path = repository.toPath( version1 );
@@ -789,7 +790,7 @@ public class DefaultRepositoriesService
             ArchivaItemSelector selector = ArchivaItemSelector.builder( )
                 .withNamespace( artifact.getGroupId( ) )
                 .withProjectId( artifact.getArtifactId( ) )
-                .withVersion( artifact.getVersion( ) )
+                .withVersion( baseVersion )
                 .withClassifier( artifact.getClassifier( ) )
                 .withArtifactId( artifact.getArtifactId( ) )
                 .withType( artifact.getType( ) )
@@ -849,21 +850,19 @@ public class DefaultRepositoriesService
                 else
                 {
                     // We are deleting all version related artifacts for a snapshot version
-                    VersionedReference versionRef = layout.toVersion( artifactReference );
-                    List<ArtifactReference> related = layout.getRelatedArtifacts( versionRef );
-                    log.debug( "related: {}", related );
-                    for ( ArtifactReference artifactRef : related )
-                    {
+                    for ( org.apache.archiva.repository.content.Artifact delArtifact : layout.getArtifacts( selector )) {
                         try
                         {
-                            layout.deleteArtifact( artifactRef );
-                        } catch (ContentNotFoundException e) {
-                            log.warn( "Artifact that should be deleted, was not found: {}", artifactRef );
+                            repository.deleteItem( delArtifact );
+                        }
+                        catch ( ItemNotFoundException e )
+                        {
+                            log.warn( "Artifact that should be deleted, was not found: {}", delArtifact );
                         }
+
                     }
                     StorageAsset metadataFile = getMetadata( repo, targetPath.getPath() );
                     ArchivaRepositoryMetadata metadata = getMetadata( repository.getRepository().getType(), metadataFile );
-
                     updateMetadata( metadata, metadataFile, lastUpdatedTimestamp, artifact );
                 }
             }
@@ -871,7 +870,6 @@ public class DefaultRepositoriesService
 
             if ( snapshotVersion )
             {
-                String baseVersion = VersionUtil.getBaseVersion( artifact.getVersion() );
                 artifacts =
                     metadataRepository.getArtifacts(repositorySession , repositoryId, artifact.getGroupId(),
                         artifact.getArtifactId(), baseVersion );