From 555756e6b80eb255a0d660fb322e8223967f18a7 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Mon, 23 Dec 2024 21:48:48 -0500 Subject: [PATCH 01/14] add TagPreEvent --- .../listener/api/event/TagPreEvent.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/TagPreEvent.java diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/TagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/TagPreEvent.java new file mode 100644 index 00000000000..8dd918d5384 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/TagPreEvent.java @@ -0,0 +1,31 @@ +/* + * 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 a pre-event for tag operations. */ +@DeveloperApi +public abstract class TagPreEvent extends PreEvent { + protected TagPreEvent(String user, NameIdentifier identifier) { + super(user, identifier); + } +} From 90300bb43645d18a9e68f5491f7fa0db25ce53b8 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Mon, 23 Dec 2024 21:52:20 -0500 Subject: [PATCH 02/14] feat: Add pre-event logic for listTags method --- .../listener/TagEventDispatcher.java | 13 +++++++- .../listener/api/event/ListTagsPreEvent.java | 32 +++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsPreEvent.java 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 302d82a93c7..01644daff11 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -32,6 +32,17 @@ import org.apache.gravitino.listener.api.event.ListTagsForMetadataObjectFailureEvent; import org.apache.gravitino.listener.api.event.ListTagsInfoFailureEvent; import org.apache.gravitino.listener.api.event.ListTagsInfoForMetadataObjectFailureEvent; +import org.apache.gravitino.listener.api.event.AlterTagPreEvent; +import org.apache.gravitino.listener.api.event.AssociateTagsForMetadataObjectPreEvent; +import org.apache.gravitino.listener.api.event.CreateTagPreEvent; +import org.apache.gravitino.listener.api.event.DeleteTagPreEvent; +import org.apache.gravitino.listener.api.event.GetTagForMetadataObjectPreEvent; +import org.apache.gravitino.listener.api.event.GetTagPreEvent; +import org.apache.gravitino.listener.api.event.ListMetadataObjectsForTagPreEvent; +import org.apache.gravitino.listener.api.event.ListTagsForMetadataObjectPreEvent; +import org.apache.gravitino.listener.api.event.ListTagsInfoForMetadataObjectPreEvent; +import org.apache.gravitino.listener.api.event.ListTagsInfoPreEvent; +import org.apache.gravitino.listener.api.event.ListTagsPreEvent; import org.apache.gravitino.listener.api.info.TagInfo; import org.apache.gravitino.tag.Tag; import org.apache.gravitino.tag.TagChange; @@ -55,7 +66,7 @@ public TagEventDispatcher(EventBus eventBus, TagDispatcher dispatcher) { @Override public String[] listTags(String metalake) { - // TODO: listTagsPreEvent + eventBus.dispatchEvent(new ListTagsPreEvent(PrincipalUtils.getCurrentUserName(), metalake)); try { // TODO: listTagsEvent return dispatcher.listTags(metalake); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsPreEvent.java new file mode 100644 index 00000000000..feee8e1eb88 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsPreEvent.java @@ -0,0 +1,32 @@ +/* + * 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; + +public class ListTagsPreEvent extends TagPreEvent { + public ListTagsPreEvent(String user, String metalake) { + super(user, NameIdentifier.of(metalake)); + } + + @Override + public OperationType operationType() { + return OperationType.LIST_TAGS; + } +} From 36da9d7dcec48c62b98bd38f24c50823de3aa5bf Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Mon, 23 Dec 2024 21:56:48 -0500 Subject: [PATCH 03/14] feat: Add pre-event logic for listTagsInfo method --- .../listener/TagEventDispatcher.java | 2 +- .../api/event/ListTagsInfoPreEvent.java | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoPreEvent.java 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 01644daff11..b178cd915fd 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -79,7 +79,7 @@ public String[] listTags(String metalake) { @Override public Tag[] listTagsInfo(String metalake) { - // TODO: listTagsInfoPreEvent + eventBus.dispatchEvent(new ListTagsInfoPreEvent(PrincipalUtils.getCurrentUserName(), metalake)); try { // TODO: listTagsInfoEvent return dispatcher.listTagsInfo(metalake); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoPreEvent.java new file mode 100644 index 00000000000..f7578e97a8d --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoPreEvent.java @@ -0,0 +1,32 @@ +/* + * 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; + +public class ListTagsInfoPreEvent extends TagPreEvent { + public ListTagsInfoPreEvent(String user, String metalake) { + super(user, NameIdentifier.of(metalake)); + } + + @Override + public OperationType operationType() { + return OperationType.LIST_TAGS_INFO; + } +} From 8cf92897758af1d8053130cc2a75096831743937 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:15:46 -0500 Subject: [PATCH 04/14] feat: Add pre-event logic for getTag method --- .../listener/TagEventDispatcher.java | 2 +- .../listener/api/event/GetTagPreEvent.java | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/GetTagPreEvent.java 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 b178cd915fd..97abac2e0e2 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -92,7 +92,7 @@ public Tag[] listTagsInfo(String metalake) { @Override public Tag getTag(String metalake, String name) throws NoSuchTagException { - // TODO: getTagPreEvent + eventBus.dispatchEvent(new GetTagPreEvent(PrincipalUtils.getCurrentUserName(), metalake, name)); try { // TODO: getTagEvent return dispatcher.getTag(metalake, name); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagPreEvent.java new file mode 100644 index 00000000000..edbcbc69309 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagPreEvent.java @@ -0,0 +1,39 @@ +/* + * 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; + +public class GetTagPreEvent extends TagPreEvent { + private final String tagName; + + public GetTagPreEvent(String user, String metalake, String tagName) { + super(user, NameIdentifier.of(metalake)); + this.tagName = tagName; + } + + public String getTagName() { + return tagName; + } + + @Override + public OperationType operationType() { + return OperationType.GET_TAG; + } +} From f5e310ed8310493165bc2dbe4cbc587c908d5cc3 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:17:08 -0500 Subject: [PATCH 05/14] feat: Add pre-event logic for createTag method --- .../listener/TagEventDispatcher.java | 3 ++ .../listener/api/event/CreateTagPreEvent.java | 41 +++++++++++++++++++ .../gravitino/listener/api/info/TagInfo.java | 1 - 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java 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 97abac2e0e2..74e74a64134 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -108,6 +108,9 @@ public Tag createTag( String metalake, String name, String comment, Map properties) { TagInfo tagInfo = new TagInfo(name, comment, properties); // TODO: createTagPreEvent + + eventBus.dispatchEvent( + new CreateTagPreEvent(PrincipalUtils.getCurrentUserName(), metalake, tagInfo)); try { // TODO: createTagEvent return dispatcher.createTag(metalake, name, comment, properties); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java new file mode 100644 index 00000000000..04006592e7d --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java @@ -0,0 +1,41 @@ +/* + * 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.listener.api.info.TagInfo; + +public class CreateTagPreEvent extends TagPreEvent { + private final TagInfo createTagRequest; + + public CreateTagPreEvent(String user, String metalake, TagInfo createTagRequest) { + super(user, NameIdentifier.of(metalake)); + this.createTagRequest = createTagRequest; + } + + public TagInfo getCreateTagRequest() { + return createTagRequest; + } + + @Override + public OperationType operationType() { + return OperationType.CREATE_TAG; + } +} diff --git a/core/src/main/java/org/apache/gravitino/listener/api/info/TagInfo.java b/core/src/main/java/org/apache/gravitino/listener/api/info/TagInfo.java index 20164f4c931..81d6444ab5f 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/info/TagInfo.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/info/TagInfo.java @@ -16,7 +16,6 @@ * specific language governing permissions and limitations * under the License. */ - package org.apache.gravitino.listener.api.info; import com.google.common.collect.ImmutableMap; From b7f58942acb7e0ccb61f9b9351afe5aff73d5f78 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:18:00 -0500 Subject: [PATCH 06/14] feat: Add pre-event logic for alterTag method --- .../listener/TagEventDispatcher.java | 5 +- .../listener/api/event/AlterTagPreEvent.java | 63 +++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagPreEvent.java 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 74e74a64134..4ec6646e3a2 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -123,7 +123,10 @@ public Tag createTag( @Override public Tag alterTag(String metalake, String name, TagChange... changes) { - // TODO: alterTagPreEvent + AlterTagPreEvent preEvent = + new AlterTagPreEvent(PrincipalUtils.getCurrentUserName(), metalake, name, changes); + + eventBus.dispatchEvent(preEvent); try { // TODO: alterTagEvent return dispatcher.alterTag(metalake, name, changes); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagPreEvent.java new file mode 100644 index 00000000000..fbf795679de --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/AlterTagPreEvent.java @@ -0,0 +1,63 @@ +/* + * 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.TagChange; + +/** Represents an event triggered before altering a tag. */ +@DeveloperApi +public class AlterTagPreEvent extends TagPreEvent { + + private final TagChange[] changes; + + /** + * Constructs a new AlterTagPreEvent instance. + * + * @param user The user responsible for the operation. + * @param metalake The namespace of the tag. + * @param tagName The name of the tag being altered. + * @param changes The changes being applied to the tag. + */ + public AlterTagPreEvent(String user, String metalake, String tagName, TagChange[] changes) { + super(user, NameIdentifier.of(metalake, tagName)); + this.changes = changes; + } + + /** + * Returns the changes being applied to the tag. + * + * @return An array of {@link TagChange}. + */ + public TagChange[] getChanges() { + return changes; + } + + /** + * Returns the operation type for this event. + * + * @return The operation type {@link OperationType#ALTER_TAG}. + */ + @Override + public OperationType operationType() { + return OperationType.ALTER_TAG; + } +} From 8557203f04f67207ca1515aab8df095c9c3ab0ad Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:18:45 -0500 Subject: [PATCH 07/14] feat: Add pre-event logic for deleteTag method --- .../listener/TagEventDispatcher.java | 5 ++- .../listener/api/event/DeleteTagPreEvent.java | 36 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagPreEvent.java 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 4ec6646e3a2..ddd27323859 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -140,7 +140,10 @@ public Tag alterTag(String metalake, String name, TagChange... changes) { @Override public boolean deleteTag(String metalake, String name) { - // TODO: deleteTagPreEvent + DeleteTagPreEvent preEvent = + new DeleteTagPreEvent(PrincipalUtils.getCurrentUserName(), metalake, name); + + eventBus.dispatchEvent(preEvent); try { // TODO: deleteTagEvent return dispatcher.deleteTag(metalake, name); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagPreEvent.java new file mode 100644 index 00000000000..94bbfb65464 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/DeleteTagPreEvent.java @@ -0,0 +1,36 @@ +/* + * 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 deleting a tag. */ +@DeveloperApi +public class DeleteTagPreEvent extends TagPreEvent { + + public DeleteTagPreEvent(String user, String metalake, String tagName) { + super(user, NameIdentifier.of(metalake, tagName)); + } + + @Override + public OperationType operationType() { + return OperationType.DELETE_TAG; + } +} From bf2d86187e6996b15f25083aedbbf4f09ba46f69 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:19:39 -0500 Subject: [PATCH 08/14] feat: Add pre-event logic for listMetadataObjectsForTag method --- .../listener/TagEventDispatcher.java | 3 +- .../ListMetadataObjectsForTagPreEvent.java | 55 +++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagPreEvent.java 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 ddd27323859..b6f13767836 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -156,7 +156,8 @@ public boolean deleteTag(String metalake, String name) { @Override public MetadataObject[] listMetadataObjectsForTag(String metalake, String name) { - // TODO: listMetadataObjectsForTagPreEvent + eventBus.dispatchEvent( + new ListMetadataObjectsForTagPreEvent(PrincipalUtils.getCurrentUserName(), metalake, name)); try { // TODO: listMetadataObjectsForTagEvent return dispatcher.listMetadataObjectsForTag(metalake, name); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagPreEvent.java new file mode 100644 index 00000000000..79d6d821e60 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagPreEvent.java @@ -0,0 +1,55 @@ +/* + * 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 a pre-event for listing metadata objects associated with a tag. */ +@DeveloperApi +public class ListMetadataObjectsForTagPreEvent extends TagPreEvent { + + private final String tagName; + + /** + * Constructs a new ListMetadataObjectsForTagPreEvent instance. + * + * @param user The user performing the operation. + * @param metalake The name of the Metalake environment. + * @param tagName The name of the tag. + */ + public ListMetadataObjectsForTagPreEvent(String user, String metalake, String tagName) { + super(user, NameIdentifier.of(metalake)); + this.tagName = tagName; + } + + /** + * Gets the name of the tag for which metadata objects are being listed. + * + * @return The tag name. + */ + public String getTagName() { + return tagName; + } + + @Override + public OperationType operationType() { + return OperationType.LIST_METADATA_OBJECTS_FOR_TAG; + } +} From 050c17b530500e6d41e1b683b1c392dcd195a0cb Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:21:18 -0500 Subject: [PATCH 09/14] feat: Add pre-event logic for listTagsForMetadataObject method --- .../listener/TagEventDispatcher.java | 5 +- .../ListTagsForMetadataObjectPreEvent.java | 49 +++++++++++++++++++ 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectPreEvent.java 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 b6f13767836..acaf01590b7 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -171,7 +171,10 @@ public MetadataObject[] listMetadataObjectsForTag(String metalake, String name) @Override public String[] listTagsForMetadataObject(String metalake, MetadataObject metadataObject) { - // TODO: listTagsForMetadataObjectPreEvent + eventBus.dispatchEvent( + new ListTagsForMetadataObjectPreEvent( + PrincipalUtils.getCurrentUserName(), metalake, metadataObject)); + try { // TODO: listTagsForMetadataObjectEvent return dispatcher.listTagsForMetadataObject(metalake, metadataObject); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectPreEvent.java new file mode 100644 index 00000000000..e0532ef827e --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectPreEvent.java @@ -0,0 +1,49 @@ +/* + * 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.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; + +/** Represents an event triggered before listing tags for a metadata object. */ +@DeveloperApi +public class ListTagsForMetadataObjectPreEvent extends TagPreEvent { + private final MetadataObject metadataObject; + + public ListTagsForMetadataObjectPreEvent( + String user, String metalake, MetadataObject metadataObject) { + super(user, NameIdentifier.of(metalake)); + this.metadataObject = metadataObject; + } + + /** + * get MetadataObject。 + * + * @return MetadataObject instance + */ + public MetadataObject getMetadataObject() { + return metadataObject; + } + + @Override + public OperationType operationType() { + return OperationType.LIST_TAGS_FOR_METADATA_OBJECT; + } +} From 816fdcbe03a225c74007af9d049175b6636b0710 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:21:48 -0500 Subject: [PATCH 10/14] feat: Add pre-event logic for listTagsInfoForMetadataObject method --- .../listener/TagEventDispatcher.java | 4 +- ...ListTagsInfoForMetadataObjectPreEvent.java | 67 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectPreEvent.java 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 acaf01590b7..ac31d46d222 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -188,7 +188,9 @@ public String[] listTagsForMetadataObject(String metalake, MetadataObject metada @Override public Tag[] listTagsInfoForMetadataObject(String metalake, MetadataObject metadataObject) { - // TODO: listTagsInfoForMetadataObjectPreEvent + eventBus.dispatchEvent( + new ListTagsInfoForMetadataObjectPreEvent( + PrincipalUtils.getCurrentUserName(), metalake, metadataObject)); try { // TODO: listTagsInfoForMetadataObjectEvent return dispatcher.listTagsInfoForMetadataObject(metalake, metadataObject); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectPreEvent.java new file mode 100644 index 00000000000..c3a4f1f6d62 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectPreEvent.java @@ -0,0 +1,67 @@ +/* + * 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.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; + +/** + * Represents an event triggered before listing detailed tag information for a specific metadata + * object. + */ +@DeveloperApi +public class ListTagsInfoForMetadataObjectPreEvent extends TagPreEvent { + // Metadata object to associate with the event + private final MetadataObject metadataObject; + + /** + * Constructs the pre-event with user, metalake, and metadata object details. + * + * @param user The user initiating the operation. + * @param metalake The metalake environment name. + * @param metadataObject The metadata object for which tags' information will be listed. + */ + public ListTagsInfoForMetadataObjectPreEvent( + String user, String metalake, MetadataObject metadataObject) { + super( + user, + NameIdentifier.of(metalake)); // Pass the user and metalake identifier to the parent class + this.metadataObject = metadataObject; + } + + /** + * Returns the metadata object associated with this event. + * + * @return The metadata object instance. + */ + public MetadataObject getMetadataObject() { + return metadataObject; + } + + /** + * Returns the operation type for this event. + * + * @return The operation type, which is LIST_TAGS_INFO_FOR_METADATA_OBJECT. + */ + @Override + public OperationType operationType() { + return OperationType.LIST_TAGS_INFO_FOR_METADATA_OBJECT; + } +} From f0a0bc94450d6a9af00c93ecdb6cad8c13d16ae4 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:22:32 -0500 Subject: [PATCH 11/14] feat: Add pre-event logic for associateTagsForMetadataObject method --- .../listener/TagEventDispatcher.java | 9 +- ...ssociateTagsForMetadataObjectPreEvent.java | 89 +++++++++++++++++++ 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java 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 ac31d46d222..55cbff2f099 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -205,7 +205,14 @@ public Tag[] listTagsInfoForMetadataObject(String metalake, MetadataObject metad @Override public String[] associateTagsForMetadataObject( String metalake, MetadataObject metadataObject, String[] tagsToAdd, String[] tagsToRemove) { - // TODO: associateTagsForMetadataObjectPreEvent + eventBus.dispatchEvent( + new AssociateTagsForMetadataObjectPreEvent( + PrincipalUtils.getCurrentUserName(), + metalake, + metadataObject, + tagsToAdd, + tagsToRemove)); + try { // TODO: associateTagsForMetadataObjectEvent return dispatcher.associateTagsForMetadataObject( diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java new file mode 100644 index 00000000000..e69b3ef1bcd --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java @@ -0,0 +1,89 @@ +/* + * 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.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; + +/** Represents an event triggered before associating tags with a specific metadata object. */ +@DeveloperApi +public class AssociateTagsForMetadataObjectPreEvent extends TagPreEvent { + private final MetadataObject metadataObject; + private final String[] tagsToAdd; + private final String[] tagsToRemove; + + /** + * Constructs the pre-event with user, metalake, metadata object, tags to add, and tags to remove. + * + * @param user The user initiating the operation. + * @param metalake The metalake environment name. + * @param metadataObject The metadata object for which tags will be associated. + * @param tagsToAdd Tags to be added to the metadata object. + * @param tagsToRemove Tags to be removed from the metadata object. + */ + public AssociateTagsForMetadataObjectPreEvent( + String user, + String metalake, + MetadataObject metadataObject, + String[] tagsToAdd, + String[] tagsToRemove) { + super(user, NameIdentifier.of(metalake)); + this.metadataObject = metadataObject; + this.tagsToAdd = tagsToAdd; + this.tagsToRemove = tagsToRemove; + } + + /** + * Returns the metadata object associated with this event. + * + * @return The metadata object instance. + */ + public MetadataObject getMetadataObject() { + return metadataObject; + } + + /** + * Returns the tags to be added. + * + * @return Array of tag names to be added. + */ + public String[] getTagsToAdd() { + return tagsToAdd; + } + + /** + * Returns the tags to be removed. + * + * @return Array of tag names to be removed. + */ + public String[] getTagsToRemove() { + return tagsToRemove; + } + + /** + * Returns the operation type for this event. + * + * @return The operation type, which is ASSOCIATE_TAGS_FOR_METADATA_OBJECT. + */ + @Override + public OperationType operationType() { + return OperationType.ASSOCIATE_TAGS_FOR_METADATA_OBJECT; + } +} From 867b2c33cfa8662575587ad723ef4324f7dadf62 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:23:15 -0500 Subject: [PATCH 12/14] feat: Add pre-event logic for getTagForMetadataObject method --- .../listener/TagEventDispatcher.java | 4 +- .../GetTagForMetadataObjectPreEvent.java | 73 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectPreEvent.java 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 55cbff2f099..088e594b641 100644 --- a/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java +++ b/core/src/main/java/org/apache/gravitino/listener/TagEventDispatcher.java @@ -232,7 +232,9 @@ public String[] associateTagsForMetadataObject( @Override public Tag getTagForMetadataObject(String metalake, MetadataObject metadataObject, String name) { - // TODO: getTagForMetadataObjectPreEvent + eventBus.dispatchEvent( + new GetTagForMetadataObjectPreEvent( + PrincipalUtils.getCurrentUserName(), metalake, metadataObject, name)); try { // TODO: getTagForMetadataObjectEvent return dispatcher.getTagForMetadataObject(metalake, metadataObject, name); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectPreEvent.java new file mode 100644 index 00000000000..57138093262 --- /dev/null +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectPreEvent.java @@ -0,0 +1,73 @@ +/* + * 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.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; + +/** Represents an event triggered before retrieving a tag for a specific metadata object. */ +@DeveloperApi +public class GetTagForMetadataObjectPreEvent extends TagPreEvent { + private final MetadataObject metadataObject; + private final String tagName; + + /** + * Constructs the pre-event with user, metalake, metadata object, and tag name. + * + * @param user The user initiating the operation. + * @param metalake The metalake environment name. + * @param metadataObject The metadata object associated with the tag. + * @param tagName The name of the tag being retrieved. + */ + public GetTagForMetadataObjectPreEvent( + String user, String metalake, MetadataObject metadataObject, String tagName) { + super(user, NameIdentifier.of(metalake)); + this.metadataObject = metadataObject; + this.tagName = tagName; + } + + /** + * Returns the metadata object associated with this event. + * + * @return The metadata object instance. + */ + public MetadataObject getMetadataObject() { + return metadataObject; + } + + /** + * Returns the name of the tag being retrieved. + * + * @return The tag name. + */ + public String getTagName() { + return tagName; + } + + /** + * Returns the operation type for this event. + * + * @return The operation type, which is GET_TAG_FOR_METADATA_OBJECT. + */ + @Override + public OperationType operationType() { + return OperationType.GET_TAG_FOR_METADATA_OBJECT; + } +} From 08ffb2310e6974e1fe13fe2fd28cd648c0f70f71 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Tue, 24 Dec 2024 22:23:39 -0500 Subject: [PATCH 13/14] feat: Add tag event in OperationType --- .../gravitino/listener/api/event/OperationType.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 515e63a7c30..b1d7cd5b29b 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 @@ -99,5 +99,18 @@ public enum OperationType { RENAME_VIEW, LIST_VIEW, + // Tag Event + LIST_TAGS, + LIST_TAGS_INFO, + GET_TAG, + CREATE_TAG, + ALTER_TAG, + DELETE_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, } From f944fec2e2513d6c6c250e31a47055990a727801 Mon Sep 17 00:00:00 2001 From: amazingLychee <834994869@qq.com> Date: Thu, 16 Jan 2025 10:32:44 -0500 Subject: [PATCH 14/14] feat: Modify Tag PreEvent --- ...ssociateTagsForMetadataObjectPreEvent.java | 15 ++------------- .../listener/api/event/CreateTagPreEvent.java | 16 +++++++++------- .../GetTagForMetadataObjectPreEvent.java | 14 ++------------ .../listener/api/event/GetTagPreEvent.java | 13 ++++--------- .../ListMetadataObjectsForTagPreEvent.java | 16 ++-------------- .../ListTagsForMetadataObjectPreEvent.java | 16 ++-------------- ...ListTagsInfoForMetadataObjectPreEvent.java | 19 ++----------------- .../api/event/ListTagsInfoPreEvent.java | 2 ++ .../listener/api/event/ListTagsPreEvent.java | 4 +++- .../listener/api/event/OperationType.java | 14 -------------- 10 files changed, 28 insertions(+), 101 deletions(-) diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java index e69b3ef1bcd..915e14ba3d4 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/AssociateTagsForMetadataObjectPreEvent.java @@ -19,13 +19,12 @@ package org.apache.gravitino.listener.api.event; import org.apache.gravitino.MetadataObject; -import org.apache.gravitino.NameIdentifier; import org.apache.gravitino.annotation.DeveloperApi; +import org.apache.gravitino.utils.MetadataObjectUtil; /** Represents an event triggered before associating tags with a specific metadata object. */ @DeveloperApi public class AssociateTagsForMetadataObjectPreEvent extends TagPreEvent { - private final MetadataObject metadataObject; private final String[] tagsToAdd; private final String[] tagsToRemove; @@ -44,21 +43,11 @@ public AssociateTagsForMetadataObjectPreEvent( MetadataObject metadataObject, String[] tagsToAdd, String[] tagsToRemove) { - super(user, NameIdentifier.of(metalake)); - this.metadataObject = metadataObject; + super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject)); this.tagsToAdd = tagsToAdd; this.tagsToRemove = tagsToRemove; } - /** - * Returns the metadata object associated with this event. - * - * @return The metadata object instance. - */ - public MetadataObject getMetadataObject() { - return metadataObject; - } - /** * Returns the tags to be added. * diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java index 04006592e7d..993e0dde191 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/CreateTagPreEvent.java @@ -19,19 +19,21 @@ package org.apache.gravitino.listener.api.event; -import org.apache.gravitino.NameIdentifier; import org.apache.gravitino.listener.api.info.TagInfo; +import org.apache.gravitino.utils.NameIdentifierUtil; +import org.apache.gravitino.annotation.DeveloperApi; +@DeveloperApi public class CreateTagPreEvent extends TagPreEvent { - private final TagInfo createTagRequest; + private final TagInfo tagInfo; - public CreateTagPreEvent(String user, String metalake, TagInfo createTagRequest) { - super(user, NameIdentifier.of(metalake)); - this.createTagRequest = createTagRequest; + public CreateTagPreEvent(String user, String metalake, TagInfo tagInfo) { + super(user, NameIdentifierUtil.ofTag(metalake, tagInfo.name())); + this.tagInfo = tagInfo; } - public TagInfo getCreateTagRequest() { - return createTagRequest; + public TagInfo tagInfo() { + return tagInfo; } @Override diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectPreEvent.java index 57138093262..08d6d389483 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagForMetadataObjectPreEvent.java @@ -21,11 +21,11 @@ import org.apache.gravitino.MetadataObject; import org.apache.gravitino.NameIdentifier; import org.apache.gravitino.annotation.DeveloperApi; +import org.apache.gravitino.utils.MetadataObjectUtil; /** Represents an event triggered before retrieving a tag for a specific metadata object. */ @DeveloperApi public class GetTagForMetadataObjectPreEvent extends TagPreEvent { - private final MetadataObject metadataObject; private final String tagName; /** @@ -38,20 +38,10 @@ public class GetTagForMetadataObjectPreEvent extends TagPreEvent { */ public GetTagForMetadataObjectPreEvent( String user, String metalake, MetadataObject metadataObject, String tagName) { - super(user, NameIdentifier.of(metalake)); - this.metadataObject = metadataObject; + super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject)); this.tagName = tagName; } - /** - * Returns the metadata object associated with this event. - * - * @return The metadata object instance. - */ - public MetadataObject getMetadataObject() { - return metadataObject; - } - /** * Returns the name of the tag being retrieved. * diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagPreEvent.java index edbcbc69309..4e65882684e 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/GetTagPreEvent.java @@ -18,18 +18,13 @@ */ package org.apache.gravitino.listener.api.event; -import org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; +import org.apache.gravitino.utils.NameIdentifierUtil; +@DeveloperApi public class GetTagPreEvent extends TagPreEvent { - private final String tagName; - public GetTagPreEvent(String user, String metalake, String tagName) { - super(user, NameIdentifier.of(metalake)); - this.tagName = tagName; - } - - public String getTagName() { - return tagName; + super(user, NameIdentifierUtil.ofTag(metalake, tagName)); } @Override diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagPreEvent.java index 79d6d821e60..c632b4e3467 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListMetadataObjectsForTagPreEvent.java @@ -20,13 +20,11 @@ import org.apache.gravitino.NameIdentifier; import org.apache.gravitino.annotation.DeveloperApi; +import org.apache.gravitino.utils.NameIdentifierUtil; /** Represents a pre-event for listing metadata objects associated with a tag. */ @DeveloperApi public class ListMetadataObjectsForTagPreEvent extends TagPreEvent { - - private final String tagName; - /** * Constructs a new ListMetadataObjectsForTagPreEvent instance. * @@ -35,17 +33,7 @@ public class ListMetadataObjectsForTagPreEvent extends TagPreEvent { * @param tagName The name of the tag. */ public ListMetadataObjectsForTagPreEvent(String user, String metalake, String tagName) { - super(user, NameIdentifier.of(metalake)); - this.tagName = tagName; - } - - /** - * Gets the name of the tag for which metadata objects are being listed. - * - * @return The tag name. - */ - public String getTagName() { - return tagName; + super(user, NameIdentifierUtil.ofTag(metalake, tagName)); } @Override diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectPreEvent.java index e0532ef827e..1e02c7c0e97 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsForMetadataObjectPreEvent.java @@ -19,27 +19,15 @@ package org.apache.gravitino.listener.api.event; import org.apache.gravitino.MetadataObject; -import org.apache.gravitino.NameIdentifier; import org.apache.gravitino.annotation.DeveloperApi; +import org.apache.gravitino.utils.MetadataObjectUtil; /** Represents an event triggered before listing tags for a metadata object. */ @DeveloperApi public class ListTagsForMetadataObjectPreEvent extends TagPreEvent { - private final MetadataObject metadataObject; - public ListTagsForMetadataObjectPreEvent( String user, String metalake, MetadataObject metadataObject) { - super(user, NameIdentifier.of(metalake)); - this.metadataObject = metadataObject; - } - - /** - * get MetadataObject。 - * - * @return MetadataObject instance - */ - public MetadataObject getMetadataObject() { - return metadataObject; + super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject)); } @Override diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectPreEvent.java index c3a4f1f6d62..6b03746e905 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoForMetadataObjectPreEvent.java @@ -19,8 +19,8 @@ package org.apache.gravitino.listener.api.event; import org.apache.gravitino.MetadataObject; -import org.apache.gravitino.NameIdentifier; import org.apache.gravitino.annotation.DeveloperApi; +import org.apache.gravitino.utils.MetadataObjectUtil; /** * Represents an event triggered before listing detailed tag information for a specific metadata @@ -28,9 +28,6 @@ */ @DeveloperApi public class ListTagsInfoForMetadataObjectPreEvent extends TagPreEvent { - // Metadata object to associate with the event - private final MetadataObject metadataObject; - /** * Constructs the pre-event with user, metalake, and metadata object details. * @@ -40,19 +37,7 @@ public class ListTagsInfoForMetadataObjectPreEvent extends TagPreEvent { */ public ListTagsInfoForMetadataObjectPreEvent( String user, String metalake, MetadataObject metadataObject) { - super( - user, - NameIdentifier.of(metalake)); // Pass the user and metalake identifier to the parent class - this.metadataObject = metadataObject; - } - - /** - * Returns the metadata object associated with this event. - * - * @return The metadata object instance. - */ - public MetadataObject getMetadataObject() { - return metadataObject; + super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject)); } /** diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoPreEvent.java index f7578e97a8d..d2261d9baba 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsInfoPreEvent.java @@ -19,7 +19,9 @@ package org.apache.gravitino.listener.api.event; import org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; +@DeveloperApi public class ListTagsInfoPreEvent extends TagPreEvent { public ListTagsInfoPreEvent(String user, String metalake) { super(user, NameIdentifier.of(metalake)); diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsPreEvent.java index feee8e1eb88..e00fdec41ea 100644 --- a/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsPreEvent.java +++ b/core/src/main/java/org/apache/gravitino/listener/api/event/ListTagsPreEvent.java @@ -19,7 +19,9 @@ package org.apache.gravitino.listener.api.event; import org.apache.gravitino.NameIdentifier; +import org.apache.gravitino.annotation.DeveloperApi; +@DeveloperApi public class ListTagsPreEvent extends TagPreEvent { public ListTagsPreEvent(String user, String metalake) { super(user, NameIdentifier.of(metalake)); @@ -27,6 +29,6 @@ public ListTagsPreEvent(String user, String metalake) { @Override public OperationType operationType() { - return OperationType.LIST_TAGS; + return OperationType.LIST_TAG; } } 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 b1d7cd5b29b..fbf5e12866b 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 @@ -98,19 +98,5 @@ public enum OperationType { VIEW_EXISTS, RENAME_VIEW, LIST_VIEW, - - // Tag Event - LIST_TAGS, - LIST_TAGS_INFO, - GET_TAG, - CREATE_TAG, - ALTER_TAG, - DELETE_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, }