jerqi commented on code in PR #4055:
URL: https://github.com/apache/gravitino/pull/4055#discussion_r1665408598
##########
core/src/main/java/com/datastrato/gravitino/storage/relational/service/UserMetaService.java:
##########
@@ -221,6 +224,39 @@ 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 = Lists.newArrayList();
+ AtomicLong metalakeId = new AtomicLong();
+ SessionUtils.doMultipleWithoutCommit(
+ () -> {
+ Long id =
+ SessionUtils.doWithoutCommitAndFetchResult(
+ MetalakeMetaMapper.class,
+ mapper -> mapper.selectMetalakeIdMetaByName(metalakeName));
+ if (id == null) {
+ throw new NoSuchEntityException(
+ NoSuchEntityException.NO_SUCH_ENTITY_MESSAGE,
+ Entity.EntityType.METALAKE.name().toLowerCase(),
+ metalakeName);
+ }
+ metalakeId.set(id);
+ },
+ () ->
+ userPOs.addAll(
+ SessionUtils.doWithoutCommitAndFetchResult(
+ UserMetaMapper.class,
+ mapper ->
mapper.listUserPOsByMetalakeId(metalakeId.get()))));
+ for (UserPO userPO : userPOs) {
+ List<RolePO> rolePOs =
RoleMetaService.getInstance().listRolesByUserId(userPO.getUserId());
+ userEntities.add(POConverters.fromUserPO(userPO, rolePOs, namespace));
+ }
Review Comment:
cc @yuqi1129 Maybe we can have a common cache layer for this.
--
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]