From 308d624796e5a3fa0d1bf6f8e4befe769301c572 Mon Sep 17 00:00:00 2001 From: Holash Chand Date: Fri, 21 Jun 2024 16:42:20 +0530 Subject: [PATCH] Fixed attestation causing issues when using an array type property --- .../src/main/java/dev/sunbirdrc/registry/dao/VertexReader.java | 2 +- .../sunbirdrc/registry/service/impl/RegistryServiceImpl.java | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/java/registry/src/main/java/dev/sunbirdrc/registry/dao/VertexReader.java b/java/registry/src/main/java/dev/sunbirdrc/registry/dao/VertexReader.java index f63d939ff..7ed1cb1af 100644 --- a/java/registry/src/main/java/dev/sunbirdrc/registry/dao/VertexReader.java +++ b/java/registry/src/main/java/dev/sunbirdrc/registry/dao/VertexReader.java @@ -357,7 +357,7 @@ private ArrayNode expandChildObject(ObjectNode entityNode, List processe if (expandChildObject.size() == 0 && entityNode.get(field).size() == 0) { entityNode.remove(field); } - if (expandChildObject != null && expandChildObject.size() > 0) { + if (expandChildObject != null && entityNode.get(field).size() == 1) { entityNode.set(field, expandChildObject); } } diff --git a/java/registry/src/main/java/dev/sunbirdrc/registry/service/impl/RegistryServiceImpl.java b/java/registry/src/main/java/dev/sunbirdrc/registry/service/impl/RegistryServiceImpl.java index 989037820..cd844ca81 100755 --- a/java/registry/src/main/java/dev/sunbirdrc/registry/service/impl/RegistryServiceImpl.java +++ b/java/registry/src/main/java/dev/sunbirdrc/registry/service/impl/RegistryServiceImpl.java @@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; +import com.fasterxml.jackson.databind.node.JsonNodeType; import com.fasterxml.jackson.databind.node.ObjectNode; import com.jayway.jsonpath.DocumentContext; import com.jayway.jsonpath.JsonPath; @@ -517,7 +518,7 @@ private void doUpdate(Shard shard, Graph graph, IRegistryDao registryDao, Vertex oneElementNode.isValueNode() || oneElementNode.isArray()) { logger.info("Value or array node, going to update {}", oneElement.getKey()); - if (oneElementNode.isArray()) { + if (oneElementNode.isArray() && (oneElementNode.isEmpty() || oneElementNode.get(0).getNodeType().equals(JsonNodeType.OBJECT))) { // Arrays are treated specially - we create a blank node and then // individual items String arrayRefLabel = RefLabelHelper.getArrayLabel(oneElement.getKey(), uuidPropertyName);