diff options
author | Martin Stockhammer <martin_s@apache.org> | 2020-06-02 16:33:20 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2020-06-02 16:33:20 +0200 |
commit | 22a8cbfd22c8cfb33a8d4e3e82cf22a7c03df68b (patch) | |
tree | ff9558f4655cc13bd4b39505a69eabb0e8cf43f6 | |
parent | 7219cf4ffcc9cba30c02fa421a1cdf9921839f33 (diff) | |
download | archiva-22a8cbfd22c8cfb33a8d4e3e82cf22a7c03df68b.tar.gz archiva-22a8cbfd22c8cfb33a8d4e3e82cf22a7c03df68b.zip |
Switching to layout interface
6 files changed, 8 insertions, 121 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 20a9577ff..bd1e2933c 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 @@ -386,23 +386,6 @@ public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLay */ String getRepoRoot(); - /** - * Determines if the artifact referenced exists in the repository. - * - * @param reference the artifact reference to check for. - * @return true if the artifact referenced exists. - */ - boolean hasContent( ArtifactReference reference ) throws ContentAccessException; - - /** - * Determines if the version reference exists in the repository. - * - * @param reference the version reference to check for. - * @return true if the version referenced exists. - */ - boolean hasContent( VersionedReference reference ) throws ContentAccessException; - - /** * Given an {@link ArtifactReference}, return the file reference to the artifact. @@ -420,13 +403,5 @@ public interface BaseRepositoryContentLayout extends ManagedRepositoryContentLay */ StorageAsset toFile( ArtifactReference reference ); - /** - * Given an {@link ArchivaArtifact}, return the file reference to the artifact. - * - * @param reference the archiva artifact to use. - * @return the relative path to the artifact. - */ - StorageAsset toFile( ArchivaArtifact 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 16c83a7af..ae32b0ee9 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 @@ -19,7 +19,6 @@ package org.apache.archiva.repository.mock; * under the License. */ -import org.apache.archiva.model.ArchivaArtifact; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; @@ -376,18 +375,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout } @Override - public boolean hasContent( ArtifactReference reference ) throws ContentAccessException - { - return false; - } - - @Override - public boolean hasContent( VersionedReference reference ) throws ContentAccessException - { - return false; - } - - @Override public void setRepository( ManagedRepository repo ) { this.repository = repo; @@ -412,12 +399,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout } @Override - public StorageAsset toFile( ArchivaArtifact 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 ab42866bb..604c70b21 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 @@ -23,7 +23,6 @@ import org.apache.archiva.common.filelock.DefaultFileLockManager; 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.ArchivaArtifact; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; @@ -386,18 +385,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout } @Override - public boolean hasContent( ArtifactReference reference ) throws ContentAccessException - { - return false; - } - - @Override - public boolean hasContent( VersionedReference reference ) throws ContentAccessException - { - return false; - } - - @Override public void setRepository( ManagedRepository repo ) { this.repository = repo; @@ -604,12 +591,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout return getRepoRootAsset().resolve(refs.get(reference)); } - @Override - public StorageAsset toFile( ArchivaArtifact reference ) - { - return null; - } - private String formatAsDirectory( String directory ) { return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR ); 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 623bf8c67..e49c913c7 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 @@ -23,7 +23,6 @@ import org.apache.archiva.common.filelock.DefaultFileLockManager; 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.ArchivaArtifact; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; @@ -398,18 +397,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout } @Override - public boolean hasContent( ArtifactReference reference ) throws ContentAccessException - { - return false; - } - - @Override - public boolean hasContent( VersionedReference reference ) throws ContentAccessException - { - return false; - } - - @Override public void setRepository( ManagedRepository repo ) { this.repository = repo; @@ -616,12 +603,6 @@ public class ManagedRepositoryContentMock implements BaseRepositoryContentLayout return getRepoRootAsset().resolve( refs.get(reference)); } - @Override - public StorageAsset toFile( ArchivaArtifact reference ) - { - return null; - } - private String formatAsDirectory( String directory ) { return directory.replace( GROUP_SEPARATOR, PATH_SEPARATOR ); 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 91657ce09..032c531d7 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 @@ -20,11 +20,9 @@ package org.apache.archiva.repository.maven.content; import org.apache.archiva.common.filelock.FileLockManager; import org.apache.archiva.common.utils.FileUtils; -import org.apache.archiva.common.utils.VersionUtil; 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.ArchivaArtifact; import org.apache.archiva.model.ArtifactReference; import org.apache.archiva.model.ProjectReference; import org.apache.archiva.model.VersionedReference; @@ -1625,32 +1623,6 @@ public class ManagedDefaultRepositoryContent } @Override - public boolean hasContent( ArtifactReference reference ) throws ContentAccessException - { - StorageAsset artifactFile = toFile( reference ); - return artifactFile.exists( ) && !artifactFile.isContainer( ); - } - - @Override - public boolean hasContent( VersionedReference reference ) throws ContentAccessException - { - try - { - return ( getFirstArtifact( reference ) != null ); - } - catch ( LayoutException | ContentNotFoundException e ) - { - return false; - } - 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 ); - } - } - - @Override public void setRepository( final ManagedRepository repo ) { this.repository = repo; @@ -1724,12 +1696,6 @@ public class ManagedDefaultRepositoryContent } @Override - public StorageAsset toFile( ArchivaArtifact reference ) - { - return repository.getAsset( toPath( reference ) ); - } - - @Override public StorageAsset toFile( VersionedReference reference ) { return repository.getAsset( toPath( reference ) ); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java index f10286339..fcc9c844b 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/main/java/org/apache/archiva/webdav/ArchivaDavResourceFactory.java @@ -66,6 +66,8 @@ import org.apache.archiva.repository.ReleaseScheme; import org.apache.archiva.repository.RepositoryGroup; import org.apache.archiva.repository.RepositoryRegistry; import org.apache.archiva.repository.RepositoryRequestInfo; +import org.apache.archiva.repository.content.Artifact; +import org.apache.archiva.repository.content.ContentItem; import org.apache.archiva.repository.storage.fs.FilesystemStorage; import org.apache.archiva.repository.storage.StorageAsset; import org.apache.archiva.metadata.audit.AuditListener; @@ -647,16 +649,17 @@ public class ArchivaDavResourceFactory if ( managedRepositoryContent.getRepository().getActiveReleaseSchemes().contains( ReleaseScheme.RELEASE ) && !repositoryRequestInfo.isMetadata( resourcePath ) && !repositoryRequestInfo.isSupportFile( resourcePath ) ) { - ArtifactReference artifact = null; + // ArtifactReference artifact = null; + Artifact artifact = null; try { BaseRepositoryContentLayout layout = managedRepositoryContent.getLayout( BaseRepositoryContentLayout.class ); - artifact = managedRepositoryContent.toArtifactReference( resourcePath ); - - if ( !VersionUtil.isSnapshot( artifact.getVersion() ) ) + ContentItem artifactItem = managedRepositoryContent.toItem( resourcePath ); + artifact = layout.adaptItem( Artifact.class, artifactItem ); + if ( !VersionUtil.isSnapshot( artifact.getVersion().getVersion() ) ) { // check if artifact already exists and if artifact re-deployment to the repository is allowed - if ( layout.hasContent( artifact ) + if ( artifactItem.exists() && managedRepositoryContent.getRepository().blocksRedeployments()) { log.warn( "Overwriting released artifacts in repository '{}' is not allowed.", |