Class ArtifactStore

java.lang.Object
com.tnsai.coordination.resources.ArtifactStore

public class ArtifactStore extends Object
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");
 
  • Constructor Details

    • ArtifactStore

      public ArtifactStore()
      Creates a new empty ArtifactStore.
  • Method Details

    • store

      public void store(String name, String producedBy, byte[] data, String contentType)
      Stores an artifact. If an artifact with the same name already exists, it is replaced.
      Parameters:
      name - the artifact name
      producedBy - the agent ID that produced this artifact
      data - the binary content
      contentType - 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 name
      producedBy - the agent ID that produced this artifact
      data - the binary content
      contentType - the MIME content type
      metadata - 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

      public List<ArtifactStore.Artifact> getByProducer(String agentId)
      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

      public List<String> listNames()
      Lists the names of all stored artifacts.
      Returns:
      list of artifact names
    • remove

      public boolean remove(String name)
      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