archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1345397 - in /archiva/trunk/archiva-modules: archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ arch...
Date Fri, 01 Jun 2012 23:48:02 GMT
Author: olamy
Date: Fri Jun  1 23:48:01 2012
New Revision: 1345397

URL: http://svn.apache.org/viewvc?rev=1345397&view=rev
Log:
fix an issue with not removing project version when removing an artifact from Metadatarepository

Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml
    archiva/trunk/archiva-modules/metadata/metadata-repository-api/pom.xml
    archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
    archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
    archiva/trunk/archiva-modules/plugins/metadata-store-file/pom.xml
    archiva/trunk/archiva-modules/plugins/metadata-store-jcr/pom.xml
    archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
    archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
Fri Jun  1 23:48:01 2012
@@ -216,7 +216,7 @@ public abstract class AbstractRestServic
             }
             else
             {
-                sb.append( '.' ).append( artifact.getPackaging() );
+                sb.append( '.' ).append( artifact.getFileExtension() );
             }
 
             return sb.toString();

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
Fri Jun  1 23:48:01 2012
@@ -204,7 +204,8 @@ public class DefaultBrowseService
 
         try
         {
-            return new VersionsList( new ArrayList<String>( getVersions( selectedRepos,
groupId, artifactId ) ) );
+            Collection<String> versions = getVersions( selectedRepos, groupId, artifactId
);
+            return new VersionsList( new ArrayList<String>( versions ) );
         }
         catch ( MetadataResolutionException e )
         {
@@ -227,8 +228,9 @@ public class DefaultBrowseService
 
             for ( String repoId : selectedRepos )
             {
-                versions.addAll(
-                    metadataResolver.resolveProjectVersions( repositorySession, repoId, groupId,
artifactId ) );
+                Collection<String> projectVersions =
+                    metadataResolver.resolveProjectVersions( repositorySession, repoId, groupId,
artifactId );
+                versions.addAll( projectVersions );
             }
 
             List<String> sortedVersions = new ArrayList<String>( versions );

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
Fri Jun  1 23:48:01 2012
@@ -717,7 +717,7 @@ public class DefaultRepositoriesService
             for ( ArtifactMetadata artifactMetadata : artifacts )
             {
                 // TODO: mismatch between artifact (snapshot) version and project (base)
version here
-                if ( artifact.getVersion().equals( artifact.getVersion() ) )
+                if ( artifactMetadata.getVersion().equals( artifact.getVersion() ) )
                 {
                     metadataRepository.removeArtifact( artifactMetadata.getRepositoryId(),
                                                        artifactMetadata.getNamespace(), artifactMetadata.getProject(),
@@ -735,7 +735,10 @@ public class DefaultRepositoriesService
                     triggerAuditEvent( repositoryId, path, AuditEvent.REMOVE_FILE );
                 }
             }
+
             repositorySession.save();
+
+            repositorySession.close();
         }
 
         catch ( ContentNotFoundException e )

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
Fri Jun  1 23:48:01 2012
@@ -55,7 +55,7 @@ public abstract class AbstractArchivaRes
 
     // START SNIPPET: authz-header
     // guest with an empty password
-    public String guestAuthzHeader =
+    public static String guestAuthzHeader =
         "Basic " + org.apache.cxf.common.util.Base64Utility.encode( ( "guest" + ":" ).getBytes()
);
 
     // with an other login/password

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
Fri Jun  1 23:48:01 2012
@@ -22,11 +22,13 @@ package org.apache.archiva.rest.services
 import org.apache.archiva.admin.model.beans.ManagedRepository;
 import org.apache.archiva.common.utils.FileUtil;
 import org.apache.archiva.rest.api.model.Artifact;
+import org.apache.archiva.rest.api.model.VersionsList;
 import org.apache.archiva.rest.api.services.BrowseService;
 import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
 import org.apache.archiva.rest.api.services.RepositoriesService;
 import org.apache.cxf.jaxrs.client.ServerWebApplicationException;
 import org.fest.assertions.Assertions;
+import org.junit.Ignore;
 import org.junit.Test;
 
 import java.io.File;
@@ -134,16 +136,82 @@ public class RepositoriesServiceTest
         BrowseService browseService = getBrowseService( authorizationHeader, false );
 
         List<Artifact> artifacts =
+            browseService.getArtifactDownloadInfos( "org.apache.karaf.features", "org.apache.karaf.features.core",
+                                                    "2.2.2", SOURCE_REPO_ID );
+
+        log.info( "artifacts: {}", artifacts );
+
+        Assertions.assertThat( artifacts ).isNotNull().isNotEmpty().hasSize( 2 );
+
+        VersionsList versionsList =
+            browseService.getVersionsList( "org.apache.karaf.features", "org.apache.karaf.features.core",
+                                           SOURCE_REPO_ID );
+        Assertions.assertThat( versionsList.getVersions() ).isNotNull().isNotEmpty().hasSize(
2 );
+
+        log.info( "artifacts.size: {}", artifacts.size() );
+
+        try
+        {
+            File artifactFile = new File(
+                "target/test-origin-repo/org/apache/karaf/features/org.apache.karaf.features.core/2.2.2/org.apache.karaf.features.core-2.2.2.jar"
);
+
+            assertTrue( "artifact not exists:" + artifactFile.getPath(), artifactFile.exists()
);
+
+            Artifact artifact = new Artifact();
+            artifact.setGroupId( "org.apache.karaf.features" );
+            artifact.setArtifactId( "org.apache.karaf.features.core" );
+            artifact.setVersion( "2.2.2" );
+            artifact.setPackaging( "jar" );
+            artifact.setContext( SOURCE_REPO_ID );
+
+            RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader
);
+
+            repositoriesService.deleteArtifact( artifact );
+
+            assertFalse( "artifact not deleted exists:" + artifactFile.getPath(), artifactFile.exists()
);
+
+            artifacts =
+                browseService.getArtifactDownloadInfos( "org.apache.karaf.features", "org.apache.karaf.features.core",
+                                                        "2.2.2", SOURCE_REPO_ID );
+
+            Assertions.assertThat( artifacts ).isNotNull().isEmpty();
+
+            versionsList = browseService.getVersionsList( "org.apache.karaf.features", "org.apache.karaf.features.core",
+                                                          SOURCE_REPO_ID );
+
+            Assertions.assertThat( versionsList.getVersions() ).isNotNull().isNotEmpty().hasSize(
1 );
+
+        }
+        finally
+        {
+            cleanRepos();
+        }
+    }
+
+    @Test
+    @Ignore
+    public void deleteArtifactWithClassifier()
+        throws Exception
+    {
+        initSourceTargetRepo();
+
+        BrowseService browseService = getBrowseService( authorizationHeader, false );
+
+        List<Artifact> artifacts =
             browseService.getArtifactDownloadInfos( "commons-logging", "commons-logging",
"1.0.1", SOURCE_REPO_ID );
 
         Assertions.assertThat( artifacts ).isNotNull().isNotEmpty().hasSize( 3 );
 
+        VersionsList versionsList =
+            browseService.getVersionsList( "commons-logging", "commons-logging", SOURCE_REPO_ID
);
+        Assertions.assertThat( versionsList.getVersions() ).isNotNull().isNotEmpty().hasSize(
6 );
+
         log.info( "artifacts.size: {}", artifacts.size() );
 
         try
         {
-            File artifactFile =
-                new File( "target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1.jar"
);
+            File artifactFile = new File(
+                "target/test-origin-repo/commons-logging/commons-logging/1.0.1/commons-logging-1.0.1-javadoc.jar"
);
 
             assertTrue( "artifact not exists:" + artifactFile.getPath(), artifactFile.exists()
);
 
@@ -151,6 +219,7 @@ public class RepositoriesServiceTest
             artifact.setGroupId( "commons-logging" );
             artifact.setArtifactId( "commons-logging" );
             artifact.setVersion( "1.0.1" );
+            artifact.setClassifier( "javadoc" );
             artifact.setPackaging( "jar" );
             artifact.setContext( SOURCE_REPO_ID );
 
@@ -165,6 +234,8 @@ public class RepositoriesServiceTest
 
             Assertions.assertThat( artifacts ).isNotNull().isEmpty();
 
+            Assertions.assertThat( versionsList.getVersions() ).isNotNull().isNotEmpty().hasSize(
5 );
+
         }
         finally
         {
@@ -172,6 +243,7 @@ public class RepositoriesServiceTest
         }
     }
 
+
     @Test
     public void authorizedToDeleteArtifacts()
         throws Exception

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml
Fri Jun  1 23:48:01 2012
@@ -77,6 +77,7 @@
   <bean id="repository" class="org.apache.jackrabbit.core.RepositoryImpl" destroy-method="shutdown">
     <constructor-arg ref="config"/>
   </bean>
+
   <bean id="config" class="org.apache.jackrabbit.core.config.RepositoryConfig" factory-method="create">
     <constructor-arg value="${basedir}/src/test/repository.xml"/>
     <constructor-arg value="${appserver.base}/jcr"/>

Modified: archiva/trunk/archiva-modules/metadata/metadata-repository-api/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/metadata/metadata-repository-api/pom.xml?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/metadata/metadata-repository-api/pom.xml (original)
+++ archiva/trunk/archiva-modules/metadata/metadata-repository-api/pom.xml Fri Jun  1 23:48:01
2012
@@ -57,6 +57,11 @@
       <groupId>org.slf4j</groupId>
       <artifactId>slf4j-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.easytesting</groupId>
+      <artifactId>fest-assert</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Modified: archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
(original)
+++ archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java
Fri Jun  1 23:48:01 2012
@@ -296,6 +296,7 @@ public class DefaultMetadataResolver
         try
         {
             MetadataRepository metadataRepository = session.getRepository();
+
             Collection<String> projectVersions = metadataRepository.getProjectVersions(
repoId, namespace, projectId );
             Collection<String> storageProjectVersions =
                 repositoryStorage.listProjectVersions( repoId, namespace, projectId,

Modified: archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
(original)
+++ archiva/trunk/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
Fri Jun  1 23:48:01 2012
@@ -32,8 +32,11 @@ import org.apache.archiva.metadata.model
 import org.apache.archiva.metadata.model.ProjectMetadata;
 import org.apache.archiva.metadata.model.ProjectVersionMetadata;
 import org.apache.archiva.metadata.model.Scm;
+import org.fest.assertions.Assertions;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
@@ -64,6 +67,8 @@ public abstract class AbstractMetadataRe
 
     private static final String TEST_PROJECT_VERSION = "1.0";
 
+    private static final String TEST_PROJECT_VERSION_2_0 = "2.0";
+
     private static final String TEST_FACET_ID = "test-facet-id";
 
     private static final String TEST_NAME = "test/name";
@@ -78,6 +83,8 @@ public abstract class AbstractMetadataRe
 
     private static final String TEST_METADATA_VALUE = "test-metadata";
 
+    protected Logger log = LoggerFactory.getLogger( getClass() );
+
     protected static Map<String, MetadataFacetFactory> createTestMetadataFacetFactories()
     {
         Map<String, MetadataFacetFactory> factories = new HashMap<String, MetadataFacetFactory>();
@@ -603,6 +610,7 @@ public abstract class AbstractMetadataRe
     public void testGetMetadataFacetsWhenEmpty()
         throws Exception
     {
+
         List<String> facets = repository.getMetadataFacets( TEST_REPO_ID, TEST_FACET_ID
);
         assertTrue( facets.isEmpty() );
     }
@@ -1049,10 +1057,27 @@ public abstract class AbstractMetadataRe
         assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>(
             repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION
) ) );
 
+        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION_2_0,
artifact );
+
+        Collection<String> versions = repository.getProjectVersions( TEST_REPO_ID,
TEST_NAMESPACE, TEST_PROJECT );
+
+        log.info( "versions {}", versions );
+
+        Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
"1.0", "2.0" );
+
         repository.removeArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION,
artifact.getId() );
 
+        versions = repository.getProjectVersions( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT
);
+
+        log.info( "versions {}", versions );
+
+        Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
"2.0" );
+
         assertTrue(
             repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION
).isEmpty() );
+
+        Assertions.assertThat( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT,
+                                                        TEST_PROJECT_VERSION_2_0 ) ).isNotEmpty().hasSize(
1 );
     }
 
     @Test
@@ -1093,6 +1118,27 @@ public abstract class AbstractMetadataRe
         assertTrue( repository.getRootNamespaces( TEST_REPO_ID ).isEmpty() );
     }
 
+
+    @Test
+    public void deleteVersion()
+        throws Exception
+    {
+        ArtifactMetadata artifact = createArtifact();
+        artifact.addFacet( new TestMetadataFacet( "value" ) );
+
+        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION,
artifact );
+
+        repository.updateArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION,
artifact );
+
+        assertEquals( Collections.singletonList( artifact ), new ArrayList<ArtifactMetadata>(
+            repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION
) ) );
+
+        repository.removeArtifact( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION,
artifact.getId() );
+
+        assertTrue(
+            repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION
).isEmpty() );
+    }
+
     private static ProjectMetadata createProject()
     {
         return createProject( TEST_NAMESPACE );

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-file/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-file/pom.xml?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-file/pom.xml (original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-file/pom.xml Fri Jun  1 23:48:01
2012
@@ -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>

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-jcr/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-jcr/pom.xml?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-jcr/pom.xml (original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-jcr/pom.xml Fri Jun  1 23:48:01 2012
@@ -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>

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java
Fri Jun  1 23:48:01 2012
@@ -35,6 +35,7 @@ import org.apache.archiva.metadata.model
 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

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java?rev=1345397&r1=1345396&r2=1345397&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-jcr/src/test/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepositoryTest.java
Fri Jun  1 23:48:01 2012
@@ -77,6 +77,7 @@ public class JcrMetadataRepositoryTest
         this.repository = jcrMetadataRepository;
     }
 
+
     @After
     public void tearDown()
         throws Exception



Mime
View raw message