From 076a33f877500585b17b5f8f68a3d0fb28333f19 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Tue, 29 Mar 2011 12:42:47 +0000 Subject: [PATCH] [MRM-1327] fix 'used by' to work under JCR store. Remove updateProjectReferences API git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1086569 13f79535-47bb-0310-9956-ffa450edef68 --- .../repository/TestMetadataRepository.java | 6 ----- .../NewArtifactsRssFeedProcessorTest.java | 6 ----- .../memory/TestMetadataRepository.java | 6 ----- .../repository/TestMetadataRepository.java | 6 ----- .../repository/DefaultMetadataResolver.java | 14 ----------- .../repository/MetadataRepository.java | 4 ---- .../repository/TestMetadataRepository.java | 6 ----- .../file/FileMetadataRepository.java | 13 ++++++++-- .../repository/jcr/JcrMetadataRepository.java | 24 ------------------- 9 files changed, 11 insertions(+), 74 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index 2d8584e4d..73b8616cc 100644 --- a/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/archiva-base/archiva-proxy/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -94,12 +94,6 @@ public class TestMetadataRepository //To change body of implemented methods use File | Settings | File Templates. } - public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion, - ProjectVersionReference reference ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - public void updateNamespace( String repoId, String namespace ) { //To change body of implemented methods use File | Settings | File Templates. diff --git a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java index 796f32dab..dc6f11568 100644 --- a/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java +++ b/archiva-modules/archiva-web/archiva-rss/src/test/java/org/apache/archiva/rss/processor/NewArtifactsRssFeedProcessorTest.java @@ -195,12 +195,6 @@ public class NewArtifactsRssFeedProcessorTest throw new UnsupportedOperationException(); } - public void updateProjectReference( String arg0, String arg1, String arg2, String arg3, - ProjectVersionReference arg4 ) - { - throw new UnsupportedOperationException(); - } - public void updateProjectVersion( String arg0, String arg1, String arg2, ProjectVersionMetadata arg3 ) { throw new UnsupportedOperationException(); diff --git a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java index b1d60e7e4..f1ae981af 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/archiva/metadata/repository/memory/TestMetadataRepository.java @@ -133,12 +133,6 @@ public class TestMetadataRepository throw new UnsupportedOperationException(); } - public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion, - ProjectVersionReference reference ) - { - throw new UnsupportedOperationException(); - } - public void updateNamespace( String repoId, String namespace ) { throw new UnsupportedOperationException(); diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index 40db2513d..fc1370c52 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -94,12 +94,6 @@ public class TestMetadataRepository //To change body of implemented methods use File | Settings | File Templates. } - public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion, - ProjectVersionReference reference ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - public void updateNamespace( String repoId, String namespace ) { //To change body of implemented methods use File | Settings | File Templates. diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java index 3e61ab990..08115b1cb 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/DefaultMetadataResolver.java @@ -20,7 +20,6 @@ package org.apache.archiva.metadata.repository; */ import org.apache.archiva.metadata.model.ArtifactMetadata; -import org.apache.archiva.metadata.model.Dependency; import org.apache.archiva.metadata.model.ProjectMetadata; import org.apache.archiva.metadata.model.ProjectVersionMetadata; import org.apache.archiva.metadata.model.ProjectVersionReference; @@ -108,19 +107,6 @@ public class DefaultMetadataResolver ref.setProjectId( projectId ); ref.setProjectVersion( projectVersion ); ref.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY ); - for ( Dependency dependency : metadata.getDependencies() ) - { - try - { - metadataRepository.updateProjectReference( repoId, dependency.getGroupId(), - dependency.getArtifactId(), - dependency.getVersion(), ref ); - } - catch ( MetadataRepositoryException e ) - { - log.warn( "Unable to persist resolved information: " + e.getMessage(), e ); - } - } } try { diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java index 727a4e7a5..4e8450070 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java +++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/MetadataRepository.java @@ -48,10 +48,6 @@ public interface MetadataRepository ProjectVersionMetadata versionMetadata ) throws MetadataRepositoryException; - void updateProjectReference( String repositoryId, String namespace, String projectId, String projectVersion, - ProjectVersionReference reference ) - throws MetadataRepositoryException; - void updateNamespace( String repositoryId, String namespace ) throws MetadataRepositoryException; diff --git a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java index bd07c142a..499223e17 100644 --- a/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java +++ b/archiva-modules/plugins/maven2-repository/src/test/java/org/apache/archiva/metadata/repository/TestMetadataRepository.java @@ -54,12 +54,6 @@ public class TestMetadataRepository //To change body of implemented methods use File | Settings | File Templates. } - public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion, - ProjectVersionReference reference ) - { - //To change body of implemented methods use File | Settings | File Templates. - } - public void updateNamespace( String repoId, String namespace ) { //To change body of implemented methods use File | Settings | File Templates. diff --git a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java index 2d2fea31a..df353fa19 100644 --- a/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java +++ b/archiva-modules/plugins/metadata-repository-file/src/main/java/org/apache/archiva/metadata/repository/file/FileMetadataRepository.java @@ -188,6 +188,11 @@ public class FileMetadataRepository i++; } i = 0; + ProjectVersionReference reference = new ProjectVersionReference(); + reference.setNamespace( namespace ); + reference.setProjectId( projectId ); + reference.setProjectVersion( versionMetadata.getId() ); + reference.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY ); for ( Dependency dependency : versionMetadata.getDependencies() ) { setProperty( properties, "dependency." + i + ".classifier", dependency.getClassifier() ); @@ -198,6 +203,10 @@ public class FileMetadataRepository setProperty( properties, "dependency." + i + ".version", dependency.getVersion() ); setProperty( properties, "dependency." + i + ".type", dependency.getType() ); setProperty( properties, "dependency." + i + ".optional", String.valueOf( dependency.isOptional() ) ); + + updateProjectReference( repoId, dependency.getGroupId(), dependency.getArtifactId(), + dependency.getVersion(), reference ); + i++; } Set facetIds = new LinkedHashSet( versionMetadata.getFacetIds() ); @@ -250,8 +259,8 @@ public class FileMetadataRepository } } - public void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion, - ProjectVersionReference reference ) + private void updateProjectReference( String repoId, String namespace, String projectId, String projectVersion, + ProjectVersionReference reference ) { File directory = new File( getDirectory( repoId ), namespace + "/" + projectId + "/" + projectVersion ); 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 3e2b6c11a..449703437 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 @@ -345,30 +345,6 @@ public class JcrMetadataRepository } } - // FIXME: remove this and projectversionreference - public void updateProjectReference( String repositoryId, String namespace, String projectId, String projectVersion, - ProjectVersionReference reference ) - throws MetadataRepositoryException - { - // not using weak references, since they still need to exist upfront to be referred to - try - { - Node node = getOrAddRepositoryContentNode( repositoryId ); - node = JcrUtils.getOrAddNode( node, namespace ); - node = JcrUtils.getOrAddNode( node, projectId ); - node = JcrUtils.getOrAddNode( node, projectVersion ); - node = JcrUtils.getOrAddNode( node, "references" ); - node = JcrUtils.getOrAddNode( node, reference.getNamespace() ); - node = JcrUtils.getOrAddNode( node, reference.getProjectId() ); - node = JcrUtils.getOrAddNode( node, reference.getProjectVersion() ); - node.setProperty( "type", reference.getReferenceType().toString() ); - } - catch ( RepositoryException e ) - { - throw new MetadataRepositoryException( e.getMessage(), e ); - } - } - public void updateNamespace( String repositoryId, String namespace ) throws MetadataRepositoryException { -- 2.39.5