From ea5ddd09615bd26400024da1b8de70b592391c58 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 5 Jun 2012 21:42:02 +0000 Subject: improve MetadataRepository api to be able to remove an artifact with MetadataFacet use case deleting a maven artifact with a classifier git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1346609 13f79535-47bb-0310-9956-ffa450edef68 --- .../storage/maven2/MavenArtifactFacet.java | 19 +++++++++++ .../storage/maven2/MavenProjectFacet.java | 39 ++++++++++++++++++++++ .../repository/TestMetadataRepository.java | 8 +++++ 3 files changed, 66 insertions(+) (limited to 'archiva-modules/plugins/maven2-repository/src') diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenArtifactFacet.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenArtifactFacet.java index aa330385d..6e72fdcd7 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenArtifactFacet.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenArtifactFacet.java @@ -20,6 +20,7 @@ package org.apache.archiva.metadata.repository.storage.maven2; */ import org.apache.archiva.metadata.model.MetadataFacet; +import org.apache.commons.lang.StringUtils; import java.util.HashMap; import java.util.Map; @@ -118,4 +119,22 @@ public class MavenArtifactFacet this.buildNumber = Integer.parseInt( buildNumber ); } } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( !( o instanceof MavenArtifactFacet ) ) + { + return false; + } + + MavenArtifactFacet that = (MavenArtifactFacet) o; + + return StringUtils.equals( that.getClassifier(), this.classifier ); + } + } diff --git a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java index 83fe1693e..93826d8d1 100644 --- a/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java +++ b/archiva-modules/plugins/maven2-repository/src/main/java/org/apache/archiva/metadata/repository/storage/maven2/MavenProjectFacet.java @@ -118,4 +118,43 @@ public class MavenProjectFacet this.parent = parent; } } + + @Override + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( !( o instanceof MavenProjectFacet ) ) + { + return false; + } + + MavenProjectFacet that = (MavenProjectFacet) o; + + if ( !artifactId.equals( that.artifactId ) ) + { + return false; + } + if ( !groupId.equals( that.groupId ) ) + { + return false; + } + if ( !packaging.equals( that.packaging ) ) + { + return false; + } + + return true; + } + + @Override + public int hashCode() + { + int result = groupId.hashCode(); + result = 31 * result + artifactId.hashCode(); + result = 31 * result + packaging.hashCode(); + return result; + } } diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index 3d5760765..24a0a5d44 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -198,4 +198,12 @@ public class TestMetadataRepository { return null; //To change body of implemented methods use File | Settings | File Templates. } + + + public void removeArtifact( String repositoryId, String namespace, String project, String projectVersion, + String projectId, MetadataFacet metadataFacet ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } } \ No newline at end of file -- cgit v1.2.3