xunliu commented on code in PR #4623:
URL: https://github.com/apache/gravitino/pull/4623#discussion_r1726527742


##########
core/src/main/java/org/apache/gravitino/authorization/AuthorizationUtils.java:
##########
@@ -150,29 +150,46 @@ public static void callAuthorizationPlugin(
       if (needApplyAllAuthorizationPlugin(securableObject)) {
         Catalog[] catalogs = 
catalogManager.listCatalogsInfo(Namespace.of(metalake));
         for (Catalog catalog : catalogs) {
-          callAuthorizationPluginImpl(catalogsAlreadySet, consumer, catalog);
+          callAuthorizationPluginImpl(consumer, catalog);
         }
 
       } else if (supportsSingleAuthorizationPlugin(securableObject.type())) {
         NameIdentifier catalogIdent =
             NameIdentifierUtil.getCatalogIdentifier(
                 MetadataObjectUtil.toEntityIdent(metalake, securableObject));
         Catalog catalog = catalogManager.loadCatalog(catalogIdent);
-        callAuthorizationPluginImpl(catalogsAlreadySet, consumer, catalog);
+        if (!catalogsAlreadySet.contains(catalog.name())) {
+          catalogsAlreadySet.add(catalog.name());
+          callAuthorizationPluginImpl(consumer, catalog);
+        }
+      }
+    }
+  }
+
+  public static void callAuthorizationPluginForMetadataObject(
+      String metalake, MetadataObject metadataObject, 
Consumer<AuthorizationPlugin> consumer) {
+    CatalogManager catalogManager = 
GravitinoEnv.getInstance().catalogManager();
+    if (needApplyAuthorizationPluginSetOwner(metadataObject.type())) {

Review Comment:
   I think we can directly judge `if (metadataObject.type() == 
MetadataObject.Type.METALAKE)` would be clear.



##########
core/src/main/java/org/apache/gravitino/authorization/AuthorizationUtils.java:
##########
@@ -190,6 +207,10 @@ public static boolean 
needApplyAllAuthorizationPlugin(SecurableObject securableO
     return false;
   }
 
+  private static boolean 
needApplyAuthorizationPluginSetOwner(MetadataObject.Type type) {
+    return type == MetadataObject.Type.METALAKE;
+  }
+
   private static boolean supportsSingleAuthorizationPlugin(MetadataObject.Type 
type) {

Review Comment:
   What does `Single` mean in the `supportsSingleAuthorizationPlugin()` 
function?
   Can we have a better name?



-- 
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