xunliu commented on code in PR #4323:
URL: https://github.com/apache/gravitino/pull/4323#discussion_r1701274312
##########
core/src/main/java/org/apache/gravitino/authorization/AuthorizationUtils.java:
##########
@@ -131,58 +132,127 @@ public static <T> void prepareAuthorizationHooks(T
manager, DispatcherHooks hook
hooks.addPostHook(
"createMetalake",
Review Comment:
hi @jerqi I think using function name string comparing is too error-prone.
We can create a `SetOwner` annotation to supports, for example:
```
public class MetalakeManager implements MetalakeDispatcher {
@Override
@SetOwner
public BaseMetalake createMetalake(
NameIdentifier ident, String comment, Map<String, String> properties)
throws MetalakeAlreadyExistsException {
long uid = idGenerator.nextId();
......
```
Use `SetOwner` annotation to comparing
```
if (method.isAnnotationPresent(SetOwner.class)) {
NameIdentifier identifier = (NameIdentifier) ((Object[]) args)[0];
GravitinoEnv.getInstance()
.ownershipManager()
.setOwner(
identifier,
Entity.EntityType.METALAKE,
PrincipalUtils.getCurrentUserName(),
Owner.Type.USER);
}
```
--
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]