aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2020-06-03 14:21:08 +0200
committerMartin Stockhammer <martin_s@apache.org>2020-06-03 14:21:08 +0200
commitd8f55d0c99feccb781d0b02954023bb0af4fb35b (patch)
treef88d4fcef260732f519576747e569de7d351cc78
parentb9dd7edf9eac052e4400fd37e12b3e123b8b9f55 (diff)
downloadarchiva-d8f55d0c99feccb781d0b02954023bb0af4fb35b.tar.gz
archiva-d8f55d0c99feccb781d0b02954023bb0af4fb35b.zip
Removing old API methods for layout
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java101
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java58
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java56
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-proxy/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java56
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/main/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContent.java212
-rw-r--r--archiva-modules/archiva-maven/archiva-maven-repository/src/test/java/org/apache/archiva/repository/maven/content/ManagedDefaultRepositoryContentTest.java98
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java22
7 files changed, 10 insertions, 593 deletions
diff --git a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java
index 2fc7aee97..3cb7b153c 100644
--- a/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java
+++ b/archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java
@@ -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 );
-
-
}
diff --git a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
index c10c6c319..60e8fd35f 100644
--- a/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
+++ b/archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java
@@ -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;
@@ -61,18 +58,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
@@ -313,25 +292,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 )
{
return null;
@@ -344,18 +304,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 null;
@@ -374,12 +322,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
}
@Override
- public StorageAsset toFile( VersionedReference reference )
- {
- return null;
- }
-
- @Override
public ArtifactReference toArtifactReference( String path ) throws LayoutException
{
return null;
diff --git a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java
index d7d9ab46b..ecc6430eb 100644
--- a/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java
+++ b/archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/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;
@@ -73,18 +71,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 ))
@@ -308,30 +294,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 null;
@@ -344,18 +306,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();
@@ -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
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() {
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
index cfb5dfc30..60467bcc7 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
@@ -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 );