Beispiel #1
0
 @Override
 public BlockDefinition getBlockDefinitionForSection(JsonObject json, String sectionName) {
   if (json.has(sectionName) && json.get(sectionName).isJsonObject()) {
     JsonObject sectionJson = json.getAsJsonObject(sectionName);
     json.remove(sectionName);
     JsonMergeUtil.mergeOnto(json, sectionJson);
     return createBlockDefinition(sectionJson);
   }
   return null;
 }
Beispiel #2
0
 private JsonObject inheritData(AssetUri rootAssetUri, JsonObject blockDefJson) {
   JsonObject parentObj = blockDefJson;
   while (parentObj.has("basedOn")) {
     AssetUri parentUri =
         Assets.resolveAssetUri(
             AssetType.BLOCK_DEFINITION, parentObj.get("basedOn").getAsString());
     if (rootAssetUri.equals(parentUri)) {
       logger.error("Circular inheritance detected in {}", rootAssetUri);
       break;
     } else if (!parentUri.isValid()) {
       logger.error(
           "{} based on invalid uri: {}", rootAssetUri, parentObj.get("basedOn").getAsString());
       break;
     }
     JsonObject parent = readJson(parentUri).getAsJsonObject();
     JsonMergeUtil.mergeOnto(parent, blockDefJson);
     parentObj = parent;
   }
   return blockDefJson;
 }