public class CassandraMetadataRepository extends Object implements MetadataRepository
Modifier and Type | Class and Description |
---|---|
private static class |
CassandraMetadataRepository.ModelMapperHolder |
Modifier and Type | Field and Description |
---|---|
private me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> |
artifactMetadataTemplate |
private CassandraArchivaManager |
cassandraArchivaManager |
private ArchivaConfiguration |
configuration |
private me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> |
dependencyTemplate |
private me.prettyprint.hector.api.Keyspace |
keyspace |
private me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> |
licenseTemplate |
private org.slf4j.Logger |
logger |
private me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> |
mailingListTemplate |
private Map<String,MetadataFacetFactory> |
metadataFacetFactories |
private me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> |
metadataFacetTemplate |
private me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> |
projectTemplate |
private me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> |
projectVersionMetadataTemplate |
private me.prettyprint.cassandra.serializers.StringSerializer |
ss |
Constructor and Description |
---|
CassandraMetadataRepository(Map<String,MetadataFacetFactory> metadataFacetFactories,
ArchivaConfiguration configuration,
CassandraArchivaManager cassandraArchivaManager) |
Modifier and Type | Method and Description |
---|---|
void |
addMetadataFacet(String repositoryId,
MetadataFacet metadataFacet) |
boolean |
canObtainAccess(Class<?> aClass) |
void |
close() |
List<ArtifactMetadata> |
getArtifacts(String repositoryId) |
Collection<ArtifactMetadata> |
getArtifacts(String repoId,
String namespace,
String projectId,
String projectVersion) |
Collection<ArtifactMetadata> |
getArtifactsByChecksum(String repositoryId,
String checksum) |
List<ArtifactMetadata> |
getArtifactsByDateRange(String repositoryId,
Date startTime,
Date endTime)
if startTime or endTime are
null they are not used for search |
List<ArtifactMetadata> |
getArtifactsByMetadata(String key,
String value,
String repositoryId)
Get artifacts with an artifact metadata key that matches the passed value.
|
List<ArtifactMetadata> |
getArtifactsByProjectVersionMetadata(String key,
String value,
String repositoryId)
Project version and artifact level metadata are stored in the same place, no distinctions in Cassandra
implementation, just calls
getArtifactsByMetadata(String, String, String) |
List<ArtifactMetadata> |
getArtifactsByProperty(String key,
String value,
String repositoryId)
Get artifacts with a property key that matches the passed value.
|
Collection<String> |
getArtifactVersions(String repoId,
String namespace,
String projectId,
String projectVersion) |
protected List<Dependency> |
getDependencies(String projectVersionMetadataKey) |
protected List<License> |
getLicenses(String projectVersionMetadataKey) |
protected List<MailingList> |
getMailingLists(String projectVersionMetadataKey) |
MetadataFacet |
getMetadataFacet(String repositoryId,
String facetId,
String name) |
List<String> |
getMetadataFacets(String repositoryId,
String facetId) |
protected org.modelmapper.ModelMapper |
getModelMapper() |
protected Namespace |
getNamespace(String repositoryId,
String namespaceId) |
protected List<String> |
getNamespaces(String repoId) |
Collection<String> |
getNamespaces(String repoId,
String namespaceId) |
Repository |
getOrCreateRepository(String repositoryId)
if the repository doesn't exist it will be created
|
ProjectMetadata |
getProject(String repoId,
String namespace,
String id)
basically just checking it exists not complete data returned
|
Collection<ProjectVersionReference> |
getProjectReferences(String repoId,
String namespace,
String projectId,
String projectVersion)
Retrieve project references from the metadata repository.
|
Collection<String> |
getProjects(String repoId,
String namespace) |
ProjectVersionMetadata |
getProjectVersion(String repoId,
String namespace,
String projectId,
String projectVersion) |
Collection<String> |
getProjectVersions(String repoId,
String namespace,
String projectId) |
Collection<String> |
getRepositories() |
protected Repository |
getRepository(String repositoryId) |
Collection<String> |
getRootNamespaces(String repoId) |
boolean |
hasMetadataFacet(String repositoryId,
String facetId) |
protected ArtifactMetadata |
mapArtifactMetadataLongColumnSlice(me.prettyprint.hector.api.beans.ColumnSlice<String,Long> columnSlice) |
protected ArtifactMetadata |
mapArtifactMetadataStringColumnSlice(me.prettyprint.hector.api.beans.ColumnSlice<String,String> columnSlice) |
private List<ArtifactMetadata> |
mapArtifactMetadataToArtifact(me.prettyprint.hector.api.query.QueryResult<me.prettyprint.hector.api.beans.OrderedRows<String,String,String>> result,
List<ArtifactMetadata> artifactMetadatas)
Attach metadata to each of the ArtifactMetadata objects
|
protected ProjectVersionMetadataModel |
mapProjectVersionMetadataModel(me.prettyprint.hector.api.beans.ColumnSlice<String,String> columnSlice) |
<T> T |
obtainAccess(Class<T> aClass) |
protected void |
recordDependencies(String projectVersionMetadataKey,
List<Dependency> dependencies,
String repositoryId) |
protected void |
recordLicenses(String projectVersionMetadataKey,
List<License> licenses) |
protected void |
recordMailingList(String projectVersionMetadataKey,
List<MailingList> mailingLists) |
void |
removeArtifact(ArtifactMetadata artifactMetadata,
String baseVersion)
used for deleting timestamped version of SNAPSHOT artifacts
|
void |
removeArtifact(String repositoryId,
String namespace,
String project,
String version,
MetadataFacet metadataFacet)
FIXME need a unit test!!!
Only remove
MetadataFacet for the artifact |
void |
removeArtifact(String repositoryId,
String namespace,
String project,
String version,
String id) |
protected void |
removeDependencies(String projectVersionMetadataKey) |
protected void |
removeLicenses(String projectVersionMetadataKey) |
protected void |
removeMailingList(String projectVersionMetadataKey) |
void |
removeMetadataFacet(String repositoryId,
String facetId,
String name) |
void |
removeMetadataFacets(String repositoryId,
String facetId) |
void |
removeNamespace(String repositoryId,
String namespaceId) |
void |
removeProject(String repositoryId,
String namespaceId,
String projectId)
remove a project
|
void |
removeProjectVersion(String repoId,
String namespace,
String projectId,
String projectVersion) |
void |
removeRepository(String repositoryId)
Delete a repository's metadata.
|
void |
revert()
implementations can throw RuntimeException
|
void |
save()
implementations can throw RuntimeException
|
List<ArtifactMetadata> |
searchArtifacts(String text,
String repositoryId,
boolean exact)
This implementation just calls getArtifactsByMetadata( null, text, repositoryId ).
|
List<ArtifactMetadata> |
searchArtifacts(String key,
String text,
String repositoryId,
boolean exact)
The exact parameter is ignored as we can't do non exact searches in Cassandra
|
void |
updateArtifact(String repositoryId,
String namespaceId,
String projectId,
String projectVersion,
ArtifactMetadata artifactMeta) |
private void |
updateFacets(FacetedMetadata facetedMetadata,
ArtifactMetadataModel artifactMetadataModel)
iterate over available facets to remove/add from the artifactMetadata
|
void |
updateNamespace(String repositoryId,
String namespaceId)
create the namespace in the repository.
|
private Namespace |
updateOrAddNamespace(String repositoryId,
String namespaceId) |
void |
updateProject(String repositoryId,
ProjectMetadata projectMetadata)
Update metadata for a particular project in the metadata repository, or create it if it does not already exist.
|
void |
updateProjectVersion(String repositoryId,
String namespaceId,
String projectId,
ProjectVersionMetadata versionMetadata) |
private org.slf4j.Logger logger
private ArchivaConfiguration configuration
private final Map<String,MetadataFacetFactory> metadataFacetFactories
private final CassandraArchivaManager cassandraArchivaManager
private final me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> projectVersionMetadataTemplate
private final me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> projectTemplate
private final me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> artifactMetadataTemplate
private final me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> metadataFacetTemplate
private final me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> mailingListTemplate
private final me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> licenseTemplate
private final me.prettyprint.cassandra.service.template.ColumnFamilyTemplate<String,String> dependencyTemplate
private final me.prettyprint.hector.api.Keyspace keyspace
private final me.prettyprint.cassandra.serializers.StringSerializer ss
public CassandraMetadataRepository(Map<String,MetadataFacetFactory> metadataFacetFactories, ArchivaConfiguration configuration, CassandraArchivaManager cassandraArchivaManager)
public Repository getOrCreateRepository(String repositoryId) throws MetadataRepositoryException
repositoryId
- MetadataRepositoryException
protected Repository getRepository(String repositoryId) throws MetadataRepositoryException
MetadataRepositoryException
public void updateNamespace(String repositoryId, String namespaceId) throws MetadataRepositoryException
MetadataRepository
updateNamespace
in interface MetadataRepository
MetadataRepositoryException
private Namespace updateOrAddNamespace(String repositoryId, String namespaceId) throws MetadataRepositoryException
MetadataRepositoryException
protected Namespace getNamespace(String repositoryId, String namespaceId)
public void removeNamespace(String repositoryId, String namespaceId) throws MetadataRepositoryException
removeNamespace
in interface MetadataRepository
namespaceId
- (groupId for maven )MetadataRepositoryException
public void removeRepository(String repositoryId) throws MetadataRepositoryException
MetadataRepository
removeRepository
in interface MetadataRepository
repositoryId
- the repository to deleteMetadataRepositoryException
public Collection<String> getRepositories() throws MetadataRepositoryException
getRepositories
in interface MetadataRepository
MetadataRepositoryException
public Collection<String> getRootNamespaces(String repoId) throws MetadataResolutionException
getRootNamespaces
in interface MetadataRepository
MetadataResolutionException
public Collection<String> getNamespaces(String repoId, String namespaceId) throws MetadataResolutionException
getNamespaces
in interface MetadataRepository
Collection
of child namespaces of the namespace argumentMetadataResolutionException
protected List<String> getNamespaces(String repoId) throws MetadataResolutionException
MetadataResolutionException
public void updateProject(String repositoryId, ProjectMetadata projectMetadata) throws MetadataRepositoryException
MetadataRepository
updateProject
in interface MetadataRepository
repositoryId
- the repository the project is inprojectMetadata
- the project metadata to create or updateMetadataRepositoryException
public Collection<String> getProjects(String repoId, String namespace) throws MetadataResolutionException
getProjects
in interface MetadataRepository
MetadataResolutionException
public void removeProject(String repositoryId, String namespaceId, String projectId) throws MetadataRepositoryException
MetadataRepository
removeProject
in interface MetadataRepository
MetadataRepositoryException
public Collection<String> getProjectVersions(String repoId, String namespace, String projectId) throws MetadataResolutionException
getProjectVersions
in interface MetadataRepository
MetadataResolutionException
public ProjectMetadata getProject(String repoId, String namespace, String id) throws MetadataResolutionException
MetadataRepository
getProject
in interface MetadataRepository
MetadataResolutionException
protected ProjectVersionMetadataModel mapProjectVersionMetadataModel(me.prettyprint.hector.api.beans.ColumnSlice<String,String> columnSlice)
public void updateProjectVersion(String repositoryId, String namespaceId, String projectId, ProjectVersionMetadata versionMetadata) throws MetadataRepositoryException
updateProjectVersion
in interface MetadataRepository
MetadataRepositoryException
public ProjectVersionMetadata getProjectVersion(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getProjectVersion
in interface MetadataRepository
MetadataResolutionException
protected void recordMailingList(String projectVersionMetadataKey, List<MailingList> mailingLists)
protected void removeMailingList(String projectVersionMetadataKey)
protected List<MailingList> getMailingLists(String projectVersionMetadataKey)
protected void recordLicenses(String projectVersionMetadataKey, List<License> licenses)
protected void removeLicenses(String projectVersionMetadataKey)
protected List<License> getLicenses(String projectVersionMetadataKey)
protected void recordDependencies(String projectVersionMetadataKey, List<Dependency> dependencies, String repositoryId)
protected void removeDependencies(String projectVersionMetadataKey)
protected List<Dependency> getDependencies(String projectVersionMetadataKey)
public void updateArtifact(String repositoryId, String namespaceId, String projectId, String projectVersion, ArtifactMetadata artifactMeta) throws MetadataRepositoryException
updateArtifact
in interface MetadataRepository
MetadataRepositoryException
public Collection<String> getArtifactVersions(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getArtifactVersions
in interface MetadataRepository
MetadataResolutionException
private void updateFacets(FacetedMetadata facetedMetadata, ArtifactMetadataModel artifactMetadataModel)
facetedMetadata
- artifactMetadataModel
- only use for the keypublic List<String> getMetadataFacets(String repositoryId, String facetId) throws MetadataRepositoryException
getMetadataFacets
in interface MetadataRepository
MetadataRepositoryException
public boolean hasMetadataFacet(String repositoryId, String facetId) throws MetadataRepositoryException
hasMetadataFacet
in interface MetadataRepository
MetadataRepositoryException
public MetadataFacet getMetadataFacet(String repositoryId, String facetId, String name) throws MetadataRepositoryException
getMetadataFacet
in interface MetadataRepository
MetadataRepositoryException
public void addMetadataFacet(String repositoryId, MetadataFacet metadataFacet) throws MetadataRepositoryException
addMetadataFacet
in interface MetadataRepository
MetadataRepositoryException
public void removeMetadataFacets(String repositoryId, String facetId) throws MetadataRepositoryException
removeMetadataFacets
in interface MetadataRepository
MetadataRepositoryException
public void removeMetadataFacet(String repositoryId, String facetId, String name) throws MetadataRepositoryException
removeMetadataFacet
in interface MetadataRepository
MetadataRepositoryException
public List<ArtifactMetadata> getArtifactsByDateRange(String repositoryId, Date startTime, Date endTime) throws MetadataRepositoryException
MetadataRepository
null
they are not used for searchgetArtifactsByDateRange
in interface MetadataRepository
startTime
- can be null
endTime
- can be null
MetadataRepositoryException
protected ArtifactMetadata mapArtifactMetadataLongColumnSlice(me.prettyprint.hector.api.beans.ColumnSlice<String,Long> columnSlice)
protected ArtifactMetadata mapArtifactMetadataStringColumnSlice(me.prettyprint.hector.api.beans.ColumnSlice<String,String> columnSlice)
public Collection<ArtifactMetadata> getArtifactsByChecksum(String repositoryId, String checksum) throws MetadataRepositoryException
getArtifactsByChecksum
in interface MetadataRepository
MetadataRepositoryException
public List<ArtifactMetadata> getArtifactsByProjectVersionMetadata(String key, String value, String repositoryId) throws MetadataRepositoryException
getArtifactsByMetadata(String, String, String)
getArtifactsByProjectVersionMetadata
in interface MetadataRepository
repositoryId
- can be null, meaning search in all repositoriesMetadataRepositoryException
public List<ArtifactMetadata> getArtifactsByMetadata(String key, String value, String repositoryId) throws MetadataRepositoryException
MetadataRepository
getArtifactsByMetadata
in interface MetadataRepository
repositoryId
- can be null, meaning search in all repositoriesMetadataRepositoryException
public List<ArtifactMetadata> getArtifactsByProperty(String key, String value, String repositoryId) throws MetadataRepositoryException
MetadataRepository
getArtifactsByProperty
in interface MetadataRepository
repositoryId
- can be null, meaning search in all repositoriesMetadataRepositoryException
public void removeArtifact(String repositoryId, String namespace, String project, String version, String id) throws MetadataRepositoryException
removeArtifact
in interface MetadataRepository
MetadataRepositoryException
public void removeArtifact(ArtifactMetadata artifactMetadata, String baseVersion) throws MetadataRepositoryException
MetadataRepository
removeArtifact
in interface MetadataRepository
artifactMetadata
- the artifactMetadata with the timestamped version (2.0-20120618.214135-2)baseVersion
- the base version of the snapshot (2.0-SNAPSHOT)MetadataRepositoryException
public void removeArtifact(String repositoryId, String namespace, String project, String version, MetadataFacet metadataFacet) throws MetadataRepositoryException
MetadataRepository
MetadataFacet
for the artifactremoveArtifact
in interface MetadataRepository
MetadataRepositoryException
public List<ArtifactMetadata> getArtifacts(String repositoryId) throws MetadataRepositoryException
getArtifacts
in interface MetadataRepository
MetadataRepositoryException
public Collection<ProjectVersionReference> getProjectReferences(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
MetadataRepository
getProjectReferences
in interface MetadataRepository
repoId
- the repository ID to look withinnamespace
- the namespace of the project to get references toprojectId
- the identifier of the project to get references toprojectVersion
- the version of the project to get references toMetadataResolutionException
public void removeProjectVersion(String repoId, String namespace, String projectId, String projectVersion) throws MetadataRepositoryException
removeProjectVersion
in interface MetadataRepository
MetadataRepositoryException
public Collection<ArtifactMetadata> getArtifacts(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getArtifacts
in interface MetadataRepository
MetadataResolutionException
private List<ArtifactMetadata> mapArtifactMetadataToArtifact(me.prettyprint.hector.api.query.QueryResult<me.prettyprint.hector.api.beans.OrderedRows<String,String,String>> result, List<ArtifactMetadata> artifactMetadatas)
public void save()
MetadataRepository
save
in interface MetadataRepository
public void close() throws MetadataRepositoryException
close
in interface MetadataRepository
MetadataRepositoryException
public void revert()
MetadataRepository
revert
in interface MetadataRepository
public boolean canObtainAccess(Class<?> aClass)
canObtainAccess
in interface MetadataRepository
public <T> T obtainAccess(Class<T> aClass) throws MetadataRepositoryException
obtainAccess
in interface MetadataRepository
MetadataRepositoryException
protected org.modelmapper.ModelMapper getModelMapper()
public List<ArtifactMetadata> searchArtifacts(String text, String repositoryId, boolean exact) throws MetadataRepositoryException
searchArtifacts
in interface MetadataRepository
repositoryId
- can be null to search in all repositoriesexact
- running an exact search, the value must exactly match the text.MetadataRepositoryException
public List<ArtifactMetadata> searchArtifacts(String key, String text, String repositoryId, boolean exact) throws MetadataRepositoryException
searchArtifacts
in interface MetadataRepository
key
- search only inside this keyrepositoryId
- can be null to search in all repositoriesexact
- running an exact search, the value must exactly match the text.MetadataRepositoryException
Copyright © 2006–2023 The Apache Software Foundation. All rights reserved.