Skip to content

Commit

Permalink
Merge branch 'dg-1854-fix-tag-fetch' into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
sumandas0 committed Oct 7, 2024
2 parents 6b75c86 + 54b17b6 commit 9b4568b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.apache.atlas.type.AtlasEntityType;
import org.apache.atlas.type.AtlasStructType.AtlasAttribute;
import org.apache.atlas.type.AtlasTypeRegistry;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -33,6 +34,8 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.ArrayList;
import java.util.LinkedHashSet;

public class AtlasAccessRequest {
private static Logger LOG = LoggerFactory.getLogger(AtlasAccessRequest.class);
Expand Down Expand Up @@ -176,7 +179,7 @@ public String getEntityId(AtlasEntityHeader entity, AtlasTypeRegistry typeRegist
return ret == null ? "" : ret.toString();
}

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

if (entity == null || entity.getClassifications() == null) {
Expand All @@ -188,7 +191,19 @@ public Set<AtlasClassification> getClassificationNames(AtlasEntityHeader entity)
ret.add(classification);
}
}
return ret;
}

public Set<AtlasClassification> getClassificationNames(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));
}
return ret;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public AtlasEntityAccessRequest(AtlasTypeRegistry typeRegistry, AtlasPrivilege a
this.businessMetadata = businessMetadata;
this.attributeName = attributeName;
this.typeRegistry = typeRegistry;
this.entityClassifications = super.getClassificationNames(entity);
this.entityClassifications = super.getClassifications(entity);
this.auditEnabled = auditEnabled;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,10 @@ public void authorizeRemoveRelation(AtlasEdge edge) throws AtlasBaseException {
if (relationshipDef == null) {
return;
}
RequestContext.get().setIncludeClassificationNames(true);

end1Entity = entityRetriever.toAtlasEntityHeaderWithClassifications(edge.getOutVertex());
end2Entity = entityRetriever.toAtlasEntityHeaderWithClassifications(edge.getInVertex());
end1Entity = entityRetriever.toAtlasEntityHeader(edge.getOutVertex());
end2Entity = entityRetriever.toAtlasEntityHeader(edge.getInVertex());

AtlasAuthorizationUtils.verifyAccess(new AtlasRelationshipAccessRequest(typeRegistry, AtlasPrivilege.RELATIONSHIP_REMOVE, relationShipType, end1Entity, end2Entity ));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3191,9 +3191,13 @@ public void cleanUpClassificationPropagation(String classificationName, int batc
}
}

AtlasEntity entity = repairClassificationMappings(vertex);
try {
AtlasEntity entity = repairClassificationMappings(vertex);
entityChangeNotifier.onClassificationDeletedFromEntity(entity, deletedClassifications);
} catch (IllegalStateException | AtlasBaseException e) {
e.printStackTrace();
}

entityChangeNotifier.onClassificationDeletedFromEntity(entity, deletedClassifications);
}

transactionInterceptHelper.intercept();
Expand Down

0 comments on commit 9b4568b

Please sign in to comment.