jerqi commented on code in PR #6821:
URL: https://github.com/apache/gravitino/pull/6821#discussion_r2033163201


##########
authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationHDFSPlugin.java:
##########
@@ -740,4 +776,39 @@ protected Map<String, String> 
getServiceConfigs(Map<String, String> config) {
                 RangerAuthorizationProperties.FS_DEFAULT_VALUE))
         .build();
   }
+
+  private interface PathExtractor {
+    String getPath(Entity.EntityType type, String location);
+  }
+
+  private static class TableOrFilesetPathExtractor implements PathExtractor {
+    @Override
+    public String getPath(Entity.EntityType type, String location) {
+      if (type == Entity.EntityType.CATALOG) {
+        return String.format("%s/*/*/", location);
+      } else if (type == Entity.EntityType.SCHEMA) {
+        return String.format("%s/*/", location);
+      }
+      if (type == Entity.EntityType.TABLE || type == 
Entity.EntityType.FILESET) {
+        return location;
+      } else {
+        throw new AuthorizationPluginException(
+            "Don't support %s to get table or fileset location", type);
+      }
+    }
+  }
+
+  private static class SchemaPathExtractor implements PathExtractor {
+    @Override
+    public String getPath(Entity.EntityType type, String location) {
+      if (type == Entity.EntityType.CATALOG) {
+        return String.format("%s/*/", location);
+      } else if (type == Entity.EntityType.SCHEMA) {
+        return location;
+      } else {
+        throw new AuthorizationPluginException(
+            "Don't support %s to get table or fileset location", type);

Review Comment:
   Done.



-- 
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: commits-unsubscr...@gravitino.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to