aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java1
-rw-r--r--archiva-modules/plugins/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java213
2 files changed, 120 insertions, 94 deletions
diff --git a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
index 2189b0ae3..9db23c698 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/test/java/org/apache/archiva/metadata/repository/AbstractMetadataRepositoryTest.java
@@ -321,7 +321,6 @@ public abstract class AbstractMetadataRepositoryTest
assertEquals( 1, metadata.getMailingLists().size() );
mailingList = metadata.getMailingLists().get( 0 );
assertEquals( "Foo List", mailingList.getName() );
- //assertEquals( Collections.singletonList( "other archive" ), mailingList.getOtherArchives() );
Assertions.assertThat( mailingList.getOtherArchives() ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
"other archive" );
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 90d9a4e76..7af4581fc 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
@@ -261,16 +261,79 @@ public class CassandraMetadataRepository
public void removeNamespace( String repositoryId, String namespaceId )
throws MetadataRepositoryException
{
+ Keyspace keyspace = cassandraArchivaManager.getKeyspace();
try
{
String key =
new Namespace.KeyBuilder().withNamespace( namespaceId ).withRepositoryId( repositoryId ).build();
- MutationResult result =
- HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
- .addDeletion( key, cassandraArchivaManager.getNamespaceFamilyName() ) //
- .execute();
+ HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
+ .addDeletion( key, cassandraArchivaManager.getNamespaceFamilyName() ) //
+ .execute();
+
+ QueryResult<OrderedRows<String, String, String>> result = HFactory //
+ .createRangeSlicesQuery( keyspace, //
+ StringSerializer.get(), //
+ StringSerializer.get(), //
+ StringSerializer.get() ) //
+ .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) //
+ .setColumnNames( "repositoryName" ) //
+ .addEqualsExpression( "repositoryName", repositoryId ) //
+ .addEqualsExpression( "namespaceId", namespaceId ) //
+ .execute();
+
+ for ( Row<String, String, String> row : result.get() )
+ {
+ this.projectTemplate.deleteRow( row.getKey() );
+ }
+ result = HFactory //
+ .createRangeSlicesQuery( keyspace, //
+ StringSerializer.get(), //
+ StringSerializer.get(), //
+ StringSerializer.get() ) //
+ .setColumnFamily( cassandraArchivaManager.getProjectVersionMetadataModelFamilyName() ) //
+ .setColumnNames( "repositoryName" ) //
+ .addEqualsExpression( "repositoryName", repositoryId ) //
+ .addEqualsExpression( "namespaceId", namespaceId ) //
+ .execute();
+
+ for ( Row<String, String, String> row : result.get() )
+ {
+ this.projectVersionMetadataModelTemplate.deleteRow( row.getKey() );
+ }
+
+ result = HFactory //
+ .createRangeSlicesQuery( keyspace, //
+ StringSerializer.get(), //
+ StringSerializer.get(), //
+ StringSerializer.get() ) //
+ .setColumnFamily( cassandraArchivaManager.getArtifactMetadataModelFamilyName() ) //
+ .setColumnNames( "repositoryName" ) //
+ .addEqualsExpression( "repositoryName", repositoryId ) //
+ .addEqualsExpression( "namespaceId", namespaceId ) //
+ .execute();
+
+ for ( Row<String, String, String> row : result.get() )
+ {
+ this.artifactMetadataTemplate.deleteRow( row.getKey() );
+ }
+
+ result = HFactory //
+ .createRangeSlicesQuery( keyspace, //
+ StringSerializer.get(), //
+ StringSerializer.get(), //
+ StringSerializer.get() ) //
+ .setColumnFamily( cassandraArchivaManager.getMetadataFacetModelFamilyName() ) //
+ .setColumnNames( "repositoryName" ) //
+ .addEqualsExpression( "repositoryName", repositoryId ) //
+ .addEqualsExpression( "namespaceId", namespaceId ) //
+ .execute();
+
+ for ( Row<String, String, String> row : result.get() )
+ {
+ this.metadataFacetTemplate.deleteRow( row.getKey() );
+ }
}
catch ( HInvalidRequestException e )
@@ -286,21 +349,16 @@ public class CassandraMetadataRepository
throws MetadataRepositoryException
{
- // FIXME remove all datas attached to the repositoryId
-
- // retrieve and delete all namespace with this repositoryId
+ StringSerializer ss = StringSerializer.get();
// TODO use cql queries to delete all
List<String> namespacesKey = new ArrayList<String>();
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
QueryResult<OrderedRows<String, String, String>> result = HFactory //
- .createRangeSlicesQuery( keyspace, //
- StringSerializer.get(), //
- StringSerializer.get(), //
- StringSerializer.get() ) //
+ .createRangeSlicesQuery( keyspace, ss, ss, ss ) //
.setColumnFamily( cassandraArchivaManager.getNamespaceFamilyName() ) //
- .setColumnNames( "repositoryName", "name" ) //
+ .setColumnNames( "repositoryName" ) //
.addEqualsExpression( "repositoryName", repositoryId ) //
.execute();
@@ -309,109 +367,78 @@ public class CassandraMetadataRepository
namespacesKey.add( row.getKey() );
}
- HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
+ HFactory.createMutator( cassandraArchivaManager.getKeyspace(), ss ) //
.addDeletion( namespacesKey, cassandraArchivaManager.getNamespaceFamilyName() ) //
.execute();
//delete repositoryId
- HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
+ HFactory.createMutator( cassandraArchivaManager.getKeyspace(), ss ) //
.addDeletion( repositoryId, cassandraArchivaManager.getRepositoryFamilyName() ) //
.execute();
-/*
- final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
- // remove data related to the repository
- this.getArtifactMetadataModelEntityManager().visitAll( new Function<ArtifactMetadataModel, Boolean>()
- {
- @Override
- public Boolean apply( ArtifactMetadataModel artifactMetadataModel )
- {
- if ( artifactMetadataModel != null )
- {
- if ( StringUtils.equals( artifactMetadataModel.getRepositoryId(), repositoryId ) )
- {
- artifactMetadataModels.add( artifactMetadataModel );
- }
- }
- return Boolean.TRUE;
- }
- } );
-
- getArtifactMetadataModelEntityManager().remove( artifactMetadataModels );
- final List<Namespace> namespaces = new ArrayList<Namespace>();
+ result = HFactory //
+ .createRangeSlicesQuery( keyspace, //
+ StringSerializer.get(), //
+ StringSerializer.get(), //
+ StringSerializer.get() ) //
+ .setColumnFamily( cassandraArchivaManager.getProjectFamilyName() ) //
+ .setColumnNames( "repositoryName" ) //
+ .addEqualsExpression( "repositoryName", repositoryId ) //
+ .execute();
- getNamespaceEntityManager().visitAll( new Function<Namespace, Boolean>()
+ for ( Row<String, String, String> row : result.get() )
{
- @Override
- public Boolean apply( Namespace namespace )
- {
- if ( namespace != null )
- {
- if ( StringUtils.equals( namespace.getRepository().getId(), repositoryId ) )
- {
- namespaces.add( namespace );
- }
- }
- return Boolean.TRUE;
- }
- } );
+ this.projectTemplate.deleteRow( row.getKey() );
+ }
- getNamespaceEntityManager().remove( namespaces );
+ result = HFactory //
+ .createRangeSlicesQuery( keyspace, //
+ StringSerializer.get(), //
+ StringSerializer.get(), //
+ StringSerializer.get() ) //
+ .setColumnFamily( cassandraArchivaManager.getProjectVersionMetadataModelFamilyName() ) //
+ .setColumnNames( "repositoryName" ) //
+ .addEqualsExpression( "repositoryName", repositoryId ) //
+ .execute();
- final List<Project> projects = new ArrayList<Project>();
- getProjectEntityManager().visitAll( new Function<Project, Boolean>()
+ for ( Row<String, String, String> row : result.get() )
{
- @Override
- public Boolean apply( Project project )
- {
- if ( project != null )
- {
- if ( StringUtils.equals( project.getNamespace().getRepository().getId(), repositoryId ) )
- {
- projects.add( project );
- }
- }
- return Boolean.TRUE;
- }
- } );
-
- getProjectEntityManager().remove( projects );
-
- // TODO cleanup or not
- //final List<MetadataFacetModel> metadataFacetModels = new ArrayList<MetadataFacetModel>( );
- //getMetadataFacetModelEntityManager().visitAll( new Function<MetadataFacetModel, Boolean>()
+ this.projectVersionMetadataModelTemplate.deleteRow( row.getKey() );
+ }
- final List<ProjectVersionMetadataModel> projectVersionMetadataModels =
- new ArrayList<ProjectVersionMetadataModel>();
+ result = HFactory //
+ .createRangeSlicesQuery( keyspace, //
+ StringSerializer.get(), //
+ StringSerializer.get(), //
+ StringSerializer.get() ) //
+ .setColumnFamily( cassandraArchivaManager.getArtifactMetadataModelFamilyName() ) //
+ .setColumnNames( "repositoryName" ) //
+ .addEqualsExpression( "repositoryName", repositoryId ) //
+ .execute();
- getProjectVersionMetadataModelEntityManager().visitAll( new Function<ProjectVersionMetadataModel, Boolean>()
+ for ( Row<String, String, String> row : result.get() )
{
- @Override
- public Boolean apply( ProjectVersionMetadataModel projectVersionMetadataModel )
- {
- if ( projectVersionMetadataModel != null )
- {
- if ( StringUtils.equals( projectVersionMetadataModel.getNamespace().getRepository().getId(),
- repositoryId ) )
- {
- projectVersionMetadataModels.add( projectVersionMetadataModel );
- }
- }
- return Boolean.TRUE;
- }
- } );
+ this.artifactMetadataTemplate.deleteRow( row.getKey() );
+ }
- getProjectVersionMetadataModelEntityManager().remove( projectVersionMetadataModels );
+ result = HFactory //
+ .createRangeSlicesQuery( keyspace, //
+ StringSerializer.get(), //
+ StringSerializer.get(), //
+ StringSerializer.get() ) //
+ .setColumnFamily( cassandraArchivaManager.getMetadataFacetModelFamilyName() ) //
+ .setColumnNames( "repositoryName" ) //
+ .addEqualsExpression( "repositoryName", repositoryId ) //
+ .execute();
- Repository repository = getRepositoryEntityManager().get( repositoryId );
- if ( repository != null )
+ for ( Row<String, String, String> row : result.get() )
{
- getRepositoryEntityManager().remove( repository );
+ this.metadataFacetTemplate.deleteRow( row.getKey() );
}
- */
+
}
@Override