diff options
author | Olivier Lamy <olamy@apache.org> | 2014-03-26 06:01:32 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2014-03-26 06:01:32 +0000 |
commit | 1754cb76e065f83d76550a55af674bff34a490cc (patch) | |
tree | ebf46e02de08d7089dfb52ec118f90c6cddb8129 /archiva-modules/plugins/metadata-store-cassandra | |
parent | 3c0c99a9f2ec8da9bf44c63de4a202ec9595e558 (diff) | |
download | archiva-1754cb76e065f83d76550a55af674bff34a490cc.tar.gz archiva-1754cb76e065f83d76550a55af674bff34a490cc.zip |
all tests passed with cassandra implementation: does not mean everyhting is really working but a good step :-)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1581699 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/plugins/metadata-store-cassandra')
2 files changed, 43 insertions, 17 deletions
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 f7525e61d..db913362b 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 @@ -853,8 +853,13 @@ public class CassandraMetadataRepository projectVersionMetadataModel.setLicenses( versionMetadata.getLicenses() ); // we don't test of repository and namespace really exist ! - String key = new ProjectVersionMetadataModel.KeyBuilder().withRepository( repositoryId ).withNamespace( - namespaceId ).withProjectId( projectId ).withId( versionMetadata.getId() ).build(); + String key = new ProjectVersionMetadataModel.KeyBuilder() // + .withRepository( repositoryId ) // + .withNamespace( namespaceId ) // + .withProjectId( projectId ) // + .withProjectVersion( versionMetadata.getVersion() ) // + .withVersion( versionMetadata.getId() ) // + .build(); // FIXME nested objects to store!!! if ( creation ) @@ -1435,10 +1440,25 @@ public class CassandraMetadataRepository .withRepository( repositoryId ) // .withNamespace( namespace ) // .withProjectId( projectId ) // - .withId( artifactMeta.getId() ) // + .withProjectVersion( projectVersion ) // + .withVersion( artifactMeta.getId() ) // .build(); - exists = this.projectVersionMetadataModelTemplate.isColumnsExist( key ); + Keyspace keyspace = cassandraArchivaManager.getKeyspace(); + StringSerializer ss = StringSerializer.get(); + + QueryResult<OrderedRows<String, String, String>> result = HFactory // + .createRangeSlicesQuery( keyspace, ss, ss, ss ) // + .setColumnFamily( cassandraArchivaManager.getProjectVersionMetadataFamilyName() ) // + .setColumnNames( "version" ) // + .addEqualsExpression( "repositoryName", repositoryId ) // + .addEqualsExpression( "namespaceId", namespaceId ) // + .addEqualsExpression( "projectId", projectId ) // + .addEqualsExpression( "projectVersion", projectVersion ) // + .addEqualsExpression( "version", artifactMeta.getVersion() ) // + .execute(); + + exists = result.get().getCount() > 0; if ( !exists ) { @@ -1892,9 +1912,13 @@ public class CassandraMetadataRepository this.artifactMetadataTemplate.deleteRow( key ); - key = - new ProjectVersionMetadataModel.KeyBuilder().withId( version ).withRepository( repositoryId ).withNamespace( - namespace ).withProjectId( project ).build(); + key = new ProjectVersionMetadataModel.KeyBuilder() // + .withRepository( repositoryId ) // + .withNamespace( namespace ) // + .withProjectId( project ) // + .withProjectVersion( version ) // + .withVersion( id ) // + .build(); this.projectVersionMetadataModelTemplate.deleteRow( key ); } diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java index d441d19bd..faacbc14f 100644 --- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java +++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java @@ -248,7 +248,6 @@ public class ProjectVersionMetadataModel } - public static class KeyBuilder { @@ -258,11 +257,13 @@ public class ProjectVersionMetadataModel private String projectId; - private String id; + private String projectVersion; + + private String version; public KeyBuilder() { - + // no op } public KeyBuilder withNamespace( Namespace namespace ) @@ -284,28 +285,29 @@ public class ProjectVersionMetadataModel return this; } - public KeyBuilder withRepository( Repository repository ) + public KeyBuilder withProjectId( String projectId ) { - this.repositoryName = repository.getName(); + this.projectId = projectId; return this; } - public KeyBuilder withProjectId( String projectId ) + public KeyBuilder withProjectVersion( String projectVersion ) { - this.projectId = projectId; + this.projectVersion = projectVersion; return this; } - public KeyBuilder withId( String id ) + public KeyBuilder withVersion( String version ) { - this.id = id; + this.version = version; return this; } public String build() { // FIXME add some controls - return CassandraUtils.generateKey( this.repositoryName, this.namespace, this.projectId, this.id ); + return CassandraUtils.generateKey( this.repositoryName, this.namespace, this.projectId, this.projectVersion, + this.version ); } } } |