diff options
author | Martin Stockhammer <martin_s@apache.org> | 2020-06-01 14:03:03 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2020-06-01 14:03:03 +0200 |
commit | 2257aae023b20646e0b34369be24f5fc1718750f (patch) | |
tree | 7118f423730ab645510567f83e6aa4bf72348ef4 /archiva-modules/archiva-web | |
parent | 6d7a510dea283ff8c4b1e6ae54a395dbe386e4a5 (diff) | |
download | archiva-2257aae023b20646e0b34369be24f5fc1718750f.tar.gz archiva-2257aae023b20646e0b34369be24f5fc1718750f.zip |
Repository content refactoring
Diffstat (limited to 'archiva-modules/archiva-web')
-rw-r--r-- | archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java | 25 |
1 files changed, 16 insertions, 9 deletions
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 f6d11dcbc..1eca75d14 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 @@ -769,14 +769,16 @@ public class DefaultRepositoriesService fmt.setTimeZone( timezone ); ManagedRepository repo = repositoryRegistry.getManagedRepository( repositoryId ); - VersionedReference ref = new VersionedReference(); - ref.setArtifactId( artifact.getArtifactId() ); - ref.setGroupId( artifact.getGroupId() ); - ref.setVersion( artifact.getVersion() ); - ManagedRepositoryContent repository = getManagedRepositoryContent( repositoryId ); BaseRepositoryContentLayout layout = repository.getLayout( BaseRepositoryContentLayout.class ); + ArchivaItemSelector versionSelector = ArchivaItemSelector.builder( ).withNamespace( artifact.getGroupId( ) ) + .withProjectId( artifact.getArtifactId( ) ) + .withVersion( artifact.getVersion( ) ).build( ); + + Version version1 = layout.getVersion( versionSelector ); + String path = layout.toPath( version1 ); + ArtifactReference artifactReference = new ArtifactReference(); artifactReference.setArtifactId( artifact.getArtifactId() ); artifactReference.setGroupId( artifact.getGroupId() ); @@ -796,8 +798,6 @@ public class DefaultRepositoriesService MetadataRepository metadataRepository = repositorySession.getRepository(); - String path = layout.toMetadataPath( ref ); - if ( StringUtils.isNotBlank( artifact.getClassifier() ) ) { if ( StringUtils.isBlank( artifact.getPackaging() ) ) @@ -835,9 +835,16 @@ public class DefaultRepositoriesService // TODO: this should be in the storage mechanism so that it is all tied together // delete from file system - if ( !snapshotVersion ) + if ( !snapshotVersion && version1.exists() ) { - layout.deleteVersion( ref ); + try + { + layout.deleteItem( version1 ); + } + catch ( ItemNotFoundException e ) + { + log.error( "Could not delete version item {}", e.getMessage( ) ); + } } else { |