]> source.dussan.org Git - archiva.git/commitdiff
some cleanup
authorOlivier Lamy <olamy@apache.org>
Thu, 20 Mar 2014 23:22:31 +0000 (23:22 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 20 Mar 2014 23:22:31 +0000 (23:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1579820 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraArchivaManager.java
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/DefaultCassandraArchivaManager.java

index 12c63ece8da4b2b162acb87619816f5b71a747ed..88ed20ff937405d81ad94d76aa9bb47ce6824f39 100644 (file)
@@ -96,7 +96,7 @@ public class CassandraMetadataRepository
         QueryResult<OrderedRows<String, String, String>> result = HFactory //
             .createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(),
                                      StringSerializer.get() ) //
-            .setColumnFamily( "repository" ) //
+            .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() ) //
             .setColumnNames( "id", "name" ) //
             .addEqualsExpression( "id", repositoryId ) //
             .execute();
@@ -110,12 +110,13 @@ public class CassandraMetadataRepository
             {
                 MutationResult mutationResult = HFactory.createMutator( keyspace, StringSerializer.get() ) //
                     //  values
-                    .addInsertion( repositoryId, "repository",
+                    .addInsertion( repositoryId, //
+                                   cassandraArchivaManager.getRepositoryFamilyName(), //
                                    CassandraUtils.column( "id", repository.getId() ) ) //
-                    .addInsertion( repositoryId, "repository",
+                    .addInsertion( repositoryId, //
+                                   cassandraArchivaManager.getRepositoryFamilyName(), //
                                    CassandraUtils.column( "name", repository.getName() ) ) //
                     .execute();
-                logger.debug( "" );
                 return repository;
             }
             catch ( HInvalidRequestException e )
@@ -137,7 +138,7 @@ public class CassandraMetadataRepository
         QueryResult<OrderedRows<String, String, String>> result = HFactory //
             .createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(),
                                      StringSerializer.get() ) //
-            .setColumnFamily( "repository" ) //
+            .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() ) //
             .setColumnNames( "id", "name" ) //
             .addEqualsExpression( "id", repositoryId ) //
             .execute();
@@ -167,9 +168,11 @@ public class CassandraMetadataRepository
                 namespace = new Namespace( namespaceId, repository );
                 HFactory.createMutator( keyspace, StringSerializer.get() )
                     //  values
-                    .addInsertion( namespace.getId(), "namespace", //
+                    .addInsertion( namespace.getId(), //
+                                   cassandraArchivaManager.getNamespaceFamilyName(), //
                                    CassandraUtils.column( "name", namespace.getName() ) ) //
-                    .addInsertion( namespace.getId(), "namespace", //
+                    .addInsertion( namespace.getId(), //
+                                   cassandraArchivaManager.getNamespaceFamilyName(), //
                                    CassandraUtils.column( "repositoryId", repository.getId() ) ) //
                     .execute();
             }
@@ -191,7 +194,7 @@ public class CassandraMetadataRepository
                                      StringSerializer.get(), //
                                      StringSerializer.get(), //
                                      StringSerializer.get() ) //
-            .setColumnFamily( "namespace" ) //
+            .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
             .setColumnNames( "repositoryId", "name" ) //
             .addEqualsExpression( "repositoryId", repositoryId ) //
             .addEqualsExpression( "name", namespaceId ) //
@@ -217,8 +220,9 @@ public class CassandraMetadataRepository
                 new Namespace.KeyBuilder().withNamespace( namespaceId ).withRepositoryId( repositoryId ).build();
 
             MutationResult result =
-                HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ).addDeletion(
-                    key, "namespace" ).execute();
+                HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
+                    .addDeletion( key, cassandraArchivaManager.getNamespaceFamilyName() ) //
+                    .execute();
 
 
         }
@@ -247,7 +251,7 @@ public class CassandraMetadataRepository
                                      StringSerializer.get(), //
                                      StringSerializer.get(), //
                                      StringSerializer.get() ) //
-            .setColumnFamily( "namespace" ) //
+            .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
             .setColumnNames( "repositoryId", "name" ) //
             .addEqualsExpression( "repositoryId", repositoryId ) //
             .execute();
@@ -258,12 +262,12 @@ public class CassandraMetadataRepository
         }
 
         HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
-            .addDeletion( namespacesKey, "namespace" ) //
+            .addDeletion( namespacesKey, cassandraArchivaManager.getNamespaceFamilyName() ) //
             .execute();
 
         //delete repositoryId
         HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
-            .addDeletion( repositoryId, "repository" ) //
+            .addDeletion( repositoryId, cassandraArchivaManager.getRepositoryFamilyName() ) //
             .execute();
 
 /*
@@ -434,7 +438,7 @@ public class CassandraMetadataRepository
                                      StringSerializer.get(), //
                                      StringSerializer.get(), //
                                      StringSerializer.get() ) //
-            .setColumnFamily( "namespace" ) //
+            .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
             .setColumnNames( "name" ) //
             .addEqualsExpression( "repositoryId", repoId ) //
             .execute();
@@ -473,7 +477,7 @@ public class CassandraMetadataRepository
                                      StringSerializer.get(), //
                                      StringSerializer.get(), //
                                      StringSerializer.get() ) //
-            .setColumnFamily( "namespace" ) //
+            .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
             .setColumnNames( "name" ) //
             .addEqualsExpression( "repositoryId", repoId ) //
             .execute();
index 3af8ca2d42fa8b0cbd7e9ddcfcbae14c405dbb32..56f6a45420b8d3e3276796ae655586e007ba78e3 100644 (file)
@@ -48,7 +48,7 @@ import java.util.List;
  * @author Olivier Lamy
  * @since 2.0.0
  */
-@Service( "archivaEntityManagerFactory#cassandra" )
+@Service("archivaEntityManagerFactory#cassandra")
 public class DefaultCassandraArchivaManager
     implements CassandraArchivaManager
 {
@@ -68,6 +68,11 @@ public class DefaultCassandraArchivaManager
 
     private Keyspace keyspace;
 
+    // configurable???
+    private String repositoryFamilyName = "repository";
+
+    private String namespaceFamilyName = "namespace";
+
 
     @PostConstruct
     public void initialize()
@@ -180,4 +185,14 @@ public class DefaultCassandraArchivaManager
     {
         return cluster;
     }
+
+    public String getRepositoryFamilyName()
+    {
+        return repositoryFamilyName;
+    }
+
+    public String getNamespaceFamilyName()
+    {
+        return namespaceFamilyName;
+    }
 }