org.codehaus.mojo.mrm.api.maven
Interface ArtifactStore

All Superinterfaces:
Serializable
All Known Implementing Classes:
BaseArtifactStore

public interface ArtifactStore
extends Serializable

An artifact store holds Maven Artifacts and can provide Metadata about the artifacts that it holds.

Since:
1.0

Method Summary
 InputStream get(Artifact artifact)
          Retrieves the the artifact as an InputStream.
 Set getArtifactIds(String groupId)
          Returns the set of artifactIds that belong in the specified groupId.
 Set getArtifacts(String groupId, String artifactId, String version)
          Returns the set of artifacts at the specified groupId:artifactId:version.
 Set 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 getMetadataLastModified(String path)
          Returns the time that the specified metadata was last modified.
 long getSize(Artifact artifact)
          Returns the size in bytes of the specified artifact.
 Set 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.
 

Method Detail

getGroupIds

Set getGroupIds(String parentGroupId)
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 get(Artifact) method.

If there are known to be groupIds: org.codehaus.mojo, org.apache.maven and commons-io then
 assertEquals(new HashSet<String>(Arrays.asList("commons-io","org")), getGroupIds("")); // Query root level
 assertEquals(new HashSet<String>(Arrays.asList("org.codehaus", "org.apache")), getGroupIds("org")); // query with a prefix
 assertEquals(new HashSet<String>(Arrays.asList("org.codehaus.mojo")), getGroupIds("org.codehaus"));
 
Note that while the existence of groupId org.codehaus.mojo implies that there must be groupIds org and org.codehaus there is no requirement that an implementation should report these inferred parent groupIds, it is just strongly encouraged.

Note that where an implementation cannot differentiate between artifactIds, child groupIds and perhaps even versions, it is permitted to return all three.

Parameters:
parentGroupId - The prefix to query or the empty string to query the root, cannot be null.
Returns:
A set (with all elements of type String) of groupIds that are known to have parentGroupId as their prefix. All returned elements must start with parentGroupId and must have one and only one additional segment.
Since:
1.0

getArtifactIds

Set getArtifactIds(String groupId)
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 get(Artifact) method.

Note that where an implementation cannot differentiate between artifactIds, child groupIds and perhaps even versions, it is permitted to return all three.

Parameters:
groupId - The groupId to query cannot be empty or null.
Returns:
A set (with all elements of type String) of artifactIds that are known to belong to groupId.
Since:
1.0

getVersions

Set getVersions(String groupId,
                String artifactId)
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 get(Artifact) method.

Note that where an implementation cannot differentiate between artifactIds, child groupIds and perhaps even versions, it is permitted to return all three.

Parameters:
groupId - The groupId to query cannot be empty or null.
artifactId - The artifactId to query cannot be empty or null.
Returns:
A set (with all elements of type String) of versions that are known to exist for groupId:artifactId.
Since:
1.0

getArtifacts

Set getArtifacts(String groupId,
                 String artifactId,
                 String version)
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 the get(Artifact) method.

Parameters:
groupId - The groupId to query cannot be empty or null.
artifactId - The artifactId to query cannot be empty or null.
version - The version to query cannot be empty or null.
Returns:
A set (with all elements of type Artifact of artifacts that are known to exist of the specified groupId:artifactId:version.
Since:
1.0

getLastModified

long getLastModified(Artifact artifact)
                     throws IOException,
                            ArtifactNotFoundException
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), or 0L if the artifact might not exist (where the artifact is known to not exist an ArtifactNotFoundException must be thrown.
Throws:
IOException - if an I/O error occurs.
ArtifactNotFoundException - if the artifact definitely does not exist.
Since:
1.0

getSize

long getSize(Artifact artifact)
             throws IOException,
                    ArtifactNotFoundException
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

InputStream get(Artifact artifact)
                throws IOException,
                       ArtifactNotFoundException
Retrieves the the artifact as an InputStream. 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

void set(Artifact artifact,
         InputStream content)
         throws IOException
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 the maven-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

getMetadataLastModified

long getMetadataLastModified(String path)
                             throws IOException,
                                    MetadataNotFoundException
Returns the time that the specified metadata was last modified.

Parameters:
path - of the metadata (should not include the maven-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), or 0L if the metadata might not exist (where the metadtat is known to not exist a MetadataNotFoundException must be thrown.
Throws:
IOException - if an I/O error occurs.
MetadataNotFoundException - if the metadata definitely does not exist.
Since:
1.0


Copyright © 2009-2011 Codehaus. All Rights Reserved.