mirror of https://github.com/apache/archiva.git
move cassandra to simply use hector client: start with repositories and namespaces
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1579819 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
44880ea190
commit
50cb8970ef
|
@ -73,13 +73,14 @@
|
|||
<artifactId>modelmapper</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.geronimo.specs</groupId>
|
||||
<artifactId>geronimo-jpa_2.0_spec</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- FIXME still need old jackson -->
|
||||
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-mapper-asl</artifactId>
|
||||
|
@ -145,7 +146,7 @@
|
|||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>org.apache.cassandra</groupId>
|
||||
<artifactId>cassandra-all</artifactId>
|
||||
|
|
|
@ -19,14 +19,8 @@ package org.apache.archiva.metadata.repository.cassandra;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.netflix.astyanax.Keyspace;
|
||||
import com.netflix.astyanax.entitystore.EntityManager;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.ArtifactMetadataModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.MetadataFacetModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Namespace;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Project;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Repository;
|
||||
import me.prettyprint.hector.api.Cluster;
|
||||
import me.prettyprint.hector.api.Keyspace;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
|
@ -34,25 +28,14 @@ import org.apache.archiva.metadata.repository.cassandra.model.Repository;
|
|||
*/
|
||||
public interface CassandraArchivaManager
|
||||
{
|
||||
Keyspace getKeyspace();
|
||||
|
||||
void start();
|
||||
|
||||
void shutdown();
|
||||
|
||||
boolean started();
|
||||
|
||||
EntityManager<Repository, String> getRepositoryEntityManager();
|
||||
|
||||
EntityManager<Namespace, String> getNamespaceEntityManager();
|
||||
|
||||
EntityManager<Project, String> getProjectEntityManager();
|
||||
|
||||
EntityManager<ArtifactMetadataModel, String> getArtifactMetadataModelEntityManager();
|
||||
|
||||
EntityManager<MetadataFacetModel, String> getMetadataFacetModelEntityManager();
|
||||
|
||||
EntityManager<ProjectVersionMetadataModel, String> getProjectVersionMetadataModelEntityManager();
|
||||
Keyspace getKeyspace();
|
||||
|
||||
Cluster getCluster();
|
||||
|
||||
}
|
||||
|
|
|
@ -19,10 +19,15 @@ package org.apache.archiva.metadata.repository.cassandra;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.netflix.astyanax.entitystore.EntityManager;
|
||||
import me.prettyprint.cassandra.serializers.StringSerializer;
|
||||
import me.prettyprint.hector.api.Keyspace;
|
||||
import me.prettyprint.hector.api.beans.ColumnSlice;
|
||||
import me.prettyprint.hector.api.beans.OrderedRows;
|
||||
import me.prettyprint.hector.api.beans.Row;
|
||||
import me.prettyprint.hector.api.exceptions.HInvalidRequestException;
|
||||
import me.prettyprint.hector.api.factory.HFactory;
|
||||
import me.prettyprint.hector.api.mutation.MutationResult;
|
||||
import me.prettyprint.hector.api.query.QueryResult;
|
||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.archiva.metadata.model.ArtifactMetadata;
|
||||
import org.apache.archiva.metadata.model.FacetedMetadata;
|
||||
|
@ -35,10 +40,7 @@ import org.apache.archiva.metadata.repository.MetadataRepository;
|
|||
import org.apache.archiva.metadata.repository.MetadataRepositoryException;
|
||||
import org.apache.archiva.metadata.repository.MetadataResolutionException;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.ArtifactMetadataModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.MetadataFacetModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Namespace;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Project;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Repository;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.modelmapper.ModelMapper;
|
||||
|
@ -50,9 +52,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -83,34 +83,65 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
|
||||
|
||||
public EntityManager<Repository, String> getRepositoryEntityManager()
|
||||
/**
|
||||
* if the repository doesn't exist it will be created
|
||||
*
|
||||
* @param repositoryId
|
||||
* @return
|
||||
*/
|
||||
public Repository getOrCreateRepository( String repositoryId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
return this.cassandraArchivaManager.getRepositoryEntityManager();
|
||||
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
|
||||
QueryResult<OrderedRows<String, String, String>> result = HFactory //
|
||||
.createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(),
|
||||
StringSerializer.get() ) //
|
||||
.setColumnFamily( "repository" ) //
|
||||
.setColumnNames( "id", "name" ) //
|
||||
.addEqualsExpression( "id", repositoryId ) //
|
||||
.execute();
|
||||
|
||||
if ( result.get().getCount() < 1 )
|
||||
{
|
||||
// we need to create the repository
|
||||
Repository repository = new Repository( repositoryId );
|
||||
|
||||
try
|
||||
{
|
||||
MutationResult mutationResult = HFactory.createMutator( keyspace, StringSerializer.get() ) //
|
||||
// values
|
||||
.addInsertion( repositoryId, "repository",
|
||||
CassandraUtils.column( "id", repository.getId() ) ) //
|
||||
.addInsertion( repositoryId, "repository",
|
||||
CassandraUtils.column( "name", repository.getName() ) ) //
|
||||
.execute();
|
||||
logger.debug( "" );
|
||||
return repository;
|
||||
}
|
||||
catch ( HInvalidRequestException e )
|
||||
{
|
||||
logger.error( e.getMessage(), e );
|
||||
throw new MetadataRepositoryException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
public EntityManager<Namespace, String> getNamespaceEntityManager()
|
||||
{
|
||||
return this.cassandraArchivaManager.getNamespaceEntityManager();
|
||||
}
|
||||
|
||||
public EntityManager<Project, String> getProjectEntityManager()
|
||||
{
|
||||
return this.cassandraArchivaManager.getProjectEntityManager();
|
||||
return new Repository( result.get().getList().get( 0 ).getColumnSlice().getColumnByName( "id" ).getValue() );
|
||||
}
|
||||
|
||||
public EntityManager<ArtifactMetadataModel, String> getArtifactMetadataModelEntityManager()
|
||||
{
|
||||
return cassandraArchivaManager.getArtifactMetadataModelEntityManager();
|
||||
}
|
||||
|
||||
public EntityManager<MetadataFacetModel, String> getMetadataFacetModelEntityManager()
|
||||
protected Repository getRepository( String repositoryId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
return this.cassandraArchivaManager.getMetadataFacetModelEntityManager();
|
||||
}
|
||||
|
||||
public EntityManager<ProjectVersionMetadataModel, String> getProjectVersionMetadataModelEntityManager()
|
||||
{
|
||||
return this.cassandraArchivaManager.getProjectVersionMetadataModelEntityManager();
|
||||
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
|
||||
QueryResult<OrderedRows<String, String, String>> result = HFactory //
|
||||
.createRangeSlicesQuery( keyspace, StringSerializer.get(), StringSerializer.get(),
|
||||
StringSerializer.get() ) //
|
||||
.setColumnFamily( "repository" ) //
|
||||
.setColumnNames( "id", "name" ) //
|
||||
.addEqualsExpression( "id", repositoryId ) //
|
||||
.execute();
|
||||
return ( result.get().getCount() > 0 ) ? new Repository( repositoryId ) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -126,32 +157,53 @@ public class CassandraMetadataRepository
|
|||
{
|
||||
try
|
||||
{
|
||||
Repository repository = this.getRepositoryEntityManager().get( repositoryId );
|
||||
Repository repository = getOrCreateRepository( repositoryId );
|
||||
|
||||
if ( repository == null )
|
||||
{
|
||||
repository = new Repository( repositoryId );
|
||||
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
|
||||
|
||||
Namespace namespace = new Namespace( namespaceId, repository );
|
||||
this.getRepositoryEntityManager().put( repository );
|
||||
|
||||
this.getNamespaceEntityManager().put( namespace );
|
||||
}
|
||||
// FIXME add a Namespace id builder
|
||||
Namespace namespace = getNamespaceEntityManager().get(
|
||||
new Namespace.KeyBuilder().withNamespace( namespaceId ).withRepositoryId( repositoryId ).build() );
|
||||
Namespace namespace = getNamespace( repositoryId, namespaceId );
|
||||
if ( namespace == null )
|
||||
{
|
||||
namespace = new Namespace( namespaceId, repository );
|
||||
getNamespaceEntityManager().put( namespace );
|
||||
}
|
||||
return namespace;
|
||||
}
|
||||
catch ( PersistenceException e )
|
||||
{
|
||||
throw new MetadataRepositoryException( e.getMessage(), e );
|
||||
HFactory.createMutator( keyspace, StringSerializer.get() )
|
||||
// values
|
||||
.addInsertion( namespace.getId(), "namespace", //
|
||||
CassandraUtils.column( "name", namespace.getName() ) ) //
|
||||
.addInsertion( namespace.getId(), "namespace", //
|
||||
CassandraUtils.column( "repositoryId", repository.getId() ) ) //
|
||||
.execute();
|
||||
}
|
||||
|
||||
return namespace;
|
||||
}
|
||||
catch ( HInvalidRequestException e )
|
||||
{
|
||||
logger.error( e.getMessage(), e );
|
||||
throw new MetadataRepositoryException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
protected Namespace getNamespace( String repositoryId, String namespaceId )
|
||||
{
|
||||
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
|
||||
QueryResult<OrderedRows<String, String, String>> result = HFactory //
|
||||
.createRangeSlicesQuery( keyspace, //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get() ) //
|
||||
.setColumnFamily( "namespace" ) //
|
||||
.setColumnNames( "repositoryId", "name" ) //
|
||||
.addEqualsExpression( "repositoryId", 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() ) );
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,15 +213,18 @@ public class CassandraMetadataRepository
|
|||
{
|
||||
try
|
||||
{
|
||||
Namespace namespace = getNamespaceEntityManager().get(
|
||||
new Namespace.KeyBuilder().withNamespace( namespaceId ).withRepositoryId( repositoryId ).build() );
|
||||
if ( namespace != null )
|
||||
{
|
||||
getNamespaceEntityManager().remove( namespace );
|
||||
String key =
|
||||
new Namespace.KeyBuilder().withNamespace( namespaceId ).withRepositoryId( repositoryId ).build();
|
||||
|
||||
MutationResult result =
|
||||
HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ).addDeletion(
|
||||
key, "namespace" ).execute();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
catch ( PersistenceException e )
|
||||
catch ( HInvalidRequestException e )
|
||||
{
|
||||
logger.error( e.getMessage(), e );
|
||||
throw new MetadataRepositoryException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
@ -179,8 +234,39 @@ public class CassandraMetadataRepository
|
|||
public void removeRepository( final String repositoryId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
try
|
||||
|
||||
// FIXME remove all datas attached to the repositoryId
|
||||
|
||||
// retrieve and delete all namespace with this repositoryId
|
||||
|
||||
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() ) //
|
||||
.setColumnFamily( "namespace" ) //
|
||||
.setColumnNames( "repositoryId", "name" ) //
|
||||
.addEqualsExpression( "repositoryId", repositoryId ) //
|
||||
.execute();
|
||||
|
||||
for ( Row<String, String, String> row : result.get().getList() )
|
||||
{
|
||||
namespacesKey.add( row.getKey() );
|
||||
}
|
||||
|
||||
HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
|
||||
.addDeletion( namespacesKey, "namespace" ) //
|
||||
.execute();
|
||||
|
||||
//delete repositoryId
|
||||
HFactory.createMutator( cassandraArchivaManager.getKeyspace(), new StringSerializer() ) //
|
||||
.addDeletion( repositoryId, "repository" ) //
|
||||
.execute();
|
||||
|
||||
/*
|
||||
final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
|
||||
// remove data related to the repository
|
||||
|
@ -273,11 +359,7 @@ public class CassandraMetadataRepository
|
|||
getRepositoryEntityManager().remove( repository );
|
||||
}
|
||||
|
||||
}
|
||||
catch ( PersistenceException e )
|
||||
{
|
||||
throw new MetadataRepositoryException( e.getMessage(), e );
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -288,17 +370,23 @@ public class CassandraMetadataRepository
|
|||
{
|
||||
logger.debug( "getRepositories" );
|
||||
|
||||
List<Repository> repositories = getRepositoryEntityManager().getAll();
|
||||
if ( repositories == null )
|
||||
final QueryResult<OrderedRows<String, String, String>> cResult = //
|
||||
HFactory.createRangeSlicesQuery( cassandraArchivaManager.getKeyspace(), //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get() ) //
|
||||
.setColumnFamily( "repository" ) //
|
||||
.setColumnNames( "name" ) //
|
||||
.setRange( null, null, false, Integer.MAX_VALUE ) //
|
||||
.execute();
|
||||
|
||||
List<String> repoIds = new ArrayList<String>( cResult.get().getCount() );
|
||||
|
||||
for ( Row<String, String, String> row : cResult.get() )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
repoIds.add( row.getColumnSlice().getColumnByName( "name" ).getValue() );
|
||||
}
|
||||
List<String> repoIds = new ArrayList<String>( repositories.size() );
|
||||
for ( Repository repository : repositories )
|
||||
{
|
||||
repoIds.add( repository.getName() );
|
||||
}
|
||||
logger.debug( "getRepositories found: {}", repoIds );
|
||||
|
||||
return repoIds;
|
||||
}
|
||||
catch ( PersistenceException e )
|
||||
|
@ -313,122 +401,56 @@ public class CassandraMetadataRepository
|
|||
public Collection<String> getRootNamespaces( final String repoId )
|
||||
throws MetadataResolutionException
|
||||
{
|
||||
try
|
||||
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
|
||||
QueryResult<OrderedRows<String, String, String>> result = HFactory //
|
||||
.createRangeSlicesQuery( keyspace, //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get() ) //
|
||||
.setColumnFamily( "namespace" ) //
|
||||
.setColumnNames( "name" ) //
|
||||
.addEqualsExpression( "repositoryId", repoId ) //
|
||||
.execute();
|
||||
|
||||
Set<String> namespaces = new HashSet<String>( result.get().getCount() );
|
||||
|
||||
for ( Row<String, String, String> row : result.get() )
|
||||
{
|
||||
|
||||
|
||||
RootNamesSpaceVisitAll rootNamesSpaceVisitAll = new RootNamesSpaceVisitAll( repoId );
|
||||
|
||||
getNamespaceEntityManager().visitAll( rootNamesSpaceVisitAll );
|
||||
|
||||
return rootNamesSpaceVisitAll.namespaces;
|
||||
|
||||
|
||||
// using cql query with index
|
||||
/*
|
||||
List<Namespace> namespacesList = getNamespaceEntityManager().find( "SELECT * from namespace where id <> null AND repositoryid = '" + repoId + "'" );
|
||||
|
||||
Set<String> namespaces = new HashSet<String>();
|
||||
|
||||
for (Namespace namespace : namespacesList)
|
||||
{
|
||||
String name = namespace.getName();
|
||||
if ( StringUtils.isNotEmpty( name ) )
|
||||
{
|
||||
namespaces.add( StringUtils.substringBefore( name, "." ) );
|
||||
}
|
||||
namespaces.add(
|
||||
StringUtils.substringBefore( row.getColumnSlice().getColumnByName( "name" ).getValue(), "." ) );
|
||||
}
|
||||
|
||||
return namespaces;
|
||||
*/
|
||||
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
throw new MetadataResolutionException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private static class RootNamesSpaceVisitAll
|
||||
implements Function<Namespace, Boolean>
|
||||
{
|
||||
private String repoId;
|
||||
|
||||
Set<String> namespaces = new HashSet<String>();
|
||||
|
||||
private RootNamesSpaceVisitAll( String repoId )
|
||||
{
|
||||
this.repoId = repoId;
|
||||
}
|
||||
|
||||
// @Nullable add dependency ?
|
||||
@Override
|
||||
public Boolean apply( Namespace namespace )
|
||||
{
|
||||
if ( namespace != null && namespace.getRepository() != null && StringUtils.equalsIgnoreCase( repoId,
|
||||
namespace.getRepository().getId() ) )
|
||||
{
|
||||
String name = namespace.getName();
|
||||
if ( StringUtils.isNotEmpty( name ) )
|
||||
{
|
||||
namespaces.add( StringUtils.substringBefore( name, "." ) );
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getNamespaces( final String repoId, final String namespaceId )
|
||||
throws MetadataResolutionException
|
||||
{
|
||||
try
|
||||
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
|
||||
QueryResult<OrderedRows<String, String, String>> result = HFactory //
|
||||
.createRangeSlicesQuery( keyspace, //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get() ) //
|
||||
.setColumnFamily( "namespace" ) //
|
||||
.setColumnNames( "name" ) //
|
||||
.addEqualsExpression( "repositoryId", repoId ) //
|
||||
.execute();
|
||||
|
||||
List<String> namespaces = new ArrayList<String>( result.get().getCount() );
|
||||
|
||||
for ( Row<String, String, String> row : result.get() )
|
||||
{
|
||||
final FindNamesSpaceVisitAll findNamesSpaceVisitAll = new FindNamesSpaceVisitAll( repoId, namespaceId );
|
||||
|
||||
getNamespaceEntityManager().visitAll( findNamesSpaceVisitAll );
|
||||
|
||||
return findNamesSpaceVisitAll.namespaces;
|
||||
}
|
||||
catch ( PersistenceException e )
|
||||
{
|
||||
throw new MetadataResolutionException( e.getMessage(), e );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class FindNamesSpaceVisitAll
|
||||
implements Function<Namespace, Boolean>
|
||||
{
|
||||
private String repoId;
|
||||
|
||||
private String namespaceId;
|
||||
|
||||
Set<String> namespaces = new HashSet<String>();
|
||||
|
||||
private FindNamesSpaceVisitAll( String repoId, String namespaceId )
|
||||
{
|
||||
this.repoId = repoId;
|
||||
this.namespaceId = namespaceId;
|
||||
}
|
||||
|
||||
// @Nullable add dependency ?
|
||||
@Override
|
||||
public Boolean apply( Namespace namespace )
|
||||
{
|
||||
if ( namespace != null && namespace.getRepository() != null && StringUtils.equalsIgnoreCase( repoId,
|
||||
namespace.getRepository().getId() ) )
|
||||
{
|
||||
String currentNamespace = namespace.getName();
|
||||
// we only return childs
|
||||
if ( StringUtils.startsWith( currentNamespace, namespaceId ) && (
|
||||
StringUtils.length( currentNamespace ) > StringUtils.length( namespaceId ) ) )
|
||||
String currentNamespace = row.getColumnSlice().getColumnByName( "name" ).getValue();
|
||||
if ( StringUtils.startsWith( currentNamespace, namespaceId ) && ( StringUtils.length( currentNamespace )
|
||||
> StringUtils.length( namespaceId ) ) )
|
||||
{
|
||||
// store after namespaceId '.' but before next '.'
|
||||
// call org namespace org.apache.maven.shared -> stored apache
|
||||
|
||||
String calledNamespace =
|
||||
StringUtils.endsWith( namespaceId, "." ) ? namespaceId : namespaceId + ".";
|
||||
String calledNamespace = StringUtils.endsWith( namespaceId, "." ) ? namespaceId : namespaceId + ".";
|
||||
String storedNamespace = StringUtils.substringAfter( currentNamespace, calledNamespace );
|
||||
|
||||
storedNamespace = StringUtils.substringBefore( storedNamespace, "." );
|
||||
|
@ -436,78 +458,34 @@ public class CassandraMetadataRepository
|
|||
namespaces.add( storedNamespace );
|
||||
}
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
return namespaces;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<String> getNamespaces( final String repoId )
|
||||
throws MetadataResolutionException
|
||||
{
|
||||
try
|
||||
Keyspace keyspace = cassandraArchivaManager.getKeyspace();
|
||||
QueryResult<OrderedRows<String, String, String>> result = HFactory //
|
||||
.createRangeSlicesQuery( keyspace, //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get(), //
|
||||
StringSerializer.get() ) //
|
||||
.setColumnFamily( "namespace" ) //
|
||||
.setColumnNames( "name" ) //
|
||||
.addEqualsExpression( "repositoryId", repoId ) //
|
||||
.execute();
|
||||
|
||||
List<String> namespaces = new ArrayList<String>( result.get().getCount() );
|
||||
|
||||
for ( Row<String, String, String> row : result.get() )
|
||||
{
|
||||
logger.debug( "getNamespaces for repository '{}'", repoId );
|
||||
//TypedQuery<Repository> typedQuery =
|
||||
// entityManager.createQuery( "select n from Namespace n where n.repository_id=:id", Namespace.class );
|
||||
|
||||
//List<Repository> namespaces = typedQuery.setParameter( "id", repoId ).getResultList();
|
||||
|
||||
Repository repository = getRepositoryEntityManager().get( repoId );
|
||||
|
||||
if ( repository == null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
namespaces.add( row.getColumnSlice().getColumnByName( "name" ).getValue() );
|
||||
}
|
||||
|
||||
// FIXME find correct cql query
|
||||
//String query = "select * from namespace where repository.id = '" + repoId + "';";
|
||||
|
||||
//List<Namespace> namespaces = getNamespaceEntityManager().find( query );
|
||||
|
||||
//final Set<Namespace> namespaces = new HashSet<Namespace>();
|
||||
final Set<String> namespaces = new HashSet<String>();
|
||||
|
||||
getNamespaceEntityManager().visitAll( new Function<Namespace, Boolean>()
|
||||
{
|
||||
// @Nullable add dependency ?
|
||||
@Override
|
||||
public Boolean apply( Namespace namespace )
|
||||
{
|
||||
if ( namespace != null && namespace.getRepository() != null && StringUtils.equalsIgnoreCase( repoId,
|
||||
namespace.getRepository().getId() ) )
|
||||
{
|
||||
namespaces.add( namespace.getId() );
|
||||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
} );
|
||||
|
||||
|
||||
/*
|
||||
|
||||
repository.setNamespaces( new ArrayList<Namespace>( namespaces ) );
|
||||
if ( repository == null || repository.getNamespaces().isEmpty() )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<String> namespaceIds = new ArrayList<String>( repository.getNamespaces().size() );
|
||||
|
||||
for ( Namespace n : repository.getNamespaces() )
|
||||
{
|
||||
namespaceIds.add( n.getName() );
|
||||
}
|
||||
|
||||
logger.debug( "getNamespaces for repository '{}' found {}", repoId, namespaceIds.size() );
|
||||
|
||||
return namespaceIds;
|
||||
*/
|
||||
return new ArrayList<String>( namespaces );
|
||||
}
|
||||
catch ( PersistenceException e )
|
||||
{
|
||||
throw new MetadataResolutionException( e.getMessage(), e );
|
||||
}
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
|
||||
|
@ -515,7 +493,7 @@ public class CassandraMetadataRepository
|
|||
public void updateProject( String repositoryId, ProjectMetadata projectMetadata )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
|
||||
/*
|
||||
// project exists ? if yes return
|
||||
String projectKey = new Project.KeyBuilder().withProjectId( projectMetadata.getId() ).withNamespace(
|
||||
new Namespace( projectMetadata.getNamespace(), new Repository( repositoryId ) ) ).build();
|
||||
|
@ -543,7 +521,7 @@ public class CassandraMetadataRepository
|
|||
catch ( PersistenceException e )
|
||||
{
|
||||
throw new MetadataRepositoryException( e.getMessage(), e );
|
||||
}
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -552,7 +530,7 @@ public class CassandraMetadataRepository
|
|||
throws MetadataRepositoryException
|
||||
{
|
||||
|
||||
// cleanup ArtifactMetadataModel
|
||||
/* // cleanup ArtifactMetadataModel
|
||||
final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
|
||||
getArtifactMetadataModelEntityManager().visitAll( new Function<ArtifactMetadataModel, Boolean>()
|
||||
|
@ -614,14 +592,15 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
logger.debug( "removeProject {}", project );
|
||||
|
||||
getProjectEntityManager().remove( project );
|
||||
getProjectEntityManager().remove( project );*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getProjectVersions( final String repoId, final String namespace, final String projectId )
|
||||
throws MetadataResolutionException
|
||||
{
|
||||
final Set<String> versions = new HashSet<String>();
|
||||
return null;
|
||||
/* final Set<String> versions = new HashSet<String>();
|
||||
getProjectVersionMetadataModelEntityManager().visitAll( new Function<ProjectVersionMetadataModel, Boolean>()
|
||||
{
|
||||
@Override
|
||||
|
@ -659,7 +638,7 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
} );
|
||||
|
||||
return versions;
|
||||
return versions;*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -667,7 +646,7 @@ public class CassandraMetadataRepository
|
|||
ArtifactMetadata artifactMeta )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
String namespaceKey =
|
||||
/* String namespaceKey =
|
||||
new Namespace.KeyBuilder().withRepositoryId( repositoryId ).withNamespace( namespaceId ).build();
|
||||
// create the namespace if not exists
|
||||
Namespace namespace = getNamespaceEntityManager().get( namespaceKey );
|
||||
|
@ -745,7 +724,7 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
|
||||
// now facets
|
||||
updateFacets( artifactMeta, artifactMetadataModel );
|
||||
updateFacets( artifactMeta, artifactMetadataModel );*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -754,7 +733,7 @@ public class CassandraMetadataRepository
|
|||
final String projectVersion )
|
||||
throws MetadataResolutionException
|
||||
{
|
||||
final Set<String> versions = new HashSet<String>();
|
||||
/* final Set<String> versions = new HashSet<String>();
|
||||
// FIXME use cql query
|
||||
getArtifactMetadataModelEntityManager().visitAll( new Function<ArtifactMetadataModel, Boolean>()
|
||||
{
|
||||
|
@ -775,7 +754,8 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
} );
|
||||
|
||||
return versions;
|
||||
return versions;*/
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -788,7 +768,7 @@ public class CassandraMetadataRepository
|
|||
final ArtifactMetadataModel artifactMetadataModel )
|
||||
{
|
||||
|
||||
for ( final String facetId : metadataFacetFactories.keySet() )
|
||||
/* for ( final String facetId : metadataFacetFactories.keySet() )
|
||||
{
|
||||
MetadataFacet metadataFacet = facetedMetadata.getFacet( facetId );
|
||||
if ( metadataFacet == null )
|
||||
|
@ -834,8 +814,7 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
|
||||
getMetadataFacetModelEntityManager().put( metadataFacetModelsToAdd );
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -843,7 +822,7 @@ public class CassandraMetadataRepository
|
|||
ProjectVersionMetadata versionMetadata )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
String namespaceKey =
|
||||
/* String namespaceKey =
|
||||
new Namespace.KeyBuilder().withRepositoryId( repositoryId ).withNamespace( namespaceId ).build();
|
||||
Namespace namespace = getNamespaceEntityManager().get( namespaceKey );
|
||||
if ( namespace == null )
|
||||
|
@ -869,8 +848,7 @@ public class CassandraMetadataRepository
|
|||
|
||||
if ( projectVersionMetadataModel == null )
|
||||
{
|
||||
projectVersionMetadataModel =
|
||||
getModelMapper().map( versionMetadata, ProjectVersionMetadataModel.class );
|
||||
projectVersionMetadataModel = getModelMapper().map( versionMetadata, ProjectVersionMetadataModel.class );
|
||||
projectVersionMetadataModel.setRowId( key );
|
||||
}
|
||||
projectVersionMetadataModel.setProjectId( projectId );
|
||||
|
@ -892,7 +870,8 @@ public class CassandraMetadataRepository
|
|||
artifactMetadataModel.setArtifactMetadataModelId(
|
||||
new ArtifactMetadataModel.KeyBuilder().withId( versionMetadata.getId() ).withRepositoryId(
|
||||
repositoryId ).withNamespace( namespaceId ).withProjectVersion(
|
||||
versionMetadata.getVersion() ).withProject( projectId ).build() );
|
||||
versionMetadata.getVersion() ).withProject( projectId ).build()
|
||||
);
|
||||
artifactMetadataModel.setRepositoryId( repositoryId );
|
||||
artifactMetadataModel.setNamespace( namespaceId );
|
||||
artifactMetadataModel.setProject( projectId );
|
||||
|
@ -904,7 +883,7 @@ public class CassandraMetadataRepository
|
|||
catch ( PersistenceException e )
|
||||
{
|
||||
throw new MetadataRepositoryException( e.getMessage(), e );
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -917,7 +896,7 @@ public class CassandraMetadataRepository
|
|||
public List<String> getMetadataFacets( final String repositoryId, final String facetId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
// FIXME use cql query !!
|
||||
/* // FIXME use cql query !!
|
||||
final List<String> facets = new ArrayList<String>();
|
||||
this.getMetadataFacetModelEntityManager().visitAll( new Function<MetadataFacetModel, Boolean>()
|
||||
{
|
||||
|
@ -937,7 +916,8 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
} );
|
||||
|
||||
return facets;
|
||||
return facets;*/
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
@ -952,7 +932,7 @@ public class CassandraMetadataRepository
|
|||
public MetadataFacet getMetadataFacet( final String repositoryId, final String facetId, final String name )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
// FIXME use cql query !!
|
||||
/* // FIXME use cql query !!
|
||||
final List<MetadataFacetModel> facets = new ArrayList<MetadataFacetModel>();
|
||||
this.getMetadataFacetModelEntityManager().visitAll( new Function<MetadataFacetModel, Boolean>()
|
||||
{
|
||||
|
@ -990,14 +970,15 @@ public class CassandraMetadataRepository
|
|||
map.put( metadataFacetModel.getKey(), metadataFacetModel.getValue() );
|
||||
}
|
||||
metadataFacet.fromProperties( map );
|
||||
return metadataFacet;
|
||||
return metadataFacet;*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
|
||||
/*
|
||||
if ( metadataFacet == null )
|
||||
{
|
||||
return;
|
||||
|
@ -1061,14 +1042,14 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadataFacets( final String repositoryId, final String facetId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
logger.debug( "removeMetadataFacets repositoryId: '{}', facetId: '{}'", repositoryId, facetId );
|
||||
/* logger.debug( "removeMetadataFacets repositoryId: '{}', facetId: '{}'", repositoryId, facetId );
|
||||
final List<MetadataFacetModel> toRemove = new ArrayList<MetadataFacetModel>();
|
||||
|
||||
// FIXME cql query
|
||||
|
@ -1091,14 +1072,14 @@ public class CassandraMetadataRepository
|
|||
} );
|
||||
logger.debug( "removeMetadataFacets repositoryId: '{}', facetId: '{}', toRemove: {}", repositoryId, facetId,
|
||||
toRemove );
|
||||
getMetadataFacetModelEntityManager().remove( toRemove );
|
||||
getMetadataFacetModelEntityManager().remove( toRemove );*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadataFacet( final String repositoryId, final String facetId, final String name )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
logger.debug( "removeMetadataFacets repositoryId: '{}', facetId: '{}'", repositoryId, facetId );
|
||||
/* logger.debug( "removeMetadataFacets repositoryId: '{}', facetId: '{}'", repositoryId, facetId );
|
||||
final List<MetadataFacetModel> toRemove = new ArrayList<MetadataFacetModel>();
|
||||
|
||||
// FIXME cql query
|
||||
|
@ -1122,7 +1103,7 @@ public class CassandraMetadataRepository
|
|||
} );
|
||||
logger.debug( "removeMetadataFacets repositoryId: '{}', facetId: '{}', toRemove: {}", repositoryId, facetId,
|
||||
toRemove );
|
||||
getMetadataFacetModelEntityManager().remove( toRemove );
|
||||
getMetadataFacetModelEntityManager().remove( toRemove );*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1131,7 +1112,7 @@ public class CassandraMetadataRepository
|
|||
throws MetadataRepositoryException
|
||||
{
|
||||
|
||||
final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
/* final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
|
||||
// FIXME cql query
|
||||
getArtifactMetadataModelEntityManager().visitAll( new Function<ArtifactMetadataModel, Boolean>()
|
||||
|
@ -1172,12 +1153,13 @@ public class CassandraMetadataRepository
|
|||
logger.debug( "getArtifactsByDateRange repositoryId: {}, startTime: {}, endTime: {}, artifactMetadatas: {}",
|
||||
repositoryId, startTime, endTime, artifactMetadatas );
|
||||
|
||||
return artifactMetadatas;
|
||||
return artifactMetadatas;*/
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected void populateFacets( final ArtifactMetadata artifactMetadata )
|
||||
{
|
||||
final List<MetadataFacetModel> metadataFacetModels = new ArrayList<MetadataFacetModel>();
|
||||
/* final List<MetadataFacetModel> metadataFacetModels = new ArrayList<MetadataFacetModel>();
|
||||
|
||||
getMetadataFacetModelEntityManager().visitAll( new Function<MetadataFacetModel, Boolean>()
|
||||
{
|
||||
|
@ -1228,14 +1210,14 @@ public class CassandraMetadataRepository
|
|||
factory.createMetadataFacet( artifactMetadata.getRepositoryId(), entry.getKey() );
|
||||
metadataFacet.fromProperties( entry.getValue() );
|
||||
artifactMetadata.addFacet( metadataFacet );
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ArtifactMetadata> getArtifactsByChecksum( final String repositoryId, final String checksum )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
/* final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
|
||||
if ( logger.isDebugEnabled() )
|
||||
{
|
||||
|
@ -1277,7 +1259,8 @@ public class CassandraMetadataRepository
|
|||
logger.debug( "getArtifactsByChecksum repositoryId: {}, checksum: {}, artifactMetadatas: {}", repositoryId,
|
||||
checksum, artifactMetadatas );
|
||||
|
||||
return artifactMetadatas;
|
||||
return artifactMetadatas;*/
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1285,7 +1268,7 @@ public class CassandraMetadataRepository
|
|||
final String version, final String id )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
logger.debug( "removeArtifact repositoryId: '{}', namespace: '{}', project: '{}', version: '{}', id: '{}'",
|
||||
/* logger.debug( "removeArtifact repositoryId: '{}', namespace: '{}', project: '{}', version: '{}', id: '{}'",
|
||||
repositoryId, namespace, project, version, id );
|
||||
String key =
|
||||
new ArtifactMetadataModel.KeyBuilder().withRepositoryId( repositoryId ).withNamespace( namespace ).withId(
|
||||
|
@ -1303,7 +1286,7 @@ public class CassandraMetadataRepository
|
|||
ProjectVersionMetadataModel projectVersionMetadataModel = new ProjectVersionMetadataModel();
|
||||
projectVersionMetadataModel.setRowId( key );
|
||||
|
||||
getProjectVersionMetadataModelEntityManager().remove( projectVersionMetadataModel );
|
||||
getProjectVersionMetadataModelEntityManager().remove( projectVersionMetadataModel );*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1313,7 +1296,7 @@ public class CassandraMetadataRepository
|
|||
logger.debug( "removeArtifact repositoryId: '{}', namespace: '{}', project: '{}', version: '{}', id: '{}'",
|
||||
artifactMetadata.getRepositoryId(), artifactMetadata.getNamespace(),
|
||||
artifactMetadata.getProject(), baseVersion, artifactMetadata.getId() );
|
||||
String key =
|
||||
/* String key =
|
||||
new ArtifactMetadataModel.KeyBuilder().withRepositoryId( artifactMetadata.getRepositoryId() ).withNamespace(
|
||||
artifactMetadata.getNamespace() ).withId( artifactMetadata.getId() ).withProjectVersion(
|
||||
baseVersion ).withProject( artifactMetadata.getProject() ).build();
|
||||
|
@ -1321,7 +1304,7 @@ public class CassandraMetadataRepository
|
|||
ArtifactMetadataModel artifactMetadataModel = new ArtifactMetadataModel();
|
||||
artifactMetadataModel.setArtifactMetadataModelId( key );
|
||||
|
||||
getArtifactMetadataModelEntityManager().remove( artifactMetadataModel );
|
||||
getArtifactMetadataModelEntityManager().remove( artifactMetadataModel );*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1329,7 +1312,7 @@ public class CassandraMetadataRepository
|
|||
final String version, final MetadataFacet metadataFacet )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
/* final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
getArtifactMetadataModelEntityManager().visitAll( new Function<ArtifactMetadataModel, Boolean>()
|
||||
{
|
||||
@Override
|
||||
|
@ -1348,7 +1331,7 @@ public class CassandraMetadataRepository
|
|||
return Boolean.TRUE;
|
||||
}
|
||||
} );
|
||||
getArtifactMetadataModelEntityManager().remove( artifactMetadataModels );
|
||||
getArtifactMetadataModelEntityManager().remove( artifactMetadataModels );*/
|
||||
|
||||
}
|
||||
|
||||
|
@ -1357,7 +1340,7 @@ public class CassandraMetadataRepository
|
|||
public List<ArtifactMetadata> getArtifacts( final String repositoryId )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
/* final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
// FIXME use cql query !
|
||||
getArtifactMetadataModelEntityManager().visitAll( new Function<ArtifactMetadataModel, Boolean>()
|
||||
{
|
||||
|
@ -1385,14 +1368,16 @@ public class CassandraMetadataRepository
|
|||
artifactMetadatas.add( artifactMetadata );
|
||||
}
|
||||
|
||||
return artifactMetadatas;
|
||||
return artifactMetadatas;*/
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectMetadata getProject( final String repoId, final String namespace, final String id )
|
||||
throws MetadataResolutionException
|
||||
{
|
||||
//basically just checking it exists
|
||||
|
||||
/* //basically just checking it exists
|
||||
// FIXME use cql query
|
||||
|
||||
final BooleanHolder booleanHolder = new BooleanHolder();
|
||||
|
@ -1427,7 +1412,8 @@ public class CassandraMetadataRepository
|
|||
logger.debug( "getProject repoId: {}, namespace: {}, projectId: {} -> {}", repoId, namespace, id,
|
||||
projectMetadata );
|
||||
|
||||
return projectMetadata;
|
||||
return projectMetadata;*/
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1435,7 +1421,7 @@ public class CassandraMetadataRepository
|
|||
final String projectId, final String projectVersion )
|
||||
throws MetadataResolutionException
|
||||
{
|
||||
String key = new ProjectVersionMetadataModel.KeyBuilder().withRepository( repoId ).withNamespace(
|
||||
/* String key = new ProjectVersionMetadataModel.KeyBuilder().withRepository( repoId ).withNamespace(
|
||||
namespace ).withProjectId( projectId ).withId( projectVersion ).build();
|
||||
|
||||
ProjectVersionMetadataModel projectVersionMetadataModel =
|
||||
|
@ -1512,7 +1498,8 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
}
|
||||
|
||||
return projectVersionMetadata;
|
||||
return projectVersionMetadata;*/
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1531,7 +1518,7 @@ public class CassandraMetadataRepository
|
|||
{
|
||||
final Set<String> projects = new HashSet<String>();
|
||||
|
||||
// FIXME use cql query
|
||||
/* // FIXME use cql query
|
||||
getProjectEntityManager().visitAll( new Function<Project, Boolean>()
|
||||
{
|
||||
@Override
|
||||
|
@ -1547,7 +1534,7 @@ public class CassandraMetadataRepository
|
|||
}
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
} );
|
||||
} );*/
|
||||
|
||||
return projects;
|
||||
}
|
||||
|
@ -1558,7 +1545,7 @@ public class CassandraMetadataRepository
|
|||
final String projectVersion )
|
||||
throws MetadataRepositoryException
|
||||
{
|
||||
|
||||
/*
|
||||
final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
|
||||
// FIXME use cql query
|
||||
|
@ -1597,6 +1584,7 @@ public class CassandraMetadataRepository
|
|||
projectVersionMetadataModel.setRowId( key );
|
||||
|
||||
getProjectVersionMetadataModelEntityManager().remove( projectVersionMetadataModel );
|
||||
*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1605,6 +1593,7 @@ public class CassandraMetadataRepository
|
|||
throws MetadataResolutionException
|
||||
{
|
||||
final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
|
||||
/*
|
||||
// FIXME use cql query !
|
||||
getArtifactMetadataModelEntityManager().visitAll( new Function<ArtifactMetadataModel, Boolean>()
|
||||
{
|
||||
|
@ -1625,9 +1614,9 @@ public class CassandraMetadataRepository
|
|||
return Boolean.TRUE;
|
||||
}
|
||||
} );
|
||||
|
||||
*/
|
||||
List<ArtifactMetadata> artifactMetadatas = new ArrayList<ArtifactMetadata>( artifactMetadataModels.size() );
|
||||
|
||||
/*
|
||||
for ( ArtifactMetadataModel model : artifactMetadataModels )
|
||||
{
|
||||
ArtifactMetadata artifactMetadata = getModelMapper().map( model, ArtifactMetadata.class );
|
||||
|
@ -1715,7 +1704,7 @@ public class CassandraMetadataRepository
|
|||
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
return artifactMetadatas;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,11 @@ package org.apache.archiva.metadata.repository.cassandra;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import me.prettyprint.cassandra.serializers.SerializerTypeInferer;
|
||||
import me.prettyprint.hector.api.Serializer;
|
||||
import me.prettyprint.hector.api.beans.HColumn;
|
||||
import me.prettyprint.hector.api.factory.HFactory;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
* @since 2.0.0
|
||||
|
@ -57,6 +62,14 @@ public class CassandraUtils
|
|||
return builder.toString();
|
||||
}
|
||||
|
||||
public static <A, B> HColumn<A, B> column( final A name, final B value )
|
||||
{
|
||||
return HFactory.createColumn( name, //
|
||||
value, //
|
||||
(Serializer<A>) SerializerTypeInferer.getSerializer( name ), //
|
||||
(Serializer<B>) SerializerTypeInferer.getSerializer( value ) );
|
||||
}
|
||||
|
||||
private CassandraUtils()
|
||||
{
|
||||
// no-op
|
||||
|
|
|
@ -19,26 +19,18 @@ package org.apache.archiva.metadata.repository.cassandra;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.netflix.astyanax.AstyanaxContext;
|
||||
import com.netflix.astyanax.Keyspace;
|
||||
import com.netflix.astyanax.connectionpool.NodeDiscoveryType;
|
||||
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
|
||||
import com.netflix.astyanax.connectionpool.exceptions.NotFoundException;
|
||||
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolConfigurationImpl;
|
||||
import com.netflix.astyanax.connectionpool.impl.ConnectionPoolType;
|
||||
import com.netflix.astyanax.connectionpool.impl.Slf4jConnectionPoolMonitorImpl;
|
||||
import com.netflix.astyanax.ddl.KeyspaceDefinition;
|
||||
import com.netflix.astyanax.entitystore.DefaultEntityManager;
|
||||
import com.netflix.astyanax.entitystore.EntityManager;
|
||||
import com.netflix.astyanax.impl.AstyanaxConfigurationImpl;
|
||||
import com.netflix.astyanax.thrift.ThriftFamilyFactory;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.ArtifactMetadataModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.MetadataFacetModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Namespace;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Project;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.ProjectVersionMetadataModel;
|
||||
import org.apache.archiva.metadata.repository.cassandra.model.Repository;
|
||||
import me.prettyprint.cassandra.model.BasicColumnDefinition;
|
||||
import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel;
|
||||
import me.prettyprint.cassandra.serializers.StringSerializer;
|
||||
import me.prettyprint.cassandra.service.CassandraHostConfigurator;
|
||||
import me.prettyprint.cassandra.service.ThriftKsDef;
|
||||
import me.prettyprint.hector.api.Cluster;
|
||||
import me.prettyprint.hector.api.HConsistencyLevel;
|
||||
import me.prettyprint.hector.api.Keyspace;
|
||||
import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
|
||||
import me.prettyprint.hector.api.ddl.ColumnIndexType;
|
||||
import me.prettyprint.hector.api.ddl.ComparatorType;
|
||||
import me.prettyprint.hector.api.factory.HFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
@ -47,8 +39,8 @@ import org.springframework.stereotype.Service;
|
|||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.PreDestroy;
|
||||
import javax.inject.Inject;
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.util.Properties;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* FIXME make all configuration not hardcoded :-)
|
||||
|
@ -70,215 +62,104 @@ public class DefaultCassandraArchivaManager
|
|||
|
||||
private static final String KEYSPACE_NAME = "ArchivaKeySpace";
|
||||
|
||||
private AstyanaxContext<Keyspace> keyspaceContext;
|
||||
private boolean started;
|
||||
|
||||
private Cluster cluster;
|
||||
|
||||
private Keyspace keyspace;
|
||||
|
||||
private boolean started = false;
|
||||
|
||||
private EntityManager<Repository, String> repositoryEntityManager;
|
||||
|
||||
private EntityManager<Namespace, String> namespaceEntityManager;
|
||||
|
||||
private EntityManager<Project, String> projectEntityManager;
|
||||
|
||||
private EntityManager<ArtifactMetadataModel, String> artifactMetadataModelEntityManager;
|
||||
|
||||
private EntityManager<MetadataFacetModel, String> metadataFacetModelEntityManager;
|
||||
|
||||
private EntityManager<ProjectVersionMetadataModel, String> projectVersionMetadataModelEntityManager;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void initialize()
|
||||
throws ConnectionException
|
||||
{
|
||||
// FIXME must come from configuration not sys props
|
||||
String cassandraHost = System.getProperty( "cassandraHost", "localhost" );
|
||||
String cassandraPort = System.getProperty( "cassandraPort" );
|
||||
String cqlVersion = System.getProperty( "cassandra.cqlversion", "3.0.0" );
|
||||
keyspaceContext = new AstyanaxContext.Builder().forCluster( CLUSTER_NAME ).forKeyspace(
|
||||
KEYSPACE_NAME ).withAstyanaxConfiguration(
|
||||
new AstyanaxConfigurationImpl()
|
||||
//.setCqlVersion( cqlVersion )
|
||||
.setDiscoveryType( NodeDiscoveryType.RING_DESCRIBE )
|
||||
.setConnectionPoolType( ConnectionPoolType.TOKEN_AWARE ) )
|
||||
.withConnectionPoolConfiguration(
|
||||
new ConnectionPoolConfigurationImpl( CLUSTER_NAME + "_" + KEYSPACE_NAME )
|
||||
.setSocketTimeout( 30000 )
|
||||
.setMaxTimeoutWhenExhausted( 2000 )
|
||||
.setMaxConnsPerHost( 20 )
|
||||
.setInitConnsPerHost( 10 )
|
||||
.setSeeds( cassandraHost + ":" + cassandraPort ) )
|
||||
.withConnectionPoolMonitor( new Slf4jConnectionPoolMonitorImpl() )
|
||||
.buildKeyspace( ThriftFamilyFactory.getInstance() );
|
||||
int maxActive = Integer.getInteger( "cassandra.maxActive", 20 );
|
||||
String readConsistencyLevel =
|
||||
System.getProperty( "cassandra.readConsistencyLevel", HConsistencyLevel.QUORUM.name() );
|
||||
String writeConsistencyLevel =
|
||||
System.getProperty( "cassandra.readConsistencyLevel", HConsistencyLevel.QUORUM.name() );
|
||||
|
||||
this.start();
|
||||
int replicationFactor = Integer.getInteger( "cassandra.replicationFactor", 1 );
|
||||
|
||||
keyspace = keyspaceContext.getClient();
|
||||
//Partitioner partitioner = keyspace.getPartitioner();
|
||||
String keyspaceName = System.getProperty( "cassandra.keyspace.name", KEYSPACE_NAME );
|
||||
String clusterName = System.getProperty( "cassandra.cluster.name", CLUSTER_NAME );
|
||||
|
||||
ImmutableMap<String, Object> options = ImmutableMap.<String, Object>builder().put( "strategy_options",
|
||||
ImmutableMap.<String, Object>builder().put(
|
||||
"replication_factor",
|
||||
"1" ).build() ).put(
|
||||
"strategy_class", "SimpleStrategy" ).build();
|
||||
final CassandraHostConfigurator configurator =
|
||||
new CassandraHostConfigurator( cassandraHost + ":" + cassandraPort );
|
||||
configurator.setMaxActive( maxActive );
|
||||
|
||||
// test if the namespace already exists if exception or null create it
|
||||
boolean keyspaceExists = false;
|
||||
try
|
||||
cluster = HFactory.getOrCreateCluster( clusterName, configurator );
|
||||
|
||||
final ConfigurableConsistencyLevel consistencyLevelPolicy = new ConfigurableConsistencyLevel();
|
||||
consistencyLevelPolicy.setDefaultReadConsistencyLevel( HConsistencyLevel.valueOf( readConsistencyLevel ) );
|
||||
consistencyLevelPolicy.setDefaultWriteConsistencyLevel( HConsistencyLevel.valueOf( writeConsistencyLevel ) );
|
||||
keyspace = HFactory.createKeyspace( keyspaceName, cluster, consistencyLevelPolicy );
|
||||
|
||||
List<ColumnFamilyDefinition> cfds = new ArrayList<ColumnFamilyDefinition>();
|
||||
|
||||
// namespace table
|
||||
{
|
||||
KeyspaceDefinition keyspaceDefinition = keyspace.describeKeyspace();
|
||||
if ( keyspaceDefinition != null )
|
||||
{
|
||||
keyspaceExists = true;
|
||||
|
||||
final ColumnFamilyDefinition namespaces =
|
||||
HFactory.createColumnFamilyDefinition( keyspace.getKeyspaceName(), "namespace",
|
||||
ComparatorType.UTF8TYPE );
|
||||
cfds.add( namespaces );
|
||||
|
||||
// creating indexes for cql query
|
||||
|
||||
BasicColumnDefinition nameColumn = new BasicColumnDefinition();
|
||||
nameColumn.setName( StringSerializer.get().toByteBuffer( "name" ) );
|
||||
nameColumn.setIndexName( "name" );
|
||||
nameColumn.setIndexType( ColumnIndexType.KEYS );
|
||||
nameColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() );
|
||||
namespaces.addColumnDefinition( nameColumn );
|
||||
|
||||
BasicColumnDefinition repositoryIdColumn = new BasicColumnDefinition();
|
||||
repositoryIdColumn.setName( StringSerializer.get().toByteBuffer( "repositoryId" ) );
|
||||
repositoryIdColumn.setIndexName( "repositoryId" );
|
||||
repositoryIdColumn.setIndexType( ColumnIndexType.KEYS );
|
||||
repositoryIdColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() );
|
||||
namespaces.addColumnDefinition( repositoryIdColumn );
|
||||
}
|
||||
|
||||
}
|
||||
catch ( ConnectionException e )
|
||||
{
|
||||
final ColumnFamilyDefinition repository =
|
||||
HFactory.createColumnFamilyDefinition( keyspace.getKeyspaceName(), "repository",
|
||||
ComparatorType.UTF8TYPE );
|
||||
|
||||
cfds.add( repository );
|
||||
|
||||
BasicColumnDefinition nameColumn = new BasicColumnDefinition();
|
||||
nameColumn.setName( StringSerializer.get().toByteBuffer( "name" ) );
|
||||
nameColumn.setIndexName( "name" );
|
||||
nameColumn.setIndexType( ColumnIndexType.KEYS );
|
||||
nameColumn.setValidationClass( ComparatorType.UTF8TYPE.getClassName() );
|
||||
repository.addColumnDefinition( nameColumn );
|
||||
}
|
||||
|
||||
if ( !keyspaceExists )
|
||||
{ // ensure keyspace exists, here if the keyspace doesn't exist we suppose nothing exist
|
||||
if ( cluster.describeKeyspace( keyspaceName ) == null )
|
||||
{
|
||||
keyspace.createKeyspace( options );
|
||||
logger.info( "Creating Archiva Cassandra '" + keyspaceName + "' keyspace." );
|
||||
cluster.addKeyspace( HFactory.createKeyspaceDefinition( keyspaceName, //
|
||||
ThriftKsDef.DEF_STRATEGY_CLASS, //
|
||||
replicationFactor, //
|
||||
cfds )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Properties properties = keyspace.getKeyspaceProperties();
|
||||
logger.info( "keyspace properties: {}", properties );
|
||||
}
|
||||
catch ( ConnectionException e )
|
||||
{
|
||||
// FIXME better logging !
|
||||
logger.warn( e.getMessage(), e );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
repositoryEntityManager =
|
||||
DefaultEntityManager.<Repository, String>builder()
|
||||
.withEntityType( Repository.class )
|
||||
.withKeyspace( keyspace )
|
||||
.withAutoCommit( true )
|
||||
.withColumnFamily( "repository" )
|
||||
.build();
|
||||
boolean exists = columnFamilyExists( "repository" );
|
||||
// TODO very basic test we must test model change too
|
||||
if ( !exists )
|
||||
{
|
||||
repositoryEntityManager.createStorage( null );
|
||||
}
|
||||
|
||||
namespaceEntityManager =
|
||||
DefaultEntityManager.<Namespace, String>builder()
|
||||
.withEntityType( Namespace.class )
|
||||
.withKeyspace( keyspace )
|
||||
.withAutoCommit( true )
|
||||
.withColumnFamily( "namespace" )
|
||||
.build();
|
||||
|
||||
exists = columnFamilyExists( "namespace" );
|
||||
if ( !exists )
|
||||
{
|
||||
// create secondary index
|
||||
|
||||
options =
|
||||
ImmutableMap.<String, Object>builder()
|
||||
.put("repositoryid", ImmutableMap.<String, Object>builder()
|
||||
.put("validation_class", "UTF8Type")
|
||||
.put("index_name", "Indexrepositoryid")
|
||||
.put("index_type", "KEYS")
|
||||
.build()).build();
|
||||
|
||||
namespaceEntityManager.createStorage( options );
|
||||
}
|
||||
|
||||
|
||||
|
||||
projectEntityManager =
|
||||
DefaultEntityManager.<Project, String>builder()
|
||||
.withEntityType( Project.class )
|
||||
.withKeyspace( keyspace )
|
||||
.withAutoCommit( true )
|
||||
.withColumnFamily( "project" )
|
||||
.build();
|
||||
|
||||
exists = columnFamilyExists( "project" );
|
||||
if ( !exists )
|
||||
{
|
||||
projectEntityManager.createStorage( null );
|
||||
}
|
||||
|
||||
artifactMetadataModelEntityManager =
|
||||
DefaultEntityManager.<ArtifactMetadataModel, String>builder()
|
||||
.withEntityType( ArtifactMetadataModel.class )
|
||||
.withAutoCommit( true )
|
||||
.withKeyspace( keyspace )
|
||||
.withColumnFamily( "artifactmetadatamodel" )
|
||||
.build();
|
||||
|
||||
exists = columnFamilyExists( "artifactmetadatamodel" );
|
||||
if ( !exists )
|
||||
{
|
||||
artifactMetadataModelEntityManager.createStorage( null );
|
||||
}
|
||||
|
||||
metadataFacetModelEntityManager =
|
||||
DefaultEntityManager.<MetadataFacetModel, String>builder()
|
||||
.withEntityType( MetadataFacetModel.class )
|
||||
.withAutoCommit( true )
|
||||
.withKeyspace( keyspace )
|
||||
.withColumnFamily( "metadatafacetmodel" )
|
||||
.build();
|
||||
|
||||
exists = columnFamilyExists( "metadatafacetmodel" );
|
||||
if ( !exists )
|
||||
{
|
||||
metadataFacetModelEntityManager.createStorage( null );
|
||||
}
|
||||
|
||||
projectVersionMetadataModelEntityManager =
|
||||
DefaultEntityManager.<ProjectVersionMetadataModel, String>builder()
|
||||
.withEntityType( ProjectVersionMetadataModel.class )
|
||||
.withAutoCommit( true )
|
||||
.withKeyspace( keyspace )
|
||||
.withColumnFamily( "projectversionmetadatamodel" )
|
||||
.build();
|
||||
|
||||
exists = columnFamilyExists( "projectversionmetadatamodel" );
|
||||
if ( !exists )
|
||||
{
|
||||
projectVersionMetadataModelEntityManager.createStorage( null );
|
||||
}
|
||||
|
||||
}
|
||||
catch ( PersistenceException e )
|
||||
{
|
||||
// FIXME report exception
|
||||
logger.error( e.getMessage(), e );
|
||||
}
|
||||
catch ( ConnectionException e )
|
||||
{
|
||||
// FIXME report exception
|
||||
logger.error( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
keyspaceContext.start();
|
||||
started = true;
|
||||
}
|
||||
|
||||
@PreDestroy
|
||||
public void shutdown()
|
||||
{
|
||||
if ( keyspaceContext != null )
|
||||
{
|
||||
keyspaceContext.shutdown();
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -288,21 +169,6 @@ public class DefaultCassandraArchivaManager
|
|||
return started;
|
||||
}
|
||||
|
||||
private boolean columnFamilyExists( String columnFamilyName )
|
||||
throws ConnectionException
|
||||
{
|
||||
try
|
||||
{
|
||||
Properties properties = keyspace.getColumnFamilyProperties( columnFamilyName );
|
||||
logger.debug( "getColumnFamilyProperties for {}: {}", columnFamilyName, properties );
|
||||
return true;
|
||||
}
|
||||
catch ( NotFoundException e )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Keyspace getKeyspace()
|
||||
|
@ -310,66 +176,8 @@ public class DefaultCassandraArchivaManager
|
|||
return keyspace;
|
||||
}
|
||||
|
||||
public EntityManager<Repository, String> getRepositoryEntityManager()
|
||||
public Cluster getCluster()
|
||||
{
|
||||
return repositoryEntityManager;
|
||||
}
|
||||
|
||||
public void setRepositoryEntityManager( EntityManager<Repository, String> repositoryEntityManager )
|
||||
{
|
||||
this.repositoryEntityManager = repositoryEntityManager;
|
||||
}
|
||||
|
||||
public EntityManager<Namespace, String> getNamespaceEntityManager()
|
||||
{
|
||||
return namespaceEntityManager;
|
||||
}
|
||||
|
||||
public void setNamespaceEntityManager( EntityManager<Namespace, String> namespaceEntityManager )
|
||||
{
|
||||
this.namespaceEntityManager = namespaceEntityManager;
|
||||
}
|
||||
|
||||
public EntityManager<Project, String> getProjectEntityManager()
|
||||
{
|
||||
return projectEntityManager;
|
||||
}
|
||||
|
||||
public void setProjectEntityManager( EntityManager<Project, String> projectEntityManager )
|
||||
{
|
||||
this.projectEntityManager = projectEntityManager;
|
||||
}
|
||||
|
||||
public EntityManager<ArtifactMetadataModel, String> getArtifactMetadataModelEntityManager()
|
||||
{
|
||||
return artifactMetadataModelEntityManager;
|
||||
}
|
||||
|
||||
public void setArtifactMetadataModelEntityManager(
|
||||
EntityManager<ArtifactMetadataModel, String> artifactMetadataModelEntityManager )
|
||||
{
|
||||
this.artifactMetadataModelEntityManager = artifactMetadataModelEntityManager;
|
||||
}
|
||||
|
||||
public EntityManager<MetadataFacetModel, String> getMetadataFacetModelEntityManager()
|
||||
{
|
||||
return metadataFacetModelEntityManager;
|
||||
}
|
||||
|
||||
public void setMetadataFacetModelEntityManager(
|
||||
EntityManager<MetadataFacetModel, String> metadataFacetModelEntityManager )
|
||||
{
|
||||
this.metadataFacetModelEntityManager = metadataFacetModelEntityManager;
|
||||
}
|
||||
|
||||
public EntityManager<ProjectVersionMetadataModel, String> getProjectVersionMetadataModelEntityManager()
|
||||
{
|
||||
return projectVersionMetadataModelEntityManager;
|
||||
}
|
||||
|
||||
public void setProjectVersionMetadataModelEntityManager(
|
||||
EntityManager<ProjectVersionMetadataModel, String> projectVersionMetadataModelEntityManager )
|
||||
{
|
||||
this.projectVersionMetadataModelEntityManager = projectVersionMetadataModelEntityManager;
|
||||
return cluster;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,12 +19,9 @@ package org.apache.archiva.metadata.repository.cassandra.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.netflix.astyanax.entitystore.Serializer;
|
||||
import com.netflix.astyanax.serializers.LongSerializer;
|
||||
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
@ -35,58 +32,45 @@ import java.util.Date;
|
|||
* @author Olivier Lamy
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Entity
|
||||
public class ArtifactMetadataModel
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
// repositoryId + namespaceId + project + projectVersion + id
|
||||
@Id
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
private String artifactMetadataModelId;
|
||||
|
||||
@Column( name = "id" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "id")
|
||||
private String id;
|
||||
|
||||
@Column( name = "repositoryId" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "repositoryId")
|
||||
private String repositoryId;
|
||||
|
||||
@Column( name = "namespace" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "namespace")
|
||||
private String namespace;
|
||||
|
||||
@Column( name = "project" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "project")
|
||||
private String project;
|
||||
|
||||
@Column( name = "projectVersion" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "projectVersion")
|
||||
private String projectVersion;
|
||||
|
||||
@Column( name = "version" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "version")
|
||||
private String version;
|
||||
|
||||
@Column( name = "fileLastModified" )
|
||||
@Serializer( LongSerializer.class )
|
||||
@Column(name = "fileLastModified")
|
||||
private long fileLastModified;
|
||||
|
||||
@Column( name = "size" )
|
||||
@Serializer( LongSerializer.class )
|
||||
@Column(name = "size")
|
||||
private long size;
|
||||
|
||||
@Column( name = "md5" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "md5")
|
||||
private String md5;
|
||||
|
||||
@Column( name = "sha1" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "sha1")
|
||||
private String sha1;
|
||||
|
||||
@Column( name = "whenGathered" )
|
||||
@Serializer( LongSerializer.class )
|
||||
@Column(name = "whenGathered")
|
||||
private long whenGathered;
|
||||
|
||||
public ArtifactMetadataModel()
|
||||
|
|
|
@ -1,149 +0,0 @@
|
|||
package org.apache.archiva.metadata.repository.cassandra.model;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
import com.netflix.astyanax.serializers.AbstractSerializer;
|
||||
import com.netflix.astyanax.serializers.ComparatorType;
|
||||
import org.apache.commons.codec.binary.StringUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.zip.Deflater;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
|
||||
/**
|
||||
* For Huge String we use a deflate compression
|
||||
* @author Olivier Lamy
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public class DeflateStringSerializer
|
||||
extends AbstractSerializer<String>
|
||||
{
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
private static final String UTF_8 = "UTF-8";
|
||||
|
||||
private static final DeflateStringSerializer instance = new DeflateStringSerializer();
|
||||
|
||||
private static final Charset charset = Charset.forName( UTF_8 );
|
||||
|
||||
public static DeflateStringSerializer get()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer toByteBuffer( String obj )
|
||||
{
|
||||
if ( obj == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
byte[] bytes = compressWithDeflate( StringUtils.getBytesUtf8( obj ) );
|
||||
return ByteBuffer.wrap( bytes );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Fail to compress column data", e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fromByteBuffer( ByteBuffer byteBuffer )
|
||||
{
|
||||
if ( byteBuffer == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ByteBuffer dup = byteBuffer.duplicate();
|
||||
try
|
||||
{
|
||||
String str = getFromDeflateBytes( dup.array() );
|
||||
return str;
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
throw new RuntimeException( "Fail to decompress column data", e );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getFromDeflateBytes( byte[] bytes )
|
||||
throws IOException
|
||||
{
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( bytes );
|
||||
InflaterInputStream inflaterInputStream = new InflaterInputStream( byteArrayInputStream );
|
||||
return IOUtils.toString( inflaterInputStream );
|
||||
}
|
||||
|
||||
public byte[] compressWithDeflate( byte[] unCompress )
|
||||
throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
||||
DeflaterOutputStream out = new DeflaterOutputStream( buffer, new Deflater( Deflater.BEST_COMPRESSION ) );
|
||||
out.write( unCompress );
|
||||
out.finish();
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream( buffer.toByteArray() );
|
||||
byte[] res = IOUtils.toByteArray( bais );
|
||||
return res;
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
logger.debug( "IOException in compressStringWithDeflate", e );
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComparatorType getComparatorType()
|
||||
{
|
||||
return ComparatorType.BYTESTYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ByteBuffer fromString( String str )
|
||||
{
|
||||
return instance.fromString( str );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getString( ByteBuffer byteBuffer )
|
||||
{
|
||||
return instance.getString( byteBuffer );
|
||||
}
|
||||
|
||||
}
|
|
@ -19,11 +19,9 @@ package org.apache.archiva.metadata.repository.cassandra.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.netflix.astyanax.entitystore.Serializer;
|
||||
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
|
||||
/**
|
||||
|
@ -32,32 +30,26 @@ import javax.persistence.Id;
|
|||
* @author Olivier Lamy
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Entity
|
||||
public class MetadataFacetModel
|
||||
{
|
||||
// id is repositoryId + namespaceId + projectId + facetId + name + mapKey
|
||||
@Id
|
||||
@Column( name = "id" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "id")
|
||||
private String id;
|
||||
|
||||
@Column( name = "artifactMetadataModel" )
|
||||
@Column(name = "artifactMetadataModel")
|
||||
private ArtifactMetadataModel artifactMetadataModel;
|
||||
|
||||
@Column( name = "facetId" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "facetId")
|
||||
private String facetId;
|
||||
|
||||
@Column( name = "key" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "key")
|
||||
private String key;
|
||||
|
||||
@Column( name = "name" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column( name = "value" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "value")
|
||||
private String value;
|
||||
|
||||
public MetadataFacetModel()
|
||||
|
@ -232,7 +224,8 @@ public class MetadataFacetModel
|
|||
String str = CassandraUtils.generateKey( this.artifactMetadataModel == null
|
||||
? this.repositoryId
|
||||
: this.artifactMetadataModel.getArtifactMetadataModelId(),
|
||||
this.facetId, this.name, this.key );
|
||||
this.facetId, this.name, this.key
|
||||
);
|
||||
|
||||
//return Long.toString( str.hashCode() );
|
||||
return str;
|
||||
|
|
|
@ -19,12 +19,9 @@ package org.apache.archiva.metadata.repository.cassandra.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.netflix.astyanax.entitystore.Serializer;
|
||||
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
@ -32,32 +29,18 @@ import java.io.Serializable;
|
|||
* @author Olivier Lamy
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Entity
|
||||
public class Namespace
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
@Id
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
private String id;
|
||||
|
||||
@Column( name = "name" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
private String name;
|
||||
|
||||
@Column( name = "repositoryid" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
private String repositoryId;
|
||||
|
||||
@Column( name = "repositoryname" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
private String repositoryName;
|
||||
|
||||
//@ManyToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
|
||||
//@JoinColumn(name = "repository_id")
|
||||
//private transient Repository repository;
|
||||
|
||||
|
||||
public Namespace()
|
||||
{
|
||||
// no op
|
||||
|
|
|
@ -19,11 +19,9 @@ package org.apache.archiva.metadata.repository.cassandra.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.netflix.astyanax.entitystore.Serializer;
|
||||
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -31,21 +29,18 @@ import java.io.Serializable;
|
|||
* @author Olivier Lamy
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Entity
|
||||
public class Project
|
||||
implements Serializable
|
||||
{
|
||||
@Id
|
||||
@Column( name = "projectKey" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "projectKey")
|
||||
private String projectKey;
|
||||
|
||||
@Column( name = "projectId" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "projectId")
|
||||
private String projectId;
|
||||
|
||||
|
||||
@Column( name = "repository" )
|
||||
@Column(name = "repository")
|
||||
private Namespace namespace;
|
||||
|
||||
public Project()
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.archiva.metadata.repository.cassandra.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.netflix.astyanax.entitystore.Serializer;
|
||||
import org.apache.archiva.metadata.model.CiManagement;
|
||||
import org.apache.archiva.metadata.model.Dependency;
|
||||
import org.apache.archiva.metadata.model.IssueManagement;
|
||||
|
@ -30,7 +29,6 @@ import org.apache.archiva.metadata.model.Scm;
|
|||
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -39,63 +37,56 @@ import java.util.List;
|
|||
* @author Olivier Lamy
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Entity
|
||||
public class ProjectVersionMetadataModel
|
||||
{
|
||||
// repositoryId + namespace + projectId + id (version)
|
||||
@Id
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
private String rowId;
|
||||
|
||||
@Column( name = "namespace" )
|
||||
@Column(name = "namespace")
|
||||
private Namespace namespace;
|
||||
|
||||
/**
|
||||
* id is the version
|
||||
*/
|
||||
@Column( name = "id" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "id")
|
||||
private String id;
|
||||
|
||||
@Column( name = "projectId" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "projectId")
|
||||
private String projectId;
|
||||
|
||||
@Column( name = "url" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "url")
|
||||
private String url;
|
||||
|
||||
@Column( name = "name" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Column( name = "description" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
@Column( name = "organization" )
|
||||
@Column(name = "organization")
|
||||
private Organization organization;
|
||||
|
||||
@Column( name = "issueManagement" )
|
||||
@Column(name = "issueManagement")
|
||||
private IssueManagement issueManagement;
|
||||
|
||||
@Column( name = "scm" )
|
||||
@Column(name = "scm")
|
||||
private Scm scm;
|
||||
|
||||
@Column( name = "ciManagement" )
|
||||
@Column(name = "ciManagement")
|
||||
private CiManagement ciManagement;
|
||||
|
||||
// FIXME store those values in a separate table
|
||||
@Column( name = "licenses" )
|
||||
@Column(name = "licenses")
|
||||
private List<License> licenses = new ArrayList<License>();
|
||||
|
||||
@Column( name = "mailingLists" )
|
||||
@Column(name = "mailingLists")
|
||||
private List<MailingList> mailingLists = new ArrayList<MailingList>();
|
||||
|
||||
@Column( name = "dependencies" )
|
||||
@Column(name = "dependencies")
|
||||
private List<Dependency> dependencies = new ArrayList<Dependency>();
|
||||
|
||||
@Column( name = "incomplete" )
|
||||
@Column(name = "incomplete")
|
||||
private boolean incomplete;
|
||||
|
||||
public String getProjectId()
|
||||
|
|
|
@ -19,12 +19,6 @@ package org.apache.archiva.metadata.repository.cassandra.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import com.netflix.astyanax.entitystore.Serializer;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
|
@ -32,22 +26,14 @@ import java.io.Serializable;
|
|||
* @author Olivier Lamy
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@Entity
|
||||
public class Repository
|
||||
implements Serializable
|
||||
{
|
||||
|
||||
@Id
|
||||
@Column( name = "id" )
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
private String id;
|
||||
|
||||
@Column(name = "name")
|
||||
@Serializer( DeflateStringSerializer.class )
|
||||
private String name;
|
||||
|
||||
//private transient List<Namespace> namespaces = new ArrayList<Namespace>();
|
||||
|
||||
public Repository()
|
||||
{
|
||||
// no op
|
||||
|
@ -79,22 +65,6 @@ public class Repository
|
|||
this.name = name;
|
||||
}
|
||||
|
||||
/*
|
||||
public List<Namespace> getNamespaces()
|
||||
{
|
||||
if ( this.namespaces == null )
|
||||
{
|
||||
this.namespaces = new ArrayList<Namespace>();
|
||||
}
|
||||
return namespaces;
|
||||
}
|
||||
|
||||
public void setNamespaces( List<Namespace> namespaces )
|
||||
{
|
||||
this.namespaces = namespaces;
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean equals( Object o )
|
||||
{
|
||||
|
|
|
@ -41,7 +41,7 @@ public class CassandraMetadataRepositoryTest
|
|||
private Logger logger = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
@Inject
|
||||
@Named( value = "archivaEntityManagerFactory#cassandra" )
|
||||
@Named(value = "archivaEntityManagerFactory#cassandra")
|
||||
CassandraArchivaManager cassandraArchivaManager;
|
||||
|
||||
CassandraMetadataRepository cmr;
|
||||
|
@ -78,45 +78,12 @@ public class CassandraMetadataRepositoryTest
|
|||
protected void clearReposAndNamespace()
|
||||
throws Exception
|
||||
{
|
||||
/*
|
||||
List<Project> projects = cmr.getProjectEntityManager().getAll();
|
||||
|
||||
cmr.getProjectEntityManager().remove( projects );
|
||||
*/
|
||||
cmr.getProjectEntityManager().truncate();
|
||||
|
||||
/*
|
||||
List<Namespace> namespaces = cmr.getNamespaceEntityManager().getAll();
|
||||
|
||||
cmr.getNamespaceEntityManager().remove( namespaces );
|
||||
*/
|
||||
cmr.getNamespaceEntityManager().truncate();
|
||||
|
||||
/*
|
||||
List<Repository> repositories = cmr.getRepositoryEntityManager().getAll();
|
||||
|
||||
cmr.getRepositoryEntityManager().remove( repositories );
|
||||
*/
|
||||
cmr.getRepositoryEntityManager().truncate();
|
||||
|
||||
/*
|
||||
List<ArtifactMetadataModel> artifactMetadataModels = cmr.getArtifactMetadataModelEntityManager().getAll();
|
||||
cmr.getArtifactMetadataModelEntityManager().remove( artifactMetadataModels );
|
||||
*/
|
||||
cmr.getArtifactMetadataModelEntityManager().truncate();
|
||||
|
||||
/*
|
||||
List<MetadataFacetModel> metadataFacetModels = cmr.getMetadataFacetModelEntityManager().getAll();
|
||||
cmr.getMetadataFacetModelEntityManager().remove( metadataFacetModels );
|
||||
*/
|
||||
cmr.getMetadataFacetModelEntityManager().truncate();
|
||||
|
||||
/*
|
||||
List<ProjectVersionMetadataModel> projectVersionMetadataModels =
|
||||
cmr.getProjectVersionMetadataModelEntityManager().getAll();
|
||||
cmr.getProjectVersionMetadataModelEntityManager().remove( projectVersionMetadataModels );
|
||||
*/
|
||||
cmr.getProjectVersionMetadataModelEntityManager().truncate();
|
||||
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
|
||||
"project" );
|
||||
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
|
||||
"namespace" );
|
||||
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
|
||||
"repository" );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -37,15 +37,15 @@ import javax.inject.Named;
|
|||
/**
|
||||
* @author Olivier Lamy
|
||||
*/
|
||||
@RunWith(ArchivaSpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" })
|
||||
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
|
||||
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
|
||||
public class RepositoriesNamespaceTest
|
||||
{
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger( getClass() );
|
||||
|
||||
@Inject
|
||||
@Named(value = "archivaEntityManagerFactory#cassandra")
|
||||
@Named( value = "archivaEntityManagerFactory#cassandra" )
|
||||
CassandraArchivaManager cassandraArchivaManager;
|
||||
|
||||
|
||||
|
@ -85,24 +85,35 @@ public class RepositoriesNamespaceTest
|
|||
|
||||
cmr.updateNamespace( "release", "org" );
|
||||
|
||||
r = cmr.getRepositoryEntityManager().get( "release" );
|
||||
r = cmr.getRepository( "release" );
|
||||
|
||||
Assertions.assertThat( r ).isNotNull();
|
||||
|
||||
Assertions.assertThat( cmr.getRepositories() ).isNotEmpty().hasSize( 1 );
|
||||
Assertions.assertThat( cmr.getNamespaces( "release" ) ).isNotEmpty().hasSize( 1 );
|
||||
|
||||
n = cmr.getNamespaceEntityManager().get( "release" + CassandraUtils.SEPARATOR + "org" );
|
||||
n = cmr.getNamespace( "release", "org" );
|
||||
|
||||
Assertions.assertThat( n ).isNotNull();
|
||||
Assertions.assertThat( n.getRepository() ).isNotNull();
|
||||
|
||||
cmr.updateNamespace( "release", "org.apache" );
|
||||
|
||||
r = cmr.getRepositoryEntityManager().get( "release" );
|
||||
r = cmr.getRepository( "release" );
|
||||
|
||||
Assertions.assertThat( r ).isNotNull();
|
||||
Assertions.assertThat( cmr.getNamespaces( "release" ) ).isNotEmpty().hasSize( 2 );
|
||||
|
||||
cmr.removeNamespace( "release", "org.apache" );
|
||||
Assertions.assertThat( cmr.getNamespaces( "release" ) ).isNotEmpty().hasSize( 1 );
|
||||
Assertions.assertThat( cmr.getNamespaces( "release" ) ).containsExactly( "org" );
|
||||
|
||||
cmr.removeRepository( "release" );
|
||||
|
||||
r = cmr.getRepository( "release" );
|
||||
|
||||
Assertions.assertThat( r ).isNull();
|
||||
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
|
@ -118,22 +129,11 @@ public class RepositoriesNamespaceTest
|
|||
protected void clearReposAndNamespace()
|
||||
throws Exception
|
||||
{
|
||||
/*
|
||||
List<Project> projects = cmr.getProjectEntityManager().getAll();
|
||||
cmr.getProjectEntityManager().remove( projects );
|
||||
*/
|
||||
cmr.getProjectEntityManager().truncate();
|
||||
|
||||
/*
|
||||
List<Namespace> namespaces = cmr.getNamespaceEntityManager().getAll();
|
||||
cmr.getNamespaceEntityManager().remove( namespaces );
|
||||
*/
|
||||
cmr.getNamespaceEntityManager().truncate();
|
||||
|
||||
/*
|
||||
List<Repository> repositories = cmr.getRepositoryEntityManager().getAll();
|
||||
cmr.getRepositoryEntityManager().remove( repositories );
|
||||
*/
|
||||
cmr.getRepositoryEntityManager().truncate();
|
||||
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
|
||||
"project" );
|
||||
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
|
||||
"namespace" );
|
||||
cassandraArchivaManager.getCluster().truncate( cassandraArchivaManager.getKeyspace().getKeyspaceName(),
|
||||
"repository" );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue