Class WorkflowBundleLocator

java.lang.Object
com.agentforge4j.config.loader.workflow.WorkflowBundleLocator

public final class WorkflowBundleLocator extends Object
Resolves shipped workflow bundle resources from the classpath.

Resources are resolved through ClassLoader.getResource(String) on this class's own loader, not Class.getResource(String): the shipped catalog ships as a separate module/jar (the independently-versioned workflow catalog), so its resources are not in this loader's own module. The shipped-workflows root contains a hyphen, so it does not map to a Java package and is therefore not JPMS-encapsulated — it is discoverable across the class path and the module path. When no catalog is present on the classpath the shipped index is simply absent and shippedWorkflowIds() is empty.

  • Method Details

    • shippedWorkflowIds

      public static List<String> shippedWorkflowIds()
      Returns workflow ids listed in the shipped workflow index.
      Returns:
      immutable list of shipped workflow ids, empty when no catalog is present
    • locateWorkflowJson

      public static URL locateWorkflowJson(String workflowId)
      Resolves the workflow.json resource for a shipped workflow id.
      Parameters:
      workflowId - workflow id listed in the shipped workflow index
      Returns:
      classpath URL of the workflow definition
      Throws:
      IllegalStateException - when the workflow resource is not present
    • retrieveWorkflowBundleFiles

      public static List<String> retrieveWorkflowBundleFiles(String workflowId)
      Returns bundle entries listed in a shipped workflow bundle index.
      Parameters:
      workflowId - workflow id listed in the shipped workflow index
      Returns:
      classpath-relative bundle entry paths, or an empty list when no index is present
      Throws:
      IllegalStateException - when the bundle index cannot be read
    • openBundleResource

      public static InputStream openBundleResource(String classpathPath, String workflowId)
      Opens a shipped workflow bundle resource.
      Parameters:
      classpathPath - classpath path to a bundle entry (no leading slash)
      workflowId - owning workflow id, used in error messages
      Returns:
      open input stream for the requested resource
      Throws:
      IllegalStateException - when the resource does not exist
      UncheckedIOException - when the resource exists but cannot be opened
    • workflowPath

      public static String workflowPath(String workflowId)
      Classpath prefix for the given shipped workflow id (trailing slash), under shipped-workflows/. The prefix has no leading slash so it composes with ClassLoader.getResource(String). The id is validated against path traversal and separators so a malicious or malformed catalog index cannot steer resolution outside the shipped-workflows/ root — mirroring the agent bundle-entry guard. (Not exploitable for a trusted, build-time catalog, but the same surface admits third-party catalogs on the roadmap, and ClassLoader.getResource can normalise .. on exploded-directory classpath entries.)
      Parameters:
      workflowId - id from shippedWorkflowIds(); must not be blank, contain .., or contain path separators
      Returns:
      path such as shipped-workflows/my.workflow/