diff --git a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java index 24028674ac6..22d7718b571 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -19,8 +19,10 @@ package org.apache.gravitino.listener; import java.util.Map; + import org.apache.gravitino.MetadataObject; import org.apache.gravitino.exceptions.NoSuchTagException; +import org.apache.gravitino.listener.api.event.AssociateTagsForMetadataObjectEvent; import org.apache.gravitino.listener.api.event.AlterTagFailureEvent; import org.apache.gravitino.listener.api.event.AssociateTagsForMetadataObjectFailureEvent; import org.apache.gravitino.listener.api.event.CreateTagFailureEvent; @@ -34,7 +36,15 @@ import org.apache.gravitino.listener.api.event.ListTagsInfoForMetadataObjectFailureEvent; import org.apache.gravitino.listener.api.info.TagInfo; import org.apache.gravitino.listener.api.event.CreateTagEvent; +import org.apache.gravitino.listener.api.event.DeleteTagEvent; +import org.apache.gravitino.listener.api.event.GetTagEvent; +import org.apache.gravitino.listener.api.event.GetTagForMetadataObjectEvent; +import org.apache.gravitino.listener.api.event.ListMetadataObjectsForTagEvent; import org.apache.gravitino.listener.api.event.ListTagEvent; +import org.apache.gravitino.listener.api.event.ListTagInfoEvent; +import org.apache.gravitino.listener.api.event.AlterTagEvent; +import org.apache.gravitino.listener.api.event.ListTagsForMetadataObjectEvent; +import org.apache.gravitino.listener.api.event.ListTagsInfoForMetadataObjectEvent; import org.apache.gravitino.listener.api.info.TagInfo; import org.apache.gravitino.tag.Tag; import org.apache.gravitino.tag.TagChange; @@ -48,53 +58,55 @@ * of tag operations. */ public class TagEventDispatcher implements TagDispatcher { - private final EventBus eventBus; - private final TagDispatcher dispatcher; + private final EventBus eventBus; + private final TagDispatcher dispatcher; - public TagEventDispatcher(EventBus eventBus, TagDispatcher dispatcher) { - this.eventBus = eventBus; - this.dispatcher = dispatcher; - } + public TagEventDispatcher(EventBus eventBus, TagDispatcher dispatcher) { + this.eventBus = eventBus; + this.dispatcher = dispatcher; + } - @Override - public String[] listTags(String metalake) { - // TODO: listTagsPreEvent - try { - String[] tags = dispatcher.listTags(metalake); - eventBus.dispatchEvent(new ListTagEvent(PrincipalUtils.getCurrentUserName(), metalake)); - return tags; - } catch (Exception e) { - eventBus.dispatchEvent( - new ListTagsFailureEvent(PrincipalUtils.getCurrentUserName(), metalake, e)); - throw e; + @Override + public String[] listTags(String metalake) { + // TODO: listTagsPreEvent + try { + String[] tagNames = dispatcher.listTags(metalake); + eventBus.dispatchEvent(new ListTagEvent(PrincipalUtils.getCurrentUserName(), metalake)); + return tagNames; + } catch (Exception e) { + eventBus.dispatchEvent( + new ListTagsFailureEvent(PrincipalUtils.getCurrentUserName(), metalake, e)); + throw e; + } } - } - @Override - public Tag[] listTagsInfo(String metalake) { - // TODO: listTagsInfoPreEvent - try { - // TODO: listTagsInfoEvent - return dispatcher.listTagsInfo(metalake); - } catch (Exception e) { - eventBus.dispatchEvent( - new ListTagsInfoFailureEvent(PrincipalUtils.getCurrentUserName(), metalake, e)); - throw e; + @Override + public Tag[] listTagsInfo(String metalake) { + // TODO: listTagsInfoPreEvent + try { + Tag[] tags = dispatcher.listTagsInfo(metalake); + eventBus.dispatchEvent(new ListTagInfoEvent(PrincipalUtils.getCurrentUserName(), metalake, tags)); + return tags; + } catch (Exception e) { + eventBus.dispatchEvent( + new ListTagsInfoFailureEvent(PrincipalUtils.getCurrentUserName(), metalake, e)); + throw e; + } } - } - @Override - public Tag getTag(String metalake, String name) throws NoSuchTagException { - // TODO: getTagPreEvent - try { - // TODO: getTagEvent - return dispatcher.getTag(metalake, name); - } catch (Exception e) { - eventBus.dispatchEvent( - new GetTagFailureEvent(PrincipalUtils.getCurrentUserName(), metalake, name, e)); - throw e; + @Override + public Tag getTag(String metalake, String name) throws NoSuchTagException { + // TODO: getTagPreEvent + try { + // TODO: getTagEvent + Tag tag = dispatcher.getTag(metalake, name); + eventBus.dispatchEvent(new GetTagEvent(PrincipalUtils.getCurrentUserName(), metalake, name, tag)); + return tag; + } catch (NoSuchTagException e) { + new GetTagFailureEvent(PrincipalUtils.getCurrentUserName(), metalake, name, e)); + throw e; + } } - } @Override public Tag createTag( diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagEvent.java index 1def3a36765..7ad756b55bc 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagEvent.java @@ -35,18 +35,17 @@ public final class AlterTagEvent extends TagEvent { * successful alteration of a tag. * * @param user The username of the individual responsible for initiating the tag alteration. - * @param identifier The unique identifier of the altered tag, serving as a clear reference - * point for the tag in question. + * @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, - NameIdentifier identifier, + String metalake, TagChange[] tagChanges, TagInfo updatedTagInfo) { - super(user, identifier); + super(user, NameIdentifier.of(metalake)); this.tagChanges = tagChanges.clone(); this.updatedTagInfo = updatedTagInfo; } diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectEvent.java new file mode 100644 index 00000000000..b2628c7f360 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectEvent.java @@ -0,0 +1,108 @@ +/* + * 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; +import org.apache.gravitino.MetadataObject; + +/** Represents an event that is triggered upon successfully associating tags with a metadata object. */ +@DeveloperApi +public final class AssociateTagsForMetadataObjectEvent extends TagEvent { + private final String metalake; + private final MetadataObject metadataObject; + private final String[] tagsToAdd; + private final String[] tagsToRemove; + private final String[] associatedTags; + + /** + * Constructs an instance of {@code AssociateTagsForMetadataObjectEvent}. + * + * @param user The username of the individual who initiated the tag association. + * @param metalake The metalake from which the tags were associated. + * @param metadataObject The metadata object with which the tags were associated. + * @param tagsToAdd The tags that were added. + * @param tagsToRemove The tags that were removed. + * @param associatedTags The resulting list of associated tags after the operation. + */ + public AssociateTagsForMetadataObjectEvent(String user, String metalake, MetadataObject metadataObject, String[] tagsToAdd, String[] tagsToRemove, String[] associatedTags) { + super(user, NameIdentifier.of(metalake)); + this.metalake = metalake; + this.metadataObject = metadataObject; + this.tagsToAdd = tagsToAdd; + this.tagsToRemove = tagsToRemove; + this.associatedTags = associatedTags; + } + + /** + * Provides the metalake associated with this event. + * + * @return The metalake from which the tags were associated. + */ + public String metalake() { + return metalake; + } + + /** + * Provides the metadata object associated with this event. + * + * @return The {@link MetadataObject} with which the tags were associated. + */ + public MetadataObject metadataObject() { + return metadataObject; + } + + /** + * Provides the tags that were added in this operation. + * + * @return An array of tag names that were added. + */ + public String[] tagsToAdd() { + return tagsToAdd; + } + + /** + * Provides the tags that were removed in this operation. + * + * @return An array of tag names that were removed. + */ + public String[] tagsToRemove() { + return tagsToRemove; + } + + /** + * Provides the resulting list of associated tags after the operation. + * + * @return An array of tag names representing the associated tags. + */ + public String[] associatedTags() { + return associatedTags; + } + + /** + * Returns the type of operation. + * + * @return The operation type. + */ + @Override + public OperationType operationType() { + return OperationType.ASSOCIATE_TAGS_FOR_METADATA_OBJECT; + } +} diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagEvent.java index 52d623bc97b..c641d338880 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagEvent.java @@ -29,7 +29,6 @@ @DeveloperApi public final class CreateTagEvent extends TagEvent { private final TagInfo createdTagInfo; - private final String metalake; /** * Constructs an instance of {@code CreateTagEvent}, capturing essential details about the @@ -41,7 +40,6 @@ public final class CreateTagEvent extends TagEvent { */ public CreateTagEvent(String user, String metalake, TagInfo createdTagInfo) { super(user, NameIdentifier.of(metalake)); - this.metalake = metalake; this.createdTagInfo = createdTagInfo; } diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagEvent.java index c84d928c2a1..ddfcf08f638 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagEvent.java @@ -32,12 +32,12 @@ public final class DeleteTagEvent extends TagEvent { * of a tag delete operation. * * @param user The user who initiated the delete tag operation. - * @param identifier The identifier of the tag that was attempted to be deleted. + * @param metalake The metalake from which the tag was deleted. * @param isExists A boolean flag indicating whether the tag existed at the time of the delete * operation. */ - public DeleteTagEvent(String user, NameIdentifier identifier, boolean isExists) { - super(user, identifier); + public DeleteTagEvent(String user, String metalake, boolean isExists) { + super(user, NameIdentifier.of(metalake)); this.isExists = isExists; } diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagEvent.java new file mode 100644 index 00000000000..ff977af049d --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagEvent.java @@ -0,0 +1,84 @@ +/* + * 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; +import org.apache.gravitino.tag.Tag; + +/** Represents an event that is triggered upon successfully retrieving a tag. */ +@DeveloperApi +public final class GetTagEvent extends TagEvent { + private final String metalake; + private final String tagName; + private final Tag tag; + + /** + * 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 tag The {@link Tag} object representing the retrieved tag. + */ + public GetTagEvent(String user, String metalake, String tagName, Tag tag) { + super(user, NameIdentifier.of(metalake)); + this.metalake = metalake; + this.tagName = tagName; + this.tag = tag; + } + + /** + * Provides the metalake associated with this event. + * + * @return The metalake from which the tag was retrieved. + */ + public String metalake() { + return metalake; + } + + /** + * Provides the name of the retrieved tag. + * + * @return The name of the tag. + */ + public String tagName() { + return tagName; + } + + /** + * Provides the retrieved tag object. + * + * @return The {@link Tag} object. + */ + public Tag tag() { + return tag; + } + + /** + * Returns the type of operation. + * + * @return The operation type. + */ + @Override + public OperationType operationType() { + return OperationType.GET_TAG; + } +} diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectEvent.java new file mode 100644 index 00000000000..d40ce1976e5 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectEvent.java @@ -0,0 +1,97 @@ +/* + * 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; +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.tag.Tag; + +/** Represents an event that is triggered upon successfully retrieving a tag for a metadata object. */ +@DeveloperApi +public final class GetTagForMetadataObjectEvent extends TagEvent { + private final String metalake; + private final MetadataObject metadataObject; + private final String tagName; + private final Tag tag; + + /** + * 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 tag The {@link Tag} object representing the retrieved tag. + */ + public GetTagForMetadataObjectEvent(String user, String metalake, MetadataObject metadataObject, String tagName, Tag tag) { + super(user, NameIdentifier.of(metalake)); + this.metalake = metalake; + this.metadataObject = metadataObject; + this.tagName = tagName; + this.tag = tag; + } + + /** + * Provides the metalake associated with this event. + * + * @return The metalake from which the tag was retrieved. + */ + public String metalake() { + return metalake; + } + + /** + * Provides the metadata object associated with this event. + * + * @return The {@link MetadataObject} for which the tag was retrieved. + */ + public MetadataObject metadataObject() { + return metadataObject; + } + + /** + * Provides the name of the retrieved tag. + * + * @return The name of the tag. + */ + public String tagName() { + return tagName; + } + + /** + * Provides the retrieved tag object. + * + * @return The {@link Tag} object. + */ + public Tag tag() { + return tag; + } + + /** + * Returns the type of operation. + * + * @return The operation type. + */ + @Override + public OperationType operationType() { + return OperationType.GET_TAG_FOR_METADATA_OBJECT; + } +} diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagEvent.java new file mode 100644 index 00000000000..106a1f7ef43 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagEvent.java @@ -0,0 +1,84 @@ +/* + * 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; +import org.apache.gravitino.MetadataObject; + +/** Represents an event that is triggered upon successfully listing metadata objects for a tag. */ +@DeveloperApi +public final class ListMetadataObjectsForTagEvent extends TagEvent { + private final String metalake; + private final String tagName; + private final MetadataObject[] metadataObjects; + + /** + * Constructs an instance of {@code ListMetadataObjectsForTagEvent}. + * + * @param user The username of the individual who initiated the metadata objects listing. + * @param metalake The metalake from which metadata objects were listed. + * @param tagName The name of the tag for which metadata objects were listed. + * @param metadataObjects An array of {@link MetadataObject} representing the listed metadata objects. + */ + public ListMetadataObjectsForTagEvent(String user, String metalake, String tagName, MetadataObject[] metadataObjects) { + super(user, NameIdentifier.of(metalake)); + this.metalake = metalake; + this.tagName = tagName; + this.metadataObjects = metadataObjects; + } + + /** + * Provides the metalake associated with this event. + * + * @return The metalake from which metadata objects were listed. + */ + public String metalake() { + return metalake; + } + + /** + * Provides the name of the tag associated with this event. + * + * @return The name of the tag. + */ + public String tagName() { + return tagName; + } + + /** + * Provides the metadata objects associated with this event. + * + * @return An array of {@link MetadataObject}. + */ + public MetadataObject[] metadataObjects() { + return metadataObjects; + } + + /** + * Returns the type of operation. + * + * @return The operation type. + */ + @Override + public OperationType operationType() { + return OperationType.LIST_METADATA_OBJECTS_FOR_TAG; + } +} diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagInfoEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagInfoEvent.java new file mode 100644 index 00000000000..22107bca0ca --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagInfoEvent.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; +import org.apache.gravitino.tag.Tag; + +/** Represents an event that is triggered upon the successful listing of tags. */ +@DeveloperApi +public final class ListTagInfoEvent extends TagEvent { + private final Tag[] tags; + + /** + * 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 ListTagInfoEvent(String user, String metalake, Tag[] tags) { + super(user, NameIdentifier.of(metalake)); + this.tags = tags; + } + + /** + * Provides the tags associated with this event. + * + * @return An array of {@link Tag} objects. + */ + public Tag[] tags() { + return tags; + } + + /** + * Returns the type of operation. + * + * @return the operation type. + */ + @Override + public OperationType operationType() { + return OperationType.LISTINFO_TAG; + } +} diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectEvent.java new file mode 100644 index 00000000000..6591c824da7 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectEvent.java @@ -0,0 +1,84 @@ +/* + * 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; +import org.apache.gravitino.MetadataObject; + +/** Represents an event that is triggered upon successfully listing tags for a metadata object. */ +@DeveloperApi +public final class ListTagsForMetadataObjectEvent extends TagEvent { + private final String metalake; + private final MetadataObject metadataObject; + private final String[] tags; + + /** + * Constructs an instance of {@code ListTagsForMetadataObjectEvent}. + * + * @param user The username of the individual who initiated the tag listing. + * @param metalake The metalake from which tags were listed. + * @param metadataObject The metadata object for which tags were listed. + * @param tags An array of tag names representing the tags listed for the metadata object. + */ + public ListTagsForMetadataObjectEvent(String user, String metalake, MetadataObject metadataObject, String[] tags) { + super(user, NameIdentifier.of(metalake)); + this.metalake = metalake; + this.metadataObject = metadataObject; + this.tags = tags; + } + + /** + * Provides the metalake associated with this event. + * + * @return The metalake from which tags were listed. + */ + public String metalake() { + return metalake; + } + + /** + * Provides the metadata object associated with this event. + * + * @return The {@link MetadataObject} for which tags were listed. + */ + public MetadataObject metadataObject() { + return metadataObject; + } + + /** + * Provides the tags associated with this event. + * + * @return An array of tag names. + */ + public String[] tags() { + return tags; + } + + /** + * Returns the type of operation. + * + * @return The operation type. + */ + @Override + public OperationType operationType() { + return OperationType.LIST_TAGS_FOR_METADATA_OBJECT; + } +} diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectEvent.java new file mode 100644 index 00000000000..634a6278700 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectEvent.java @@ -0,0 +1,85 @@ +/* + * 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; +import org.apache.gravitino.MetadataObject; +import org.apache.gravitino.tag.Tag; + +/** Represents an event that is triggered upon successfully listing detailed tag information for a metadata object. */ +@DeveloperApi +public final class ListTagsInfoForMetadataObjectEvent extends TagEvent { + private final String metalake; + private final MetadataObject metadataObject; + private final Tag[] tags; + + /** + * 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, NameIdentifier.of(metalake)); + this.metalake = metalake; + this.metadataObject = metadataObject; + this.tags = tags; + } + + /** + * Provides the metalake associated with this event. + * + * @return The metalake from which tag information was listed. + */ + public String metalake() { + return metalake; + } + + /** + * Provides the metadata object associated with this event. + * + * @return The {@link MetadataObject} for which tag information was listed. + */ + public MetadataObject metadataObject() { + return metadataObject; + } + + /** + * Provides the detailed tag information associated with this event. + * + * @return An array of {@link Tag} objects. + */ + public Tag[] tags() { + return tags; + } + + /** + * Returns the type of operation. + * + * @return The operation type. + */ + @Override + public OperationType operationType() { + return OperationType.LIST_TAGS_INFO_FOR_METADATA_OBJECT; + } +} diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java b/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java index 381121995b7..b014398749a 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/OperationType.java @@ -104,6 +104,13 @@ public enum OperationType { ALTER_TAG, LIST_TAG, DELETE_TAG, + LISTINFO_TAG, + GET_TAG, + LIST_METADATA_OBJECTS_FOR_TAG, + LIST_TAGS_FOR_METADATA_OBJECT, + LIST_TAGS_INFO_FOR_METADATA_OBJECT, + ASSOCIATE_TAGS_FOR_METADATA_OBJECT, + GET_TAG_FOR_METADATA_OBJECT, UNKNOWN, }