Class EmbeddedFilesResolver

java.lang.Object
org.sentrysoftware.metricshub.engine.connector.parser.EmbeddedFilesResolver

public class EmbeddedFilesResolver extends Object
Resolves and internalizes embedded files within a JsonNode.
  • Constructor Summary

    Constructors
    Constructor
    Description
    EmbeddedFilesResolver(com.fasterxml.jackson.databind.JsonNode connector, Path connectorDirectory, Set<URI> parents)
    Constructs an EmbeddedFilesResolver with the given parameters.
  • Method Summary

    Modifier and Type
    Method
    Description
    findAbsoluteUri(String fileName, Path connectorDirectory)
    Find the absolute URI of the file in parameter
    void
    Look for all references of embedded files that look like: $file("...")$, find the referenced file, add its content in a new node at the end of the connector and replace the reference to the external file by a reference to the internalized embedded file

    Methods inherited from class java.lang.Object

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

    • EmbeddedFilesResolver

      public EmbeddedFilesResolver(com.fasterxml.jackson.databind.JsonNode connector, Path connectorDirectory, Set<URI> parents)
      Constructs an EmbeddedFilesResolver with the given parameters.
      Parameters:
      connector - The JsonNode representing the connector.
      connectorDirectory - The directory of the connector.
      parents - Set of parent directories URIs.
  • Method Details

    • internalize

      public void internalize() throws IOException
      Look for all references of embedded files that look like: $file("...")$, find the referenced file, add its content in a new node at the end of the connector and replace the reference to the external file by a reference to the internalized embedded file
      Throws:
      IOException - If there is an issue finding the embedded file or processing the JSON structure.
    • findAbsoluteUri

      public URI findAbsoluteUri(String fileName, Path connectorDirectory)
      Find the absolute URI of the file in parameter
      Parameters:
      fileName - The name or relative path of the file
      connectorDirectory - The name of the connector directory where to look for the file
      Returns:
      The absolute path of the file if found, null otherwise.
      Throws:
      IllegalStateException - when the file can't be found