public static <BE> void validate(Transaction<BE> tx, StructuredData data, BE dataEntity) { CanonicalPath path = tx.extractCanonicalPath(dataEntity); DataRole role = DataRole.valueOf(path.ids().getDataRole()); if (role.isSchema()) { try { JsonNode schema = new JsonNodeReader(new ObjectMapper()) .fromInputStream(BaseData.class.getResourceAsStream("/json-meta-schema.json")); CanonicalPath dataPath = tx.extractCanonicalPath(dataEntity); validate(dataPath, convert(data), schema); } catch (IOException e) { throw new IllegalStateException("Could not load the embedded JSON Schema meta-schema."); } } else { validateIfSchemaFound(tx, data, dataEntity, Query.path().with(navigateToSchema(role)).get()); } }