You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2013/05/22 15:10:42 UTC
svn commit: r1485200 -
/archiva/sandbox/trunk/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
Author: olamy
Date: Wed May 22 13:10:41 2013
New Revision: 1485200
URL: http://svn.apache.org/r1485200
Log:
implement more methods
Modified:
archiva/sandbox/trunk/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
Modified: archiva/sandbox/trunk/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java
URL: http://svn.apache.org/viewvc/archiva/sandbox/trunk/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java?rev=1485200&r1=1485199&r2=1485200&view=diff
==============================================================================
--- archiva/sandbox/trunk/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java (original)
+++ archiva/sandbox/trunk/metadata-store-cassandra/src/main/java/org/apache/archiva/metadata/repository/cassandra/CassandraMetadataRepository.java Wed May 22 13:10:41 2013
@@ -1216,32 +1216,138 @@ public class CassandraMetadataRepository
}
@Override
- public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
+ public Collection<String> getProjectVersions( final String repoId, final String namespace, final String projectId )
throws MetadataResolutionException
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ final Set<String> versions = new HashSet<String>();
+
+ // FIXME use cql query
+ artifactMetadataModelEntityManager.visitAll( new Function<ArtifactMetadataModel, Boolean>()
+ {
+ @Override
+ public Boolean apply( ArtifactMetadataModel artifactMetadataModel )
+ {
+ if ( artifactMetadataModel != null )
+ {
+ if ( StringUtils.equals( repoId, artifactMetadataModel.getRepositoryId() ) && StringUtils.equals(
+ namespace, artifactMetadataModel.getNamespace() ) && StringUtils.equals( projectId,
+ artifactMetadataModel.getId() ) )
+ {
+ versions.add( artifactMetadataModel.getVersion() );
+ }
+ }
+ return Boolean.TRUE;
+ }
+ } );
+
+ return versions;
}
@Override
- public void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
+ public void removeProjectVersion( final String repoId, final String namespace, final String projectId,
+ final String projectVersion )
throws MetadataRepositoryException
{
- //To change body of implemented methods use File | Settings | File Templates.
+
+ String key =
+ new ArtifactMetadataModel.KeyBuilder().withRepositoryId( repoId ).withNamespace( namespace ).withId(
+ projectId ).withProjectVersion( projectVersion ).build();
+
+ ArtifactMetadataModel artifactMetadataModel = artifactMetadataModelEntityManager.get( key );
+
+ if ( artifactMetadataModel == null )
+ {
+ logger.debug( "removeProjectVersion not found" );
+ return;
+ }
+
+ logger.debug( "removeProjectVersion" );
+
+ artifactMetadataModelEntityManager.remove( artifactMetadataModel );
+
+ /*
+
+ final List<ArtifactMetadataModel> versions = new ArrayList<ArtifactMetadataModel>();
+
+ // FIXME use cql query
+ artifactMetadataModelEntityManager.visitAll( new Function<ArtifactMetadataModel, Boolean>()
+ {
+ @Override
+ public Boolean apply( ArtifactMetadataModel artifactMetadataModel )
+ {
+ if ( artifactMetadataModel != null )
+ {
+ if ( StringUtils.equals( repoId, artifactMetadataModel.getRepositoryId() ) && StringUtils.equals(
+ namespace, artifactMetadataModel.getNamespace() ) && StringUtils.equals( projectId,
+ artifactMetadataModel.getId() )
+ && StringUtils.equals( projectId,
+ artifactMetadataModel.getProjectVersion() )
+ )
+ {
+ versions.add( artifactMetadataModel );
+ }
+ }
+ return Boolean.TRUE;
+ }
+ } );
+
+ artifactMetadataModelEntityManager.remove( versions );
+ */
}
@Override
- public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
- String projectVersion )
+ public Collection<ArtifactMetadata> getArtifacts( final String repoId, final String namespace,
+ final String projectId, final String projectVersion )
throws MetadataResolutionException
{
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ final List<ArtifactMetadataModel> artifactMetadataModels = new ArrayList<ArtifactMetadataModel>();
+ // FIXME use cql query !
+ artifactMetadataModelEntityManager.visitAll( new Function<ArtifactMetadataModel, Boolean>()
+ {
+ @Override
+ public Boolean apply( ArtifactMetadataModel artifactMetadataModel )
+ {
+ if ( artifactMetadataModel != null )
+ {
+ if ( StringUtils.equals( repoId, artifactMetadataModel.getRepositoryId() ) && StringUtils.equals(
+ namespace, artifactMetadataModel.getNamespace() ) && StringUtils.equals( projectId,
+ artifactMetadataModel.getProject() )
+ && StringUtils.equals( projectVersion, artifactMetadataModel.getProjectVersion() ) )
+ {
+ artifactMetadataModels.add( artifactMetadataModel );
+ }
+ }
+
+ return Boolean.TRUE;
+ }
+ } );
+
+ List<ArtifactMetadata> artifactMetadatas = new ArrayList<ArtifactMetadata>( artifactMetadataModels.size() );
+
+ for ( ArtifactMetadataModel model : artifactMetadataModels )
+ {
+ ArtifactMetadata artifactMetadata = new BeanReplicator().replicateBean( model, ArtifactMetadata.class );
+ populateFacets( artifactMetadata );
+ artifactMetadatas.add( artifactMetadata );
+ }
+
+ return artifactMetadatas;
}
@Override
public void removeProject( String repositoryId, String namespace, String projectId )
throws MetadataRepositoryException
{
- //To change body of implemented methods use File | Settings | File Templates.
+ String key = new Project.KeyBuilder().withNamespace(
+ new Namespace( namespace, new Repository( repositoryId ) ) ).withProjectId( projectId ).build();
+ Project project = projectEntityManager.get( key );
+ if ( project == null )
+ {
+ logger.debug( "removeProject notfound" );
+ return;
+ }
+ logger.debug( "removeProject {}", project );
+ projectEntityManager.remove( project );
}
@Override