summaryrefslogtreecommitdiffstats
path: root/archiva-modules
diff options
context:
space:
mode:
Diffstat (limited to 'archiva-modules')
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java24
-rw-r--r--archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java51
2 files changed, 23 insertions, 52 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
index 9eea712e5..2d9c87bd7 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
@@ -30,7 +30,6 @@ import org.apache.archiva.metadata.model.MetadataFacetFactory;
import org.apache.archiva.metadata.model.Organization;
import org.apache.archiva.metadata.model.ProjectMetadata;
import org.apache.archiva.metadata.model.ProjectVersionMetadata;
-import org.apache.archiva.metadata.model.ProjectVersionReference;
import org.apache.archiva.metadata.model.Scm;
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
@@ -307,29 +306,6 @@ public abstract class AbstractMetadataRepositoryTest
assertTrue( d.isOptional() );
}
- public void testUpdateProjectReference()
- throws Exception
- {
- ProjectVersionReference reference = new ProjectVersionReference();
- reference.setNamespace( "another.namespace" );
- reference.setProjectId( "another-project-id" );
- reference.setProjectVersion( "1.1" );
- reference.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
-
- repository.updateProjectReference( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION,
- reference );
-
- Collection<ProjectVersionReference> references = repository.getProjectReferences( TEST_REPO_ID, TEST_NAMESPACE,
- TEST_PROJECT,
- TEST_PROJECT_VERSION );
- assertEquals( 1, references.size() );
- reference = references.iterator().next();
- assertEquals( "another.namespace", reference.getNamespace() );
- assertEquals( "another-project-id", reference.getProjectId() );
- assertEquals( "1.1", reference.getProjectVersion() );
- assertEquals( ProjectVersionReference.ReferenceType.DEPENDENCY, reference.getReferenceType() );
- }
-
public void testGetRepositories()
throws Exception
{
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 58bbb2009..3e2b6c11a 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
@@ -943,42 +943,37 @@ public class JcrMetadataRepository
{
List<ProjectVersionReference> references = new ArrayList<ProjectVersionReference>();
+ // TODO: bind variables instead
+ String q = "SELECT * FROM [archiva:dependency] WHERE ISDESCENDANTNODE([/repositories/" + repositoryId +
+ "/content]) AND [groupId]='" + namespace + "' AND [artifactId]='" + projectId + "'";
+ if ( projectVersion != null )
+ {
+ q += " AND [version]='" + projectVersion + "'";
+ }
try
{
- Node root = session.getRootNode();
+ Query query = session.getWorkspace().getQueryManager().createQuery( q, Query.JCR_SQL2 );
+ QueryResult result = query.execute();
- String path = getProjectVersionPath( repositoryId, namespace, projectId, projectVersion ) + "/references";
- if ( root.hasNode( path ) )
+ for ( Node n : JcrUtils.getNodes( result ) )
{
- Node node = root.getNode( path );
+ n = n.getParent(); // dependencies grouping element
- NodeIterator i = node.getNodes();
- while ( i.hasNext() )
- {
- Node ns = i.nextNode();
+ n = n.getParent(); // project version
+ String usedByProjectVersion = n.getName();
- NodeIterator j = ns.getNodes();
-
- while ( j.hasNext() )
- {
- Node project = j.nextNode();
+ n = n.getParent(); // project
+ String usedByProject = n.getName();
- NodeIterator k = project.getNodes();
+ n = n.getParent(); // namespace
+ String usedByNamespace = n.getProperty( "namespace" ).getString();
- while ( k.hasNext() )
- {
- Node version = k.nextNode();
-
- ProjectVersionReference ref = new ProjectVersionReference();
- ref.setNamespace( ns.getName() );
- ref.setProjectId( project.getName() );
- ref.setProjectVersion( version.getName() );
- String type = version.getProperty( "type" ).getString();
- ref.setReferenceType( ProjectVersionReference.ReferenceType.valueOf( type ) );
- references.add( ref );
- }
- }
- }
+ ProjectVersionReference ref = new ProjectVersionReference();
+ ref.setNamespace( usedByNamespace );
+ ref.setProjectId( usedByProject );
+ ref.setProjectVersion( usedByProjectVersion );
+ ref.setReferenceType( ProjectVersionReference.ReferenceType.DEPENDENCY );
+ references.add( ref );
}
}
catch ( RepositoryException e )