From 1cb386248da3f595f78d13d217baf3651b52b2a2 Mon Sep 17 00:00:00 2001 From: hr2904 Date: Wed, 10 Jul 2024 15:56:21 +0530 Subject: [PATCH] MESH-40 Fixed the TODOs left by previous part of the task. --- .../v2/preprocessor/AuthPolicyPreProcessor.java | 16 ++++++---------- .../datamesh/StakeholderTitlePreProcessor.java | 14 +++++--------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/AuthPolicyPreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/AuthPolicyPreProcessor.java index b8f832d3f2..58fb516564 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/AuthPolicyPreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/AuthPolicyPreProcessor.java @@ -125,11 +125,9 @@ private void processCreatePolicy(AtlasStruct entity) throws AtlasBaseException { if (!POLICY_SUB_CATEGORY_DOMAIN.equals(policySubCategory)) { validator.validate(policy, null, parentEntity, CREATE); validateConnectionAdmin(policy); + } else { + validateAndReduce(policy); } - // TODO : uncomment after FE release -// else { -// validateAndReduce(policy); -// } policy.setAttribute(QUALIFIED_NAME, String.format("%s/%s", getEntityQualifiedName(parentEntity), getUUID())); @@ -173,11 +171,11 @@ private void validateAndReduce(AtlasEntity policy) { boolean hasAllDomainPattern = resources.stream().anyMatch(resource -> resource.equals("entity:*") || resource.equals("entity:*/super") || - resource.equals("entity:default/domain/*/super") + resource.equals(ENTITY_DEFAULT_DOMAIN_SUPER) ); if (hasAllDomainPattern) { - policy.setAttribute(ATTR_POLICY_RESOURCES, Collections.singletonList("entity:default/domain/*/super")); + policy.setAttribute(ATTR_POLICY_RESOURCES, Collections.singletonList(ENTITY_DEFAULT_DOMAIN_SUPER)); } } @@ -199,11 +197,9 @@ private void processUpdatePolicy(AtlasStruct entity, AtlasVertex vertex) throws if (!POLICY_SUB_CATEGORY_DOMAIN.equals(policySubCategory)) { validator.validate(policy, existingPolicy, parentEntity, UPDATE); validateConnectionAdmin(policy); + } else { + validateAndReduce(policy); } - // TODO : uncomment after FE release -// else { -// validateAndReduce(policy); -// } String qName = getEntityQualifiedName(existingPolicy); policy.setAttribute(QUALIFIED_NAME, qName); diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/StakeholderTitlePreProcessor.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/StakeholderTitlePreProcessor.java index 4ece545cb8..1de5fe685e 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/StakeholderTitlePreProcessor.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/preprocessor/datamesh/StakeholderTitlePreProcessor.java @@ -117,15 +117,12 @@ private void processCreateStakeholderTitle(AtlasEntity entity) throws AtlasBaseE } if (domainQualifiedNames.contains(NEW_STAR) || domainQualifiedNames.contains(STAR)) { if (domainQualifiedNames.size() > 1) { - domainQualifiedNames.clear(); - // TODO : convert this to NEW_STAR after FE release - domainQualifiedNames.add(STAR); + domainQualifiedNames.add(NEW_STAR); entity.setAttribute(ATTR_DOMAIN_QUALIFIED_NAMES, domainQualifiedNames); - } // TODO : uncomment this after FE release -// else { -// domainQualifiedNames.replaceAll(s -> s.equals(STAR) ? NEW_STAR : s); -// } + }else { + domainQualifiedNames.replaceAll(s -> s.equals(STAR) ? NEW_STAR : s); + } String qualifiedName = format(PATTERN_QUALIFIED_NAME_ALL_DOMAINS, getUUID()); entity.setAttribute(QUALIFIED_NAME, qualifiedName); @@ -216,8 +213,7 @@ private void authorizeDomainAccess(List domainQualifiedNames) throws Atl String domainQualifiedNameToAuth; if (domainQualifiedNames.contains(STAR) || domainQualifiedNames.contains(NEW_STAR)) { - //TODO : Convert this to NEW_STAR - domainQualifiedNameToAuth = STAR; + domainQualifiedNameToAuth = NEW_STAR; } else { domainQualifiedNameToAuth = domainQualifiedName; }