Class EmbeddedFilesResolver
java.lang.Object
org.sentrysoftware.metricshub.engine.connector.parser.EmbeddedFilesResolver
Resolves and internalizes embedded files within a JsonNode.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassA custom exception class for errors that occur during the processing of embedded files. -
Constructor Summary
ConstructorsConstructorDescriptionEmbeddedFilesResolver(com.fasterxml.jackson.databind.JsonNode connector, Path connectorDirectory, Set<URI> parents) Constructs an EmbeddedFilesResolver with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionCollects all processed embedded files into a map where each file is indexed by its unique identifier.voidprocess()Look for all references of embedded files that look like: ${file::}, find the referenced file, load its content as byte array to create a newEmbeddedFileinstance, store the created embedded file in theprocessedEmbeddedFileslookup and replace the reference to the external file by a reference to the internalized embedded file in theJsonNoderepresenting the connector.processFile(String fileName, Path connectorDirectory) Reads the file content and generate anEmbeddedFileinstance.
-
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
-
process
Look for all references of embedded files that look like: ${file::}, find the referenced file, load its content as byte array to create a newEmbeddedFileinstance, store the created embedded file in theprocessedEmbeddedFileslookup and replace the reference to the external file by a reference to the internalized embedded file in theJsonNoderepresenting the connector.- Throws:
IOException- If there is an issue finding the embedded file or processing the JSON structure.
-
processFile
Reads the file content and generate anEmbeddedFileinstance.- Parameters:
fileName- The name or relative path of the fileconnectorDirectory- The name of the connector directory where to look for the file- Returns:
- The absolute path of the file if found, null otherwise.
- Throws:
IOExceptionIllegalStateException- when the file can't be found
-
collectEmbeddedFiles
Collects all processed embedded files into a map where each file is indexed by its unique identifier.- Returns:
- A
Mapwith integer keys representing the unique ID of each embedded file and values as the correspondingEmbeddedFileinstances.
-