Skip to content

Commit

Permalink
Add Tag/Classification Roles
Browse files Browse the repository at this point in the history
  • Loading branch information
harshach committed Oct 19, 2024
1 parent fff3eea commit d15558b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Objects;
import java.util.UUID;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.jdbi.v3.sqlobject.transaction.Transaction;
Expand Down Expand Up @@ -99,6 +100,7 @@ public void storeRelationships(Classification entity) {
assignRoles(entity, entity.getRoles());
}


private int getTermCount(Classification classification) {
ListFilter filter =
new ListFilter(Include.NON_DELETED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2322,6 +2322,7 @@ protected void validateTags(T entity) {
entity.setTags(addDerivedTags(entity.getTags()));
checkMutuallyExclusive(entity.getTags());
checkDisabledTags(entity.getTags());
checkTagsPermissions(entity.getTags(), entity.getUpdatedBy());
}

protected void validateTags(List<TagLabel> labels) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void setInheritedFields(Tag tag, Fields fields) {
if (parent.getDisabled() != null && parent.getDisabled()) {
tag.setDisabled(true);
}
tag.setInheritedRoles(classification.getRoles());
tag.setInheritedRoles(parent.getRoles());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@
import org.openmetadata.schema.entity.classification.Tag;
import org.openmetadata.schema.entity.data.Glossary;
import org.openmetadata.schema.entity.data.GlossaryTerm;
import org.openmetadata.schema.type.EntityReference;
import org.openmetadata.schema.type.TagLabel;
import org.openmetadata.schema.type.TagLabel.TagSource;
import org.openmetadata.service.Entity;
import org.openmetadata.service.exception.CatalogExceptionMessage;
import org.openmetadata.service.security.AuthorizationException;
import org.openmetadata.service.security.policyevaluator.SubjectContext;
import org.openmetadata.service.util.EntityUtil;
import org.openmetadata.service.util.FullyQualifiedName;

Expand Down Expand Up @@ -155,6 +158,20 @@ public static void checkDisabledTags(List<TagLabel> tagLabels) {
}
}

public static void checkTagsPermissions(List<TagLabel> tagLabels, String user) {
if (tagLabels == null || tagLabels.isEmpty()) {
return;
}
List<TagLabel> classificationTags = tagLabels.stream()
.filter(tagLabel -> tagLabel.getSource() != TagSource.GLOSSARY)
.toList();
if (classificationTags.isEmpty()) {
return; // No classification tags to check
}
SubjectContext subjectContext = SubjectContext.getSubjectContext(user);

}

public static void checkMutuallyExclusiveForParentAndSubField(
String assetFqn,
String assetFqnHash,
Expand Down

0 comments on commit d15558b

Please sign in to comment.