diff options
author | Olivier Lamy <olamy@apache.org> | 2014-03-24 03:18:11 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-03-24 03:18:11 +0000 |
commit | c593a9a77f0e66578eb309e984319ab4823098f6 (patch) | |
tree | 24d34133a3efd40c3ce2e65ee1730d695a290571 | |
parent | 6f7387447474cc3533534b635a0aa1cccc9ff6fe (diff) | |
download | archiva-c593a9a77f0e66578eb309e984319ab4823098f6.tar.gz archiva-c593a9a77f0e66578eb309e984319ab4823098f6.zip |
fix retrieve project versions
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1580722 13f79535-47bb-0310-9956-ffa450edef68
2 files changed, 12 insertions, 98 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java index ffec0fd5f..2189b0ae3 100644 --- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java +++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java @@ -204,8 +204,9 @@ public abstract class AbstractMetadataRepositoryTest { assertEquals( Collections.<ArtifactMetadata>emptyList(), new ArrayList<ArtifactMetadata>( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ) ); - assertNull( repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ); - assertNull( repository.getProject( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ) ); + Assertions.assertThat( + repository.getProjectVersion( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION ) ).isNull(); + Assertions.assertThat( repository.getProject( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT ) ).isNull(); Assertions.assertThat( repository.getRootNamespaces( TEST_REPO_ID ) ).isNotNull().isEmpty(); @@ -1239,7 +1240,7 @@ public abstract class AbstractMetadataRepositoryTest Assertions.assertThat( versions ).isNotNull().isNotEmpty().hasSize( 1 ).contains( "2.0" ); Assertions.assertThat( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, - TEST_PROJECT_VERSION )).isNotNull().isEmpty(); + TEST_PROJECT_VERSION ) ).isNotNull().isEmpty(); Assertions.assertThat( repository.getArtifacts( TEST_REPO_ID, TEST_NAMESPACE, TEST_PROJECT, TEST_PROJECT_VERSION_2_0 ) ).isNotEmpty().hasSize( 1 ); 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 044cb0834..b2f5e74f2 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 @@ -1093,7 +1093,7 @@ public class CassandraMetadataRepository .addInsertion( key, cf, column( "repositoryName", repositoryId ) ) // .addInsertion( key, cf, column( "namespaceId", namespaceId ) ) // .addInsertion( key, cf, column( "project", artifactMeta.getProject() ) ) // - .addInsertion( key, cf, column( "projectVersion", artifactMeta.getProjectVersion() ) ) // + .addInsertion( key, cf, column( "projectVersion", projectVersion ) ) // .addInsertion( key, cf, column( "version", artifactMeta.getVersion() ) ) // .addInsertion( key, cf, column( "fileLastModified", artifactMeta.getFileLastModified().getTime() ) ) // .addInsertion( key, cf, column( "size", artifactMeta.getSize() ) ) // @@ -1120,7 +1120,7 @@ public class CassandraMetadataRepository projectVersionMetadataModelTemplate.createMutator() // .addInsertion( key, cf, column( "namespaceId", namespace.getName() ) ) // .addInsertion( key, cf, column( "repositoryName", repositoryId ) ) // - .addInsertion( key, cf, column( "id", artifactMeta.getId() ) ) // + .addInsertion( key, cf, column( "projectVersion", projectVersion ) ) // .addInsertion( key, cf, column( "projectId", projectId ) ) // .execute(); @@ -1163,106 +1163,18 @@ public class CassandraMetadataRepository .execute(); } - /*artifactMetadataModel.setArtifactMetadataModelId( - new ArtifactMetadataModel.KeyBuilder().withId( versionMetadata.getId() ).withRepositoryId( - repositoryId ).withNamespace( namespaceId ).withProjectVersion( - versionMetadata.getVersion() ).withProject( projectId ).build() - );*/ artifactMetadataModel.setRepositoryId( repositoryId ); artifactMetadataModel.setNamespace( namespaceId ); artifactMetadataModel.setProject( projectId ); - artifactMetadataModel.setProjectVersion( artifactMeta.getVersion() ); + artifactMetadataModel.setProjectVersion( projectVersion ); artifactMetadataModel.setVersion( artifactMeta.getVersion() ); artifactMetadataModel.setFileLastModified( artifactMeta.getFileLastModified() == null ? new Date().getTime() : artifactMeta.getFileLastModified().getTime() ); - // - // now facets updateFacets( artifactMeta, artifactMetadataModel ); - -/* String namespaceKey = - new Namespace.KeyBuilder().withRepositoryId( repositoryId ).withNamespace( namespaceId ).build(); - // create the namespace if not exists - Namespace namespace = getNamespaceEntityManager().get( namespaceKey ); - if ( namespace == null ) - { - namespace = updateOrAddNamespace( repositoryId, namespaceId ); - } - - // create the project if not exist - String projectKey = new Project.KeyBuilder().withNamespace( namespace ).withProjectId( projectId ).build(); - - Project project = getProjectEntityManager().get( projectKey ); - if ( project == null ) - { - project = new Project( projectKey, projectId, namespace ); - try - { - getProjectEntityManager().put( project ); - } - catch ( PersistenceException e ) - { - throw new MetadataRepositoryException( e.getMessage(), e ); - } - } - - String key = new ArtifactMetadataModel.KeyBuilder().withNamespace( namespace ).withProject( projectId ).withId( - artifactMeta.getId() ).withProjectVersion( projectVersion ).build(); - - ArtifactMetadataModel artifactMetadataModel = getArtifactMetadataModelEntityManager().get( key ); - if ( artifactMetadataModel == null ) - { - artifactMetadataModel = new ArtifactMetadataModel( key, artifactMeta.getId(), repositoryId, namespaceId, - artifactMeta.getProject(), projectVersion, - artifactMeta.getVersion(), - artifactMeta.getFileLastModified(), - artifactMeta.getSize(), artifactMeta.getMd5(), - artifactMeta.getSha1(), artifactMeta.getWhenGathered() ); - - } - else - { - artifactMetadataModel.setFileLastModified( artifactMeta.getFileLastModified().getTime() ); - artifactMetadataModel.setWhenGathered( artifactMeta.getWhenGathered().getTime() ); - artifactMetadataModel.setSize( artifactMeta.getSize() ); - artifactMetadataModel.setMd5( artifactMeta.getMd5() ); - artifactMetadataModel.setSha1( artifactMeta.getSha1() ); - artifactMetadataModel.setVersion( artifactMeta.getVersion() ); - } - - try - { - getArtifactMetadataModelEntityManager().put( artifactMetadataModel ); - } - catch ( PersistenceException e ) - { - throw new MetadataRepositoryException( e.getMessage(), e ); - } - - key = new ProjectVersionMetadataModel.KeyBuilder().withRepository( repositoryId ).withNamespace( - namespace ).withProjectId( projectId ).withId( projectVersion ).build(); - - ProjectVersionMetadataModel projectVersionMetadataModel = - getProjectVersionMetadataModelEntityManager().get( key ); - - if ( projectVersionMetadataModel == null ) - { - projectVersionMetadataModel = new ProjectVersionMetadataModel(); - projectVersionMetadataModel.setRowId( key ); - projectVersionMetadataModel.setProjectId( projectId ); - projectVersionMetadataModel.setId( projectVersion ); - projectVersionMetadataModel.setNamespace( namespace ); - - getProjectVersionMetadataModelEntityManager().put( projectVersionMetadataModel ); - - } - - // now facets - updateFacets( artifactMeta, artifactMetadataModel );*/ - } @Override @@ -1274,18 +1186,19 @@ public class CassandraMetadataRepository StringSerializer ss = StringSerializer.get(); QueryResult<OrderedRows<String, String, String>> result = HFactory // .createRangeSlicesQuery( keyspace, ss, ss, ss ) // - .setColumnFamily( cassandraArchivaManager.getArtifactMetadataModelFamilyName() ) // - .setColumnNames( "version" ) // + .setColumnFamily( cassandraArchivaManager.getProjectVersionMetadataModelFamilyName() ) // + .setColumnNames( "projectVersion" ) // .addEqualsExpression( "repositoryName", repoId ) // .addEqualsExpression( "namespaceId", namespace ) // .addEqualsExpression( "projectId", projectId ) // - .addEqualsExpression( "projectVersion", projectVersion ).execute(); + .addEqualsExpression( "projectVersion", projectVersion ) // + .execute(); final Set<String> versions = new HashSet<String>(); for ( Row<String, String, String> row : result.get() ) { - versions.add( getStringValue( row.getColumnSlice(), "version" ) ); + versions.add( getStringValue( row.getColumnSlice(), "projectVersion" ) ); } return versions; |