Class ServerDatasetResolver

java.lang.Object
dev.dokimos.server.client.ServerDatasetResolver
All Implemented Interfaces:
DatasetResolver

public class ServerDatasetResolver extends Object implements DatasetResolver
Resolves dataset URIs of the form dataset://<name>@<version> against a Dokimos server.

Pinned versions (numeric) are fetched network-first with a local fallback cached under ~/.dokimos/datasets-cache/<name>@<version>/items.json. The latest alias always goes to the network so newly published versions are picked up; once it resolves to a concrete version a pinned cache entry is written.

Discovered via ServiceLoader; the no-arg constructor reads DOKIMOS_SERVER_URL and DOKIMOS_API_KEY from the environment at supports(String) time, so a JVM that never sets the variable keeps the resolver inert and lets the next resolver in the chain handle the URI.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Version path alias that resolves to the newest version on the server.
    static final int
    Page size used when listing dataset items.
    static final String
    URI scheme handled by this resolver.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a resolver wired to DOKIMOS_SERVER_URL / DOKIMOS_API_KEY.
  • Method Summary

    Modifier and Type
    Method
    Description
    Fetches the dataset at the URI from the server, applying retries on 5xx responses and falling back to the offline cache when a pinned version is unreachable.
    boolean
    Indicates whether this resolver will attempt the given URI.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SCHEME

      public static final String SCHEME
      URI scheme handled by this resolver.
      See Also:
    • LATEST

      public static final String LATEST
      Version path alias that resolves to the newest version on the server.
      See Also:
    • PAGE_SIZE

      public static final int PAGE_SIZE
      Page size used when listing dataset items.
      See Also:
  • Constructor Details

    • ServerDatasetResolver

      public ServerDatasetResolver()
      Creates a resolver wired to DOKIMOS_SERVER_URL / DOKIMOS_API_KEY. Used by ServiceLoader when discovering resolvers on the classpath.
  • Method Details

    • supports

      public boolean supports(String uri)
      Indicates whether this resolver will attempt the given URI.

      Returns false for non dataset:// URIs and when no server URL is configured, so the registry can fall through to file/classpath resolvers. Malformed URIs are accepted here and rejected in resolve(String) with a precise error message.

      Specified by:
      supports in interface DatasetResolver
      Parameters:
      uri - the dataset URI
      Returns:
      true if this resolver can handle the given URI
    • resolve

      public Dataset resolve(String uri)
      Fetches the dataset at the URI from the server, applying retries on 5xx responses and falling back to the offline cache when a pinned version is unreachable.
      Specified by:
      resolve in interface DatasetResolver
      Parameters:
      uri - the dataset's URI
      Returns:
      the loaded Dataset
      Throws:
      DatasetResolutionException - if the URI is malformed, the server returns a 4xx, or all retries fail with no usable cache entry