try
{
QueryManager queryManager = session.getWorkspace().getQueryManager();
- Query query = queryManager.createQuery( "SELECT size FROM [archiva:artifact]", Query.JCR_SQL2 );
+ String whereClause = "WHERE ISDESCENDANTNODE([/repositories/" + repositoryId + "/content])";
+ Query query = queryManager.createQuery( "SELECT size FROM [archiva:artifact] " + whereClause,
+ Query.JCR_SQL2 );
QueryResult queryResult = query.execute();
for ( Row row : JcrUtils.getRows( queryResult ) )
{
Node n = row.getNode();
- if ( n.getPath().startsWith( "/repositories/" + repositoryId + "/content/" ) )
+// if ( n.getPath().startsWith( "/repositories/" + repositoryId + "/content/" ) )
{
totalSize += row.getValue( "size" ).getLong();
repositoryStatistics.setTotalCountForType( entry.getKey(), entry.getValue() );
}
- query = queryManager.createQuery( "SELECT * FROM [archiva:project]", Query.JCR_SQL2 );
+ query = queryManager.createQuery( "SELECT * FROM [archiva:project] " + whereClause, Query.JCR_SQL2 );
repositoryStatistics.setTotalProjectCount( query.execute().getRows().getSize() );
- query = queryManager.createQuery( "SELECT * FROM [archiva:namespace] WHERE namespace IS NOT NULL",
- Query.JCR_SQL2 );
+ query = queryManager.createQuery(
+ "SELECT * FROM [archiva:namespace] " + whereClause + " AND namespace IS NOT NULL", Query.JCR_SQL2 );
repositoryStatistics.setTotalGroupCount( query.execute().getRows().getSize() );
}
catch ( RepositoryException e )
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
import java.io.File;
+import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.zip.GZIPInputStream;
cal.add( Calendar.HOUR, -1 );
Date startTime = cal.getTime();
- Node n = JcrUtils.getOrAddNode( session.getRootNode(), "repositories" );
- n = JcrUtils.getOrAddNode( n, TEST_REPO );
- n = JcrUtils.getOrAddNode( n, "content" );
- n = JcrUtils.getOrAddNode( n, "org" );
- n = JcrUtils.getOrAddNode( n, "apache" );
-
- GZIPInputStream inputStream = new GZIPInputStream( getClass().getResourceAsStream( "/artifacts.xml.gz" ) );
- session.importXML( n.getPath(), inputStream, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW );
- session.save();
+ loadContentIntoRepo( TEST_REPO );
+ loadContentIntoRepo( "another-repo" );
repositoryStatisticsManager.addStatisticsAfterScan( metadataRepository, TEST_REPO, startTime, endTime,
TOTAL_FILE_COUNT, NEW_FILE_COUNT );
verify( metadataRepository ).addMetadataFacet( TEST_REPO, expectedStatistics );
}
+
+ private void loadContentIntoRepo( String repoId )
+ throws RepositoryException, IOException
+ {
+ Node n = JcrUtils.getOrAddNode( session.getRootNode(), "repositories" );
+ n = JcrUtils.getOrAddNode( n, repoId );
+ n = JcrUtils.getOrAddNode( n, "content" );
+ n = JcrUtils.getOrAddNode( n, "org" );
+ n = JcrUtils.getOrAddNode( n, "apache" );
+
+ GZIPInputStream inputStream = new GZIPInputStream( getClass().getResourceAsStream( "/artifacts.xml.gz" ) );
+ session.importXML( n.getPath(), inputStream, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW );
+ session.save();
+ }
}