FANNG1 commented on code in PR #6714: URL: https://github.com/apache/gravitino/pull/6714#discussion_r2009319045
########## core/src/main/java/org/apache/gravitino/listener/api/event/AddUserPreEvent.java: ########## @@ -0,0 +1,61 @@ +/* + * 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 org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; + +/** Represents an event triggered before add a user to a metalake. */ +@DeveloperApi +public class AddUserPreEvent extends UserPreEvent { + private final String addUserName; + + /** + * Construct a new {@link AddUserPreEvent} instance. + * + * @param user the user who initiated the add-user request. + * @param identifier the identifier of the metalake which the user is being added to. + * @param addUserName the username which is requested to be added to the metalake. + */ + public AddUserPreEvent(String user, NameIdentifier identifier, String addUserName) { + super(user, identifier); + + this.addUserName = addUserName; + } + + /** + * Returns the user information which is being added to the metalake. + * + * @return the username which is requested to be added to the metalake. + */ + public String addUserRequest() { Review Comment: The method name seems not correct? ########## core/src/main/java/org/apache/gravitino/listener/api/event/GetUserPreEvent.java: ########## @@ -0,0 +1,61 @@ +/* + * 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 org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; + +/** Represents an event triggered before get a user from specific metalake */ +@DeveloperApi +public class GetUserPreEvent extends UserPreEvent { + private final String getUserName; + + /** + * Construct a new {@link GetUserPreEvent} instance with the specified user, identifier and user + * info. + * + * @param user the user who initiated the add-user request. + * @param identifier the identifier of the metalake which the user is being added to. + * @param getUserName the username which is requested to be retrieved. + */ + public GetUserPreEvent(String user, NameIdentifier identifier, String getUserName) { + super(user, identifier); + this.getUserName = getUserName; + } + + /** + * Returns the user info for the user which is getting retrieved. + * + * @return the username which is requested to be retrieved. + */ + public String getUserRequest() { Review Comment: typo ########## core/src/main/java/org/apache/gravitino/listener/api/event/AddUserPreEvent.java: ########## @@ -0,0 +1,61 @@ +/* + * 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 org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; + +/** Represents an event triggered before add a user to a metalake. */ +@DeveloperApi +public class AddUserPreEvent extends UserPreEvent { + private final String addUserName; + + /** + * Construct a new {@link AddUserPreEvent} instance. + * + * @param user the user who initiated the add-user request. + * @param identifier the identifier of the metalake which the user is being added to. + * @param addUserName the username which is requested to be added to the metalake. + */ + public AddUserPreEvent(String user, NameIdentifier identifier, String addUserName) { Review Comment: How about using `initiator` `userName` or something better to distinguish different users? ########## core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java: ########## @@ -112,5 +112,16 @@ public enum OperationType { LIST_MODEL_VERSIONS, REGISTER_AND_LINK_MODEL_VERSION, + // User + ADD_USER, + REMOVE_USER, + GET_USER, + LIST_USER, Review Comment: LIST_USER -> LIST_USERS ? ########## core/src/main/java/org/apache/gravitino/listener/api/info/UserInfo.java: ########## @@ -0,0 +1,80 @@ +/* + * 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 java.util.Optional; +import org.apache.gravitino.authorization.User; + +/** Provides read-only access to user information for event listeners. */ +public class UserInfo { Review Comment: The `UserInfo` is not used any more? ########## core/src/main/java/org/apache/gravitino/listener/api/event/RemoveUserPreEvent.java: ########## @@ -0,0 +1,61 @@ +/* + * 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 org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; + +/** Represents an event triggered before remove a user from specific metalake. */ +@DeveloperApi +public class RemoveUserPreEvent extends UserPreEvent { + private final String removedUserName; + + /** + * Construct a new {@link RemoveUserPreEvent} instance with the specified user and identifier. + * + * @param user the user who initiated the remove user operation. + * @param identifier the identifier of the metalake where the user is removed. + * @param removedUserName the username which is requested to be removed from the metalake. + */ + protected RemoveUserPreEvent(String user, NameIdentifier identifier, String removedUserName) { + super(user, identifier); + + this.removedUserName = removedUserName; + } + + /** + * Returns the user information of the user which is to be removed from the metalake. + * + * @return the username which is requested to be removed from the metalake. + */ + public String removeUserRequest() { Review Comment: typo -- 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]
