File tree Expand file tree Collapse file tree
src/main/java/edu/kit/datamanager/ro_crate/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99
1010/**
1111 * Utility class for expanding and pruning JSON-LD documents.
12- *
12+ * <p>
1313 * This class provides functionality to resolve references in JSON-LD based on "@id" values,
1414 * expanding the data structure by replacing references with their full content.
1515 * It also handles circular references to prevent infinite recursion.
1919public class JsonLdExpander {
2020
2121 public static JsonNode expandAndPrune (File jsonLdFile ) throws Exception {
22+ if (jsonLdFile == null ) {
23+ throw new IllegalArgumentException ("JSON-LD file must not be null." );
24+ }
25+ if (!jsonLdFile .exists () || !jsonLdFile .canRead ()) {
26+ throw new IllegalArgumentException ("JSON-LD file does not exist or cannot be read: " + jsonLdFile .getAbsolutePath ());
27+ }
2228 ObjectMapper mapper = new ObjectMapper ();
2329 JsonNode root = mapper .readTree (jsonLdFile );
2430 return expandAndPrune (root );
You can’t perform that action at this time.
0 commit comments