}
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
}
}
- 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
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",
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" );
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 );
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 ) );
}
+ 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";
+
}
</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>
{
this.metadataFacetFactories = metadataFacetFactories;
this.repository = repository;
-
- //session = repository.login( new SimpleCredentials( "admin", "admin".toCharArray() ) );
}
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
{
if ( this.jcrSession == null || !this.jcrSession.isLive() )
{
-
jcrSession = repository.login( new SimpleCredentials( "admin", "admin".toCharArray() ) );
-
}
return this.jcrSession;
}