Skip to content

Commit

Permalink
mesh-192: resolved PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
PRATHAM2002-DS committed Sep 9, 2024
1 parent 28c30d9 commit 182986e
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public class EntityGraphMapper {
private static final String TYPE_CATEGORY= "AtlasGlossaryCategory";
private static final String TYPE_TERM = "AtlasGlossaryTerm";
private static final String TYPE_PRODUCT = "DataProduct";
private static final String TYPE_DOMAIN = "DataDomain";
private static final String TYPE_PROCESS = "Process";
private static final String ATTR_MEANINGS = "meanings";
private static final String ATTR_ANCHOR = "anchor";
Expand Down Expand Up @@ -196,6 +197,9 @@ public class EntityGraphMapper {
private final IFullTextMapper fullTextMapperV2;
private final TaskManagement taskManagement;
private final TransactionInterceptHelper transactionInterceptHelper;
private final EntityGraphRetriever retrieverNoRelation;

private static final Set<String> excludedTypes = new HashSet<>(Arrays.asList(TYPE_GLOSSARY, TYPE_CATEGORY, TYPE_TERM, TYPE_PRODUCT, TYPE_DOMAIN));

@Inject
public EntityGraphMapper(DeleteHandlerDelegate deleteDelegate, RestoreHandlerV1 restoreHandlerV1, AtlasTypeRegistry typeRegistry, AtlasGraph graph,
Expand All @@ -211,6 +215,7 @@ public EntityGraphMapper(DeleteHandlerDelegate deleteDelegate, RestoreHandlerV1
this.entityChangeNotifier = entityChangeNotifier;
this.instanceConverter = instanceConverter;
this.entityRetriever = new EntityGraphRetriever(graph, typeRegistry);
this.retrieverNoRelation = new EntityGraphRetriever(graph, typeRegistry, true);
this.fullTextMapperV2 = fullTextMapperV2;
this.taskManagement = taskManagement;
this.transactionInterceptHelper = transactionInterceptHelper;}
Expand Down Expand Up @@ -4644,14 +4649,14 @@ public List<AtlasVertex> unlinkBusinessPolicy(String policyId, Set<String> unlin

public List<AtlasVertex> linkMeshEntityToAssets(String meshEntityId, Set<String> linkGuids) throws AtlasBaseException {
List<AtlasVertex> linkedVertices = new ArrayList<>();
Set<String> excludedTypes = new HashSet<>(Arrays.asList(TYPE_GLOSSARY, TYPE_CATEGORY, TYPE_TERM, TYPE_PRODUCT));

for (String guid : linkGuids) {
AtlasVertex ev = findByGuid(graph, guid);

if (ev != null) {
String typeName = ev.getProperty(TYPE_NAME_PROPERTY_KEY, String.class);
if (excludedTypes.contains(typeName)){
LOG.warn("Type {} is not allowed to link with mesh entity", typeName);
continue;
}
Set<String> existingValues = ev.getMultiValuedSetProperty(DOMAIN_GUIDS_ATTR, String.class);
Expand All @@ -4677,15 +4682,14 @@ public List<AtlasVertex> linkMeshEntityToAssets(String meshEntityId, Set<String>

public List<AtlasVertex> unlinkMeshEntityFromAssets(String meshEntityId, Set<String> unlinkGuids) throws AtlasBaseException {
List<AtlasVertex> unlinkedVertices = new ArrayList<>();
Set<String> excludedTypes = new HashSet<>(Arrays.asList(TYPE_GLOSSARY, TYPE_CATEGORY, TYPE_TERM, TYPE_PRODUCT));

for (String guid : unlinkGuids) {
AtlasVertex ev = AtlasGraphUtilsV2.findByGuid(graph, guid);

if (ev != null) {
String typeName = ev.getProperty(TYPE_NAME_PROPERTY_KEY, String.class);
if (excludedTypes.contains(typeName)){
LOG.debug("Type {} is not allowed to link with mesh entity", typeName);
LOG.warn("Type {} is not allowed to unlink with mesh entity", typeName);
continue;
}

Expand Down Expand Up @@ -4744,7 +4748,7 @@ private void setEntityCommonAttributes(AtlasVertex ev, AtlasEntity diffEntity) {
}

private void isAuthorizedToLink(AtlasVertex vertex) throws AtlasBaseException {
AtlasEntityHeader sourceEntity = entityRetriever.toAtlasEntityHeader(vertex);
AtlasEntityHeader sourceEntity = retrieverNoRelation.toAtlasEntityHeader(vertex);

// source -> UPDATE + READ
AtlasAuthorizationUtils.verifyAccess(new AtlasEntityAccessRequest(typeRegistry, AtlasPrivilege.ENTITY_UPDATE, sourceEntity),
Expand Down

0 comments on commit 182986e

Please sign in to comment.