]> source.dussan.org Git - archiva.git/commitdiff
Use the same list of ArtifactMetadata column names everywhere 13/head
authorCarlos Sanchez <carlos@apache.org>
Mon, 24 Nov 2014 11:56:52 +0000 (12:56 +0100)
committerCarlos Sanchez <carlos@apache.org>
Mon, 24 Nov 2014 11:57:22 +0000 (12:57 +0100)
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraUtils.java
archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java

index c7529ca7028e901b7d3177f3173e1b48d0d36191..f58b429b9905db7925845d4d8a13a709bbdefdc1 100644 (file)
@@ -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 ) //
index b4c03d93b1dc3a275162c1ff261fc4d4d63e3363..6366fe9f8d51b1a8291f6742f60c21fdfa7670fe 100644 (file)
@@ -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 ) )
index ce8f552d8be5510c00155cb4818b49cfd1445889..530a49e1fb4c6a163b626b33ff0428dcc3acb15f 100644 (file)
@@ -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;