git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1353618 13f79535-47bb-0310-9956-ffa450edef68tags/archiva-1.4-M3
@@ -781,10 +781,18 @@ public class DefaultRepositoriesService | |||
} | |||
else | |||
{ | |||
metadataRepository.removeArtifact( artifactMetadata.getRepositoryId(), | |||
artifactMetadata.getNamespace(), | |||
artifactMetadata.getProject(), artifact.getVersion(), | |||
artifactMetadata.getId() ); | |||
if ( snapshotVersion ) | |||
{ | |||
metadataRepository.removeArtifact( artifactMetadata, | |||
VersionUtil.getBaseVersion( artifact.getVersion() ) ); | |||
} | |||
else | |||
{ | |||
metadataRepository.removeArtifact( artifactMetadata.getRepositoryId(), | |||
artifactMetadata.getNamespace(), | |||
artifactMetadata.getProject(), artifact.getVersion(), | |||
artifactMetadata.getId() ); | |||
} | |||
} | |||
// TODO: move into the metadata repository proper - need to differentiate attachment of | |||
// repository metadata to an artifact |
@@ -341,21 +341,6 @@ public class RepositoriesServiceTest | |||
} | |||
} | |||
protected ManagedRepository getTestManagedRepository( String id, String path ) | |||
{ | |||
String location = new File( FileUtil.getBasedir(), "target/" + path ).getAbsolutePath(); | |||
return new ManagedRepository( id, id, location, "default", true, true, true, "2 * * * * ?", null, false, 80, 80, | |||
true, false ); | |||
} | |||
protected ManagedRepository getTestManagedRepository() | |||
{ | |||
return getTestManagedRepository( "TEST", "test-repo" ); | |||
} | |||
static final String SNAPSHOT_REPO_ID = "snapshot-repo"; | |||
@Test | |||
public void deleteSnapshot() | |||
throws Exception | |||
@@ -363,6 +348,10 @@ public class RepositoriesServiceTest | |||
File targetRepo = initSnapshotRepo(); | |||
try | |||
{ | |||
RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader ); | |||
//repositoriesService.scanRepositoryDirectoriesNow( SNAPSHOT_REPO_ID ); | |||
BrowseService browseService = getBrowseService( authorizationHeader, false ); | |||
List<Artifact> artifacts = | |||
browseService.getArtifactDownloadInfos( "org.apache.archiva.redback.components", "spring-quartz", | |||
@@ -372,8 +361,6 @@ public class RepositoriesServiceTest | |||
Assertions.assertThat( artifacts ).isNotNull().isNotEmpty().hasSize( 10 ); | |||
RepositoriesService repositoriesService = getRepositoriesService( authorizationHeader ); | |||
File artifactFile = new File( targetRepo, | |||
"org/apache/archiva/redback/components/spring-quartz/2.0-SNAPSHOT/spring-quartz-2.0-20120618.214127-1.jar" ); | |||
@@ -393,8 +380,10 @@ public class RepositoriesServiceTest | |||
artifact.setPackaging( "jar" ); | |||
artifact.setRepositoryId( SNAPSHOT_REPO_ID ); | |||
artifact.setContext( SNAPSHOT_REPO_ID ); | |||
repositoriesService.deleteArtifact( artifact ); | |||
artifacts = | |||
browseService.getArtifactDownloadInfos( "org.apache.archiva.redback.components", "spring-quartz", | |||
"2.0-SNAPSHOT", SNAPSHOT_REPO_ID ); | |||
@@ -436,10 +425,11 @@ public class RepositoriesServiceTest | |||
getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository( SNAPSHOT_REPO_ID, true ); | |||
assertNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SNAPSHOT_REPO_ID ) ); | |||
} | |||
ManagedRepository managedRepository = getTestManagedRepository(); | |||
managedRepository.setId( SNAPSHOT_REPO_ID ); | |||
managedRepository.setLocation( targetRepo.getCanonicalPath() ); | |||
managedRepository.setCronExpression( "* * * * * ?" ); | |||
ManagedRepository managedRepository = | |||
getTestManagedRepository( SNAPSHOT_REPO_ID, "repo-with-snapshots" ); | |||
/*managedRepository.setId( SNAPSHOT_REPO_ID ); | |||
managedRepository.setLocation( ); | |||
managedRepository.setCronExpression( "* * * * * ?" );*/ | |||
getManagedRepositoriesService( authorizationHeader ).addManagedRepository( managedRepository ); | |||
assertNotNull( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( SNAPSHOT_REPO_ID ) ); | |||
@@ -458,5 +448,20 @@ public class RepositoriesServiceTest | |||
} | |||
protected ManagedRepository getTestManagedRepository( String id, String path ) | |||
{ | |||
String location = new File( FileUtil.getBasedir(), "target/" + path ).getAbsolutePath(); | |||
return new ManagedRepository( id, id, location, "default", true, true, true, "2 * * * * ?", null, false, 80, 80, | |||
true, false ); | |||
} | |||
protected ManagedRepository getTestManagedRepository() | |||
{ | |||
return getTestManagedRepository( "TEST", "test-repo" ); | |||
} | |||
static final String SNAPSHOT_REPO_ID = "snapshot-repo"; | |||
} |
@@ -32,18 +32,20 @@ | |||
</Security> | |||
<Workspaces rootPath="${rep.home}/workspaces" defaultWorkspace="default"/> | |||
<Workspace name="${wsp.name}"> | |||
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"> | |||
<FileSystem class="org.apache.jackrabbit.core.fs.mem.MemoryFileSystem"/> | |||
<!--FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"> | |||
<param name="path" value="${wsp.home}"/> | |||
</FileSystem> | |||
</FileSystem--> | |||
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager"/> | |||
<SearchIndex class="org.apache.jackrabbit.core.query.lucene.SearchIndex"> | |||
<param name="path" value="${wsp.home}/index"/> | |||
</SearchIndex> | |||
</Workspace> | |||
<Versioning rootPath="${rep.home}/version"> | |||
<FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"> | |||
<FileSystem class="org.apache.jackrabbit.core.fs.mem.MemoryFileSystem"/> | |||
<!--FileSystem class="org.apache.jackrabbit.core.fs.local.LocalFileSystem"> | |||
<param name="path" value="${rep.home}/version"/> | |||
</FileSystem> | |||
</FileSystem--> | |||
<PersistenceManager class="org.apache.jackrabbit.core.persistence.bundle.BundleFsPersistenceManager"/> | |||
</Versioning> | |||
</Repository> |
@@ -79,6 +79,9 @@ public interface MetadataRepository | |||
void removeArtifact( String repositoryId, String namespace, String project, String version, String id ) | |||
throws MetadataRepositoryException; | |||
void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion ) | |||
throws MetadataRepositoryException; | |||
/** | |||
* @param repositoryId | |||
* @param namespace |
@@ -101,8 +101,6 @@ public class JcrMetadataRepository | |||
{ | |||
this.metadataFacetFactories = metadataFacetFactories; | |||
this.repository = repository; | |||
//session = repository.login( new SimpleCredentials( "admin", "admin".toCharArray() ) ); | |||
} | |||
@@ -1003,6 +1001,48 @@ public class JcrMetadataRepository | |||
return getNodeNames( getProjectPath( repositoryId, namespace, projectId ), PROJECT_VERSION_NODE_TYPE ); | |||
} | |||
public void removeArtifact( ArtifactMetadata artifactMetadata, String baseVersion ) | |||
throws MetadataRepositoryException | |||
{ | |||
String repositoryId = artifactMetadata.getRepositoryId(); | |||
try | |||
{ | |||
Node root = getJcrSession().getRootNode(); | |||
String path = | |||
getProjectVersionPath( repositoryId, artifactMetadata.getNamespace(), artifactMetadata.getProject(), | |||
baseVersion ); | |||
if ( root.hasNode( path ) ) | |||
{ | |||
Node node = root.getNode( path ); | |||
for ( Node n : JcrUtils.getChildNodes( node ) ) | |||
{ | |||
if ( n.isNodeType( ARTIFACT_NODE_TYPE ) ) | |||
{ | |||
if ( n.hasProperty( "version" ) ) | |||
{ | |||
String version = n.getProperty( "version" ).getString(); | |||
if ( StringUtils.equals( version, artifactMetadata.getVersion() ) ) | |||
{ | |||
n.remove(); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
catch ( RepositoryException e ) | |||
{ | |||
throw new MetadataRepositoryException( e.getMessage(), e ); | |||
} | |||
} | |||
public void removeArtifact( String repositoryId, String namespace, String projectId, String projectVersion, | |||
String id ) | |||
throws MetadataRepositoryException | |||
@@ -1422,9 +1462,7 @@ public class JcrMetadataRepository | |||
{ | |||
if ( this.jcrSession == null || !this.jcrSession.isLive() ) | |||
{ | |||
jcrSession = repository.login( new SimpleCredentials( "admin", "admin".toCharArray() ) ); | |||
} | |||
return this.jcrSession; | |||
} |
@@ -18,7 +18,7 @@ | |||
--> | |||
<!DOCTYPE Repository PUBLIC "-//The Apache Software Foundation//DTD Jackrabbit 1.6//EN" | |||
"http://jackrabbit.apache.org/dtd/repository-1.6.dtd"> | |||
"http://jackrabbit.apache.org/dtd/repository-2.0.dtd"> | |||
<!-- START SNIPPET: default-repository --> | |||
<Repository> |