archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1579827 - in /archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra: ./ model/
Date Thu, 20 Mar 2014 23:23:34 GMT
Author: olamy
Date: Thu Mar 20 23:23:33 2014
New Revision: 1579827

URL: http://svn.apache.org/r1579827
Log:
change the column name

Modified:
    archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
    archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java
    archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
    archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java
    archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java?rev=1579827&r1=1579826&r2=1579827&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
Thu Mar 20 23:23:33 2014
@@ -98,8 +98,8 @@ public class CassandraMetadataRepository
             .createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(),
                                      StringSerializer.get() ) //
             .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() ) //
-            .setColumnNames( "id", "name" ) //
-            .addEqualsExpression( "id", repositoryId ) //
+            .setColumnNames(  "repositoryName" ) //
+            .addEqualsExpression( "repositoryName", repositoryId ) //
             .execute();
 
         if ( result.get().getCount() < 1 )
@@ -110,13 +110,9 @@ public class CassandraMetadataRepository
             try
             {
                 MutationResult mutationResult = HFactory.createMutator( keyspace, StringSerializer.get()
) //
-                    //  values
-                    .addInsertion( repositoryId, //
-                                   cassandraArchivaManager.getRepositoryFamilyName(), //
-                                   CassandraUtils.column( "id", repository.getId() ) ) //
                     .addInsertion( repositoryId, //
                                    cassandraArchivaManager.getRepositoryFamilyName(), //
-                                   CassandraUtils.column( "name", repository.getName() )
) //
+                                   CassandraUtils.column( "repositoryName", repository.getName()
) ) //
                     .execute();
                 return repository;
             }
@@ -128,7 +124,7 @@ public class CassandraMetadataRepository
 
         }
 
-        return new Repository( result.get().getList().get( 0 ).getColumnSlice().getColumnByName(
"id" ).getValue() );
+        return new Repository( result.get().getList().get( 0 ).getColumnSlice().getColumnByName(
"repositoryName" ).getValue() );
     }
 
 
@@ -140,8 +136,8 @@ public class CassandraMetadataRepository
             .createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(),
                                      StringSerializer.get() ) //
             .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() ) //
-            .setColumnNames( "id", "name" ) //
-            .addEqualsExpression( "id", repositoryId ) //
+            .setColumnNames( "repositoryName" ) //
+            .addEqualsExpression( "repositoryName", repositoryId ) //
             .execute();
         return ( result.get().getCount() > 0 ) ? new Repository( repositoryId ) : null;
     }
@@ -151,7 +147,6 @@ public class CassandraMetadataRepository
         throws MetadataRepositoryException
     {
         updateOrAddNamespace( repositoryId, namespaceId );
-
     }
 
     public Namespace updateOrAddNamespace( String repositoryId, String namespaceId )
@@ -177,7 +172,7 @@ public class CassandraMetadataRepository
                                    CassandraUtils.column( "name", namespace.getName() ) )
//
                     .addInsertion( key, //
                                    cassandraArchivaManager.getNamespaceFamilyName(), //
-                                   CassandraUtils.column( "repositoryId", repository.getId()
) ) //
+                                   CassandraUtils.column( "repositoryName", repository.getName()
) ) //
                     .execute();
             }
 
@@ -199,15 +194,15 @@ public class CassandraMetadataRepository
                                      StringSerializer.get(), //
                                      StringSerializer.get() ) //
             .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
-            .setColumnNames( "repositoryId", "name" ) //
-            .addEqualsExpression( "repositoryId", repositoryId ) //
+            .setColumnNames( "repositoryName", "name" ) //
+            .addEqualsExpression( "repositoryName", repositoryId ) //
             .addEqualsExpression( "name", namespaceId ) //
             .execute();
         if ( result.get().getCount() > 0 )
         {
             ColumnSlice<String, String> columnSlice = result.get().getList().get( 0
).getColumnSlice();
             return new Namespace( columnSlice.getColumnByName( "name" ).getValue(), //
-                                  new Repository( columnSlice.getColumnByName( "repositoryId"
).getValue() ) );
+                                  new Repository( columnSlice.getColumnByName( "repositoryName"
).getValue() ) );
 
         }
         return null;
@@ -247,6 +242,7 @@ public class CassandraMetadataRepository
 
         // retrieve and delete all namespace with this repositoryId
 
+        // TODO use cql queries to delete all
         List<String> namespacesKey = new ArrayList<String>();
 
         Keyspace keyspace = cassandraArchivaManager.getKeyspace();
@@ -256,8 +252,8 @@ public class CassandraMetadataRepository
                                      StringSerializer.get(), //
                                      StringSerializer.get() ) //
             .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
-            .setColumnNames( "repositoryId", "name" ) //
-            .addEqualsExpression( "repositoryId", repositoryId ) //
+            .setColumnNames( "repositoryName", "name" ) //
+            .addEqualsExpression( "repositoryName", repositoryId ) //
             .execute();
 
         for ( Row<String, String, String> row : result.get().getList() )
@@ -383,8 +379,8 @@ public class CassandraMetadataRepository
                                                  StringSerializer.get(), //
                                                  StringSerializer.get(), //
                                                  StringSerializer.get() ) //
-                    .setColumnFamily( "repository" ) //
-                    .setColumnNames( "name" ) //
+                    .setColumnFamily( cassandraArchivaManager.getRepositoryFamilyName() )
//
+                    .setColumnNames( "repositoryName" ) //
                     .setRange( null, null, false, Integer.MAX_VALUE ) //
                     .execute();
 
@@ -392,7 +388,7 @@ public class CassandraMetadataRepository
 
             for ( Row<String, String, String> row : cResult.get() )
             {
-                repoIds.add( row.getColumnSlice().getColumnByName( "name" ).getValue() );
+                repoIds.add( row.getColumnSlice().getColumnByName( "repositoryName" ).getValue()
);
             }
 
             return repoIds;
@@ -415,9 +411,9 @@ public class CassandraMetadataRepository
                                      StringSerializer.get(), //
                                      StringSerializer.get(), //
                                      StringSerializer.get() ) //
-            .setColumnFamily( "namespace" ) //
+            .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
             .setColumnNames( "name" ) //
-            .addEqualsExpression( "repositoryId", repoId ) //
+            .addEqualsExpression( "repositoryName", repoId ) //
             .execute();
 
         Set<String> namespaces = new HashSet<String>( result.get().getCount()
);
@@ -444,7 +440,7 @@ public class CassandraMetadataRepository
                                      StringSerializer.get() ) //
             .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
             .setColumnNames( "name" ) //
-            .addEqualsExpression( "repositoryId", repoId ) //
+            .addEqualsExpression( "repositoryName", repoId ) //
             .execute();
 
         List<String> namespaces = new ArrayList<String>( result.get().getCount()
);
@@ -483,7 +479,7 @@ public class CassandraMetadataRepository
                                      StringSerializer.get() ) //
             .setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
             .setColumnNames( "name" ) //
-            .addEqualsExpression( "repositoryId", repoId ) //
+            .addEqualsExpression( "repositoryName", repoId ) //
             .execute();
 
         List<String> namespaces = new ArrayList<String>( result.get().getCount()
);
@@ -510,7 +506,7 @@ public class CassandraMetadataRepository
                                      StringSerializer.get() ) //
             .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) //
             .setColumnNames( "projectId" ) //
-            .addEqualsExpression( "repositoryId", repositoryId ) //
+            .addEqualsExpression( "repositoryName", repositoryId ) //
             .addEqualsExpression( "namespaceId", projectMetadata.getNamespace() ) //
             .addEqualsExpression( "projectId", projectMetadata.getId() ) //
             .execute();
@@ -533,7 +529,7 @@ public class CassandraMetadataRepository
                            CassandraUtils.column( "projectId", projectMetadata.getId() )
) //
             .addInsertion( key, //
                            cassandraArchivaManager.getProjectFamilyName(), //
-                           CassandraUtils.column( "repositoryId", repositoryId ) ) //
+                           CassandraUtils.column( "repositoryName", repositoryId ) ) //
             .addInsertion( key, //
                            cassandraArchivaManager.getProjectFamilyName(), //
                            CassandraUtils.column( "namespaceId", projectMetadata.getNamespace()
) )//
@@ -554,7 +550,7 @@ public class CassandraMetadataRepository
                                      StringSerializer.get() ) //
             .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) //
             .setColumnNames( "projectId" ) //
-            .addEqualsExpression( "repositoryId", repoId ) //
+            .addEqualsExpression( "repositoryName", repoId ) //
             .addEqualsExpression( "namespaceId", namespace ) //
             .execute();
 

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java?rev=1579827&r1=1579826&r2=1579827&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/DefaultCassandraArchivaManager.java
Thu Mar 20 23:23:33 2014
@@ -125,8 +125,8 @@ public class DefaultCassandraArchivaMana
             namespace.addColumnDefinition( nameColumn );
 
             BasicColumnDefinition repositoryIdColumn = new BasicColumnDefinition();
-            repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryId"
) );
-            repositoryIdColumn.setIndexName( "repositoryId" );
+            repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryName"
) );
+            repositoryIdColumn.setIndexName( "repositoryName" );
             repositoryIdColumn.setIndexType( ColumnIndexType.KEYS );
             repositoryIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName()
);
             namespace.addColumnDefinition( repositoryIdColumn );
@@ -142,8 +142,8 @@ public class DefaultCassandraArchivaMana
             cfds.add( repository );
 
             BasicColumnDefinition nameColumn = new BasicColumnDefinition();
-            nameColumn.setName( StringSerializer.get().toByteBuffer( "name" ) );
-            nameColumn.setIndexName( "name" );
+            nameColumn.setName( StringSerializer.get().toByteBuffer( "repositoryName" ) );
+            nameColumn.setIndexName( "repositoryName" );
             nameColumn.setIndexType( ColumnIndexType.KEYS );
             nameColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() );
             repository.addColumnDefinition( nameColumn );
@@ -168,8 +168,8 @@ public class DefaultCassandraArchivaMana
             project.addColumnDefinition( projectIdColumn );
 
             BasicColumnDefinition repositoryIdColumn = new BasicColumnDefinition();
-            repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryId"
) );
-            repositoryIdColumn.setIndexName( "repositoryId" );
+            repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryName"
) );
+            repositoryIdColumn.setIndexName( "repositoryName" );
             repositoryIdColumn.setIndexType( ColumnIndexType.KEYS );
             repositoryIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName()
);
             project.addColumnDefinition( repositoryIdColumn );

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java?rev=1579827&r1=1579826&r2=1579827&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ArtifactMetadataModel.java
Thu Mar 20 23:23:33 2014
@@ -292,7 +292,7 @@ public class ArtifactMetadataModel
         public KeyBuilder withNamespace( Namespace namespace )
         {
             this.namespaceId = namespace.getName();
-            this.repositoryId = namespace.getRepository().getId();
+            this.repositoryId = namespace.getRepository().getName();
             return this;
         }
 

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java?rev=1579827&r1=1579826&r2=1579827&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/Namespace.java
Thu Mar 20 23:23:33 2014
@@ -21,7 +21,6 @@ package org.apache.archiva.metadata.repo
 
 import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
 
-import javax.persistence.Entity;
 import java.io.Serializable;
 
 
@@ -35,8 +34,6 @@ public class Namespace
 
     private String name;
 
-    private String repositoryId;
-
     private String repositoryName;
 
     public Namespace()
@@ -48,7 +45,6 @@ public class Namespace
     public Namespace( String id, Repository repository )
     {
         this.name = id;
-        this.repositoryId = repository.getId();
         this.repositoryName = repository.getName();
     }
 
@@ -65,12 +61,11 @@ public class Namespace
 
     public Repository getRepository()
     {
-        return new Repository(this.repositoryId);
+        return new Repository( this.repositoryName );
     }
 
     public void setRepository( Repository repository )
     {
-        this.repositoryId = repository.getId();
         this.repositoryName = repository.getName();
     }
 
@@ -92,7 +87,7 @@ public class Namespace
         {
             return false;
         }
-        if ( !repositoryId.equals( namespace.repositoryId ) )
+        if ( !repositoryName.equals( namespace.repositoryName ) )
         {
             return false;
         }
@@ -104,7 +99,7 @@ public class Namespace
     public int hashCode()
     {
         int result = name.hashCode();
-        result = 31 * result + repositoryId.hashCode();
+        result = 31 * result + repositoryName.hashCode();
         return result;
     }
 
@@ -113,7 +108,7 @@ public class Namespace
     {
         final StringBuilder sb = new StringBuilder( "Namespace{" );
         sb.append( ", name='" ).append( name ).append( '\'' );
-        sb.append( ", repository='" ).append( repositoryId ).append( '\'' );
+        sb.append( ", repository='" ).append( repositoryName ).append( '\'' );
         sb.append( '}' );
         return sb.toString();
     }
@@ -133,7 +128,7 @@ public class Namespace
         public KeyBuilder withNamespace( Namespace namespace )
         {
             this.namespace = namespace.getName();
-            this.repositoryId = namespace.getRepository().getId();
+            this.repositoryId = namespace.getRepository().getName();
             return this;
         }
 

Modified: archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java?rev=1579827&r1=1579826&r2=1579827&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java
(original)
+++ archiva/trunk/archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/model/ProjectVersionMetadataModel.java
Thu Mar 20 23:23:33 2014
@@ -39,7 +39,7 @@ import java.util.List;
  */
 public class ProjectVersionMetadataModel
 {
-    // repositoryId + namespace + projectId + id (version)
+    // repositoryName + namespace + projectId + id (version)
     @Id
     private String rowId;
 
@@ -295,7 +295,7 @@ public class ProjectVersionMetadataModel
 
         private String namespace;
 
-        private String repositoryId;
+        private String repositoryName;
 
         private String projectId;
 
@@ -309,7 +309,7 @@ public class ProjectVersionMetadataModel
         public KeyBuilder withNamespace( Namespace namespace )
         {
             this.namespace = namespace.getName();
-            this.repositoryId = namespace.getRepository().getId();
+            this.repositoryName = namespace.getRepository().getName();
             return this;
         }
 
@@ -321,13 +321,13 @@ public class ProjectVersionMetadataModel
 
         public KeyBuilder withRepository( String repositoryId )
         {
-            this.repositoryId = repositoryId;
+            this.repositoryName = repositoryId;
             return this;
         }
 
         public KeyBuilder withRepository( Repository repository )
         {
-            this.repositoryId = repository.getId();
+            this.repositoryName = repository.getName();
             return this;
         }
 
@@ -346,7 +346,7 @@ public class ProjectVersionMetadataModel
         public String build()
         {
             // FIXME add some controls
-            return CassandraUtils.generateKey( this.repositoryId, this.namespace, this.projectId,
this.id );
+            return CassandraUtils.generateKey( this.repositoryName, this.namespace, this.projectId,
this.id );
         }
     }
 }



Mime
View raw message