diff options
author | Brett Porter <brett@apache.org> | 2010-12-30 01:41:07 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2010-12-30 01:41:07 +0000 |
commit | de23f7ef3fab748ae66ebcf95b48904397a52a55 (patch) | |
tree | dd6f692321b6fbc45a20b41faa320d901ca78e36 /archiva-modules/plugins/metadata-store-jcr/src | |
parent | e28ae522d1ce049848d2a30fa4e2371b0b4be706 (diff) | |
download | archiva-de23f7ef3fab748ae66ebcf95b48904397a52a55.tar.gz archiva-de23f7ef3fab748ae66ebcf95b48904397a52a55.zip |
[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
Diffstat (limited to 'archiva-modules/plugins/metadata-store-jcr/src')
-rw-r--r-- | archiva-modules/plugins/metadata-store-jcr/src/main/java/org/apache/archiva/metadata/repository/jcr/JcrMetadataRepository.java | 21 |
1 files changed, 11 insertions, 10 deletions
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<String, MetadataFacetFactory> metadataFacetFactories; private static final Logger log = LoggerFactory.getLogger( JcrMetadataRepository.class ); @@ -489,17 +487,15 @@ public class JcrMetadataRepository { List<ArtifactMetadata> 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<ArtifactMetadata> 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<ArtifactMetadata> 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 { |