Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dg 1854 fix tag fetch #3604

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.Set;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.stream.Collectors;

public class AtlasAccessRequest {
private static Logger LOG = LoggerFactory.getLogger(AtlasAccessRequest.class);
Expand Down Expand Up @@ -180,31 +181,19 @@ public String getEntityId(AtlasEntityHeader entity, AtlasTypeRegistry typeRegist
}

public Set<AtlasClassification> getClassifications(AtlasEntityHeader entity) {
final Set<AtlasClassification> ret;

if (entity == null || entity.getClassifications() == null) {
ret = Collections.emptySet();
} else {
ret = new HashSet<>();

for (AtlasClassification classification : entity.getClassifications()) {
ret.add(classification);
}
if (CollectionUtils.isNotEmpty(entity.getClassifications())) {
return new HashSet<>(entity.getClassifications());
}
return ret;
}

public Set<AtlasClassification> getClassificationsFromNames(AtlasEntityHeader entity) {
final Set<AtlasClassification> ret = new HashSet<>();
List<String> classificationNames = entity.getClassificationNames();
if(CollectionUtils.isEmpty(classificationNames))
return ret;

classificationNames = new ArrayList<>(new LinkedHashSet<>(classificationNames));
for (String classificationName : classificationNames) {
ret.add(new AtlasClassification(classificationName));
if (CollectionUtils.isEmpty(classificationNames)) {
return new HashSet<>();
}
return ret;
// Create new classification objects with name using stream filter
return classificationNames.stream()
.distinct()
.map(AtlasClassification::new)
.collect(Collectors.toSet());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public Set<String> getEnd1EntityTypeAndAllSuperTypes() {
}

public Set<AtlasClassification> getEnd1EntityClassifications() {
return super.getClassificationsFromNames(end1Entity);
return super.getClassifications(end1Entity);
}

public String getEnd1EntityId() {
Expand All @@ -74,7 +74,7 @@ public Set<String> getEnd2EntityTypeAndAllSuperTypes() {
}

public Set<AtlasClassification> getEnd2EntityClassifications() {
return super.getClassificationsFromNames(end2Entity);
return super.getClassifications(end2Entity);
}

public String getEnd2EntityId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ private AtlasEdge createRelationship(AtlasVertex end1Vertex, AtlasVertex end2Ver
AtlasRelationshipType relationType = typeRegistry.getRelationshipTypeByName(relationship.getTypeName());


AtlasEntityHeader end1Entity = entityRetriever.toAtlasEntityHeaderWithClassifications(end1Vertex);
AtlasEntityHeader end2Entity = entityRetriever.toAtlasEntityHeaderWithClassifications(end2Vertex);
AtlasEntityHeader end1Entity = entityRetriever.toAtlasEntityHeader(end1Vertex);
AtlasEntityHeader end2Entity = entityRetriever.toAtlasEntityHeader(end2Vertex);

AtlasAuthorizationUtils.verifyAccess(new AtlasRelationshipAccessRequest(typeRegistry, AtlasPrivilege.RELATIONSHIP_ADD,
relationship.getTypeName(), end1Entity, end2Entity));
Expand Down Expand Up @@ -532,8 +532,8 @@ private AtlasRelationship updateRelationship(AtlasEdge relationshipEdge, AtlasRe
AtlasRelationshipType relationType = typeRegistry.getRelationshipTypeByName(relationship.getTypeName());
AtlasVertex end1Vertex = relationshipEdge.getOutVertex();
AtlasVertex end2Vertex = relationshipEdge.getInVertex();
AtlasEntityHeader end1Entity = entityRetriever.toAtlasEntityHeaderWithClassifications(end1Vertex);
AtlasEntityHeader end2Entity = entityRetriever.toAtlasEntityHeaderWithClassifications(end2Vertex);
AtlasEntityHeader end1Entity = entityRetriever.toAtlasEntityHeader(end1Vertex);
AtlasEntityHeader end2Entity = entityRetriever.toAtlasEntityHeader(end2Vertex);

AtlasAuthorizationUtils.verifyAccess(new AtlasRelationshipAccessRequest(typeRegistry, AtlasPrivilege.RELATIONSHIP_UPDATE, relationship.getTypeName(), end1Entity, end2Entity));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
Expand Down
Loading