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


##########
core/src/main/java/org/apache/gravitino/authorization/UserGroupManager.java:
##########
@@ -197,4 +198,30 @@ Group getGroup(String metalake, String group) {
       throw new RuntimeException(ioe);
     }
   }
+
+  Group[] listGroups(String metalake) {
+    return listGroupInternal(metalake, true);
+  }
+
+  private Group[] listGroupInternal(String metalake, boolean allFields) {
+    try {
+      AuthorizationUtils.checkMetalakeExists(metalake);
+      Namespace namespace = AuthorizationUtils.ofGroupNamespace(metalake);
+      return store
+          .list(namespace, GroupEntity.class, EntityType.GROUP, allFields)
+          .toArray(new Group[0]);
+    } catch (NoSuchEntityException e) {
+      LOG.error("Metalake {} does not exist", metalake, e);
+      throw new NoSuchMetalakeException(METALAKE_DOES_NOT_EXIST_MSG, metalake);
+    } catch (IOException ioe) {
+      LOG.error("Listing group under metalake {} failed due to storage 
issues", metalake, ioe);
+      throw new RuntimeException(ioe);
+    }
+  }
+
+  String[] listGroupNames(String metalake) {
+    return Arrays.stream(listGroupInternal(metalake, false))
+        .map(Group::name)
+        .toArray(String[]::new);
+  }

Review Comment:
   Can you please move this method above, after `listGroups`.



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