jerryshao commented on code in PR #14326:
URL: https://github.com/apache/gravitino/pull/14326#discussion_r4510727816


##########
server/src/main/java/org/apache/gravitino/server/web/rest/MetadataObjectTagOperations.java:
##########
@@ -192,6 +194,7 @@ public Response listTagsForMetadataObject(
             Tag[] nonInheritedTags = 
tagDispatcher.listTagsInfoForMetadataObject(metalake, object);

Review Comment:
   Could we also apply `TagOperations.checkVisibleTag(metalake, object)` when 
the path object itself is a tag? Both `GET /objects/tag/{name}/tags` and `GET 
/objects/tag/{name}/policies` pass that object to the dispatcher. For a caller 
who passes authorization, an existing unassigned hidden tag can produce an 
empty list, while a missing tag produces not-found. Please cover both endpoints 
with a test that expects the same not-found response for an existing hidden tag 
and a missing one.



##########
core/src/main/java/org/apache/gravitino/policy/PolicyManager.java:
##########
@@ -73,6 +78,54 @@ public PolicyManager(IdGenerator idGenerator, EntityStore 
entityStore) {
     this.objectPolicyResolver = new ObjectPolicyResolver(entityStore);
   }
 
+  /**
+   * Applies a policy to an object through its hidden tag using the entity 
store.
+   *
+   * <p>The hidden tag is created with the policy. This method loads that tag 
and submits an
+   * idempotent object assignment. The relation operation validates the object 
endpoint and owns the
+   * transaction.
+   *
+   * <p>This internal method is not exposed through the policy dispatcher or 
client APIs.
+   *
+   * @param metalake The policy and object's metalake.
+   * @param policyName The policy name.
+   * @param object The metadata object to associate.
+   * @param auditInfo The audit information to preserve on newly created 
relations.
+   * @return The policy's hidden tag ID.
+   * @throws IOException If an entity or relation cannot be persisted.
+   * @throws NoSuchEntityException If the policy, hidden tag or target object 
does not exist.
+   * @throws IllegalArgumentException If the object type does not support tag 
assignments.
+   */
+  public long addPolicyToObject(
+      String metalake, String policyName, MetadataObject object, Audit 
auditInfo)
+      throws IOException {
+    Preconditions.checkNotNull(auditInfo, "Policy binding audit information is 
required");

Review Comment:
   Please use `checkArgument(auditInfo != null, ...)` here and in 
`RelationUpdate.withAuditInfo`, consistent with the other argument checks in 
`RelationUpdate.of`. Please update the null-audit test to expect 
`IllegalArgumentException` as well.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to