aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/plugins
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2012-06-01 23:48:01 +0000
committerOlivier Lamy <olamy@apache.org>2012-06-01 23:48:01 +0000
commiteeed20ed3604a898910b347cecd19a6d8793e210 (patch)
tree34b9685ec8cd9269359d9dde6fea881904812da7 /archiva-modules/plugins
parent096a4c0ed1d0d4e82c8ebf276554b2663d54cdec (diff)
downloadarchiva-eeed20ed3604a898910b347cecd19a6d8793e210.tar.gz
archiva-eeed20ed3604a898910b347cecd19a6d8793e210.zip
fix an issue with not removing project version when removing an artifact from Metadatarepository
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1345397 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins')
-rw-r--r--archiva-modules/plugins/metadata-store-file/pom.xml5
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/pom.xml5
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java53
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java1
4 files changed, 46 insertions, 18 deletions
diff --git a/archiva-modules/plugins/metadata-store-file/pom.xml b/archiva-modules/plugins/metadata-store-file/pom.xml
index fd50666e1..951c2e0b4 100644
--- a/archiva-modules/plugins/metadata-store-file/pom.xml
+++ b/archiva-modules/plugins/metadata-store-file/pom.xml
@@ -70,6 +70,11 @@
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-assert</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<plugins>
diff --git a/archiva-modules/plugins/metadata-store-jcr/pom.xml b/archiva-modules/plugins/metadata-store-jcr/pom.xml
index ea7932b41..218bb3923 100644
--- a/archiva-modules/plugins/metadata-store-jcr/pom.xml
+++ b/archiva-modules/plugins/metadata-store-jcr/pom.xml
@@ -73,6 +73,11 @@
<artifactId>spring-test</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.easytesting</groupId>
+ <artifactId>fest-assert</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<testResources>
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
index 0ad272528..b0acf2950 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
@@ -35,6 +35,7 @@ import org.apache.archiva.metadata.model.Scm;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
import org.apache.archiva.metadata.repository.MetadataResolutionException;
+import org.apache.commons.lang.StringUtils;
import org.apache.jackrabbit.commons.JcrUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -615,24 +616,6 @@ public class JcrMetadataRepository
return artifacts;
}
- public void removeArtifact( String repositoryId, String namespace, String projectId, String projectVersion,
- String id )
- throws MetadataRepositoryException
- {
- try
- {
- Node root = getJcrSession().getRootNode();
- String path = getArtifactPath( repositoryId, namespace, projectId, projectVersion, id );
- if ( root.hasNode( path ) )
- {
- root.getNode( path ).remove();
- }
- }
- catch ( RepositoryException e )
- {
- throw new MetadataRepositoryException( e.getMessage(), e );
- }
- }
public void removeRepository( String repositoryId )
throws MetadataRepositoryException
@@ -994,6 +977,40 @@ public class JcrMetadataRepository
return getNodeNames( getProjectPath( repositoryId, namespace, projectId ), PROJECT_VERSION_NODE_TYPE );
}
+ public void removeArtifact( String repositoryId, String namespace, String projectId, String projectVersion,
+ String id )
+ throws MetadataRepositoryException
+ {
+ try
+ {
+ Node root = getJcrSession().getRootNode();
+ String path = getArtifactPath( repositoryId, namespace, projectId, projectVersion, id );
+ if ( root.hasNode( path ) )
+ {
+ root.getNode( path ).remove();
+ }
+
+ // remove version
+
+ path = getProjectPath( repositoryId, namespace, projectId );
+
+ Node nodeAtPath = root.getNode( path );
+
+ for ( Node node : JcrUtils.getChildNodes( nodeAtPath ) )
+ {
+ if ( node.isNodeType( PROJECT_VERSION_NODE_TYPE ) && StringUtils.equals( node.getName(),
+ projectVersion ) )
+ {
+ node.remove();
+ }
+ }
+ }
+ catch ( RepositoryException e )
+ {
+ throw new MetadataRepositoryException( e.getMessage(), e );
+ }
+ }
+
public Collection<ArtifactMetadata> getArtifacts( String repositoryId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException
diff --git a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
index 365135943..1123eb30a 100644
--- a/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
+++ b/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
@@ -77,6 +77,7 @@ public class JcrMetadataRepositoryTest
this.repository = jcrMetadataRepository;
}
+
@After
public void tearDown()
throws Exception