public class FileMetadataRepository extends Object implements MetadataRepository
| Modifier and Type | Class and Description |
|---|---|
private static class |
FileMetadataRepository.ArtifactComparator |
| Modifier and Type | Field and Description |
|---|---|
private ArchivaConfiguration |
configuration |
private org.slf4j.Logger |
log |
private static String |
METADATA_KEY |
private Map<String,MetadataFacetFactory> |
metadataFacetFactories |
private static String |
NAMESPACE_METADATA_KEY |
private static String |
PROJECT_METADATA_KEY |
private static String |
PROJECT_VERSION_METADATA_KEY |
| Constructor and Description |
|---|
FileMetadataRepository(Map<String,MetadataFacetFactory> metadataFacetFactories,
ArchivaConfiguration configuration) |
| Modifier and Type | Method and Description |
|---|---|
void |
addMetadataFacet(String repositoryId,
MetadataFacet metadataFacet) |
boolean |
canObtainAccess(Class<?> aClass) |
private static void |
clearMetadataFacetProperties(Collection<MetadataFacet> facetList,
Properties properties,
String prefix) |
void |
close() |
private void |
getArtifacts(List<ArtifactMetadata> artifacts,
String repoId,
String ns) |
List<ArtifactMetadata> |
getArtifacts(String repoId) |
Collection<ArtifactMetadata> |
getArtifacts(String repoId,
String namespace,
String projectId,
String projectVersion) |
private void |
getArtifactsByChecksum(List<ArtifactMetadata> artifacts,
String repositoryId,
String ns,
String checksum) |
List<ArtifactMetadata> |
getArtifactsByChecksum(String repositoryId,
String checksum) |
private void |
getArtifactsByDateRange(List<ArtifactMetadata> artifacts,
String repoId,
String ns,
Date startTime,
Date endTime) |
List<ArtifactMetadata> |
getArtifactsByDateRange(String repoId,
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)
Get artifacts with a project version metadata key that matches the passed value.
|
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) |
private File |
getBaseDirectory(String repoId) |
private File |
getDirectory(String repoId) |
private File |
getMetadataDirectory(String repoId,
String facetId) |
MetadataFacet |
getMetadataFacet(String repositoryId,
String facetId,
String name) |
List<String> |
getMetadataFacets(String repoId,
String facetId) |
Collection<String> |
getNamespaces(String repoId,
String baseNamespace) |
ProjectMetadata |
getProject(String repoId,
String namespace,
String projectId)
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() |
Collection<String> |
getRootNamespaces(String repoId) |
boolean |
hasMetadataFacet(String repositoryId,
String facetId) |
private String |
join(Collection<String> ids) |
<T> T |
obtainAccess(Class<T> aClass) |
private Properties |
readOrCreateProperties(File directory,
String propertiesKey) |
private Properties |
readProperties(File directory,
String propertiesKey) |
private void |
recurse(List<String> facets,
String prefix,
File directory) |
void |
removeArtifact(ArtifactMetadata artifactMetadata,
String baseVersion)
used for deleting timestamped version of SNAPSHOT artifacts
|
void |
removeArtifact(String repositoryId,
String namespace,
String project,
String projectVersion,
MetadataFacet metadataFacet)
FIXME implements this !!!!
|
void |
removeArtifact(String repoId,
String namespace,
String project,
String version,
String id) |
void |
removeMetadataFacet(String repoId,
String facetId,
String name) |
void |
removeMetadataFacets(String repositoryId,
String facetId) |
void |
removeNamespace(String repositoryId,
String project) |
void |
removeProject(String repositoryId,
String namespace,
String projectId)
remove a project
|
void |
removeProjectVersion(String repoId,
String namespace,
String projectId,
String projectVersion) |
void |
removeRepository(String repoId)
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)
Full text artifacts search.
|
List<ArtifactMetadata> |
searchArtifacts(String key,
String text,
String repositoryId,
boolean exact)
Full text artifacts search inside the specified key.
|
private void |
setProperty(Properties properties,
String name,
String value) |
void |
updateArtifact(String repoId,
String namespace,
String projectId,
String projectVersion,
ArtifactMetadata artifact) |
private void |
updateArtifactFacets(ArtifactMetadata artifact,
Properties properties) |
void |
updateNamespace(String repoId,
String namespace)
create the namespace in the repository.
|
void |
updateProject(String repoId,
ProjectMetadata project)
Update metadata for a particular project in the metadata repository, or create it if it does not already exist.
|
private void |
updateProject(String repoId,
String namespace,
String id) |
private void |
updateProjectReference(String repoId,
String namespace,
String projectId,
String projectVersion,
ProjectVersionReference reference) |
void |
updateProjectVersion(String repoId,
String namespace,
String projectId,
ProjectVersionMetadata versionMetadata) |
private void |
updateProjectVersionFacets(ProjectVersionMetadata versionMetadata,
Properties properties) |
private void |
writeProperties(Properties properties,
File directory,
String propertiesKey) |
private final Map<String,MetadataFacetFactory> metadataFacetFactories
private final ArchivaConfiguration configuration
private org.slf4j.Logger log
private static final String PROJECT_METADATA_KEY
private static final String PROJECT_VERSION_METADATA_KEY
private static final String NAMESPACE_METADATA_KEY
private static final String METADATA_KEY
public FileMetadataRepository(Map<String,MetadataFacetFactory> metadataFacetFactories, ArchivaConfiguration configuration)
private File getBaseDirectory(String repoId) throws IOException
IOExceptionprivate File getDirectory(String repoId) throws IOException
IOExceptionpublic void updateProject(String repoId, ProjectMetadata project)
MetadataRepositoryupdateProject in interface MetadataRepositoryrepoId - the repository the project is inproject - the project metadata to create or updateprivate void updateProject(String repoId, String namespace, String id)
public void updateProjectVersion(String repoId, String namespace, String projectId, ProjectVersionMetadata versionMetadata)
updateProjectVersion in interface MetadataRepositoryprivate void updateProjectVersionFacets(ProjectVersionMetadata versionMetadata, Properties properties)
private static void clearMetadataFacetProperties(Collection<MetadataFacet> facetList, Properties properties, String prefix)
private void updateProjectReference(String repoId, String namespace, String projectId, String projectVersion, ProjectVersionReference reference)
public void updateNamespace(String repoId, String namespace)
MetadataRepositoryupdateNamespace in interface MetadataRepositorypublic List<String> getMetadataFacets(String repoId, String facetId) throws MetadataRepositoryException
getMetadataFacets in interface MetadataRepositoryMetadataRepositoryExceptionpublic boolean hasMetadataFacet(String repositoryId, String facetId) throws MetadataRepositoryException
hasMetadataFacet in interface MetadataRepositoryMetadataRepositoryExceptionpublic MetadataFacet getMetadataFacet(String repositoryId, String facetId, String name)
getMetadataFacet in interface MetadataRepositorypublic void addMetadataFacet(String repositoryId, MetadataFacet metadataFacet)
addMetadataFacet in interface MetadataRepositorypublic void removeMetadataFacets(String repositoryId, String facetId) throws MetadataRepositoryException
removeMetadataFacets in interface MetadataRepositoryMetadataRepositoryExceptionpublic void removeMetadataFacet(String repoId, String facetId, String name) throws MetadataRepositoryException
removeMetadataFacet in interface MetadataRepositoryMetadataRepositoryExceptionpublic List<ArtifactMetadata> getArtifactsByDateRange(String repoId, Date startTime, Date endTime) throws MetadataRepositoryException
MetadataRepositorynull they are not used for searchgetArtifactsByDateRange in interface MetadataRepositorystartTime - can be nullendTime - can be nullMetadataRepositoryExceptionprivate void getArtifactsByDateRange(List<ArtifactMetadata> artifacts, String repoId, String ns, Date startTime, Date endTime) throws MetadataRepositoryException
MetadataRepositoryExceptionpublic Collection<ArtifactMetadata> getArtifacts(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getArtifacts in interface MetadataRepositoryMetadataResolutionExceptionpublic void save()
MetadataRepositorysave in interface MetadataRepositorypublic void close()
close in interface MetadataRepositorypublic void revert()
MetadataRepositoryrevert in interface MetadataRepositorypublic boolean canObtainAccess(Class<?> aClass)
canObtainAccess in interface MetadataRepositorypublic <T> T obtainAccess(Class<T> aClass)
obtainAccess in interface MetadataRepositoryprivate void updateArtifactFacets(ArtifactMetadata artifact, Properties properties)
public Collection<String> getRepositories()
getRepositories in interface MetadataRepositorypublic List<ArtifactMetadata> getArtifactsByChecksum(String repositoryId, String checksum) throws MetadataRepositoryException
getArtifactsByChecksum in interface MetadataRepositoryMetadataRepositoryExceptionpublic void removeNamespace(String repositoryId, String project) throws MetadataRepositoryException
removeNamespace in interface MetadataRepositoryproject - (groupId for maven )MetadataRepositoryExceptionpublic void removeArtifact(ArtifactMetadata artifactMetadata, String baseVersion) throws MetadataRepositoryException
MetadataRepositoryremoveArtifact in interface MetadataRepositoryartifactMetadata - the artifactMetadata with the timestamped version (2.0-20120618.214135-2)baseVersion - the base version of the snapshot (2.0-SNAPSHOT)MetadataRepositoryExceptionpublic void removeArtifact(String repoId, String namespace, String project, String version, String id) throws MetadataRepositoryException
removeArtifact in interface MetadataRepositoryMetadataRepositoryExceptionpublic void removeArtifact(String repositoryId, String namespace, String project, String projectVersion, MetadataFacet metadataFacet) throws MetadataRepositoryException
removeArtifact in interface MetadataRepositoryrepositoryId - namespace - project - projectVersion - metadataFacet - will remove artifacts which have this MetadataFacet using equalsMetadataRepositoryExceptionpublic void removeRepository(String repoId) throws MetadataRepositoryException
MetadataRepositoryremoveRepository in interface MetadataRepositoryrepoId - the repository to deleteMetadataRepositoryExceptionprivate void getArtifactsByChecksum(List<ArtifactMetadata> artifacts, String repositoryId, String ns, String checksum) throws MetadataRepositoryException
MetadataRepositoryExceptionpublic List<ArtifactMetadata> getArtifactsByProjectVersionMetadata(String key, String value, String repositoryId) throws MetadataRepositoryException
MetadataRepositorygetArtifactsByProjectVersionMetadata in interface MetadataRepositoryrepositoryId - can be null, meaning search in all repositoriesMetadataRepositoryExceptionpublic List<ArtifactMetadata> getArtifactsByMetadata(String key, String value, String repositoryId) throws MetadataRepositoryException
MetadataRepositorygetArtifactsByMetadata in interface MetadataRepositoryrepositoryId - can be null, meaning search in all repositoriesMetadataRepositoryExceptionpublic List<ArtifactMetadata> getArtifactsByProperty(String key, String value, String repositoryId) throws MetadataRepositoryException
MetadataRepositorygetArtifactsByProperty in interface MetadataRepositoryrepositoryId - can be null, meaning search in all repositoriesMetadataRepositoryExceptionprivate File getMetadataDirectory(String repoId, String facetId) throws IOException
IOExceptionprivate String join(Collection<String> ids)
private void setProperty(Properties properties, String name, String value)
public void updateArtifact(String repoId, String namespace, String projectId, String projectVersion, ArtifactMetadata artifact)
updateArtifact in interface MetadataRepositoryprivate Properties readOrCreateProperties(File directory, String propertiesKey)
private Properties readProperties(File directory, String propertiesKey) throws IOException
IOExceptionpublic ProjectMetadata getProject(String repoId, String namespace, String projectId) throws MetadataResolutionException
MetadataRepositorygetProject in interface MetadataRepositoryMetadataResolutionExceptionpublic ProjectVersionMetadata getProjectVersion(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getProjectVersion in interface MetadataRepositoryMetadataResolutionExceptionpublic Collection<String> getArtifactVersions(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getArtifactVersions in interface MetadataRepositoryMetadataResolutionExceptionpublic Collection<ProjectVersionReference> getProjectReferences(String repoId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
MetadataRepositorygetProjectReferences in interface MetadataRepositoryrepoId - 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 toMetadataResolutionExceptionpublic Collection<String> getRootNamespaces(String repoId) throws MetadataResolutionException
getRootNamespaces in interface MetadataRepositoryMetadataResolutionExceptionpublic Collection<String> getNamespaces(String repoId, String baseNamespace) throws MetadataResolutionException
getNamespaces in interface MetadataRepositoryCollection of child namespaces of the namespace argumentMetadataResolutionExceptionpublic Collection<String> getProjects(String repoId, String namespace) throws MetadataResolutionException
getProjects in interface MetadataRepositoryMetadataResolutionExceptionpublic Collection<String> getProjectVersions(String repoId, String namespace, String projectId) throws MetadataResolutionException
getProjectVersions in interface MetadataRepositoryMetadataResolutionExceptionpublic void removeProject(String repositoryId, String namespace, String projectId) throws MetadataRepositoryException
MetadataRepositoryremoveProject in interface MetadataRepositoryMetadataRepositoryExceptionpublic void removeProjectVersion(String repoId, String namespace, String projectId, String projectVersion) throws MetadataRepositoryException
removeProjectVersion in interface MetadataRepositoryMetadataRepositoryExceptionprivate void writeProperties(Properties properties, File directory, String propertiesKey) throws IOException
IOExceptionpublic List<ArtifactMetadata> getArtifacts(String repoId) throws MetadataRepositoryException
getArtifacts in interface MetadataRepositoryMetadataRepositoryExceptionprivate void getArtifacts(List<ArtifactMetadata> artifacts, String repoId, String ns) throws MetadataResolutionException
MetadataResolutionExceptionpublic List<ArtifactMetadata> searchArtifacts(String text, String repositoryId, boolean exact) throws MetadataRepositoryException
MetadataRepositorysearchArtifacts in interface MetadataRepositoryrepositoryId - can be null to search in all repositoriesexact - running an exact search, the value must exactly match the text.MetadataRepositoryExceptionpublic List<ArtifactMetadata> searchArtifacts(String key, String text, String repositoryId, boolean exact) throws MetadataRepositoryException
MetadataRepositorysearchArtifacts in interface MetadataRepositorykey - search only inside this keyrepositoryId - can be null to search in all repositoriesexact - running an exact search, the value must exactly match the text.MetadataRepositoryExceptionCopyright © 2006–2023 The Apache Software Foundation. All rights reserved.