From 756a3ef7553875d12385d22c70950a89034b5c46 Mon Sep 17 00:00:00 2001 From: PRATHAM2002-DS Date: Mon, 24 Jun 2024 16:13:14 +0530 Subject: [PATCH 1/3] added filter for persona in creation flow for alias --- .../store/aliasstore/ESAliasStore.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java b/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java index 1991106b96..2d37d2f5fd 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java @@ -38,12 +38,7 @@ import org.springframework.stereotype.Component; import javax.inject.Inject; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; import static org.apache.atlas.ESAliasRequestBuilder.ESAliasAction.ADD; import static org.apache.atlas.repository.Constants.PERSONA_ENTITY_TYPE; @@ -90,7 +85,7 @@ public boolean createAlias(AtlasEntity entity) throws AtlasBaseException { ESAliasRequestBuilder requestBuilder = new ESAliasRequestBuilder(); if (PERSONA_ENTITY_TYPE.equals(entity.getTypeName())) { - requestBuilder.addAction(ADD, new AliasAction(getIndexNameFromAliasIfExists(VERTEX_INDEX_NAME), aliasName)); + requestBuilder.addAction(ADD, new AliasAction(getIndexNameFromAliasIfExists(VERTEX_INDEX_NAME), aliasName, getFilterForPersona(null, null))); } else { requestBuilder.addAction(ADD, new AliasAction(getIndexNameFromAliasIfExists(VERTEX_INDEX_NAME), aliasName, getFilterForPurpose(entity))); } @@ -150,6 +145,10 @@ public boolean deleteAlias(String aliasName) throws AtlasBaseException { private Map getFilterForPersona(AtlasEntity.AtlasEntityWithExtInfo persona, AtlasEntity policy) throws AtlasBaseException { List> allowClauseList = new ArrayList<>(); + if (policy == null && persona == null){ + return getEmptyFilter(); + } + List policies = getPolicies(persona); if (policy != null) { policies.add(policy); @@ -171,6 +170,12 @@ private Map getFilterForPurpose(AtlasEntity purpose) throws Atla return esClausesToFilter(allowClauseList); } +// private Map getFilterForPersona (AtlasEntity persona) throws AtlasBaseException { +// Map matchAll = mapOf("match_all", Collections.emptyMap()); +// Map mustNot = mapOf("must_not", matchAll); +// return mapOf("bool", mustNot); +// } + private void personaPolicyToESDslClauses(List policies, List> allowClauseList) throws AtlasBaseException { List terms = new ArrayList<>(); From 5db03f688456f8aa9acba3cc5b728243ba0835c0 Mon Sep 17 00:00:00 2001 From: PRATHAM2002-DS Date: Mon, 24 Jun 2024 16:26:11 +0530 Subject: [PATCH 2/3] removed comments --- .../atlas/repository/store/aliasstore/ESAliasStore.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java b/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java index 2d37d2f5fd..2247f39d8f 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java @@ -170,12 +170,6 @@ private Map getFilterForPurpose(AtlasEntity purpose) throws Atla return esClausesToFilter(allowClauseList); } -// private Map getFilterForPersona (AtlasEntity persona) throws AtlasBaseException { -// Map matchAll = mapOf("match_all", Collections.emptyMap()); -// Map mustNot = mapOf("must_not", matchAll); -// return mapOf("bool", mustNot); -// } - private void personaPolicyToESDslClauses(List policies, List> allowClauseList) throws AtlasBaseException { List terms = new ArrayList<>(); From 8b20fd95f373af6048a86ea47b66321f172007f0 Mon Sep 17 00:00:00 2001 From: PRATHAM2002-DS Date: Mon, 24 Jun 2024 16:32:11 +0530 Subject: [PATCH 3/3] added condition fo empty filter in updateAlias flow --- .../apache/atlas/repository/store/aliasstore/ESAliasStore.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java b/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java index 2247f39d8f..ddd57e2664 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/aliasstore/ESAliasStore.java @@ -124,6 +124,9 @@ public boolean updateAlias(AtlasEntity.AtlasEntityWithExtInfo accessControl, Atl if (PERSONA_ENTITY_TYPE.equals(accessControl.getEntity().getTypeName())) { filter = getFilterForPersona(accessControl, policy); + if (filter == null || filter.isEmpty()) { + filter = getEmptyFilter(); + } } else { filter = getFilterForPurpose(accessControl.getEntity()); }