aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base
diff options
context:
space:
mode:
authorMartin Stockhammer <martin_s@apache.org>2020-06-03 10:46:34 +0200
committerMartin Stockhammer <martin_s@apache.org>2020-06-03 10:46:34 +0200
commitb9dd7edf9eac052e4400fd37e12b3e123b8b9f55 (patch)
tree5b46329a8e280bd2e6d37bea2b73e37feb9fd913 /archiva-modules/archiva-base
parent873753536bbc1cd1639016ae845625f631f3cff1 (diff)
downloadarchiva-b9dd7edf9eac052e4400fd37e12b3e123b8b9f55.tar.gz
archiva-b9dd7edf9eac052e4400fd37e12b3e123b8b9f55.zip
Removing old API methods
Diffstat (limited to 'archiva-modules/archiva-base')
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java52
-rw-r--r--archiva-modules/archiva-base/archiva-repository-api/src/main/java/org/apache/archiva/repository/BaseRepositoryContentLayout.java20
-rw-r--r--archiva-modules/archiva-base/archiva-repository-layer/src/test/java/org/apache/archiva/repository/mock/ManagedRepositoryContentMock.java13
-rw-r--r--archiva-modules/archiva-base/archiva-repository-scanner/src/test/java/org/apache/archiva/repository/scanner/mock/ManagedRepositoryContentMock.java12
4 files changed, 21 insertions, 76 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
index 069730689..fe58824a3 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/main/java/org/apache/archiva/consumers/core/repository/CleanupReleasedSnapshotsRepositoryPurge.java
@@ -34,6 +34,7 @@ import org.apache.archiva.repository.BaseRepositoryContentLayout;
import org.apache.archiva.repository.ReleaseScheme;
import org.apache.archiva.repository.RepositoryRegistry;
import org.apache.archiva.metadata.audit.RepositoryListener;
+import org.apache.archiva.repository.content.ItemNotFoundException;
import org.apache.archiva.repository.content.ItemSelector;
import org.apache.archiva.repository.content.Project;
import org.apache.archiva.repository.content.Version;
@@ -108,7 +109,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
return;
}
- ItemSelector selector = ArchivaItemSelector.builder( )
+ ItemSelector projectSelector = ArchivaItemSelector.builder( )
.withNamespace( artifactRef.getGroupId( ) )
.withProjectId( artifactRef.getArtifactId( ) )
.build();
@@ -124,7 +125,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
if ( repo.getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE ))
{
BaseRepositoryContentLayout repoContent = repo.getContent().getLayout( BaseRepositoryContentLayout.class );
- Project proj = repoContent.getProject( selector );
+ Project proj = repoContent.getProject( projectSelector );
for ( Version version : repoContent.getVersions( proj ) )
{
if ( !VersionUtil.isSnapshot( version.getVersion() ) )
@@ -144,13 +145,21 @@ public class CleanupReleasedSnapshotsRepositoryPurge
versionRef.setGroupId( artifactRef.getGroupId( ) );
versionRef.setArtifactId( artifactRef.getArtifactId( ) );
+ ArchivaItemSelector.Builder versionSelectorBuilder = ArchivaItemSelector.builder( )
+ .withNamespace( artifactRef.getGroupId( ) )
+ .withProjectId( artifactRef.getArtifactId( ) )
+ .withArtifactId( artifactRef.getArtifactId( ) );
+
MetadataRepository metadataRepository = repositorySession.getRepository( );
if ( releasedVersions.contains( VersionUtil.getReleaseVersion( artifactRef.getVersion( ) ) ) )
{
- versionRef.setVersion( artifactRef.getVersion( ) );
- layout.deleteVersion( versionRef );
-
+ ArchivaItemSelector selector = versionSelectorBuilder.withVersion( artifactRef.getVersion( ) ).build( );
+ Version version = layout.getVersion( selector );
+ if (version.exists())
+ {
+ repository.deleteItem( version );
+ }
for ( RepositoryListener listener : listeners )
{
listener.deleteArtifact( metadataRepository, repository.getId( ), artifactRef.getGroupId( ),
@@ -172,10 +181,6 @@ public class CleanupReleasedSnapshotsRepositoryPurge
{
log.debug( "Not processing file that is not an artifact: {}", e.getMessage( ) );
}
- catch ( ContentNotFoundException e )
- {
- throw new RepositoryPurgeException( e.getMessage( ), e );
- }
catch ( MetadataRepositoryException e )
{
log.error( "Could not remove metadata during cleanup of released snapshots of {}", path, e );
@@ -184,6 +189,10 @@ public class CleanupReleasedSnapshotsRepositoryPurge
{
e.printStackTrace( );
}
+ catch ( ItemNotFoundException e )
+ {
+ log.error( "Could not find item to delete {}",e.getMessage( ), e );
+ }
}
@@ -211,15 +220,7 @@ public class CleanupReleasedSnapshotsRepositoryPurge
{
// Ignore. (Just means we have no snapshot versions left to reference).
}
- catch ( RepositoryMetadataException e )
- {
- // Ignore.
- }
- catch ( IOException e )
- {
- // Ignore.
- }
- catch ( LayoutException e )
+ catch ( RepositoryMetadataException | IOException | LayoutException e )
{
// Ignore.
}
@@ -228,21 +229,10 @@ public class CleanupReleasedSnapshotsRepositoryPurge
{
metadataTools.updateMetadata( repository, projectRef );
}
- catch ( ContentNotFoundException e )
+ catch ( ContentNotFoundException | RepositoryMetadataException | IOException | LayoutException e )
{
// Ignore. (Just means we have no snapshot versions left to reference).
}
- catch ( RepositoryMetadataException e )
- {
- // Ignore.
- }
- catch ( IOException e )
- {
- // Ignore.
- }
- catch ( LayoutException e )
- {
- // Ignore.
- }
+
}
}
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 bd1e2933c..2fc7aee97 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
@@ -291,18 +291,6 @@ public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLay
/**
- * Delete from the managed repository all files / directories associated with the
- * provided version reference.
- *
- * @param reference the version reference to delete.
- * @throws ContentNotFoundException
- */
- void deleteVersion( VersionedReference reference )
- throws ContentNotFoundException, ContentAccessException;
-
-
-
- /**
* delete a specified artifact from the repository
*
* @param artifactReference
@@ -395,13 +383,5 @@ public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLay
*/
StorageAsset toFile( VersionedReference reference );
- /**
- * 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( ArtifactReference 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 ae32b0ee9..c10c6c319 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
@@ -150,13 +150,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
@Override
- public void deleteVersion( VersionedReference reference ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
-
- @Override
public Version getVersion( ItemSelector versionCoordinates ) throws ContentAccessException, IllegalArgumentException
{
return null;
@@ -393,12 +386,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
}
@Override
- public StorageAsset toFile( ArtifactReference reference )
- {
- return null;
- }
-
- @Override
public String toPath( ArtifactReference reference )
{
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 604c70b21..d7d9ab46b 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
@@ -308,12 +308,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
}
@Override
- public void deleteVersion( VersionedReference reference ) throws ContentNotFoundException, ContentAccessException
- {
-
- }
-
- @Override
public void deleteArtifact( ArtifactReference artifactReference ) throws ContentNotFoundException, ContentAccessException
{
@@ -585,12 +579,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout
}
- @Override
- public StorageAsset toFile( ArtifactReference reference )
- {
- return getRepoRootAsset().resolve(refs.get(reference));
- }
-
private String formatAsDirectory( String directory )
{
return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR );