FANNG1 commented on code in PR #6746: URL: https://github.com/apache/gravitino/pull/6746#discussion_r2020339325
########## core/src/main/java/org/apache/gravitino/listener/api/event/GrantUserRolesPreEvent.java: ########## @@ -0,0 +1,74 @@ +/* + * 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.listener.api.event; + +import java.util.List; +import org.apache.gravitino.utils.NameIdentifierUtil; + +/** Represents an event triggered before granting roles to a user. */ +public class GrantUserRolesPreEvent extends UserPreEvent { Review Comment: Could you add `@DeveloperAPI` for the new added event? ########## core/src/main/java/org/apache/gravitino/listener/api/info/UserInfo.java: ########## @@ -0,0 +1,57 @@ +/* + * 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.listener.api.info; + +import java.util.List; +import org.apache.gravitino.authorization.User; + +/** Provides read-only access to user information for event listeners. */ +public class UserInfo { Review Comment: Could you add `@DeveloperAPI` for `UserInfo`, and noticed `ModelVersionInfo` missing `@DeveloperAPI` too, could you add it? ########## core/src/main/java/org/apache/gravitino/listener/api/event/RevokeUserRolesEvent.java: ########## @@ -0,0 +1,75 @@ +/* + * 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.listener.api.event; + +import java.util.List; +import org.apache.gravitino.listener.api.info.UserInfo; +import org.apache.gravitino.utils.NameIdentifierUtil; + +/** Represents an event triggered after the operation of revoking roles from a user. */ +public class RevokeUserRolesEvent extends UserEvent { + private final UserInfo revokedUserInfo; + private final List<String> roles; + + /** + * Constructs a new {@link RevokeUserRolesEvent} instance with the specified initiator, metalake + * name, user information, and revoked roles. + * + * @param initiator the user who initiated the role-revocation operation. + * @param metalake the name of the metalake that the operation affects. + * @param revokedUserInfo the user information of the user whose roles are being revoked. + * @param roles the list of roles that have been revoked from the user. + */ + public RevokeUserRolesEvent( + String initiator, String metalake, UserInfo revokedUserInfo, List<String> roles) { + super(initiator, NameIdentifierUtil.ofUser(metalake, revokedUserInfo.name())); + + this.revokedUserInfo = revokedUserInfo; + this.roles = roles; Review Comment: Could you clone roles here? ########## core/src/main/java/org/apache/gravitino/listener/api/event/GrantUserRolesEvent.java: ########## @@ -0,0 +1,75 @@ +/* + * 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.listener.api.event; + +import java.util.List; +import org.apache.gravitino.listener.api.info.UserInfo; +import org.apache.gravitino.utils.NameIdentifierUtil; + +/** Represents an event triggered after the operation of granting roles to a user. */ +public class GrantUserRolesEvent extends UserEvent { + private final UserInfo grantUserInfo; + private final List<String> roles; + + /** + * Constructs a new {@link GrantUserRolesEvent} instance with the specified initiator, metalake + * name, user information, and roles granted. + * + * @param initiator the user who initiated the role-granting operation. + * @param metalake the name of the metalake that the operation affects. + * @param grantUserInfo the user information of the user whose roles are being granted. + * @param roles the list of roles that are granted to the user. + */ + public GrantUserRolesEvent( + String initiator, String metalake, UserInfo grantUserInfo, List<String> roles) { + super(initiator, NameIdentifierUtil.ofUser(metalake, grantUserInfo.name())); + + this.grantUserInfo = grantUserInfo; + this.roles = roles; Review Comment: Could you clone roles here? -- 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: commits-unsubscr...@gravitino.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org