Skip to content

Commit

Permalink
Fixed registry deleting entities while attestating with using an arra…
Browse files Browse the repository at this point in the history
…y type property
  • Loading branch information
holashchand committed Jun 21, 2024
1 parent 6e98801 commit dbd2679
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ private ArrayNode expandChildObject(ObjectNode entityNode, List<String> 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);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ private void updateAttestation(String attestorEntity, String userId, JsonNode en
} else if (attestation.get(_osState.name()).asText().equals(States.ATTESTATION_REQUESTED.name())) {
JsonNode propertyData = JSONUtil.extractPropertyDataFromEntity(uuidPropertyName, entity, attestationPolicy.getAttestationProperties(), null);
if (attestation.has(propertiesUUIDKey)) {
ObjectNode propertiesUUIDs = attestations.get(propertiesUUIDKey).deepCopy();
ObjectNode propertiesUUIDs = attestation.get(propertiesUUIDKey).deepCopy();
Map<String, List<String>> propertiesUUIDMapper = new HashMap<>();
ObjectReader reader = objectMapper.readerFor(new TypeReference<List<String>>() {
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -483,7 +484,11 @@ private void doDelete(IRegistryDao registryDao, VertexReader vr, Set<String> pre
itemUuid = ArrayHelper.unquoteString(itemUuid);
if (!updatedUuids.contains(itemUuid)) {
// delete this item
registryDao.deleteEntity(uuidVertexMap.get(itemUuid));
if(isHardDeleteEnabled) {
registryDao.hardDeleteEntity(uuidVertexMap.get(itemUuid));
} else {
registryDao.deleteEntity(uuidVertexMap.get(itemUuid));
}
}
}
}
Expand Down Expand Up @@ -517,7 +522,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);
Expand Down

0 comments on commit dbd2679

Please sign in to comment.