FANNG1 commented on code in PR #5998:
URL: https://github.com/apache/gravitino/pull/5998#discussion_r1948293402


##########
core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagEvent.java:
##########
@@ -0,0 +1,79 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.info.TagInfo;
+import org.apache.gravitino.tag.TagChange;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents an event triggered upon the successful alteration of a tag. */
+@DeveloperApi
+public final class AlterTagEvent extends TagEvent {
+  private final TagInfo updatedTagInfo;
+  private final TagChange[] tagChanges;
+
+  /**
+   * Constructs an instance of {@code AlterTagEvent}, encapsulating the key 
details about the
+   * successful alteration of a tag.
+   *
+   * @param user The username of the individual responsible for initiating the 
tag alteration.
+   * @param metalake The metalake from which the tag is being altered.
+   * @param tagChanges An array of {@link TagChange} objects representing the 
specific changes
+   *     applied to the tag during the alteration process.
+   * @param updatedTagInfo The post-alteration state of the tag.
+   */
+  public AlterTagEvent(
+      String user, String metalake, TagChange[] tagChanges, TagInfo 
updatedTagInfo) {
+    super(user, NameIdentifierUtil.ofTag(metalake, updatedTagInfo.name()));
+    this.tagChanges = tagChanges != null ? tagChanges.clone() : new 
TagChange[0];

Review Comment:
   keep tagChanges as null, we could add `@Nullable` anotation to `tagChanges` 
method.



##########
core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectEvent.java:
##########
@@ -0,0 +1,60 @@
+/*
+ * 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.MetadataObject;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.info.TagInfo;
+import org.apache.gravitino.utils.MetadataObjectUtil;
+
+/**
+ * Represents an event that is triggered upon successfully retrieving a tag 
for a metadata object.
+ */
+@DeveloperApi
+public final class GetTagForMetadataObjectEvent extends TagEvent {
+
+  /**
+   * Constructs an instance of {@code GetTagForMetadataObjectEvent}.
+   *
+   * @param user The username of the individual who initiated the tag 
retrieval.
+   * @param metalake The metalake from which the tag was retrieved.
+   * @param metadataObject The metadata object for which the tag was retrieved.
+   * @param tagName The name of the tag being retrieved.
+   * @param tagInfo The {@link TagInfo} object representing the retrieved tag.
+   */
+  public GetTagForMetadataObjectEvent(
+      String user,
+      String metalake,
+      MetadataObject metadataObject,
+      String tagName,
+      TagInfo tagInfo) {
+    super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject));
+  }

Review Comment:
   add an method to get tagInfo?



##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsEvent.java:
##########
@@ -0,0 +1,52 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents an event that is triggered upon the successful listing of tags. 
*/
+@DeveloperApi
+public final class ListTagsEvent extends TagEvent {
+
+  /**
+   * Constructs an instance of {@code ListTagEvent}.
+   *
+   * @param user The username of the individual who initiated the tag listing.
+   * @param metalake The namespace from which tags were listed.
+   * @param tagNames The list of tag names that were retrieved.
+   */
+  public ListTagsEvent(String user, String metalake, String[] tagNames) {
+    super(
+        user,
+        NameIdentifierUtil.ofTag(

Review Comment:
   the identifier is `NameIdentifier.of(metalake)`



##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoEvent.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.tag.Tag;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents an event that is triggered upon the successful listing of tags. 
*/
+@DeveloperApi
+public final class ListTagsInfoEvent extends TagEvent {
+
+  /**
+   * Constructs an instance of {@code ListTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the tag listing.
+   * @param metalake The namespace from which tags were listed.
+   * @param tags An array of {@link Tag} objects representing the tags.
+   */
+  public ListTagsInfoEvent(String user, String metalake, Tag[] tags) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tags[0].name()));

Review Comment:
   the identifier is `NameIdentifier.of(metalake)`



##########
core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java:
##########
@@ -152,8 +186,11 @@ public MetadataObject[] listMetadataObjectsForTag(String 
metalake, String name)
   public String[] listTagsForMetadataObject(String metalake, MetadataObject 
metadataObject) {
     // TODO: listTagsForMetadataObjectPreEvent
     try {
-      // TODO: listTagsForMetadataObjectEvent
-      return dispatcher.listTagsForMetadataObject(metalake, metadataObject);
+      String[] tags = dispatcher.listTagsForMetadataObject(metalake, 
metadataObject);
+      eventBus.dispatchEvent(

Review Comment:
   please use tagInfo for the event



##########
core/src/main/java/org/apache/gravitino/listener/api/event/GetTagEvent.java:
##########
@@ -0,0 +1,51 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.info.TagInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents an event that is triggered upon successfully retrieving a tag. 
*/
+@DeveloperApi
+public final class GetTagEvent extends TagEvent {
+
+  /**
+   * Constructs an instance of {@code GetTagEvent}.
+   *
+   * @param user The username of the individual who initiated the tag 
retrieval.
+   * @param metalake The metalake from which the tag was retrieved.
+   * @param tagName The name of the tag being retrieved.
+   * @param tagInfo The {@link TagInfo} object representing the retrieved tag.
+   */
+  public GetTagEvent(String user, String metalake, String tagName, TagInfo 
tagInfo) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tagName));
+  }
+

Review Comment:
   add an method to get `tagInfo`?



##########
core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java:
##########
@@ -201,8 +250,12 @@ public String[] associateTagsForMetadataObject(
   public Tag getTagForMetadataObject(String metalake, MetadataObject 
metadataObject, String name) {
     // TODO: getTagForMetadataObjectPreEvent
     try {
-      // TODO: getTagForMetadataObjectEvent
-      return dispatcher.getTagForMetadataObject(metalake, metadataObject, 
name);
+      Tag tag = dispatcher.getTagForMetadataObject(metalake, metadataObject, 
name);
+      TagInfo tagInfo = new TagInfo(tag.name(), tag.comment(), 
tag.properties());
+      eventBus.dispatchEvent(
+          new GetTagForMetadataObjectEvent(
+              PrincipalUtils.getCurrentUserName(), metalake, metadataObject, 
name, tagInfo));

Review Comment:
   remove `name` from `GetTagForMetadataObjectEvent`, since the tag name is 
included in tagInfo



##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoEvent.java:
##########
@@ -0,0 +1,50 @@
+/*
+ * 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.annotation.DeveloperApi;
+import org.apache.gravitino.tag.Tag;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** Represents an event that is triggered upon the successful listing of tags. 
*/
+@DeveloperApi
+public final class ListTagsInfoEvent extends TagEvent {
+
+  /**
+   * Constructs an instance of {@code ListTagsEvent}.
+   *
+   * @param user The username of the individual who initiated the tag listing.
+   * @param metalake The namespace from which tags were listed.
+   * @param tags An array of {@link Tag} objects representing the tags.
+   */
+  public ListTagsInfoEvent(String user, String metalake, Tag[] tags) {
+    super(user, NameIdentifierUtil.ofTag(metalake, tags[0].name()));
+  }
+

Review Comment:
   please add method to get `tags`



##########
core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java:
##########
@@ -166,8 +203,11 @@ public String[] listTagsForMetadataObject(String metalake, 
MetadataObject metada
   public Tag[] listTagsInfoForMetadataObject(String metalake, MetadataObject 
metadataObject) {
     // TODO: listTagsInfoForMetadataObjectPreEvent
     try {
-      // TODO: listTagsInfoForMetadataObjectEvent
-      return dispatcher.listTagsInfoForMetadataObject(metalake, 
metadataObject);
+      Tag[] tags = dispatcher.listTagsInfoForMetadataObject(metalake, 
metadataObject);

Review Comment:
   please use tagInfo for the event



##########
core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectEvent.java:
##########
@@ -0,0 +1,56 @@
+/*
+ * 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.MetadataObject;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.tag.Tag;
+import org.apache.gravitino.utils.MetadataObjectUtil;
+
+/**
+ * Represents an event that is triggered upon successfully listing detailed 
tag information for a
+ * metadata object.
+ */
+@DeveloperApi
+public final class ListTagsInfoForMetadataObjectEvent extends TagEvent {
+
+  /**
+   * Constructs an instance of {@code ListTagsInfoForMetadataObjectEvent}.
+   *
+   * @param user The username of the individual who initiated the tag 
information listing.
+   * @param metalake The metalake from which tag information was listed.
+   * @param metadataObject The metadata object for which tag information was 
listed.
+   * @param tags An array of {@link Tag} objects representing the detailed tag 
information.
+   */
+  public ListTagsInfoForMetadataObjectEvent(
+      String user, String metalake, MetadataObject metadataObject, Tag[] tags) 
{
+    super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject));
+  }

Review Comment:
   please add method to get tags



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

Reply via email to