Package com.tnsai.coordination.resources
Class ArtifactStore
java.lang.Object
com.tnsai.coordination.resources.ArtifactStore
Stores named artifacts (files, data) produced by group members.
ArtifactStore provides a thread-safe in-memory store for binary artifacts produced during group work. Each artifact has a name, producer, content type, and optional metadata.
Usage Example
ArtifactStore store = new ArtifactStore();
// Store an artifact
store.store("report.json", "agent-1", jsonBytes, "application/json");
// Retrieve it
Optional<Artifact> artifact = store.get("report.json");
// List artifacts by producer
List<Artifact> agentArtifacts = store.getByProducer("agent-1");
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn artifact stored by a group member. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Clears all artifacts from the store.Retrieves an artifact by name.getByProducer(String agentId) Returns all artifacts produced by a specific agent.Lists the names of all stored artifacts.booleanRemoves an artifact by name.intsize()Returns the number of stored artifacts.voidStores an artifact.voidStores an artifact with metadata.
-
Constructor Details
-
ArtifactStore
public ArtifactStore()Creates a new empty ArtifactStore.
-
-
Method Details
-
store
Stores an artifact. If an artifact with the same name already exists, it is replaced.- Parameters:
name- the artifact nameproducedBy- the agent ID that produced this artifactdata- the binary contentcontentType- the MIME content type- Throws:
NullPointerException- if name, producedBy, or data is null
-
store
public void store(String name, String producedBy, byte[] data, String contentType, Map<String, String> metadata) Stores an artifact with metadata. If an artifact with the same name already exists, it is replaced.- Parameters:
name- the artifact nameproducedBy- the agent ID that produced this artifactdata- the binary contentcontentType- the MIME content typemetadata- additional metadata- Throws:
NullPointerException- if name, producedBy, or data is null
-
get
Retrieves an artifact by name.- Parameters:
name- the artifact name- Returns:
- the artifact, or empty if not found
- Throws:
NullPointerException- if name is null
-
getByProducer
Returns all artifacts produced by a specific agent.- Parameters:
agentId- the agent ID to filter by- Returns:
- list of artifacts produced by the agent
- Throws:
NullPointerException- if agentId is null
-
listNames
Lists the names of all stored artifacts.- Returns:
- list of artifact names
-
remove
Removes an artifact by name.- Parameters:
name- the artifact name to remove- Returns:
- true if the artifact was removed
- Throws:
NullPointerException- if name is null
-
clear
public void clear()Clears all artifacts from the store. -
size
public int size()Returns the number of stored artifacts.- Returns:
- artifact count
-