From de23f7ef3fab748ae66ebcf95b48904397a52a55 Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Thu, 30 Dec 2010 01:41:07 +0000 Subject: [MRM-1327] make sure getArtifactsByDateRange and getArtifactsByChecksum query is restricted to the right repository git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1053783 13f79535-47bb-0310-9956-ffa450edef68 --- .../repository/jcr/JcrMetadataRepository.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'archiva-modules/plugins/metadata-store-jcr/src') 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 22923eaba..4c329b39e 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 @@ -79,8 +79,6 @@ public class JcrMetadataRepository static final String FACET_NODE_TYPE = "archiva:facet"; - private static final String QUERY_ARTIFACTS = "SELECT * FROM [" + ARTIFACT_NODE_TYPE + "] AS artifact"; - private final Map metadataFacetFactories; private static final Logger log = LoggerFactory.getLogger( JcrMetadataRepository.class ); @@ -489,17 +487,15 @@ public class JcrMetadataRepository { List artifacts; - String q = QUERY_ARTIFACTS; + String q = getArtifactQuery( repoId ); - String clause = " WHERE"; if ( startTime != null ) { - q += clause + " [whenGathered] >= $start"; - clause = " AND"; + q += " AND [whenGathered] >= $start"; } if ( endTime != null ) { - q += clause + " [whenGathered] <= $end"; + q += " AND [whenGathered] <= $end"; } try @@ -566,7 +562,7 @@ public class JcrMetadataRepository { List artifacts; - String q = QUERY_ARTIFACTS + " WHERE [sha1] = $checksum OR [md5] = $checksum"; + String q = getArtifactQuery( repositoryId ) + " AND ([sha1] = $checksum OR [md5] = $checksum)"; try { @@ -630,8 +626,7 @@ public class JcrMetadataRepository { List artifacts; - String q = QUERY_ARTIFACTS + " WHERE ISDESCENDANTNODE(artifact,'/" + getRepositoryContentPath( repositoryId ) + - "')"; + String q = getArtifactQuery( repositoryId ); try { @@ -654,6 +649,12 @@ public class JcrMetadataRepository return artifacts; } + private static String getArtifactQuery( String repositoryId ) + { + return "SELECT * FROM [" + ARTIFACT_NODE_TYPE + "] AS artifact WHERE ISDESCENDANTNODE(artifact,'/" + + getRepositoryContentPath( repositoryId ) + "')"; + } + public ProjectMetadata getProject( String repositoryId, String namespace, String projectId ) throws MetadataResolutionException { -- cgit v1.2.3