summaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-web/archiva-rest/archiva-rest-services
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/archiva-web/archiva-rest/archiva-rest-services
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/archiva-web/archiva-rest/archiva-rest-services')
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java2
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java8
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java5
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java2
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java76
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml1
6 files changed, 86 insertions, 8 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
index b95fd1ee3..fbe8f85e6 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
@@ -216,7 +216,7 @@ public abstract class AbstractRestService
}
else
{
- sb.append( '.' ).append( artifact.getPackaging() );
+ sb.append( '.' ).append( artifact.getFileExtension() );
}
return sb.toString();
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
index 2ef6db202..5228ae621 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
@@ -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 );
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 3890a4cf3..6ee2cec2a 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
@@ -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 )
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
index ebf401d4d..085595cf4 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
@@ -55,7 +55,7 @@ public abstract class AbstractArchivaRestTest
// 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
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
index 111653350..4ecdddbe7 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/RepositoriesServiceTest.java
@@ -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
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml
index 4478e93dc..ba9396aa6 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/META-INF/spring-context-test.xml
@@ -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"/>