From 1f682ebb77556bfd558c6563638ee3204a6c60bb Mon Sep 17 00:00:00 2001 From: Nikhil P Bonte Date: Thu, 25 Jan 2024 18:35:38 +0530 Subject: [PATCH] Logging --- .../atlas/authorizer/store/PoliciesStore.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/repository/src/main/java/org/apache/atlas/authorizer/store/PoliciesStore.java b/repository/src/main/java/org/apache/atlas/authorizer/store/PoliciesStore.java index c205a00851..1662afcb8d 100644 --- a/repository/src/main/java/org/apache/atlas/authorizer/store/PoliciesStore.java +++ b/repository/src/main/java/org/apache/atlas/authorizer/store/PoliciesStore.java @@ -85,11 +85,12 @@ public static List getRelevantPolicies(String persona, String purp policies = getAbacPolicies(); } - + List filteredPolicies = null; if (CollectionUtils.isNotEmpty(policies)) { - policies = getFilteredPoliciesForQualifiedName(policies, policyQualifiedNamePrefix); - policies = getFilteredPoliciesForActions(policies, actions, policyType); - LOG.info("getFilteredPoliciesForActions {}", policies.stream().map(x -> x.getGuid()).collect(Collectors.toList())); + filteredPolicies = new ArrayList<>(policies); + filteredPolicies = getFilteredPoliciesForQualifiedName(filteredPolicies, policyQualifiedNamePrefix); + filteredPolicies = getFilteredPoliciesForActions(filteredPolicies, actions, policyType); + LOG.info("getFilteredPoliciesForActions {}", filteredPolicies.stream().map(x -> x.getGuid()).collect(Collectors.toList())); if (!ignoreUser) { String user = AuthorizerCommon.getCurrentUserName(); @@ -102,14 +103,16 @@ public static List getRelevantPolicies(String persona, String purp List roles = UsersStore.getRolesForUser(user, allRoles); roles.addAll(UsersStore.getNestedRolesForUser(roles, allRoles)); - policies = getFilteredPoliciesForUser(policies, user, groups, roles, policyType); - LOG.info("getFilteredPoliciesForUser {}", policies.stream().map(x -> x.getGuid()).collect(Collectors.toList())); + filteredPolicies = getFilteredPoliciesForUser(filteredPolicies, user, groups, roles, policyType); + LOG.info("getFilteredPoliciesForUser {}", filteredPolicies.stream().map(x -> x.getGuid()).collect(Collectors.toList())); } + } else { + filteredPolicies = new ArrayList<>(0); } RequestContext.get().endMetricRecord(recorder); - LOG.info("final filtered policies {}: {}", serviceName, policies.size()); - return policies; + LOG.info("final filtered policies {}: {}", serviceName, filteredPolicies.size()); + return filteredPolicies; } static List getFilteredPoliciesForQualifiedName(List policies, String qualifiedNamePrefix) {