From e4da1fa6f5a56bbf63bae1de7d1b7dd0ae0375aa Mon Sep 17 00:00:00 2001 From: Carlos Sanchez Date: Wed, 5 Nov 2014 20:11:08 +0100 Subject: [MRM-1390] Add REST methods to search JCR store for generic metadata and properties Added REST methods: artifactsByProjectVersionMetadata/{key}/{value} artifactsByMetadata/{key}/{value} artifactsByProperty/{key}/{value} searchArtifacts/{text} searchArtifacts/{key}/{text} In JCR implementation When searching into any property (key = nil) we can't do exact searchs --- .../plugins/metadata-store-cassandra/pom.xml | 5 + .../cassandra/CassandraMetadataRepository.java | 37 ++++++++ .../cassandra/CassandraMetadataRepositoryTest.java | 105 +++++++++++++++++++-- 3 files changed, 141 insertions(+), 6 deletions(-) (limited to 'archiva-modules/plugins/metadata-store-cassandra') diff --git a/archiva-modules/plugins/metadata-store-cassandra/pom.xml b/archiva-modules/plugins/metadata-store-cassandra/pom.xml index 6a8072c87..83a6b1710 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/pom.xml +++ b/archiva-modules/plugins/metadata-store-cassandra/pom.xml @@ -130,6 +130,11 @@ spring-test test + + org.apache.archiva + generic-metadata-support + test + org.assertj assertj-core diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java index f58b429b9..779c19f1c 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java @@ -21,6 +21,7 @@ package org.apache.archiva.metadata.repository.cassandra; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; + import me.prettyprint.cassandra.serializers.LongSerializer; import me.prettyprint.cassandra.serializers.StringSerializer; import me.prettyprint.cassandra.service.template.ColumnFamilyResult; @@ -37,6 +38,7 @@ import me.prettyprint.hector.api.mutation.MutationResult; import me.prettyprint.hector.api.mutation.Mutator; import me.prettyprint.hector.api.query.QueryResult; import me.prettyprint.hector.api.query.RangeSlicesQuery; + import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.metadata.model.ArtifactMetadata; import org.apache.archiva.metadata.model.CiManagement; @@ -67,6 +69,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.persistence.PersistenceException; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -1823,6 +1826,26 @@ public class CassandraMetadataRepository return artifactMetadataMap.values(); } + @Override + public List getArtifactsByProjectVersionMetadata( String key, String value, String repositoryId ) + throws MetadataRepositoryException + { + throw new UnsupportedOperationException( "not yet implemented in Cassandra backend" ); + } + + @Override + public List getArtifactsByMetadata( String key, String value, String repositoryId ) + throws MetadataRepositoryException + { + throw new UnsupportedOperationException( "not yet implemented in Cassandra backend" ); + } + + @Override + public List getArtifactsByProperty( String key, String value, String repositoryId ) + throws MetadataRepositoryException + { + throw new UnsupportedOperationException( "getArtifactsByProperty not yet implemented in Cassandra backend" ); + } @Override public void removeArtifact( final String repositoryId, final String namespace, final String project, @@ -2174,4 +2197,18 @@ public class CassandraMetadataRepository { return ModelMapperHolder.MODEL_MAPPER; } + + @Override + public List searchArtifacts( String text, String repositoryId, boolean exact ) + throws MetadataRepositoryException + { + throw new UnsupportedOperationException( "searchArtifacts not yet implemented in Cassandra backend" ); + } + + @Override + public List searchArtifacts( String key, String text, String repositoryId, boolean exact ) + throws MetadataRepositoryException + { + throw new UnsupportedOperationException( "searchArtifacts not yet implemented in Cassandra backend" ); + } } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java b/archiva-modules/plugins/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java index c26a660e8..97b3718f7 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/test/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepositoryTest.java @@ -19,21 +19,19 @@ package org.apache.archiva.metadata.repository.cassandra; * under the License. */ -import org.apache.archiva.metadata.model.MailingList; import org.apache.archiva.metadata.model.MetadataFacetFactory; import org.apache.archiva.metadata.repository.AbstractMetadataRepositoryTest; import org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel; import org.apache.commons.io.FileUtils; import org.junit.After; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import javax.inject.Inject; import javax.inject.Named; + import java.io.File; -import java.util.List; import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; @@ -44,8 +42,6 @@ import static org.assertj.core.api.Assertions.assertThat; public class CassandraMetadataRepositoryTest extends AbstractMetadataRepositoryTest { - private Logger logger = LoggerFactory.getLogger( getClass() ); - @Inject @Named(value = "archivaEntityManagerFactory#cassandra") CassandraArchivaManager cassandraArchivaManager; @@ -73,6 +69,103 @@ public class CassandraMetadataRepositoryTest clearReposAndNamespace( cassandraArchivaManager ); } + @Override + @Ignore + public void testGetArtifactsByProjectVersionMetadata() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testGetArtifactsByProjectVersionMetadataNoRepository() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testGetArtifactsByProjectVersionMetadataAllRepositories() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testGetArtifactsByMetadataAllRepositories() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testGetArtifactsByPropertySingleResult() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testSearchArtifactsByKey() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testSearchArtifactsByKeyExact() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testSearchArtifactsFullText() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testSearchArtifactsFullTextExact() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testSearchArtifactsByFacetKeyAllRepos() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testSearchArtifactsByFacetKey() + throws Exception + { + // TODO not implemented + } + + @Override + @Ignore + public void testSearchArtifactsFullTextByFacet() + throws Exception + { + // TODO not implemented + } + + /** * ensure all dependant tables are cleaned up (mailinglist, license, dependencies) * -- cgit v1.2.3