From bc5e9339fbf8e0de77d9b301cb0a4dd46bbb0dcd Mon Sep 17 00:00:00 2001 From: Nikhil Soni Date: Fri, 5 Jul 2024 16:17:16 +0530 Subject: [PATCH 1/2] fix: Ignore classification option validation when propogate is false If propogate option is false then restrict option are ingored and only checked if propogate if true --- .../atlas/repository/store/graph/v2/EntityGraphMapper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java index 596420696d..518b721d0f 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java @@ -3590,6 +3590,7 @@ public void updateClassifications(EntityMutationContext context, String guid, Li if (CollectionUtils.isEmpty(classifications)) { throw new AtlasBaseException(AtlasErrorCode.INVALID_CLASSIFICATION_PARAMS, "update", guid); } + entityRetriever.verifyClassificationsPropagationMode(classifications); AtlasVertex entityVertex = AtlasGraphUtilsV2.findByGuid(this.graph, guid); @@ -3711,7 +3712,6 @@ public void updateClassifications(EntityMutationContext context, String guid, Li Boolean updatedRestrictPropagationThroughLineage = classification.getRestrictPropagationThroughLineage(); Boolean currentRestrictPropagationThroughHierarchy = currentClassification.getRestrictPropagationThroughHierarchy(); Boolean updatedRestrictPropagationThroughHierarchy = classification.getRestrictPropagationThroughHierarchy(); - String propagationMode = entityRetriever.determinePropagationMode(updatedRestrictPropagationThroughLineage, updatedRestrictPropagationThroughHierarchy); if ((!Objects.equals(updatedRemovePropagations, currentRemovePropagations) || !Objects.equals(currentTagPropagation, updatedTagPropagation) || !Objects.equals(currentRestrictPropagationThroughLineage, updatedRestrictPropagationThroughLineage)) && @@ -3731,6 +3731,7 @@ public void updateClassifications(EntityMutationContext context, String guid, Li // compute propagatedEntityVertices once and use it for subsequent iterations and notifications if (updatedTagPropagation != null && (currentTagPropagation != updatedTagPropagation || currentRestrictPropagationThroughLineage != updatedRestrictPropagationThroughLineage || currentRestrictPropagationThroughHierarchy != updatedRestrictPropagationThroughHierarchy)) { if (updatedTagPropagation) { + String propagationMode = entityRetriever.determinePropagationMode(updatedRestrictPropagationThroughLineage, updatedRestrictPropagationThroughHierarchy); if (updatedRestrictPropagationThroughLineage != null && !currentRestrictPropagationThroughLineage && updatedRestrictPropagationThroughLineage) { deleteDelegate.getHandler().removeTagPropagation(classificationVertex); From e31e6b9d3f6c927e552705176de8afbe7161527c Mon Sep 17 00:00:00 2001 From: Nikhil Soni Date: Wed, 10 Jul 2024 14:38:23 +0530 Subject: [PATCH 2/2] Use previous values for missing restrict option If a restrict via lineage or restrict via hierarchy option is missing while updating the set classification, this will use the previously saved value. This is done to avoid bypassing the validation if setting the options one by one. --- .../store/graph/v2/EntityGraphMapper.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java index 518b721d0f..798d86071e 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphMapper.java @@ -3712,6 +3712,21 @@ public void updateClassifications(EntityMutationContext context, String guid, Li Boolean updatedRestrictPropagationThroughLineage = classification.getRestrictPropagationThroughLineage(); Boolean currentRestrictPropagationThroughHierarchy = currentClassification.getRestrictPropagationThroughHierarchy(); Boolean updatedRestrictPropagationThroughHierarchy = classification.getRestrictPropagationThroughHierarchy(); + if (updatedRestrictPropagationThroughLineage == null) { + updatedRestrictPropagationThroughLineage = currentRestrictPropagationThroughLineage; + classification.setRestrictPropagationThroughLineage(updatedRestrictPropagationThroughLineage); + } + if (updatedRestrictPropagationThroughHierarchy == null) { + updatedRestrictPropagationThroughHierarchy = currentRestrictPropagationThroughHierarchy; + classification.setRestrictPropagationThroughHierarchy(updatedRestrictPropagationThroughHierarchy); + } + + String propagationMode = CLASSIFICATION_PROPAGATION_MODE_DEFAULT; + if (updatedTagPropagation) { + // determinePropagationMode also validates the propagation restriction option values + propagationMode = entityRetriever.determinePropagationMode(updatedRestrictPropagationThroughLineage, updatedRestrictPropagationThroughHierarchy); + } + if ((!Objects.equals(updatedRemovePropagations, currentRemovePropagations) || !Objects.equals(currentTagPropagation, updatedTagPropagation) || !Objects.equals(currentRestrictPropagationThroughLineage, updatedRestrictPropagationThroughLineage)) && @@ -3731,10 +3746,8 @@ public void updateClassifications(EntityMutationContext context, String guid, Li // compute propagatedEntityVertices once and use it for subsequent iterations and notifications if (updatedTagPropagation != null && (currentTagPropagation != updatedTagPropagation || currentRestrictPropagationThroughLineage != updatedRestrictPropagationThroughLineage || currentRestrictPropagationThroughHierarchy != updatedRestrictPropagationThroughHierarchy)) { if (updatedTagPropagation) { - String propagationMode = entityRetriever.determinePropagationMode(updatedRestrictPropagationThroughLineage, updatedRestrictPropagationThroughHierarchy); if (updatedRestrictPropagationThroughLineage != null && !currentRestrictPropagationThroughLineage && updatedRestrictPropagationThroughLineage) { deleteDelegate.getHandler().removeTagPropagation(classificationVertex); - } if (updatedRestrictPropagationThroughHierarchy != null && !currentRestrictPropagationThroughHierarchy && updatedRestrictPropagationThroughHierarchy) { deleteDelegate.getHandler().removeTagPropagation(classificationVertex);