mirror of https://github.com/apache/archiva.git
[MRM-1327] fix 'used by' to work under JCR store. This will still have problems under the file store at the moment
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1085722 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1a95fa3b64
commit
bed7aa1b59
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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();
|
||||
n = n.getParent(); // project
|
||||
String usedByProject = n.getName();
|
||||
|
||||
while ( j.hasNext() )
|
||||
{
|
||||
Node project = j.nextNode();
|
||||
n = n.getParent(); // namespace
|
||||
String usedByNamespace = n.getProperty( "namespace" ).getString();
|
||||
|
||||
NodeIterator k = project.getNodes();
|
||||
|
||||
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 )
|
||||
|
|
Loading…
Reference in New Issue