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


##########
core/src/main/java/org/apache/gravitino/storage/relational/service/UserMetaService.java:
##########
@@ -221,6 +222,22 @@ public <E extends Entity & HasIdentifier> UserEntity 
updateUser(
     return newEntity;
   }
 
+  public List<UserEntity> listUsersByNamespace(Namespace namespace) {
+    AuthorizationUtils.checkUserNamespace(namespace);
+
+    List<UserEntity> userEntities = Lists.newArrayList();
+    String metalakeName = namespace.level(0);
+    List<UserPO> userPOs =
+        SessionUtils.getWithoutCommit(
+            UserMetaMapper.class, mapper -> 
mapper.listUserPOsByMetalake(metalakeName));
+
+    for (UserPO userPO : userPOs) {
+      List<RolePO> rolePOs = 
RoleMetaService.getInstance().listRolesByUserId(userPO.getUserId());
+      userEntities.add(POConverters.fromUserPO(userPO, rolePOs, namespace));
+    }

Review Comment:
   Now, we adopts the lazily loading information about users/roles.



##########
common/src/main/java/org/apache/gravitino/dto/responses/UserListResponse.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.dto.responses;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
+import org.apache.gravitino.dto.authorization.UserDTO;
+
+/** Represents a response containing a list of users. */
+@Getter
+@ToString
+@EqualsAndHashCode(callSuper = true)
+public class UserListResponse extends BaseResponse {
+
+  @JsonProperty("users")
+  private final UserDTO[] users;
+
+  /**
+   * Constructor for UserListResponse.
+   *
+   * @param users The array of users.
+   */
+  public UserListResponse(UserDTO[] users) {
+    super(0);
+    this.users = users;
+  }
+
+  /**
+   * This is the constructor that is used by Jackson deserializer to create an 
instance of
+   * UserListResponse.
+   */
+  public UserListResponse() {
+    super(0);
+    this.users = null;
+  }
+}

Review Comment:
   Added.



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