public class JcrMetadataRepository extends Object implements MetadataRepository
Modifier and Type | Field and Description |
---|---|
(package private) static String |
ARTIFACT_NODE_TYPE |
private static String |
DEPENDENCY_NODE_TYPE |
(package private) static String |
FACET_NODE_TYPE |
private static String |
JCR_LAST_MODIFIED |
private javax.jcr.Session |
jcrSession |
private org.slf4j.Logger |
log |
private Map<String,MetadataFacetFactory> |
metadataFacetFactories |
(package private) static String |
NAMESPACE_NODE_TYPE |
(package private) static String |
PROJECT_NODE_TYPE |
(package private) static String |
PROJECT_VERSION_NODE_TYPE |
private javax.jcr.Repository |
repository |
Constructor and Description |
---|
JcrMetadataRepository(Map<String,MetadataFacetFactory> metadataFacetFactories,
javax.jcr.Repository repository) |
Modifier and Type | Method and Description |
---|---|
void |
addMetadataFacet(String repositoryId,
MetadataFacet metadataFacet) |
boolean |
canObtainAccess(Class<?> aClass) |
void |
close() |
private static Calendar |
createCalendar(Date time) |
private ArtifactMetadata |
getArtifactFromNode(String repositoryId,
javax.jcr.Node artifactNode) |
private static String |
getArtifactPath(String repositoryId,
String namespace,
String projectId,
String projectVersion,
String id) |
private static String |
getArtifactQuery(String repositoryId) |
List<ArtifactMetadata> |
getArtifacts(String repositoryId) |
Collection<ArtifactMetadata> |
getArtifacts(String repositoryId,
String namespace,
String projectId,
String projectVersion) |
List<ArtifactMetadata> |
getArtifactsByChecksum(String repositoryId,
String checksum) |
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 repositoryId,
String namespace,
String projectId,
String projectVersion) |
private static String |
getFacetPath(String repositoryId,
String facetId) |
private static String |
getFacetPath(String repositoryId,
String facetId,
String name) |
javax.jcr.Session |
getJcrSession() |
MetadataFacet |
getMetadataFacet(String repositoryId,
String facetId,
String name) |
List<String> |
getMetadataFacets(String repositoryId,
String facetId) |
private static String |
getNamespacePath(String repositoryId,
String namespace) |
Collection<String> |
getNamespaces(String repositoryId,
String baseNamespace) |
private Collection<String> |
getNodeNames(String path,
String nodeType) |
private javax.jcr.Node |
getOrAddArtifactNode(String repositoryId,
String namespace,
String projectId,
String projectVersion,
String id) |
private javax.jcr.Node |
getOrAddNamespaceNode(String repositoryId,
String namespace) |
private javax.jcr.Node |
getOrAddNodeByPath(javax.jcr.Node baseNode,
String name) |
private javax.jcr.Node |
getOrAddNodeByPath(javax.jcr.Node baseNode,
String name,
String nodeType) |
private javax.jcr.Node |
getOrAddProjectNode(String repositoryId,
String namespace,
String projectId) |
private javax.jcr.Node |
getOrAddProjectVersionNode(String repositoryId,
String namespace,
String projectId,
String projectVersion) |
private javax.jcr.Node |
getOrAddRepositoryContentNode(String repositoryId) |
private javax.jcr.Node |
getOrAddRepositoryNode(String repositoryId) |
ProjectMetadata |
getProject(String repositoryId,
String namespace,
String projectId)
basically just checking it exists not complete data returned
|
private static String |
getProjectPath(String repositoryId,
String namespace,
String projectId) |
Collection<ProjectVersionReference> |
getProjectReferences(String repositoryId,
String namespace,
String projectId,
String projectVersion)
Retrieve project references from the metadata repository.
|
Collection<String> |
getProjects(String repositoryId,
String namespace) |
ProjectVersionMetadata |
getProjectVersion(String repositoryId,
String namespace,
String projectId,
String projectVersion) |
private static String |
getProjectVersionPath(String repositoryId,
String namespace,
String projectId,
String projectVersion) |
Collection<String> |
getProjectVersions(String repositoryId,
String namespace,
String projectId) |
private static String |
getPropertyString(javax.jcr.Node node,
String name) |
Collection<String> |
getRepositories() |
private static String |
getRepositoryContentPath(String repositoryId) |
private static String |
getRepositoryPath(String repositoryId) |
Collection<String> |
getRootNamespaces(String repositoryId) |
boolean |
hasMetadataFacet(String repositoryId,
String facetId) |
(package private) static void |
initialize(javax.jcr.Session session) |
private String |
join(Collection<String> ids) |
<T> T |
obtainAccess(Class<T> aClass) |
private void |
recurse(List<String> facets,
String prefix,
javax.jcr.Node node) |
private static void |
registerMixinNodeType(javax.jcr.nodetype.NodeTypeManager nodeTypeManager,
String name) |
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 need a unit test!!!
Only remove
MetadataFacet for the artifact |
void |
removeArtifact(String repositoryId,
String namespace,
String projectId,
String projectVersion,
String id) |
void |
removeMetadataFacet(String repositoryId,
String facetId,
String name) |
void |
removeMetadataFacets(String repositoryId,
String facetId) |
void |
removeNamespace(String repositoryId,
String projectId) |
void |
removeProject(String repositoryId,
String namespace,
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
|
private List<ArtifactMetadata> |
runJcrQuery(String repositoryId,
String q,
Map<String,String> bindings) |
void |
save()
implementations can throw RuntimeException
|
List<ArtifactMetadata> |
searchArtifacts(String text,
String repositoryId,
boolean exact)
Exact is ignored as we can't do exact search in any property, we need a key
|
List<ArtifactMetadata> |
searchArtifacts(String key,
String text,
String repositoryId,
boolean exact)
Full text artifacts search inside the specified key.
|
void |
updateArtifact(String repositoryId,
String namespace,
String projectId,
String projectVersion,
ArtifactMetadata artifactMeta) |
void |
updateNamespace(String repositoryId,
String namespace)
create the namespace in the repository.
|
void |
updateProject(String repositoryId,
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 repositoryId,
String namespace,
String projectId) |
void |
updateProjectVersion(String repositoryId,
String namespace,
String projectId,
ProjectVersionMetadata versionMetadata) |
private static final String JCR_LAST_MODIFIED
static final String NAMESPACE_NODE_TYPE
static final String PROJECT_NODE_TYPE
static final String PROJECT_VERSION_NODE_TYPE
static final String ARTIFACT_NODE_TYPE
static final String FACET_NODE_TYPE
private static final String DEPENDENCY_NODE_TYPE
private final Map<String,MetadataFacetFactory> metadataFacetFactories
private org.slf4j.Logger log
private javax.jcr.Repository repository
private javax.jcr.Session jcrSession
public JcrMetadataRepository(Map<String,MetadataFacetFactory> metadataFacetFactories, javax.jcr.Repository repository) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
static void initialize(javax.jcr.Session session) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private static void registerMixinNodeType(javax.jcr.nodetype.NodeTypeManager nodeTypeManager, String name) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
public void updateProject(String repositoryId, ProjectMetadata project) throws MetadataRepositoryException
MetadataRepository
updateProject
in interface MetadataRepository
repositoryId
- the repository the project is inproject
- the project metadata to create or updateMetadataRepositoryException
private void updateProject(String repositoryId, String namespace, String projectId) throws MetadataRepositoryException
MetadataRepositoryException
public void updateArtifact(String repositoryId, String namespace, String projectId, String projectVersion, ArtifactMetadata artifactMeta) throws MetadataRepositoryException
updateArtifact
in interface MetadataRepository
MetadataRepositoryException
public void updateProjectVersion(String repositoryId, String namespace, String projectId, ProjectVersionMetadata versionMetadata) throws MetadataRepositoryException
updateProjectVersion
in interface MetadataRepository
MetadataRepositoryException
public void updateNamespace(String repositoryId, String namespace) throws MetadataRepositoryException
MetadataRepository
updateNamespace
in interface MetadataRepository
MetadataRepositoryException
public void removeProject(String repositoryId, String namespace, String projectId) throws MetadataRepositoryException
MetadataRepository
removeProject
in interface MetadataRepository
MetadataRepositoryException
public boolean hasMetadataFacet(String repositoryId, String facetId) throws MetadataRepositoryException
hasMetadataFacet
in interface MetadataRepository
MetadataRepositoryException
public List<String> getMetadataFacets(String repositoryId, String facetId) throws MetadataRepositoryException
getMetadataFacets
in interface MetadataRepository
MetadataRepositoryException
private void recurse(List<String> facets, String prefix, javax.jcr.Node node) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
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 removeNamespace(String repositoryId, String projectId) throws MetadataRepositoryException
removeNamespace
in interface MetadataRepository
projectId
- (groupId for maven )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 repoId, 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
public Collection<String> getRepositories() throws MetadataRepositoryException
getRepositories
in interface MetadataRepository
MetadataRepositoryException
public List<ArtifactMetadata> getArtifactsByChecksum(String repositoryId, String checksum) throws MetadataRepositoryException
getArtifactsByChecksum
in interface MetadataRepository
MetadataRepositoryException
private List<ArtifactMetadata> runJcrQuery(String repositoryId, String q, Map<String,String> bindings) throws MetadataRepositoryException
MetadataRepositoryException
public List<ArtifactMetadata> getArtifactsByProjectVersionMetadata(String key, String value, String repositoryId) throws MetadataRepositoryException
MetadataRepository
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 removeRepository(String repositoryId) throws MetadataRepositoryException
MetadataRepository
removeRepository
in interface MetadataRepository
repositoryId
- the repository to deleteMetadataRepositoryException
public List<ArtifactMetadata> getArtifacts(String repositoryId) throws MetadataRepositoryException
getArtifacts
in interface MetadataRepository
MetadataRepositoryException
private static String getArtifactQuery(String repositoryId)
public ProjectMetadata getProject(String repositoryId, String namespace, String projectId) throws MetadataResolutionException
MetadataRepository
getProject
in interface MetadataRepository
MetadataResolutionException
public ProjectVersionMetadata getProjectVersion(String repositoryId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getProjectVersion
in interface MetadataRepository
MetadataResolutionException
public Collection<String> getArtifactVersions(String repositoryId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getArtifactVersions
in interface MetadataRepository
MetadataResolutionException
public Collection<ProjectVersionReference> getProjectReferences(String repositoryId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
MetadataRepository
getProjectReferences
in interface MetadataRepository
repositoryId
- 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 Collection<String> getRootNamespaces(String repositoryId) throws MetadataResolutionException
getRootNamespaces
in interface MetadataRepository
MetadataResolutionException
public Collection<String> getNamespaces(String repositoryId, String baseNamespace) throws MetadataResolutionException
getNamespaces
in interface MetadataRepository
Collection
of child namespaces of the namespace argumentMetadataResolutionException
public Collection<String> getProjects(String repositoryId, String namespace) throws MetadataResolutionException
getProjects
in interface MetadataRepository
MetadataResolutionException
public Collection<String> getProjectVersions(String repositoryId, String namespace, String projectId) throws MetadataResolutionException
getProjectVersions
in interface MetadataRepository
MetadataResolutionException
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 removeProjectVersion(String repoId, String namespace, String projectId, String projectVersion) throws MetadataRepositoryException
removeProjectVersion
in interface MetadataRepository
MetadataRepositoryException
public void removeArtifact(String repositoryId, String namespace, String projectId, String projectVersion, String id) throws MetadataRepositoryException
removeArtifact
in interface MetadataRepository
MetadataRepositoryException
public void removeArtifact(String repositoryId, String namespace, String project, String projectVersion, MetadataFacet metadataFacet) throws MetadataRepositoryException
MetadataRepository
MetadataFacet
for the artifactremoveArtifact
in interface MetadataRepository
MetadataRepositoryException
public Collection<ArtifactMetadata> getArtifacts(String repositoryId, String namespace, String projectId, String projectVersion) throws MetadataResolutionException
getArtifacts
in interface MetadataRepository
MetadataResolutionException
public void save()
MetadataRepository
save
in interface MetadataRepository
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
public void close() throws MetadataRepositoryException
close
in interface MetadataRepository
MetadataRepositoryException
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
MetadataRepository
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
private ArtifactMetadata getArtifactFromNode(String repositoryId, javax.jcr.Node artifactNode) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private static String getPropertyString(javax.jcr.Node node, String name) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private Collection<String> getNodeNames(String path, String nodeType) throws MetadataResolutionException
MetadataResolutionException
private static String getRepositoryPath(String repositoryId)
private static String getRepositoryContentPath(String repositoryId)
private static String getFacetPath(String repositoryId, String facetId)
private static String getNamespacePath(String repositoryId, String namespace)
private static String getProjectPath(String repositoryId, String namespace, String projectId)
private static String getProjectVersionPath(String repositoryId, String namespace, String projectId, String projectVersion)
private static String getArtifactPath(String repositoryId, String namespace, String projectId, String projectVersion, String id)
private javax.jcr.Node getOrAddNodeByPath(javax.jcr.Node baseNode, String name) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private javax.jcr.Node getOrAddNodeByPath(javax.jcr.Node baseNode, String name, String nodeType) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private static String getFacetPath(String repositoryId, String facetId, String name)
private javax.jcr.Node getOrAddRepositoryNode(String repositoryId) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private javax.jcr.Node getOrAddRepositoryContentNode(String repositoryId) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private javax.jcr.Node getOrAddNamespaceNode(String repositoryId, String namespace) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private javax.jcr.Node getOrAddProjectNode(String repositoryId, String namespace, String projectId) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private javax.jcr.Node getOrAddProjectVersionNode(String repositoryId, String namespace, String projectId, String projectVersion) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private javax.jcr.Node getOrAddArtifactNode(String repositoryId, String namespace, String projectId, String projectVersion, String id) throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
private static Calendar createCalendar(Date time)
private String join(Collection<String> ids)
public javax.jcr.Session getJcrSession() throws javax.jcr.RepositoryException
javax.jcr.RepositoryException
Copyright © 2006–2022 The Apache Software Foundation. All rights reserved.