diff options
author | Olivier Lamy <olamy@apache.org> | 2012-06-25 15:55:07 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2012-06-25 15:55:07 +0000 |
commit | 208ff50ae5e169fea618e45236153ad7a7bb4849 (patch) | |
tree | 8f3c4046eccafe90d7c6a4808f77dc1db05994bd /archiva-modules/plugins | |
parent | 2296e073bf19fb83caa38718f406420af2a0082c (diff) | |
download | archiva-208ff50ae5e169fea618e45236153ad7a7bb4849.tar.gz archiva-208ff50ae5e169fea618e45236153ad7a7bb4849.zip |
fix junit correctly delete timestamped snapshot
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1353618 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins')
2 files changed, 43 insertions, 5 deletions
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 3b5a9e2bd..e5be2d2b3 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 @@ -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; } diff --git a/archiva-modules/plugins/metadata-store-jcr/src/main/resources/org/apache/archiva/metadata/repository/jcr/repository.xml b/archiva-modules/plugins/metadata-store-jcr/src/main/resources/org/apache/archiva/metadata/repository/jcr/repository.xml index ad61c8de9..76236f54d 100644 --- a/archiva-modules/plugins/metadata-store-jcr/src/main/resources/org/apache/archiva/metadata/repository/jcr/repository.xml +++ b/archiva-modules/plugins/metadata-store-jcr/src/main/resources/org/apache/archiva/metadata/repository/jcr/repository.xml @@ -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> |