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


##########
core/src/main/java/org/apache/gravitino/authorization/AuthorizationUtils.java:
##########
@@ -66,6 +69,34 @@ public class AuthorizationUtils {
   static final String USER_DOES_NOT_EXIST_MSG = "User %s does not exist in the 
metalake %s";
   static final String GROUP_DOES_NOT_EXIST_MSG = "Group %s does not exist in 
the metalake %s";
   static final String ROLE_DOES_NOT_EXIST_MSG = "Role %s does not exist in the 
metalake %s";
+
+  /**
+   * Map of deprecated privilege names to their new equivalents. This map is 
used for backward
+   * compatibility when handling legacy privilege names.
+   *
+   * <p>When adding new deprecated privileges, simply add an entry to this map 
rather than adding
+   * more if-else conditions in the conversion methods.
+   */
+  @SuppressWarnings("deprecation")
+  private static final Map<Privilege.Name, Privilege.Name> 
DEPRECATED_PRIVILEGE_MAP =
+      ImmutableMap.of(
+          Privilege.Name.CREATE_MODEL, Privilege.Name.REGISTER_MODEL,
+          Privilege.Name.CREATE_MODEL_VERSION, 
Privilege.Name.LINK_MODEL_VERSION);
+
+  /**
+   * Reverse map from new privilege names to their deprecated equivalents. 
This is automatically
+   * built from DEPRECATED_PRIVILEGE_MAP.
+   */
+  private static final Map<Privilege.Name, Privilege.Name> 
NEW_TO_DEPRECATED_PRIVILEGE_MAP;
+
+  static {
+    Map<Privilege.Name, Privilege.Name> reverseMap = Maps.newHashMap();
+    for (Map.Entry<Privilege.Name, Privilege.Name> entry : 
DEPRECATED_PRIVILEGE_MAP.entrySet()) {
+      reverseMap.put(entry.getValue(), entry.getKey());
+    }
+    NEW_TO_DEPRECATED_PRIVILEGE_MAP = ImmutableMap.copyOf(reverseMap);
+  }
+

Review Comment:
   Addressed the comments. Thanks.



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