aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Sanchez <carlos@apache.org>2014-11-24 12:56:52 +0100
committerCarlos Sanchez <carlos@apache.org>2014-11-24 12:57:22 +0100
commit011f82dc2135d908a625610920e7f94f1082d0d5 (patch)
tree613fa16a5025c6fe659080abc74cc90166b52cc3
parentf4f7c971b626d04eab567790cbaf6be6418fcaff (diff)
downloadarchiva-011f82dc2135d908a625610920e7f94f1082d0d5.tar.gz
archiva-011f82dc2135d908a625610920e7f94f1082d0d5.zip
Use the same list of ArtifactMetadata column names everywhere
-rw-r--r--archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java12
-rw-r--r--archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java7
-rw-r--r--archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java6
3 files changed, 17 insertions, 8 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 c7529ca70..f58b429b9 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
@@ -1706,8 +1706,7 @@ public class CassandraMetadataRepository
RangeSlicesQuery<String, String, Long> query = HFactory //
.createRangeSlicesQuery( keyspace, ss, ss, ls ) //
.setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
- .setColumnNames( NAMESPACE_ID.toString(), SIZE.toString(), ID.toString(), FILE_LAST_MODIFIED.toString(), MD5.toString(), PROJECT.toString(), PROJECT_VERSION.toString(),
- REPOSITORY_NAME.toString(), VERSION.toString(), WHEN_GATHERED.toString(), SHA1.toString() ); //
+ .setColumnNames( ArtifactMetadataModel.COLUMNS ); //
if ( startTime != null )
{
@@ -1789,8 +1788,7 @@ public class CassandraMetadataRepository
RangeSlicesQuery<String, String, String> query = HFactory //
.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
.setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
- .setColumnNames( NAMESPACE_ID.toString(), SIZE.toString(), ID.toString(), FILE_LAST_MODIFIED.toString(), MD5.toString(), PROJECT.toString(), PROJECT_VERSION.toString(),
- REPOSITORY_NAME.toString(), VERSION.toString(), WHEN_GATHERED.toString(), SHA1.toString() ); //
+ .setColumnNames( ArtifactMetadataModel.COLUMNS ); //
query = query.addEqualsExpression( SHA1.toString(), checksum ).addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId );
@@ -1899,8 +1897,7 @@ public class CassandraMetadataRepository
RangeSlicesQuery<String, String, String> query = HFactory //
.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
.setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
- .setColumnNames( NAMESPACE_ID.toString(), SIZE.toString(), ID.toString(), FILE_LAST_MODIFIED.toString(), MD5.toString(), PROJECT.toString(), PROJECT_VERSION.toString(),
- REPOSITORY_NAME.toString(), VERSION.toString(), WHEN_GATHERED.toString(), SHA1.toString() ); //
+ .setColumnNames( ArtifactMetadataModel.COLUMNS ); //
query = query.addEqualsExpression( REPOSITORY_NAME.toString(), repositoryId );
@@ -2009,8 +2006,7 @@ public class CassandraMetadataRepository
QueryResult<OrderedRows<String, String, String>> result =
HFactory.createRangeSlicesQuery( keyspace, ss, ss, ss ) //
.setColumnFamily( cassandraArchivaManager.getArtifactMetadataFamilyName() ) //
- .setColumnNames( ID.toString(), REPOSITORY_NAME.toString(), NAMESPACE_ID.toString(), PROJECT.toString(), PROJECT_VERSION.toString(), VERSION.toString(),
- FILE_LAST_MODIFIED.toString(), SIZE.toString(), MD5.toString(), SHA1.toString(), WHEN_GATHERED.toString() )//
+ .setColumnNames( ArtifactMetadataModel.COLUMNS )//
.setRowCount( Integer.MAX_VALUE ) //
.addEqualsExpression( REPOSITORY_NAME.toString(), repoId ) //
.addEqualsExpression( NAMESPACE_ID.toString(), namespace ) //
diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java
index b4c03d93b..6366fe9f8 100644
--- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java
+++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java
@@ -28,6 +28,8 @@ import me.prettyprint.hector.api.beans.ColumnSlice;
import me.prettyprint.hector.api.beans.HColumn;
import me.prettyprint.hector.api.factory.HFactory;
import me.prettyprint.hector.api.mutation.Mutator;
+
+import org.apache.archiva.metadata.repository.cassandra.model.ColumnNames;
import org.apache.commons.lang.StringUtils;
/**
@@ -77,6 +79,11 @@ public class CassandraUtils
(Serializer<B>) SerializerTypeInferer.getSerializer( value ) );
}
+ public static String getStringValue( ColumnSlice<String, String> columnSlice, ColumnNames columnName )
+ {
+ return getStringValue( columnSlice, columnName.toString() );
+ }
+
public static String getStringValue( ColumnSlice<String, String> columnSlice, String columnName )
{
if ( StringUtils.isEmpty( columnName ) )
diff --git a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
index ce8f552d8..530a49e1f 100644
--- a/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
+++ b/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
@@ -19,6 +19,8 @@ package org.apache.archiva.metadata.repository.cassandra.model;
* under the License.
*/
+import static org.apache.archiva.metadata.repository.cassandra.model.ColumnNames.*;
+
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
import java.io.Serializable;
@@ -34,6 +36,10 @@ public class ArtifactMetadataModel
implements Serializable
{
+ public final static String[] COLUMNS = new String[] { ID.toString(), REPOSITORY_NAME.toString(),
+ NAMESPACE_ID.toString(), PROJECT.toString(), PROJECT_VERSION.toString(), VERSION.toString(),
+ FILE_LAST_MODIFIED.toString(), SIZE.toString(), MD5.toString(), SHA1.toString(), WHEN_GATHERED.toString() };
+
private String id;
private String repositoryId;