Interface ArtifactStore
- All Known Implementing Classes:
BaseArtifactStore
Artifact
s and can provide Metadata
about the artifacts that it holds.- Since:
- 1.0
-
Method Summary
Modifier and TypeMethodDescriptionRetrieves the the artifact as anInputStream
.org.apache.maven.archetype.catalog.ArchetypeCatalog
long
getArtifactIds
(String groupId) Returns the set of artifactIds that belong in the specified groupId.getArtifacts
(String groupId, String artifactId, String version) Returns the set of artifacts at the specified groupId:artifactId:version.getGroupIds
(String parentGroupId) Returns the set of groupIds that begin with the specified prefix.long
getLastModified
(Artifact artifact) Returns the time that the specified artifact was last modified.org.apache.maven.artifact.repository.metadata.Metadata
getMetadata
(String path) Returns the specified metadata.long
Returns the time that the specified metadata was last modified.long
Returns the size in bytes of the specified artifact.getVersions
(String groupId, String artifactId) Returns the set of versions of the specified groupId:artifactId.void
set
(Artifact artifact, InputStream content) Create/update the specified artifact.void
setArchetypeCatalog
(InputStream content) void
setMetadata
(String path, org.apache.maven.artifact.repository.metadata.Metadata content) Create/update the specified metadata.
-
Method Details
-
getGroupIds
Returns the set of groupIds that begin with the specified prefix. Some implementations may be lazy caching implementations, in which case it is permitted to return either the empty set, or only those entries which have been loaded into the cache, so consumers should not assume that a missing entry implies non-existence. The only way to be sure that an artifact does not exist is to call the
If there are known to be groupIds: org.codehaus.mojo, org.apache.maven and commons-io thenget(Artifact)
method.// Query root level assertEquals(new HashSet<String>(Arrays.asList("commons-io","org")), getGroupIds("")); // query with a prefix assertEquals(new HashSet<String>(Arrays.asList("org.codehaus", "org.apache")), getGroupIds("org")); assertEquals(new HashSet<String>(Arrays.asList("org.codehaus.mojo")), getGroupIds("org.codehaus"));
Note that while the existence of groupId
Note that where an implementation cannot differentiate between artifactIds, child groupIds and perhaps even versions, it is permitted to return all three.org.codehaus.mojo
implies that there must be groupIdsorg
andorg.codehaus
there is no requirement that an implementation should report these inferred parent groupIds, it is just strongly encouraged.- Parameters:
parentGroupId
- The prefix to query or the empty string to query the root, cannot benull
.- Returns:
- A set (with all elements of type
String
) of groupIds that are known to haveparentGroupId
as their prefix. All returned elements must start withparentGroupId
and must have one and only one additional segment. - Since:
- 1.0
-
getArtifactIds
Returns the set of artifactIds that belong in the specified groupId. Some implementations may be lazy caching implementations, in which case it is permitted to return either the empty set, or only those entries which have been loaded into the cache, so consumers should not assume that a missing entry implies non-existence. The only way to be sure that an artifact does not exist is to call the
Note that where an implementation cannot differentiate between artifactIds, child groupIds and perhaps even versions, it is permitted to return all three.get(Artifact)
method.- Parameters:
groupId
- The groupId to query cannot be empty ornull
.- Returns:
- A set (with all elements of type
String
) of artifactIds that are known to belong togroupId
. - Since:
- 1.0
-
getVersions
Returns the set of versions of the specified groupId:artifactId. Some implementations may be lazy caching implementations, in which case it is permitted to return either the empty set, or only those entries which have been loaded into the cache, so consumers should not assume that a missing entry implies non-existence. The only way to be sure that an artifact does not exist is to call the
Note that where an implementation cannot differentiate between artifactIds, child groupIds and perhaps even versions, it is permitted to return all three.get(Artifact)
method.- Parameters:
groupId
- The groupId to query cannot be empty ornull
.artifactId
- The artifactId to query cannot be empty ornull
.- Returns:
- A set (with all elements of type
String
) of versions that are known to exist forgroupId:artifactId
. - Since:
- 1.0
-
getArtifacts
Returns the set of artifacts at the specified groupId:artifactId:version. Some implementations may be lazy caching implementations, in which case it is permitted to return either the empty set, or only those entries which have been loaded into the cache, so consumers should not assume that a missing entry implies non-existence. The only way to be sure that an artifact does not exist is to call theget(Artifact)
method.- Parameters:
groupId
- The groupId to query cannot be empty ornull
.artifactId
- The artifactId to query cannot be empty ornull
.version
- The version to query cannot be empty ornull
.- Returns:
- A set (with all elements of type
Artifact
of artifacts that are known to exist of the specifiedgroupId:artifactId:version
. - Since:
- 1.0
-
getLastModified
Returns the time that the specified artifact was last modified.- Parameters:
artifact
- the artifact.- Returns:
- A
long
value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or0L
if the artifact might not exist (where the artifact is known to not exist anArtifactNotFoundException
must be thrown. - Throws:
IOException
- if an I/O error occurs.ArtifactNotFoundException
- if the artifact definitely does not exist.- Since:
- 1.0
-
getSize
Returns the size in bytes of the specified artifact.- Parameters:
artifact
- the artifact.- Returns:
- the length of the artifact in bytes or
-1L
if the length cannot be determined. - Throws:
IOException
- if an I/O error occurs.ArtifactNotFoundException
- if the artifact definitely does not exist.- Since:
- 1.0
-
get
Retrieves the the artifact as anInputStream
. The caller is responsible for closing the stream.- Parameters:
artifact
- the artifact.- Returns:
- the contents of the artifact (caller is responsible for closing).
- Throws:
IOException
- if the artifact could not be retrieved.ArtifactNotFoundException
- if the artifact does not exist.- Since:
- 1.0
-
set
Create/update the specified artifact. This is an optional method for implementers.- Parameters:
artifact
- the artifact to create/update.content
- the stream of contents (implementer is responsible for closing).- Throws:
IOException
- if the content could not be read/written.UnsupportedOperationException
- if the implementation is a read-only implementation.- Since:
- 1.0
-
getMetadata
org.apache.maven.artifact.repository.metadata.Metadata getMetadata(String path) throws IOException, MetadataNotFoundException Returns the specified metadata.- Parameters:
path
- of the metadata (should not include themaven-metadata.xml
.- Returns:
- the metadata, never
null
. - Throws:
IOException
- if an I/O error occurs.MetadataNotFoundException
- if the metadata does not exist.- Since:
- 1.0
-
setMetadata
void setMetadata(String path, org.apache.maven.artifact.repository.metadata.Metadata content) throws IOException Create/update the specified metadata.- Parameters:
path
- of the metadata (should not include themaven-metadata.xml
.content
- the metadata, nevernull
.- Throws:
IOException
- if an I/O error occurs.- Since:
- 1.1.0
-
getMetadataLastModified
Returns the time that the specified metadata was last modified.- Parameters:
path
- of the metadata (should not include themaven-metadata.xml
.- Returns:
- A
long
value representing the time the file was last modified, measured in milliseconds since the epoch (00:00:00 GMT, January 1, 1970), or0L
if the metadata might not exist (where the metadtat is known to not exist aMetadataNotFoundException
must be thrown. - Throws:
IOException
- if an I/O error occurs.MetadataNotFoundException
- if the metadata definitely does not exist.- Since:
- 1.0
-
getArchetypeCatalog
org.apache.maven.archetype.catalog.ArchetypeCatalog getArchetypeCatalog() throws IOException, ArchetypeCatalogNotFoundException- Returns:
- ArchetypeCatalog
- Throws:
IOException
- if an I/O error occurs.ArchetypeCatalogNotFoundException
- if the archetypeCatalog does not exist.- Since:
- 1.0
-
getArchetypeCatalogLastModified
- Returns:
- long
- Throws:
IOException
- if an I/O error occurs.ArchetypeCatalogNotFoundException
- if the archetypeCatalog does not exist.- Since:
- 1.0
-
setArchetypeCatalog
- Parameters:
content
- the content- Throws:
IOException
- if an I/O error occurs.- Since:
- 1.0
-