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


##########
authorizations/authorization-jdbc/src/main/java/org/apache/gravitino/authorization/jdbc/JdbcMetadataObject.java:
##########
@@ -66,13 +66,38 @@ public void validateAuthorizationMetadataObject() throws 
IllegalArgumentExceptio
         names.size() <= 2, "The name of the object is not in the format of 
'database.table'.");
     Preconditions.checkArgument(type != null, "The type of the object is 
null.");
     Preconditions.checkArgument(
-        names.size() == 1 || type == MetadataObject.Type.SCHEMA,
+        names.size() == 1 || type.metadataObjectType() == 
MetadataObject.Type.SCHEMA,
         "The type of the object is not SCHEMA.");
     Preconditions.checkArgument(
-        names.size() == 2 || type == MetadataObject.Type.TABLE,
+        names.size() == 2 || type.metadataObjectType() == 
MetadataObject.Type.TABLE,
         "The type of the object is not TABLE.");
     for (String name : names) {
       Preconditions.checkArgument(name != null, "Cannot create a metadata 
object with null name");
     }
   }
+
+  public enum Type implements AuthorizationMetadataObject.Type {
+    SCHEMA(MetadataObject.Type.SCHEMA),
+    TABLE(MetadataObject.Type.TABLE);
+
+    private final MetadataObject.Type metadataType;
+
+    Type(MetadataObject.Type type) {
+      this.metadataType = type;
+    }
+
+    public MetadataObject.Type metadataObjectType() {
+      return metadataType;
+    }
+
+    public static Type fromMetadataType(MetadataObject.Type metadataType) {
+      for (Type type : Type.values()) {
+        if (type.metadataObjectType() == metadataType) {
+          return type;
+        }
+      }
+      throw new IllegalArgumentException(
+          "No matching RangerMetadataObject.Type for " + metadataType);

Review Comment:
   Please update the exception message.



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