Skip to content

Commit

Permalink
Merge pull request #3287 from atlanhq/dg-1637-staging
Browse files Browse the repository at this point in the history
Dg 1637 Empty Filter for Persona without any policy
  • Loading branch information
nikhilbonte21 authored Jun 28, 2024
2 parents 0f0bad0 + 5e0c559 commit 7dc8c7a
Showing 1 changed file with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.HashMap;
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;
Expand Down Expand Up @@ -90,7 +86,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)));
}
Expand Down Expand Up @@ -129,6 +125,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());
}
Expand All @@ -150,6 +149,10 @@ public boolean deleteAlias(String aliasName) throws AtlasBaseException {
private Map<String, Object> getFilterForPersona(AtlasEntity.AtlasEntityWithExtInfo persona, AtlasEntity policy) throws AtlasBaseException {
List<Map<String, Object>> allowClauseList = new ArrayList<>();

if (policy == null && persona == null){
return getEmptyFilter();
}

List<AtlasEntity> policies = getPolicies(persona);
if (policy != null) {
policies.add(policy);
Expand Down

0 comments on commit 7dc8c7a

Please sign in to comment.