some cleanup

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1581702 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2014-03-26 06:02:09 +00:00
parent 07bae44727
commit 0bfb850c1b
8 changed files with 35 additions and 176 deletions

View File

@ -50,6 +50,7 @@ public interface MetadataRepository
/**
* create the namespace in the repository. (if not exist)
*
* @param repositoryId
* @param namespace
* @throws MetadataRepositoryException
@ -61,12 +62,11 @@ public interface MetadataRepository
throws MetadataRepositoryException;
/**
*
* @param repositoryId
* @param facetId
* @return true if the repository datas for this facetId
* @since 1.4-M4
* @throws MetadataRepositoryException
* @since 1.4-M4
*/
boolean hasMetadataFacet( String repositoryId, String facetId )
throws MetadataRepositoryException;
@ -85,9 +85,10 @@ public interface MetadataRepository
/**
* if startTime or endTime are <code>null</code> they are not used for search
*
* @param repositoryId
* @param startTime can be <code>null</code>
* @param endTime can be <code>null</code>
* @param startTime can be <code>null</code>
* @param endTime can be <code>null</code>
* @return
* @throws MetadataRepositoryException
*/
@ -118,6 +119,7 @@ public interface MetadataRepository
/**
* FIXME need a unit test!!!
* Only remove {@link MetadataFacet} for the artifact
*
* @param repositoryId
* @param namespace
* @param project
@ -152,6 +154,7 @@ public interface MetadataRepository
/**
* basically just checking it exists not complete data returned
*
* @param repoId
* @param namespace
* @param projectId
@ -186,7 +189,6 @@ public interface MetadataRepository
throws MetadataResolutionException;
/**
*
* @param repoId
* @param namespace
* @return {@link Collection} of child namespaces of the namespace argument
@ -195,9 +197,22 @@ public interface MetadataRepository
Collection<String> getNamespaces( String repoId, String namespace )
throws MetadataResolutionException;
/**
* @param repoId
* @param namespace
* @return
* @throws MetadataResolutionException
*/
Collection<String> getProjects( String repoId, String namespace )
throws MetadataResolutionException;
/**
* @param repoId
* @param namespace
* @param projectId
* @return
* @throws MetadataResolutionException
*/
Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
throws MetadataResolutionException;
@ -212,12 +227,21 @@ public interface MetadataRepository
void removeProjectVersion( String repoId, String namespace, String projectId, String projectVersion )
throws MetadataRepositoryException;
/**
* @param repoId
* @param namespace
* @param projectId
* @param projectVersion
* @return
* @throws MetadataResolutionException
*/
Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId,
String projectVersion )
throws MetadataResolutionException;
/**
* remove a project
*
* @param repositoryId
* @param namespace
* @param projectId
@ -244,6 +268,6 @@ public interface MetadataRepository
boolean canObtainAccess( Class<?> aClass );
<T>T obtainAccess( Class<T> aClass )
<T> T obtainAccess( Class<T> aClass )
throws MetadataRepositoryException;
}

View File

@ -75,12 +75,6 @@
<artifactId>modelmapper</artifactId>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
</dependency>
<dependency>
<groupId>org.apache.cassandra</groupId>
<artifactId>cassandra-all</artifactId>

View File

@ -1030,8 +1030,7 @@ public class CassandraMetadataRepository
String key = result.get().iterator().next().getKey();
ColumnFamilyResult<String, String> columnFamilyResult =
this.projectVersionMetadataTemplate.queryColumns( key );
ColumnFamilyResult<String, String> columnFamilyResult = this.projectVersionMetadataTemplate.queryColumns( key );
if ( !columnFamilyResult.hasResults() )
{
@ -1547,9 +1546,8 @@ public class CassandraMetadataRepository
.addEqualsExpression( "repositoryName", artifactMetadataModel.getRepositoryId() ) //
.addEqualsExpression( "namespaceId", artifactMetadataModel.getNamespace() ) //
.addEqualsExpression( "projectId", artifactMetadataModel.getProject() ) //
.addEqualsExpression( "projectVersion",
artifactMetadataModel.getProjectVersion() ).addEqualsExpression( "facetId",
facetId ) //
.addEqualsExpression( "projectVersion", artifactMetadataModel.getProjectVersion() ) //
.addEqualsExpression( "facetId", facetId ) //
.execute();
for ( Row<String, String, String> row : result.get().getList() )
@ -1686,23 +1684,12 @@ public class CassandraMetadataRepository
{
for ( Map.Entry<String, String> entry : metadataFacet.toProperties().entrySet() )
{
String key = new MetadataFacetModel.KeyBuilder().withRepositoryId( repositoryId ).withFacetId(
metadataFacet.getFacetId() ).withName( metadataFacet.getName() ).withKey( entry.getKey() ).build();
boolean exists = this.metadataFacetTemplate.isColumnsExist( key );
if ( !exists )
{
//metadataFacetModel = new MetadataFacetModel();
// we need to store the repositoryId
//ArtifactMetadataModel artifactMetadataModel = new ArtifactMetadataModel();
//artifactMetadataModel.setRepositoryId( repositoryId );
//metadataFacetModel.setArtifactMetadataModel( artifactMetadataModel );
//metadataFacetModel.setId( key );
//metadataFacetModel.setKey( entry.getKey() );
//metadataFacetModel.setFacetId( metadataFacet.getFacetId() );
//metadataFacetModel.setName( metadataFacet.getName() );
String cf = this.cassandraArchivaManager.getMetadataFacetFamilyName();
this.metadataFacetTemplate.createMutator() //
.addInsertion( key, cf, column( "repositoryName", repositoryId ) ) //
@ -1711,7 +1698,6 @@ public class CassandraMetadataRepository
.addInsertion( key, cf, column( "key", entry.getKey() ) ) //
.addInsertion( key, cf, column( "value", entry.getValue() ) ) //
.execute();
}
else
{
@ -1965,8 +1951,6 @@ public class CassandraMetadataRepository
{
this.artifactMetadataTemplate.deleteRow( row.getKey() );
}
}

View File

@ -21,7 +21,6 @@ package org.apache.archiva.metadata.repository.cassandra.model;
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
import javax.persistence.Column;
import java.io.Serializable;
import java.util.Date;
@ -35,37 +34,26 @@ public class ArtifactMetadataModel
implements Serializable
{
@Column(name = "id")
private String id;
@Column(name = "repositoryName")
private String repositoryId;
@Column(name = "namespaceId")
private String namespace;
@Column(name = "project")
private String project;
@Column(name = "projectVersion")
private String projectVersion;
@Column(name = "version")
private String version;
@Column(name = "fileLastModified")
private long fileLastModified;
@Column(name = "size")
private long size;
@Column(name = "md5")
private String md5;
@Column(name = "sha1")
private String sha1;
@Column(name = "whenGathered")
private long whenGathered;
public ArtifactMetadataModel()

View File

@ -21,8 +21,6 @@ package org.apache.archiva.metadata.repository.cassandra.model;
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
import javax.persistence.Column;
/**
* Cassandra storage model for {@link org.apache.archiva.metadata.model.MetadataFacet}
*
@ -31,21 +29,12 @@ import javax.persistence.Column;
*/
public class MetadataFacetModel
{
// id is repositoryId + namespaceId + projectId + facetId + name + mapKey
//@Column(name = "artifactMetadataModel")
//private ArtifactMetadataModel artifactMetadataModel;
@Column(name = "facetId")
private String facetId;
@Column(name = "key")
private String key;
@Column(name = "name")
private String name;
@Column(name = "value")
private String value;
private String projectVersion;

View File

@ -21,8 +21,6 @@ package org.apache.archiva.metadata.repository.cassandra.model;
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
import javax.persistence.Column;
import javax.persistence.Id;
import java.io.Serializable;
/**
@ -32,103 +30,6 @@ import java.io.Serializable;
public class Project
implements Serializable
{
@Id
@Column(name = "projectKey")
private String projectKey;
@Column(name = "projectId")
private String projectId;
@Column(name = "repository")
private Namespace namespace;
public Project()
{
// no op
}
public Project( String projectKey, String projectId, Namespace namespace )
{
this.projectId = projectId;
this.projectKey = projectKey;
this.namespace = namespace;
}
public String getProjectKey()
{
return projectKey;
}
public void setProjectKey( String projectKey )
{
this.projectKey = projectKey;
}
public Namespace getNamespace()
{
return namespace;
}
public void setNamespace( Namespace namespace )
{
this.namespace = namespace;
}
public String getProjectId()
{
return projectId;
}
public void setProjectId( String projectId )
{
this.projectId = projectId;
}
@Override
public boolean equals( Object o )
{
if ( this == o )
{
return true;
}
if ( o == null || getClass() != o.getClass() )
{
return false;
}
Project project = (Project) o;
if ( !projectKey.equals( project.projectKey ) )
{
return false;
}
if ( !namespace.equals( project.namespace ) )
{
return false;
}
return true;
}
@Override
public int hashCode()
{
int result = projectKey.hashCode();
result = 31 * result + namespace.hashCode();
return result;
}
@Override
public String toString()
{
final StringBuilder sb = new StringBuilder( "Project{" );
sb.append( "projectKey='" ).append( projectKey ).append( '\'' );
sb.append( ", projectId='" ).append( projectId ).append( '\'' );
sb.append( ", namespace=" ).append( namespace );
sb.append( '}' );
return sb.toString();
}
public static class KeyBuilder
{

View File

@ -28,7 +28,6 @@ import org.apache.archiva.metadata.model.Organization;
import org.apache.archiva.metadata.model.Scm;
import org.apache.archiva.metadata.repository.cassandra.CassandraUtils;
import javax.persistence.Column;
import java.util.ArrayList;
import java.util.List;
@ -38,52 +37,32 @@ import java.util.List;
*/
public class ProjectVersionMetadataModel
{
@Column(name = "namespaceId") // repositoryName
private Namespace namespace;
/**
* id is the id
*/
@Column(name = "id")
private String id;
@Column(name = "projectId")
private String projectId;
@Column(name = "url")
private String url;
@Column(name = "name")
private String name;
@Column(name = "description")
private String description;
@Column(name = "organization")
private Organization organization;
@Column(name = "issueManagement")
private IssueManagement issueManagement;
@Column(name = "scm")
private Scm scm;
@Column(name = "ciManagement")
private CiManagement ciManagement;
// FIXME store those values in a separate table
@Column(name = "licenses")
private List<License> licenses = new ArrayList<License>();
@Column(name = "mailingLists")
private List<MailingList> mailingLists = new ArrayList<MailingList>();
@Column(name = "dependencies")
private List<Dependency> dependencies = new ArrayList<Dependency>();
@Column(name = "incomplete")
private boolean incomplete;
public String getProjectId()

View File

@ -1148,8 +1148,8 @@ public class JcrMetadataRepository
for ( Node node : JcrUtils.getChildNodes( nodeAtPath ) )
{
if ( node.isNodeType( PROJECT_VERSION_NODE_TYPE ) && StringUtils.equals( node.getName(),
projectVersion ) )
if ( node.isNodeType( PROJECT_VERSION_NODE_TYPE ) //
&& StringUtils.equals( node.getName(), projectVersion ) )
{
node.remove();
}