Skip to content

World's most powerful open data catalog for building a high-performance, geo-distributed and federated metadata lake.

[#14906] feat(core): Add Domain events and audit integration (#14907)

Jerry Shaodcc1191900f8
diff --git a/core/src/main/java/org/apache/gravitino/GravitinoEnv.java b/core/src/main/java/org/apache/gravitino/GravitinoEnv.java
index 30ac681401..c03429463c 100644
--- a/core/src/main/java/org/apache/gravitino/GravitinoEnv.java
+++ b/core/src/main/java/org/apache/gravitino/GravitinoEnv.java
@@ -86,6 +86,7 @@ import org.apache.gravitino.job.JobOperationDispatcher;
import org.apache.gravitino.job.JobTemplateValidationDispatcher;
import org.apache.gravitino.listener.AccessControlEventDispatcher;
import org.apache.gravitino.listener.CatalogEventDispatcher;
+import org.apache.gravitino.listener.DomainEventDispatcher;
import org.apache.gravitino.listener.EventBus;
import org.apache.gravitino.listener.EventListenerManager;
import org.apache.gravitino.listener.FilesetEventDispatcher;
@@ -1222,8 +1223,9 @@ public class GravitinoEnv {
PolicyHookDispatcher policyHookDispatcher = new PolicyHookDispatcher(internalPolicyDispatcher);
this.policyDispatcher = new PolicyEventDispatcher(eventBus, policyHookDispatcher);
- // Domain audit events are added separately from lifecycle hooks.
- this.domainDispatcher = new DomainHookDispatcher(internalDomainDispatcher);
+ // Keep events outside lifecycle hooks so hook failures are audited as well.
+ this.domainDispatcher =
+ new DomainEventDispatcher(eventBus, new DomainHookDispatcher(internalDomainDispatcher));
}
private static final class MetadataOperations {
diff --git a/core/src/main/java/org/apache/gravitino/audit/AuditLog.java b/core/src/main/java/org/apache/gravitino/audit/AuditLog.java
index c74f8cdaec..1b7b63e2ab 100644
--- a/core/src/main/java/org/apache/gravitino/audit/AuditLog.java
+++ b/core/src/main/java/org/apache/gravitino/audit/AuditLog.java
@@ -111,6 +111,8 @@ import org.apache.gravitino.listener.api.event.RemovePolicyFromTagEvent;
import org.apache.gravitino.listener.api.event.RemovePolicyFromTagFailureEvent;
import org.apache.gravitino.listener.api.event.TestConnectionEvent;
import org.apache.gravitino.listener.api.event.TestConnectionFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.DomainEvent;
+import org.apache.gravitino.listener.api.event.domain.DomainFailureEvent;
import org.apache.gravitino.listener.api.event.semantic.AlterSemanticModelEvent;
import org.apache.gravitino.listener.api.event.semantic.AlterSemanticModelFailureEvent;
import org.apache.gravitino.listener.api.event.semantic.CreateSemanticModelEvent;
@@ -340,6 +342,51 @@ public interface AuditLog {
LIST_FILESET_FILES,
+ /** Domain operation: ListDomains. */
+ LIST_DOMAIN,
+
+ /** Domain operation: ListDomainsInfo. */
+ LIST_DOMAINS_INFO,
+
+ /** Domain operation: GetDomain. */
+ GET_DOMAIN,
+
+ /** Domain operation: CreateDomain. */
+ CREATE_DOMAIN,
+
+ /** Domain operation: AlterDomain. */
+ ALTER_DOMAIN,
+
+ /** Domain operation: DeleteDomain. */
+ DELETE_DOMAIN,
+
+ /** Domain operation: PublishDomain. */
+ PUBLISH_DOMAIN,
+
+ /** Domain operation: UnpublishDomain. */
+ UNPUBLISH_DOMAIN,
+
+ /** Domain operation: UpdateDomainBackingTag. */
+ UPDATE_DOMAIN_BACKING_TAG,
+
+ /** Domain operation: AttachDomain. */
+ ATTACH_DOMAIN,
+
+ /** Domain operation: DetachDomain. */
+ DETACH_DOMAIN,
+
+ /** Domain operation: ListSubdomains. */
+ LIST_SUBDOMAINS,
+
+ /** Domain operation: ListSubdomainsInfo. */
+ LIST_SUBDOMAINS_INFO,
+
+ /** Domain operation: ListDomainMembers. */
+ LIST_DOMAIN_MEMBERS,
+
+ /** Domain operation: ListDomainsForMetadataObject. */
+ LIST_DOMAINS_FOR_METADATA_OBJECT,
+
CREATE_TAG,
GET_TAG,
@@ -571,6 +618,13 @@ public interface AuditLog {
UNKNOWN_OPERATION;
public static Operation fromEvent(Event event) {
+ if (event instanceof DomainEvent || event instanceof DomainFailureEvent) {
+ try {
+ return Operation.valueOf(event.operationType().name());
+ } catch (IllegalArgumentException e) {
+ return UNKNOWN_OPERATION;
+ }
+ }
if (event instanceof CreateMetalakeEvent || event instanceof CreateMetalakeFailureEvent) {
return CREATE_METALAKE;
} else if (event instanceof AlterMetalakeEvent
diff --git a/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java b/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java
index 8a5fa5ece0..c075503f36 100644
--- a/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java
+++ b/core/src/main/java/org/apache/gravitino/audit/v2/CompatibilityUtils.java
@@ -29,6 +29,23 @@ public class CompatibilityUtils {
private static final ImmutableMap<OperationType, Operation> OPERATION_TYPE_MAP =
ImmutableMap.<OperationType, Operation>builder()
+ .put(OperationType.LIST_DOMAIN, Operation.LIST_DOMAIN)
+ .put(OperationType.LIST_DOMAINS_INFO, Operation.LIST_DOMAINS_INFO)
+ .put(OperationType.GET_DOMAIN, Operation.GET_DOMAIN)
+ .put(OperationType.CREATE_DOMAIN, Operation.CREATE_DOMAIN)
+ .put(OperationType.ALTER_DOMAIN, Operation.ALTER_DOMAIN)
+ .put(OperationType.DELETE_DOMAIN, Operation.DELETE_DOMAIN)
+ .put(OperationType.PUBLISH_DOMAIN, Operation.PUBLISH_DOMAIN)
+ .put(OperationType.UNPUBLISH_DOMAIN, Operation.UNPUBLISH_DOMAIN)
+ .put(OperationType.UPDATE_DOMAIN_BACKING_TAG, Operation.UPDATE_DOMAIN_BACKING_TAG)
+ .put(OperationType.ATTACH_DOMAIN, Operation.ATTACH_DOMAIN)
+ .put(OperationType.DETACH_DOMAIN, Operation.DETACH_DOMAIN)
+ .put(OperationType.LIST_SUBDOMAINS, Operation.LIST_SUBDOMAINS)
+ .put(OperationType.LIST_SUBDOMAINS_INFO, Operation.LIST_SUBDOMAINS_INFO)
+ .put(OperationType.LIST_DOMAIN_MEMBERS, Operation.LIST_DOMAIN_MEMBERS)
+ .put(
+ OperationType.LIST_DOMAINS_FOR_METADATA_OBJECT,
+ Operation.LIST_DOMAINS_FOR_METADATA_OBJECT)
.put(OperationType.CREATE_METALAKE, Operation.CREATE_METALAKE)
.put(OperationType.ALTER_METALAKE, Operation.ALTER_METALAKE)
.put(OperationType.DROP_METALAKE, Operation.DROP_METALAKE)
diff --git a/core/src/main/java/org/apache/gravitino/listener/DomainEventDispatcher.java b/core/src/main/java/org/apache/gravitino/listener/DomainEventDispatcher.java
new file mode 100644
index 0000000000..360b10ffbb
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/DomainEventDispatcher.java
@@ -0,0 +1,419 @@
+/*
+ * 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;
+
+import java.util.Map;
+import java.util.function.Consumer;
+import javax.annotation.Nullable;
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.SupportsDomainOperations.LockedDomainState;
+import org.apache.gravitino.domain.Domain;
+import org.apache.gravitino.domain.DomainChange;
+import org.apache.gravitino.domain.DomainDispatcher;
+import org.apache.gravitino.domain.DomainMember;
+import org.apache.gravitino.domain.DomainMemberFilter;
+import org.apache.gravitino.listener.api.event.domain.AlterDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.AlterDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.AlterDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.AttachDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.AttachDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.AttachDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.CreateDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.CreateDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.CreateDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.DeleteDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.DeleteDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.DeleteDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.DetachDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.DetachDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.DetachDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.GetDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.GetDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.GetDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainMembersEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainMembersFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainMembersPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsForMetadataObjectEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsForMetadataObjectFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsForMetadataObjectPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsInfoEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsInfoFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsInfoPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsInfoEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsInfoFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsInfoPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsPreEvent;
+import org.apache.gravitino.listener.api.event.domain.PublishDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.PublishDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.PublishDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.UnpublishDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.UnpublishDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.UnpublishDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.UpdateDomainBackingTagEvent;
+import org.apache.gravitino.listener.api.event.domain.UpdateDomainBackingTagFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.UpdateDomainBackingTagPreEvent;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.meta.DomainEntity;
+import org.apache.gravitino.tag.TagValue;
+import org.apache.gravitino.utils.PrincipalUtils;
+
+/**
+ * Dispatches domain events around the existing hook/manager chain.
+ *
+ * <p>Events describe dispatcher operations. REST visibility and member-access filtering remain at
+ * the server boundary, so list counts describe dispatcher results, not necessarily HTTP results.
+ * Internal storage and authorization lookups use the undecorated internal dispatcher.
+ */
+public final class DomainEventDispatcher implements DomainDispatcher {
+ private final EventBus eventBus;
+ private final DomainDispatcher dispatcher;
+
+ /**
+ * Creates the domain event decorator.
+ *
+ * @param eventBus The existing event bus.
+ * @param dispatcher The domain hook/manager chain.
+ */
+ public DomainEventDispatcher(EventBus eventBus, DomainDispatcher dispatcher) {
+ this.eventBus = eventBus;
+ this.dispatcher = dispatcher;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainDispatcher withMutationCheck(Consumer<LockedDomainState> check) {
+ return new DomainEventDispatcher(eventBus, dispatcher.withMutationCheck(check));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String[] listDomains(String metalake) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new ListDomainsPreEvent(user, metalake));
+ try {
+ String[] result = dispatcher.listDomains(metalake);
+ eventBus.dispatchEvent(
+ new ListDomainsEvent(user, metalake, result == null ? -1 : result.length));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new ListDomainsFailureEvent(user, metalake, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity[] listDomainInfos(String metalake) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new ListDomainsInfoPreEvent(user, metalake));
+ try {
+ DomainEntity[] result = dispatcher.listDomainInfos(metalake);
+ eventBus.dispatchEvent(
+ new ListDomainsInfoEvent(user, metalake, result == null ? -1 : result.length));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new ListDomainsInfoFailureEvent(user, metalake, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity getDomain(String metalake, String name) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new GetDomainPreEvent(user, metalake, name));
+ try {
+ DomainEntity result = dispatcher.getDomain(metalake, name);
+ eventBus.dispatchEvent(new GetDomainEvent(user, metalake, name, domainInfo(result)));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new GetDomainFailureEvent(user, metalake, name, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity createDomain(
+ String metalake,
+ String name,
+ @Nullable String comment,
+ @Nullable Map<String, String> properties,
+ TagValue backingTag,
+ boolean createBackingTag) {
+ String user = PrincipalUtils.getCurrentUserName();
+ DomainInfo requested =
+ new DomainInfo(name, comment, properties, Domain.Status.DRAFT, null, backingTag, null);
+ eventBus.dispatchEvent(
+ new CreateDomainPreEvent(user, metalake, name, requested, createBackingTag));
+ try {
+ DomainEntity result =
+ dispatcher.createDomain(
+ metalake, name, comment, properties, backingTag, createBackingTag);
+ eventBus.dispatchEvent(
+ new CreateDomainEvent(user, metalake, name, domainInfo(result), createBackingTag));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new CreateDomainFailureEvent(user, metalake, name, requested, createBackingTag, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity createSubdomain(
+ String metalake,
+ String parent,
+ String name,
+ @Nullable String comment,
+ @Nullable Map<String, String> properties,
+ TagValue backingTag,
+ boolean createBackingTag) {
+ String user = PrincipalUtils.getCurrentUserName();
+ DomainInfo requested =
+ new DomainInfo(name, comment, properties, Domain.Status.DRAFT, parent, backingTag, null);
+ eventBus.dispatchEvent(
+ new CreateDomainPreEvent(user, metalake, name, requested, createBackingTag));
+ try {
+ DomainEntity result =
+ dispatcher.createSubdomain(
+ metalake, parent, name, comment, properties, backingTag, createBackingTag);
+ eventBus.dispatchEvent(
+ new CreateDomainEvent(user, metalake, name, domainInfo(result), createBackingTag));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new CreateDomainFailureEvent(user, metalake, name, requested, createBackingTag, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity alterDomain(String metalake, String name, DomainChange... changes) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new AlterDomainPreEvent(user, metalake, name, changes));
+ try {
+ DomainEntity result = dispatcher.alterDomain(metalake, name, changes);
+ eventBus.dispatchEvent(
+ new AlterDomainEvent(user, metalake, name, changes, domainInfo(result)));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new AlterDomainFailureEvent(user, metalake, name, changes, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public boolean deleteDomain(String metalake, String name) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new DeleteDomainPreEvent(user, metalake, name));
+ try {
+ boolean result = dispatcher.deleteDomain(metalake, name);
+ eventBus.dispatchEvent(new DeleteDomainEvent(user, metalake, name, result));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new DeleteDomainFailureEvent(user, metalake, name, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity publishDomain(String metalake, String name) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new PublishDomainPreEvent(user, metalake, name));
+ try {
+ DomainEntity result = dispatcher.publishDomain(metalake, name);
+ eventBus.dispatchEvent(new PublishDomainEvent(user, metalake, name, domainInfo(result)));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new PublishDomainFailureEvent(user, metalake, name, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity unpublishDomain(String metalake, String name) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new UnpublishDomainPreEvent(user, metalake, name));
+ try {
+ DomainEntity result = dispatcher.unpublishDomain(metalake, name);
+ eventBus.dispatchEvent(new UnpublishDomainEvent(user, metalake, name, domainInfo(result)));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new UnpublishDomainFailureEvent(user, metalake, name, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity detachDomain(String metalake, String name) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new DetachDomainPreEvent(user, metalake, name));
+ try {
+ DomainEntity result = dispatcher.detachDomain(metalake, name);
+ eventBus.dispatchEvent(new DetachDomainEvent(user, metalake, name, domainInfo(result)));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new DetachDomainFailureEvent(user, metalake, name, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity attachDomain(String metalake, String name, String parent) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new AttachDomainPreEvent(user, metalake, name, parent));
+ try {
+ DomainEntity result = dispatcher.attachDomain(metalake, name, parent);
+ eventBus.dispatchEvent(
+ new AttachDomainEvent(user, metalake, name, parent, domainInfo(result)));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new AttachDomainFailureEvent(user, metalake, name, parent, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity updateBackingTag(
+ String metalake, String name, @Nullable TagValue backingTag) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new UpdateDomainBackingTagPreEvent(user, metalake, name, backingTag));
+ try {
+ DomainEntity result = dispatcher.updateBackingTag(metalake, name, backingTag);
+ eventBus.dispatchEvent(
+ new UpdateDomainBackingTagEvent(user, metalake, name, backingTag, domainInfo(result)));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new UpdateDomainBackingTagFailureEvent(user, metalake, name, backingTag, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String[] listSubdomains(String metalake, String name) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new ListSubdomainsPreEvent(user, metalake, name));
+ try {
+ String[] result = dispatcher.listSubdomains(metalake, name);
+ eventBus.dispatchEvent(
+ new ListSubdomainsEvent(user, metalake, name, result == null ? -1 : result.length));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new ListSubdomainsFailureEvent(user, metalake, name, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity[] listSubdomainInfos(String metalake, String name) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new ListSubdomainsInfoPreEvent(user, metalake, name));
+ try {
+ DomainEntity[] result = dispatcher.listSubdomainInfos(metalake, name);
+ eventBus.dispatchEvent(
+ new ListSubdomainsInfoEvent(user, metalake, name, result == null ? -1 : result.length));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new ListSubdomainsInfoFailureEvent(user, metalake, name, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainMember[] listMembers(String metalake, String name, DomainMemberFilter filter) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new ListDomainMembersPreEvent(user, metalake, name, filter));
+ try {
+ DomainMember[] result = dispatcher.listMembers(metalake, name, filter);
+ eventBus.dispatchEvent(
+ new ListDomainMembersEvent(
+ user, metalake, name, filter, result == null ? -1 : result.length));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(new ListDomainMembersFailureEvent(user, metalake, name, filter, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainMember[] listMembers(
+ String metalake, DomainEntity domain, DomainEntity[] subdomains, DomainMemberFilter filter) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new ListDomainMembersPreEvent(user, metalake, domain.name(), filter));
+ try {
+ DomainMember[] result = dispatcher.listMembers(metalake, domain, subdomains, filter);
+ eventBus.dispatchEvent(
+ new ListDomainMembersEvent(
+ user, metalake, domain.name(), filter, result == null ? -1 : result.length));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new ListDomainMembersFailureEvent(user, metalake, domain.name(), filter, e));
+ throw e;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public DomainEntity[] listDomainsForMetadataObject(String metalake, MetadataObject object) {
+ String user = PrincipalUtils.getCurrentUserName();
+ eventBus.dispatchEvent(new ListDomainsForMetadataObjectPreEvent(user, metalake, object));
+ try {
+ DomainEntity[] result = dispatcher.listDomainsForMetadataObject(metalake, object);
+ eventBus.dispatchEvent(
+ new ListDomainsForMetadataObjectEvent(
+ user, metalake, object, result == null ? -1 : result.length));
+ return result;
+ } catch (Exception e) {
+ eventBus.dispatchEvent(
+ new ListDomainsForMetadataObjectFailureEvent(user, metalake, object, e));
+ throw e;
+ }
+ }
+
+ private static DomainInfo domainInfo(DomainEntity domain) {
+ return new DomainInfo(
+ domain.name(),
+ domain.comment(),
+ domain.properties(),
+ domain.status(),
+ domain.parent().orElse(null),
+ domain.backingTag().orElse(null),
+ domain.auditInfo());
+ }
+}
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 9e4e16d60e..87b312b506 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
@@ -35,6 +35,38 @@ public enum OperationType {
TABLE_EXISTS,
REPORT_TABLE_METRICS,
+ // Domain operations
+ /** Domain operation: ListDomains. */
+ LIST_DOMAIN,
+ /** Domain operation: ListDomainsInfo. */
+ LIST_DOMAINS_INFO,
+ /** Domain operation: GetDomain. */
+ GET_DOMAIN,
+ /** Domain operation: CreateDomain. */
+ CREATE_DOMAIN,
+ /** Domain operation: AlterDomain. */
+ ALTER_DOMAIN,
+ /** Domain operation: DeleteDomain. */
+ DELETE_DOMAIN,
+ /** Domain operation: PublishDomain. */
+ PUBLISH_DOMAIN,
+ /** Domain operation: UnpublishDomain. */
+ UNPUBLISH_DOMAIN,
+ /** Domain operation: UpdateDomainBackingTag. */
+ UPDATE_DOMAIN_BACKING_TAG,
+ /** Domain operation: AttachDomain. */
+ ATTACH_DOMAIN,
+ /** Domain operation: DetachDomain. */
+ DETACH_DOMAIN,
+ /** Domain operation: ListSubdomains. */
+ LIST_SUBDOMAINS,
+ /** Domain operation: ListSubdomainsInfo. */
+ LIST_SUBDOMAINS_INFO,
+ /** Domain operation: ListDomainMembers. */
+ LIST_DOMAIN_MEMBERS,
+ /** Domain operation: ListDomainsForMetadataObject. */
+ LIST_DOMAINS_FOR_METADATA_OBJECT,
+
// Tag operations
CREATE_TAG,
GET_TAG,
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainEvent.java
new file mode 100644
index 0000000000..343d7210d6
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainEvent.java
@@ -0,0 +1,68 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.domain.DomainChange;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for AlterDomain. */
+@DeveloperApi
+public final class AlterDomainEvent extends DomainEvent {
+ private final DomainChange[] changes;
+ private final DomainInfo domainInfo;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param changes The requested domain changes.
+ * @param domainInfo The requested or returned domain snapshot.
+ */
+ public AlterDomainEvent(
+ String user, String metalake, String name, DomainChange[] changes, DomainInfo domainInfo) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.changes = changes == null ? null : changes.clone();
+ this.domainInfo = domainInfo;
+ }
+
+ /**
+ * @return The requested domain changes.
+ */
+ public DomainChange[] changes() {
+ return changes == null ? null : changes.clone();
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.ALTER_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainFailureEvent.java
new file mode 100644
index 0000000000..0ee5c39f3b
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainFailureEvent.java
@@ -0,0 +1,58 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.domain.DomainChange;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for AlterDomain. */
+@DeveloperApi
+public final class AlterDomainFailureEvent extends DomainFailureEvent {
+ private final DomainChange[] changes;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param changes The requested domain changes.
+ * @param exception The operation failure.
+ */
+ public AlterDomainFailureEvent(
+ String user, String metalake, String name, DomainChange[] changes, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ this.changes = changes == null ? null : changes.clone();
+ }
+
+ /**
+ * @return The requested domain changes.
+ */
+ public DomainChange[] changes() {
+ return changes == null ? null : changes.clone();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.ALTER_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainPreEvent.java
new file mode 100644
index 0000000000..8570682ad8
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AlterDomainPreEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.domain.DomainChange;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for AlterDomain. */
+@DeveloperApi
+public final class AlterDomainPreEvent extends DomainPreEvent {
+ private final DomainChange[] changes;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param changes The requested domain changes.
+ */
+ public AlterDomainPreEvent(String user, String metalake, String name, DomainChange[] changes) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.changes = changes == null ? null : changes.clone();
+ }
+
+ /**
+ * @return The requested domain changes.
+ */
+ public DomainChange[] changes() {
+ return changes == null ? null : changes.clone();
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.ALTER_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainEvent.java
new file mode 100644
index 0000000000..d62ed5659e
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainEvent.java
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.listener.api.event.domain;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for AttachDomain. */
+@DeveloperApi
+public final class AttachDomainEvent extends DomainEvent {
+ private final String parent;
+ private final DomainInfo domainInfo;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param parent The requested parent name.
+ * @param domainInfo The requested or returned domain snapshot.
+ */
+ public AttachDomainEvent(
+ String user, String metalake, String name, String parent, DomainInfo domainInfo) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.parent = parent;
+ this.domainInfo = domainInfo;
+ }
+
+ /**
+ * @return The requested parent name.
+ */
+ public String parent() {
+ return parent;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected Map<String, String> ownCustomInfo() {
+ return ImmutableMap.of("parent", parent);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.ATTACH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainFailureEvent.java
new file mode 100644
index 0000000000..d3d9072508
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainFailureEvent.java
@@ -0,0 +1,65 @@
+/*
+ * 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.domain;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for AttachDomain. */
+@DeveloperApi
+public final class AttachDomainFailureEvent extends DomainFailureEvent {
+ private final String parent;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param parent The requested parent name.
+ * @param exception The operation failure.
+ */
+ public AttachDomainFailureEvent(
+ String user, String metalake, String name, String parent, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ this.parent = parent;
+ }
+
+ /**
+ * @return The requested parent name.
+ */
+ public String parent() {
+ return parent;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ protected Map<String, String> ownCustomInfo() {
+ return ImmutableMap.of("parent", parent);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.ATTACH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainPreEvent.java
new file mode 100644
index 0000000000..cc9bee7e6f
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/AttachDomainPreEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for AttachDomain. */
+@DeveloperApi
+public final class AttachDomainPreEvent extends DomainPreEvent {
+ private final String parent;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param parent The requested parent name.
+ */
+ public AttachDomainPreEvent(String user, String metalake, String name, String parent) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.parent = parent;
+ }
+
+ /**
+ * @return The requested parent name.
+ */
+ public String parent() {
+ return parent;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.ATTACH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainEvent.java
new file mode 100644
index 0000000000..2001038af4
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for CreateDomain. */
+@DeveloperApi
+public final class CreateDomainEvent extends DomainEvent {
+ private final DomainInfo domainInfo;
+ private final boolean createBackingTag;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param domainInfo The requested or returned domain snapshot.
+ * @param createBackingTag Whether a new backing tag is requested.
+ */
+ public CreateDomainEvent(
+ String user, String metalake, String name, DomainInfo domainInfo, boolean createBackingTag) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.domainInfo = domainInfo;
+ this.createBackingTag = createBackingTag;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /**
+ * @return Whether a new backing tag is requested.
+ */
+ public boolean createBackingTag() {
+ return createBackingTag;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.CREATE_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainFailureEvent.java
new file mode 100644
index 0000000000..5108237891
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainFailureEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for CreateDomain. */
+@DeveloperApi
+public final class CreateDomainFailureEvent extends DomainFailureEvent {
+ private final DomainInfo domainInfo;
+ private final boolean createBackingTag;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param domainInfo The requested or returned domain snapshot.
+ * @param createBackingTag Whether a new backing tag is requested.
+ * @param exception The operation failure.
+ */
+ public CreateDomainFailureEvent(
+ String user,
+ String metalake,
+ String name,
+ DomainInfo domainInfo,
+ boolean createBackingTag,
+ Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ this.domainInfo = domainInfo;
+ this.createBackingTag = createBackingTag;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /**
+ * @return Whether a new backing tag is requested.
+ */
+ public boolean createBackingTag() {
+ return createBackingTag;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.CREATE_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainPreEvent.java
new file mode 100644
index 0000000000..ec0cd39251
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/CreateDomainPreEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for CreateDomain. */
+@DeveloperApi
+public final class CreateDomainPreEvent extends DomainPreEvent {
+ private final DomainInfo domainInfo;
+ private final boolean createBackingTag;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param domainInfo The requested or returned domain snapshot.
+ * @param createBackingTag Whether a new backing tag is requested.
+ */
+ public CreateDomainPreEvent(
+ String user, String metalake, String name, DomainInfo domainInfo, boolean createBackingTag) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.domainInfo = domainInfo;
+ this.createBackingTag = createBackingTag;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /**
+ * @return Whether a new backing tag is requested.
+ */
+ public boolean createBackingTag() {
+ return createBackingTag;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.CREATE_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainEvent.java
new file mode 100644
index 0000000000..10634ca22d
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for DeleteDomain. */
+@DeveloperApi
+public final class DeleteDomainEvent extends DomainEvent {
+ private final boolean deleted;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param deleted Whether the domain existed and was deleted.
+ */
+ public DeleteDomainEvent(String user, String metalake, String name, boolean deleted) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.deleted = deleted;
+ }
+
+ /**
+ * @return Whether the domain existed and was deleted.
+ */
+ public boolean deleted() {
+ return deleted;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.DELETE_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainFailureEvent.java
new file mode 100644
index 0000000000..4f551f85f3
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainFailureEvent.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for DeleteDomain. */
+@DeveloperApi
+public final class DeleteDomainFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param exception The operation failure.
+ */
+ public DeleteDomainFailureEvent(String user, String metalake, String name, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.DELETE_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainPreEvent.java
new file mode 100644
index 0000000000..b2b7defbc6
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DeleteDomainPreEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for DeleteDomain. */
+@DeveloperApi
+public final class DeleteDomainPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ */
+ public DeleteDomainPreEvent(String user, String metalake, String name) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.DELETE_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainEvent.java
new file mode 100644
index 0000000000..1e6277e838
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for DetachDomain. */
+@DeveloperApi
+public final class DetachDomainEvent extends DomainEvent {
+ private final DomainInfo domainInfo;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param domainInfo The requested or returned domain snapshot.
+ */
+ public DetachDomainEvent(String user, String metalake, String name, DomainInfo domainInfo) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.domainInfo = domainInfo;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.DETACH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainFailureEvent.java
new file mode 100644
index 0000000000..70a8430ba2
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainFailureEvent.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for DetachDomain. */
+@DeveloperApi
+public final class DetachDomainFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param exception The operation failure.
+ */
+ public DetachDomainFailureEvent(String user, String metalake, String name, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.DETACH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainPreEvent.java
new file mode 100644
index 0000000000..95f1361ad4
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DetachDomainPreEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for DetachDomain. */
+@DeveloperApi
+public final class DetachDomainPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ */
+ public DetachDomainPreEvent(String user, String metalake, String name) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.DETACH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainEvent.java
new file mode 100644
index 0000000000..fb72558926
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainEvent.java
@@ -0,0 +1,44 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.Event;
+import org.apache.gravitino.listener.api.event.OperationStatus;
+
+/** Base class for domain success events. */
+@DeveloperApi
+public abstract class DomainEvent extends Event {
+ /**
+ * Creates a domain event.
+ *
+ * @param user The initiating user.
+ * @param identifier The domain, metalake or leaf object identifier.
+ */
+ protected DomainEvent(String user, NameIdentifier identifier) {
+ super(user, identifier);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationStatus operationStatus() {
+ return OperationStatus.SUCCESS;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainFailureEvent.java
new file mode 100644
index 0000000000..dd7c7e8f1c
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainFailureEvent.java
@@ -0,0 +1,38 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.FailureEvent;
+
+/** Base class for domain failure events. */
+@DeveloperApi
+public abstract class DomainFailureEvent extends FailureEvent {
+ /**
+ * Creates a domain event.
+ *
+ * @param user The initiating user.
+ * @param identifier The domain, metalake or leaf object identifier.
+ * @param exception The operation failure.
+ */
+ protected DomainFailureEvent(String user, NameIdentifier identifier, Exception exception) {
+ super(user, identifier, exception);
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainPreEvent.java
new file mode 100644
index 0000000000..c942f1fc39
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/DomainPreEvent.java
@@ -0,0 +1,37 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.PreEvent;
+
+/** Base class for domain pre events. */
+@DeveloperApi
+public abstract class DomainPreEvent extends PreEvent {
+ /**
+ * Creates a domain event.
+ *
+ * @param user The initiating user.
+ * @param identifier The domain, metalake or leaf object identifier.
+ */
+ protected DomainPreEvent(String user, NameIdentifier identifier) {
+ super(user, identifier);
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainEvent.java
new file mode 100644
index 0000000000..81f9bbe5c8
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for GetDomain. */
+@DeveloperApi
+public final class GetDomainEvent extends DomainEvent {
+ private final DomainInfo domainInfo;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param domainInfo The requested or returned domain snapshot.
+ */
+ public GetDomainEvent(String user, String metalake, String name, DomainInfo domainInfo) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.domainInfo = domainInfo;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.GET_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainFailureEvent.java
new file mode 100644
index 0000000000..1d7cbe467a
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainFailureEvent.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for GetDomain. */
+@DeveloperApi
+public final class GetDomainFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param exception The operation failure.
+ */
+ public GetDomainFailureEvent(String user, String metalake, String name, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.GET_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainPreEvent.java
new file mode 100644
index 0000000000..10701d6c96
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/GetDomainPreEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for GetDomain. */
+@DeveloperApi
+public final class GetDomainPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ */
+ public GetDomainPreEvent(String user, String metalake, String name) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.GET_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersEvent.java
new file mode 100644
index 0000000000..ab23523847
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersEvent.java
@@ -0,0 +1,71 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.domain.DomainMemberFilter;
+import org.apache.gravitino.listener.api.event.ListEvent;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for ListDomainMembers. */
+@DeveloperApi
+public final class ListDomainMembersEvent extends DomainEvent implements ListEvent {
+ private final DomainMemberFilter filter;
+ private final int resultCount;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param filter The member filter.
+ * @param resultCount The number of dispatcher results before REST authorization filtering, or -1
+ * if unavailable.
+ */
+ public ListDomainMembersEvent(
+ String user, String metalake, String name, DomainMemberFilter filter, int resultCount) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.filter = filter;
+ this.resultCount = resultCount;
+ }
+
+ /**
+ * @return The member filter.
+ */
+ public DomainMemberFilter filter() {
+ return filter;
+ }
+
+ /**
+ * @return The number of dispatcher results before REST authorization filtering, or -1 if
+ * unavailable.
+ */
+ @Override
+ public int resultCount() {
+ return resultCount;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAIN_MEMBERS;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersFailureEvent.java
new file mode 100644
index 0000000000..193926ea5c
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersFailureEvent.java
@@ -0,0 +1,58 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.domain.DomainMemberFilter;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for ListDomainMembers. */
+@DeveloperApi
+public final class ListDomainMembersFailureEvent extends DomainFailureEvent {
+ private final DomainMemberFilter filter;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param filter The member filter.
+ * @param exception The operation failure.
+ */
+ public ListDomainMembersFailureEvent(
+ String user, String metalake, String name, DomainMemberFilter filter, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ this.filter = filter;
+ }
+
+ /**
+ * @return The member filter.
+ */
+ public DomainMemberFilter filter() {
+ return filter;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAIN_MEMBERS;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersPreEvent.java
new file mode 100644
index 0000000000..38157baf02
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainMembersPreEvent.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.listener.api.event.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.domain.DomainMemberFilter;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for ListDomainMembers. */
+@DeveloperApi
+public final class ListDomainMembersPreEvent extends DomainPreEvent {
+ private final DomainMemberFilter filter;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param filter The member filter.
+ */
+ public ListDomainMembersPreEvent(
+ String user, String metalake, String name, DomainMemberFilter filter) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.filter = filter;
+ }
+
+ /**
+ * @return The member filter.
+ */
+ public DomainMemberFilter filter() {
+ return filter;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAIN_MEMBERS;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsEvent.java
new file mode 100644
index 0000000000..7eae7ca792
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsEvent.java
@@ -0,0 +1,58 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.ListEvent;
+import org.apache.gravitino.listener.api.event.OperationType;
+
+/** The success event for ListDomains. */
+@DeveloperApi
+public final class ListDomainsEvent extends DomainEvent implements ListEvent {
+ private final int resultCount;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param resultCount The number of dispatcher results before REST authorization filtering, or -1
+ * if unavailable.
+ */
+ public ListDomainsEvent(String user, String metalake, int resultCount) {
+ super(user, NameIdentifier.of(metalake));
+ this.resultCount = resultCount;
+ }
+
+ /**
+ * @return The number of dispatcher results before REST authorization filtering, or -1 if
+ * unavailable.
+ */
+ @Override
+ public int resultCount() {
+ return resultCount;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsFailureEvent.java
new file mode 100644
index 0000000000..79891e92ff
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsFailureEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+
+/** The failure event for ListDomains. */
+@DeveloperApi
+public final class ListDomainsFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param exception The operation failure.
+ */
+ public ListDomainsFailureEvent(String user, String metalake, Exception exception) {
+ super(user, NameIdentifier.of(metalake), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectEvent.java
new file mode 100644
index 0000000000..d8ac0c4f95
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectEvent.java
@@ -0,0 +1,70 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.ListEvent;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.MetadataObjectUtil;
+
+/** The success event for ListDomainsForMetadataObject. */
+@DeveloperApi
+public final class ListDomainsForMetadataObjectEvent extends DomainEvent implements ListEvent {
+ private final MetadataObject metadataObject;
+ private final int resultCount;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param metadataObject The leaf metadata object.
+ * @param resultCount The number of dispatcher results before REST authorization filtering, or -1
+ * if unavailable.
+ */
+ public ListDomainsForMetadataObjectEvent(
+ String user, String metalake, MetadataObject metadataObject, int resultCount) {
+ super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject));
+ this.metadataObject = metadataObject;
+ this.resultCount = resultCount;
+ }
+
+ /**
+ * @return The leaf metadata object.
+ */
+ public MetadataObject metadataObject() {
+ return metadataObject;
+ }
+
+ /**
+ * @return The number of dispatcher results before REST authorization filtering, or -1 if
+ * unavailable.
+ */
+ @Override
+ public int resultCount() {
+ return resultCount;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAINS_FOR_METADATA_OBJECT;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectFailureEvent.java
new file mode 100644
index 0000000000..ea759f3a4e
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectFailureEvent.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.listener.api.event.domain;
+
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.MetadataObjectUtil;
+
+/** The failure event for ListDomainsForMetadataObject. */
+@DeveloperApi
+public final class ListDomainsForMetadataObjectFailureEvent extends DomainFailureEvent {
+ private final MetadataObject metadataObject;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param metadataObject The leaf metadata object.
+ * @param exception The operation failure.
+ */
+ public ListDomainsForMetadataObjectFailureEvent(
+ String user, String metalake, MetadataObject metadataObject, Exception exception) {
+ super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject), exception);
+ this.metadataObject = metadataObject;
+ }
+
+ /**
+ * @return The leaf metadata object.
+ */
+ public MetadataObject metadataObject() {
+ return metadataObject;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAINS_FOR_METADATA_OBJECT;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectPreEvent.java
new file mode 100644
index 0000000000..27be8705e7
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsForMetadataObjectPreEvent.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.domain;
+
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.MetadataObjectUtil;
+
+/** The pre event for ListDomainsForMetadataObject. */
+@DeveloperApi
+public final class ListDomainsForMetadataObjectPreEvent extends DomainPreEvent {
+ private final MetadataObject metadataObject;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param metadataObject The leaf metadata object.
+ */
+ public ListDomainsForMetadataObjectPreEvent(
+ String user, String metalake, MetadataObject metadataObject) {
+ super(user, MetadataObjectUtil.toEntityIdent(metalake, metadataObject));
+ this.metadataObject = metadataObject;
+ }
+
+ /**
+ * @return The leaf metadata object.
+ */
+ public MetadataObject metadataObject() {
+ return metadataObject;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAINS_FOR_METADATA_OBJECT;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoEvent.java
new file mode 100644
index 0000000000..2f2a20962d
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoEvent.java
@@ -0,0 +1,58 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.ListEvent;
+import org.apache.gravitino.listener.api.event.OperationType;
+
+/** The success event for ListDomainsInfo. */
+@DeveloperApi
+public final class ListDomainsInfoEvent extends DomainEvent implements ListEvent {
+ private final int resultCount;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param resultCount The number of dispatcher results before REST authorization filtering, or -1
+ * if unavailable.
+ */
+ public ListDomainsInfoEvent(String user, String metalake, int resultCount) {
+ super(user, NameIdentifier.of(metalake));
+ this.resultCount = resultCount;
+ }
+
+ /**
+ * @return The number of dispatcher results before REST authorization filtering, or -1 if
+ * unavailable.
+ */
+ @Override
+ public int resultCount() {
+ return resultCount;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAINS_INFO;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoFailureEvent.java
new file mode 100644
index 0000000000..d7bf584919
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoFailureEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+
+/** The failure event for ListDomainsInfo. */
+@DeveloperApi
+public final class ListDomainsInfoFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param exception The operation failure.
+ */
+ public ListDomainsInfoFailureEvent(String user, String metalake, Exception exception) {
+ super(user, NameIdentifier.of(metalake), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAINS_INFO;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoPreEvent.java
new file mode 100644
index 0000000000..64d16ea396
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsInfoPreEvent.java
@@ -0,0 +1,44 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+
+/** The pre event for ListDomainsInfo. */
+@DeveloperApi
+public final class ListDomainsInfoPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ */
+ public ListDomainsInfoPreEvent(String user, String metalake) {
+ super(user, NameIdentifier.of(metalake));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAINS_INFO;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsPreEvent.java
new file mode 100644
index 0000000000..1203f82fff
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListDomainsPreEvent.java
@@ -0,0 +1,44 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+
+/** The pre event for ListDomains. */
+@DeveloperApi
+public final class ListDomainsPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ */
+ public ListDomainsPreEvent(String user, String metalake) {
+ super(user, NameIdentifier.of(metalake));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsEvent.java
new file mode 100644
index 0000000000..5f89bd75e5
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsEvent.java
@@ -0,0 +1,59 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.ListEvent;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for ListSubdomains. */
+@DeveloperApi
+public final class ListSubdomainsEvent extends DomainEvent implements ListEvent {
+ private final int resultCount;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param resultCount The number of dispatcher results before REST authorization filtering, or -1
+ * if unavailable.
+ */
+ public ListSubdomainsEvent(String user, String metalake, String name, int resultCount) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.resultCount = resultCount;
+ }
+
+ /**
+ * @return The number of dispatcher results before REST authorization filtering, or -1 if
+ * unavailable.
+ */
+ @Override
+ public int resultCount() {
+ return resultCount;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_SUBDOMAINS;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsFailureEvent.java
new file mode 100644
index 0000000000..915cfe36e6
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsFailureEvent.java
@@ -0,0 +1,47 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for ListSubdomains. */
+@DeveloperApi
+public final class ListSubdomainsFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param exception The operation failure.
+ */
+ public ListSubdomainsFailureEvent(
+ String user, String metalake, String name, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_SUBDOMAINS;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoEvent.java
new file mode 100644
index 0000000000..340339ed36
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoEvent.java
@@ -0,0 +1,59 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.ListEvent;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for ListSubdomainsInfo. */
+@DeveloperApi
+public final class ListSubdomainsInfoEvent extends DomainEvent implements ListEvent {
+ private final int resultCount;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param resultCount The number of dispatcher results before REST authorization filtering, or -1
+ * if unavailable.
+ */
+ public ListSubdomainsInfoEvent(String user, String metalake, String name, int resultCount) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.resultCount = resultCount;
+ }
+
+ /**
+ * @return The number of dispatcher results before REST authorization filtering, or -1 if
+ * unavailable.
+ */
+ @Override
+ public int resultCount() {
+ return resultCount;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_SUBDOMAINS_INFO;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoFailureEvent.java
new file mode 100644
index 0000000000..66db485f81
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoFailureEvent.java
@@ -0,0 +1,47 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for ListSubdomainsInfo. */
+@DeveloperApi
+public final class ListSubdomainsInfoFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param exception The operation failure.
+ */
+ public ListSubdomainsInfoFailureEvent(
+ String user, String metalake, String name, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_SUBDOMAINS_INFO;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoPreEvent.java
new file mode 100644
index 0000000000..d74a927987
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsInfoPreEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for ListSubdomainsInfo. */
+@DeveloperApi
+public final class ListSubdomainsInfoPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ */
+ public ListSubdomainsInfoPreEvent(String user, String metalake, String name) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_SUBDOMAINS_INFO;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsPreEvent.java
new file mode 100644
index 0000000000..708ffab37c
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/ListSubdomainsPreEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for ListSubdomains. */
+@DeveloperApi
+public final class ListSubdomainsPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ */
+ public ListSubdomainsPreEvent(String user, String metalake, String name) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.LIST_SUBDOMAINS;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainEvent.java
new file mode 100644
index 0000000000..74058ff66f
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for PublishDomain. */
+@DeveloperApi
+public final class PublishDomainEvent extends DomainEvent {
+ private final DomainInfo domainInfo;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param domainInfo The requested or returned domain snapshot.
+ */
+ public PublishDomainEvent(String user, String metalake, String name, DomainInfo domainInfo) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.domainInfo = domainInfo;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.PUBLISH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainFailureEvent.java
new file mode 100644
index 0000000000..8021eb57d8
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainFailureEvent.java
@@ -0,0 +1,46 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for PublishDomain. */
+@DeveloperApi
+public final class PublishDomainFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param exception The operation failure.
+ */
+ public PublishDomainFailureEvent(String user, String metalake, String name, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.PUBLISH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainPreEvent.java
new file mode 100644
index 0000000000..5f268e6550
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/PublishDomainPreEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for PublishDomain. */
+@DeveloperApi
+public final class PublishDomainPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ */
+ public PublishDomainPreEvent(String user, String metalake, String name) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.PUBLISH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainEvent.java
new file mode 100644
index 0000000000..3e9e8ac708
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainEvent.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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for UnpublishDomain. */
+@DeveloperApi
+public final class UnpublishDomainEvent extends DomainEvent {
+ private final DomainInfo domainInfo;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param domainInfo The requested or returned domain snapshot.
+ */
+ public UnpublishDomainEvent(String user, String metalake, String name, DomainInfo domainInfo) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.domainInfo = domainInfo;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.UNPUBLISH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainFailureEvent.java
new file mode 100644
index 0000000000..fb677f9037
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainFailureEvent.java
@@ -0,0 +1,47 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for UnpublishDomain. */
+@DeveloperApi
+public final class UnpublishDomainFailureEvent extends DomainFailureEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param exception The operation failure.
+ */
+ public UnpublishDomainFailureEvent(
+ String user, String metalake, String name, Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.UNPUBLISH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainPreEvent.java
new file mode 100644
index 0000000000..e6c33c5547
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UnpublishDomainPreEvent.java
@@ -0,0 +1,45 @@
+/*
+ * 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.domain;
+
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for UnpublishDomain. */
+@DeveloperApi
+public final class UnpublishDomainPreEvent extends DomainPreEvent {
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ */
+ public UnpublishDomainPreEvent(String user, String metalake, String name) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.UNPUBLISH_DOMAIN;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagEvent.java
new file mode 100644
index 0000000000..76512b34f1
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagEvent.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.domain;
+
+import javax.annotation.Nullable;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.tag.TagValue;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The success event for UpdateDomainBackingTag. */
+@DeveloperApi
+public final class UpdateDomainBackingTagEvent extends DomainEvent {
+ private final @Nullable TagValue backingTag;
+ private final DomainInfo domainInfo;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param backingTag The requested backing tag, or null to remove it.
+ * @param domainInfo The requested or returned domain snapshot.
+ */
+ public UpdateDomainBackingTagEvent(
+ String user,
+ String metalake,
+ String name,
+ @Nullable TagValue backingTag,
+ DomainInfo domainInfo) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.backingTag = backingTag;
+ this.domainInfo = domainInfo;
+ }
+
+ /**
+ * @return The requested backing tag, or null to remove it.
+ */
+ public @Nullable TagValue backingTag() {
+ return backingTag;
+ }
+
+ /**
+ * @return The requested or returned domain snapshot.
+ */
+ public DomainInfo domainInfo() {
+ return domainInfo;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.UPDATE_DOMAIN_BACKING_TAG;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagFailureEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagFailureEvent.java
new file mode 100644
index 0000000000..732380bbcd
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagFailureEvent.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.domain;
+
+import javax.annotation.Nullable;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.tag.TagValue;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The failure event for UpdateDomainBackingTag. */
+@DeveloperApi
+public final class UpdateDomainBackingTagFailureEvent extends DomainFailureEvent {
+ private final @Nullable TagValue backingTag;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param backingTag The requested backing tag, or null to remove it.
+ * @param exception The operation failure.
+ */
+ public UpdateDomainBackingTagFailureEvent(
+ String user,
+ String metalake,
+ String name,
+ @Nullable TagValue backingTag,
+ Exception exception) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name), exception);
+ this.backingTag = backingTag;
+ }
+
+ /**
+ * @return The requested backing tag, or null to remove it.
+ */
+ public @Nullable TagValue backingTag() {
+ return backingTag;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.UPDATE_DOMAIN_BACKING_TAG;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagPreEvent.java b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagPreEvent.java
new file mode 100644
index 0000000000..5af43543db
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/event/domain/UpdateDomainBackingTagPreEvent.java
@@ -0,0 +1,58 @@
+/*
+ * 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.domain;
+
+import javax.annotation.Nullable;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.tag.TagValue;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+
+/** The pre event for UpdateDomainBackingTag. */
+@DeveloperApi
+public final class UpdateDomainBackingTagPreEvent extends DomainPreEvent {
+ private final @Nullable TagValue backingTag;
+
+ /**
+ * Creates the event.
+ *
+ * @param user The initiating user.
+ * @param metalake The metalake name.
+ * @param name The domain name addressed by the operation.
+ * @param backingTag The requested backing tag, or null to remove it.
+ */
+ public UpdateDomainBackingTagPreEvent(
+ String user, String metalake, String name, @Nullable TagValue backingTag) {
+ super(user, NameIdentifierUtil.ofDomain(metalake, name));
+ this.backingTag = backingTag;
+ }
+
+ /**
+ * @return The requested backing tag, or null to remove it.
+ */
+ public @Nullable TagValue backingTag() {
+ return backingTag;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public OperationType operationType() {
+ return OperationType.UPDATE_DOMAIN_BACKING_TAG;
+ }
+}
diff --git a/core/src/main/java/org/apache/gravitino/listener/api/info/DomainInfo.java b/core/src/main/java/org/apache/gravitino/listener/api/info/DomainInfo.java
new file mode 100644
index 0000000000..bffa67e740
--- /dev/null
+++ b/core/src/main/java/org/apache/gravitino/listener/api/info/DomainInfo.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.gravitino.listener.api.info;
+
+import com.google.common.collect.ImmutableMap;
+import java.util.Map;
+import java.util.Optional;
+import javax.annotation.Nullable;
+import org.apache.gravitino.Audit;
+import org.apache.gravitino.annotation.DeveloperApi;
+import org.apache.gravitino.domain.Domain;
+import org.apache.gravitino.tag.TagValue;
+
+/** A domain snapshot for event listeners, without storage identifiers. */
+@DeveloperApi
+public final class DomainInfo {
+ private final String name;
+ @Nullable private final String comment;
+ private final Map<String, String> properties;
+ private final Domain.Status status;
+ @Nullable private final String parent;
+ @Nullable private final TagValue backingTag;
+ @Nullable private final Audit audit;
+
+ /**
+ * Creates domain information for a request or result.
+ *
+ * @param name The domain name.
+ * @param comment The optional comment.
+ * @param properties The properties, or null for none.
+ * @param status The domain status.
+ * @param parent The parent name, or null for a top-level domain.
+ * @param backingTag The backing tag, or null if unbound.
+ * @param audit The audit information, or null for a creation request.
+ */
+ public DomainInfo(
+ String name,
+ @Nullable String comment,
+ @Nullable Map<String, String> properties,
+ Domain.Status status,
+ @Nullable String parent,
+ @Nullable TagValue backingTag,
+ @Nullable Audit audit) {
+ this.name = name;
+ this.comment = comment;
+ this.properties = properties == null ? ImmutableMap.of() : ImmutableMap.copyOf(properties);
+ this.status = status;
+ this.parent = parent;
+ this.backingTag = backingTag;
+ this.audit = audit;
+ }
+ /**
+ * @return The domain name.
+ */
+ public String name() {
+ return name;
+ }
+ /**
+ * @return The optional comment.
+ */
+ @Nullable
+ public String comment() {
+ return comment;
+ }
+ /**
+ * @return The immutable properties.
+ */
+ public Map<String, String> properties() {
+ return properties;
+ }
+ /**
+ * @return The visibility status.
+ */
+ public Domain.Status status() {
+ return status;
+ }
+ /**
+ * @return The parent name, or empty for a top-level domain.
+ */
+ public Optional<String> parent() {
+ return Optional.ofNullable(parent);
+ }
+ /**
+ * @return The backing tag, or empty if unbound.
+ */
+ public Optional<TagValue> backingTag() {
+ return Optional.ofNullable(backingTag);
+ }
+ /**
+ * @return The audit information, or null for a creation request.
+ */
+ @Nullable
+ public Audit auditInfo() {
+ return audit;
+ }
+}
diff --git a/core/src/test/java/org/apache/gravitino/TestGravitinoEnvMetadataComponents.java b/core/src/test/java/org/apache/gravitino/TestGravitinoEnvMetadataComponents.java
index bf53ea4673..9ad559c6d3 100644
--- a/core/src/test/java/org/apache/gravitino/TestGravitinoEnvMetadataComponents.java
+++ b/core/src/test/java/org/apache/gravitino/TestGravitinoEnvMetadataComponents.java
@@ -66,6 +66,7 @@ import org.apache.gravitino.hook.SemanticModelHookDispatcher;
import org.apache.gravitino.hook.TableHookDispatcher;
import org.apache.gravitino.hook.TopicHookDispatcher;
import org.apache.gravitino.hook.ViewHookDispatcher;
+import org.apache.gravitino.listener.DomainEventDispatcher;
import org.apache.gravitino.listener.FilesetEventDispatcher;
import org.apache.gravitino.listener.FunctionEventDispatcher;
import org.apache.gravitino.listener.ModelEventDispatcher;
@@ -244,11 +245,16 @@ class TestGravitinoEnvMetadataComponents {
assertInstanceOf(DomainManager.class, env.internalDomainDispatcher());
assertDispatcherChain(
- env.domainDispatcher(), DomainHookDispatcher.class, DomainManager.class);
+ env.domainDispatcher(),
+ DomainEventDispatcher.class,
+ DomainHookDispatcher.class,
+ DomainManager.class);
assertSame(
env.internalDomainDispatcher(),
- FieldUtils.readField(env.domainDispatcher(), "dispatcher", true));
-
+ FieldUtils.readField(
+ FieldUtils.readField(env.domainDispatcher(), "dispatcher", true),
+ "dispatcher",
+ true));
assertDispatcherChain(
env.filesetDispatcher(),
FilesetEventDispatcher.class,
diff --git a/core/src/test/java/org/apache/gravitino/audit/TestDomainAudit.java b/core/src/test/java/org/apache/gravitino/audit/TestDomainAudit.java
new file mode 100644
index 0000000000..b65362c3b5
--- /dev/null
+++ b/core/src/test/java/org/apache/gravitino/audit/TestDomainAudit.java
@@ -0,0 +1,121 @@
+/*
+ * 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.audit;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.concurrent.TimeUnit;
+import org.apache.gravitino.Config;
+import org.apache.gravitino.Configs;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.audit.v2.SimpleFormatterV2;
+import org.apache.gravitino.domain.Domain;
+import org.apache.gravitino.domain.DomainDispatcher;
+import org.apache.gravitino.exceptions.NoSuchDomainException;
+import org.apache.gravitino.json.JsonUtils;
+import org.apache.gravitino.listener.DomainEventDispatcher;
+import org.apache.gravitino.listener.EventListenerManager;
+import org.apache.gravitino.listener.api.event.Event;
+import org.apache.gravitino.listener.api.event.domain.AttachDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.AttachDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.DomainEvent;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+import org.apache.gravitino.utils.RequestContext;
+import org.awaitility.Awaitility;
+import org.junit.jupiter.api.Test;
+
+class TestDomainAudit {
+ @Test
+ void testParentChangeAuditIncludesRequestedParent() throws Exception {
+ for (String parent : new String[] {"Finance", "Risk"}) {
+ DomainInfo info =
+ new DomainInfo(
+ "Trading", null, Collections.emptyMap(), Domain.Status.PUBLISHED, parent, null, null);
+ for (Event event :
+ Arrays.asList(
+ new AttachDomainEvent("user", "lake", "Trading", parent, info),
+ new AttachDomainFailureEvent(
+ "user",
+ "lake",
+ "Trading",
+ parent,
+ new IllegalArgumentException("parent change rejected")))) {
+ JsonNode json =
+ JsonUtils.objectMapper().readTree(new JsonAuditFormatter().format(event).toString());
+ assertEquals(parent, json.get("customInfo").get("parent").asText());
+ assertTrue(new SimpleFormatterV2().format(event).toString().contains("parent=" + parent));
+ }
+ }
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ void testCustomDomainEventWithoutKnownOperationRetainsUnknownFallback() {
+ DomainEvent event = new DomainEvent("user", NameIdentifier.of("lake")) {};
+ assertEquals(
+ AuditLog.Operation.UNKNOWN_OPERATION, new SimpleFormatter().format(event).operation());
+ assertEquals(
+ AuditLog.Operation.UNKNOWN_OPERATION, new SimpleFormatterV2().format(event).operation());
+ }
+
+ @Test
+ @SuppressWarnings("deprecation")
+ void testExistingAuditListenerWritesDomainSuccessAndFailure() {
+ Config config = new Config(false) {};
+ config.set(Configs.AUDIT_LOG_ENABLED_CONF, true);
+ config.set(Configs.AUDIT_LOG_WRITER_CLASS_NAME, DummyAuditWriter.class.getName());
+ config.set(Configs.AUDIT_LOG_FORMATTER_CLASS_NAME, DummyAuditFormatter.class.getName());
+ EventListenerManager listeners = new EventListenerManager();
+ listeners.init(Collections.emptyMap());
+ AuditLogManager audit = new AuditLogManager();
+ audit.init(config, listeners);
+ listeners.start();
+ try {
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ when(delegate.listDomains("lake")).thenReturn(new String[] {"Finance"});
+ when(delegate.getDomain("lake", "hidden")).thenThrow(new NoSuchDomainException("hidden"));
+ DomainEventDispatcher dispatcher =
+ new DomainEventDispatcher(listeners.createEventBus(), delegate);
+ dispatcher.listDomains("lake");
+ assertThrows(NoSuchDomainException.class, () -> dispatcher.getDomain("lake", "hidden"));
+ DummyAuditWriter writer = (DummyAuditWriter) audit.getAuditLogWriter();
+ Awaitility.await()
+ .atMost(10, TimeUnit.SECONDS)
+ .until(() -> writer.getAuditLogs().size() == 2);
+ assertEquals(AuditLog.Operation.LIST_DOMAIN, writer.getAuditLogs().get(0).operation());
+ assertEquals(AuditLog.Status.SUCCESS, writer.getAuditLogs().get(0).status());
+ assertEquals(AuditLog.Operation.GET_DOMAIN, writer.getAuditLogs().get(1).operation());
+ assertEquals(AuditLog.Status.FAILURE, writer.getAuditLogs().get(1).status());
+ assertEquals(
+ NameIdentifierUtil.ofDomain("lake", "hidden").toString(),
+ writer.getAuditLogs().get(1).identifier());
+ } finally {
+ listeners.stop();
+ RequestContext.clear();
+ }
+ }
+}
diff --git a/core/src/test/java/org/apache/gravitino/domain/TestDomainMembershipResolver.java b/core/src/test/java/org/apache/gravitino/domain/TestDomainMembershipResolver.java
index 709087d170..328e8fd858 100644
--- a/core/src/test/java/org/apache/gravitino/domain/TestDomainMembershipResolver.java
+++ b/core/src/test/java/org/apache/gravitino/domain/TestDomainMembershipResolver.java
@@ -32,6 +32,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import java.io.IOException;
@@ -43,8 +44,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.reflect.FieldUtils;
import org.apache.gravitino.Entity;
import org.apache.gravitino.EntityStore;
+import org.apache.gravitino.GravitinoEnv;
import org.apache.gravitino.MetadataObject;
import org.apache.gravitino.MetadataObjects;
import org.apache.gravitino.NameIdentifier;
@@ -52,6 +55,10 @@ import org.apache.gravitino.Namespace;
import org.apache.gravitino.RelationQuery;
import org.apache.gravitino.SupportsDomainOperations;
import org.apache.gravitino.SupportsRelationOperations;
+import org.apache.gravitino.catalog.CatalogManager;
+import org.apache.gravitino.catalog.CatalogTestUtils;
+import org.apache.gravitino.connector.BaseCatalog;
+import org.apache.gravitino.connector.capability.Capability;
import org.apache.gravitino.exceptions.NoSuchMetadataObjectException;
import org.apache.gravitino.meta.AuditInfo;
import org.apache.gravitino.meta.DomainEntity;
@@ -78,6 +85,7 @@ class TestDomainMembershipResolver {
private static final AuditInfo AUDIT =
AuditInfo.builder().withCreator("test").withCreateTime(Instant.EPOCH).build();
+ private CatalogManager previousCatalogManager;
private EntityStore store;
private SupportsRelationOperations relations;
private DomainMembershipResolver resolver;
@@ -88,6 +96,13 @@ class TestDomainMembershipResolver {
@BeforeEach
void setUp() throws Exception {
+ previousCatalogManager =
+ (CatalogManager) FieldUtils.readField(GravitinoEnv.getInstance(), "catalogManager", true);
+ CatalogManager catalogManager = mock(CatalogManager.class);
+ BaseCatalog<?> catalog = mock(BaseCatalog.class);
+ CatalogTestUtils.mockDoWithCatalog(catalogManager, catalog);
+ when(catalog.capability()).thenReturn(Capability.DEFAULT);
+ FieldUtils.writeField(GravitinoEnv.getInstance(), "catalogManager", catalogManager, true);
store = mock(EntityStore.class);
relations = mock(SupportsRelationOperations.class);
when(store.relationOperations()).thenReturn(relations);
@@ -117,7 +132,9 @@ class TestDomainMembershipResolver {
}
@AfterEach
- void tearDown() {
+ void tearDown() throws IllegalAccessException {
+ FieldUtils.writeField(
+ GravitinoEnv.getInstance(), "catalogManager", previousCatalogManager, true);
metadataObjects.close();
}
@@ -317,6 +334,15 @@ class TestDomainMembershipResolver {
}
}
+ @Test
+ void testUnknownScopesReturnEmptyWithoutEnumeratingMembers() {
+ DomainEntity finance = domain(1, "Finance", null, 10L, "finance");
+ DomainMemberFilter filter =
+ DomainMemberFilter.builder().withDomains("unknown", "Secret").build();
+ assertEquals(0, resolver.listMembers(METALAKE, finance, new DomainEntity[0], filter).length);
+ verifyNoInteractions(relations);
+ }
+
@Test
void testSupportedLeafTypesAndReverseRejections() {
DomainEntity domain = domain(1, "Finance", null, 10L, null);
diff --git a/core/src/test/java/org/apache/gravitino/listener/TestDomainEventDispatcher.java b/core/src/test/java/org/apache/gravitino/listener/TestDomainEventDispatcher.java
new file mode 100644
index 0000000000..1fb00bb7c5
--- /dev/null
+++ b/core/src/test/java/org/apache/gravitino/listener/TestDomainEventDispatcher.java
@@ -0,0 +1,661 @@
+/*
+ * 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;
+
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockingDetails;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoInteractions;
+import static org.mockito.Mockito.when;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import java.lang.reflect.Array;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import org.apache.gravitino.Audit;
+import org.apache.gravitino.MetadataObject;
+import org.apache.gravitino.MetadataObjects;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.SupportsDomainOperations.LockedDomainState;
+import org.apache.gravitino.audit.JsonAuditFormatter;
+import org.apache.gravitino.audit.SimpleFormatter;
+import org.apache.gravitino.audit.v2.SimpleFormatterV2;
+import org.apache.gravitino.domain.Domain;
+import org.apache.gravitino.domain.DomainChange;
+import org.apache.gravitino.domain.DomainDispatcher;
+import org.apache.gravitino.domain.DomainMember;
+import org.apache.gravitino.domain.DomainMemberFilter;
+import org.apache.gravitino.exceptions.ForbiddenException;
+import org.apache.gravitino.exceptions.NoSuchDomainException;
+import org.apache.gravitino.json.JsonUtils;
+import org.apache.gravitino.listener.api.EventListenerPlugin;
+import org.apache.gravitino.listener.api.event.BaseEvent;
+import org.apache.gravitino.listener.api.event.Event;
+import org.apache.gravitino.listener.api.event.EventSource;
+import org.apache.gravitino.listener.api.event.FailureEvent;
+import org.apache.gravitino.listener.api.event.ListEvent;
+import org.apache.gravitino.listener.api.event.OperationStatus;
+import org.apache.gravitino.listener.api.event.OperationType;
+import org.apache.gravitino.listener.api.event.PreEvent;
+import org.apache.gravitino.listener.api.event.domain.AlterDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.AlterDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.AlterDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.AttachDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.AttachDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.AttachDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.CreateDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.CreateDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.CreateDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.DeleteDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.DeleteDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.DeleteDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.DetachDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.DetachDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.DetachDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.GetDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.GetDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.GetDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainMembersEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainMembersFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainMembersPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsForMetadataObjectEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsForMetadataObjectFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsForMetadataObjectPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsInfoEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsInfoFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsInfoPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainsPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsInfoEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsInfoFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsInfoPreEvent;
+import org.apache.gravitino.listener.api.event.domain.ListSubdomainsPreEvent;
+import org.apache.gravitino.listener.api.event.domain.PublishDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.PublishDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.PublishDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.UnpublishDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.UnpublishDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.UnpublishDomainPreEvent;
+import org.apache.gravitino.listener.api.event.domain.UpdateDomainBackingTagEvent;
+import org.apache.gravitino.listener.api.event.domain.UpdateDomainBackingTagFailureEvent;
+import org.apache.gravitino.listener.api.event.domain.UpdateDomainBackingTagPreEvent;
+import org.apache.gravitino.listener.api.info.DomainInfo;
+import org.apache.gravitino.meta.AuditInfo;
+import org.apache.gravitino.meta.DomainEntity;
+import org.apache.gravitino.tag.TagValue;
+import org.apache.gravitino.utils.MetadataObjectUtil;
+import org.apache.gravitino.utils.NameIdentifierUtil;
+import org.apache.gravitino.utils.NamespaceUtil;
+import org.apache.gravitino.utils.PrincipalUtils;
+import org.apache.gravitino.utils.RequestContext;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+class TestDomainEventDispatcher {
+ private final String metalake = "lake/with spaces";
+ private final String name = "Finance.US/a b";
+ private final String parent = "Business.EU/parent";
+ private final TagValue backingTag = TagValue.of("department", "finance");
+ private final boolean createBackingTag = false;
+ private final String comment = "comment";
+ private final Map<String, String> properties = Collections.singletonMap("key", "value");
+ private final DomainChange[] changes = new DomainChange[] {DomainChange.rename("renamed")};
+ private final DomainMemberFilter filter =
+ DomainMemberFilter.builder()
+ .withDomains("Tax,EU", "Trading/US")
+ .withTypes(MetadataObject.Type.TABLE)
+ .withNameContains("a b&?")
+ .build();
+ private final MetadataObject object =
+ MetadataObjects.parse("cat.schema.table", MetadataObject.Type.TABLE);
+ private final DomainEntity domain =
+ DomainEntity.builder()
+ .withId(1L)
+ .withName(name)
+ .withNamespace(NamespaceUtil.ofDomain(metalake))
+ .withProperties(properties)
+ .withComment(comment)
+ .withStatus(Domain.Status.PUBLISHED)
+ .withParent(parent)
+ .withBackingTagId(2L)
+ .withBackingTagName(backingTag.name())
+ .withBackingTagValue(backingTag.value().orElse(null))
+ .withAuditInfo(
+ AuditInfo.builder().withCreator("tester").withCreateTime(Instant.now()).build())
+ .build();
+ private final DomainEntity[] subdomains = new DomainEntity[0];
+ private final List<BaseEvent> observed = new ArrayList<>();
+ private EventListenerPlugin listener;
+ private EventBus bus;
+
+ @BeforeEach
+ void setUp() {
+ listener = mock(EventListenerPlugin.class);
+ doAnswer(
+ invocation -> {
+ observed.add(invocation.getArgument(0));
+ return null;
+ })
+ .when(listener)
+ .onPreEvent(any());
+ doAnswer(
+ invocation -> {
+ observed.add(invocation.getArgument(0));
+ return null;
+ })
+ .when(listener)
+ .onPostEvent(any());
+ bus = new EventBus(Collections.singletonList(listener));
+ }
+
+ @AfterEach
+ void clearContext() {
+ RequestContext.clear();
+ }
+
+ @Test
+ void testListDomains() {
+ verifyOperation(
+ d -> d.listDomains(metalake),
+ new String[] {name},
+ ListDomainsPreEvent.class,
+ ListDomainsEvent.class,
+ ListDomainsFailureEvent.class,
+ OperationType.LIST_DOMAIN,
+ NameIdentifier.of(metalake));
+ }
+
+ @Test
+ void testListDomainInfos() {
+ verifyOperation(
+ d -> d.listDomainInfos(metalake),
+ new DomainEntity[] {domain},
+ ListDomainsInfoPreEvent.class,
+ ListDomainsInfoEvent.class,
+ ListDomainsInfoFailureEvent.class,
+ OperationType.LIST_DOMAINS_INFO,
+ NameIdentifier.of(metalake));
+ }
+
+ @Test
+ void testGetDomain() {
+ verifyOperation(
+ d -> d.getDomain(metalake, name),
+ domain,
+ GetDomainPreEvent.class,
+ GetDomainEvent.class,
+ GetDomainFailureEvent.class,
+ OperationType.GET_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testCreateDomain() {
+ verifyOperation(
+ d -> d.createDomain(metalake, name, comment, properties, backingTag, createBackingTag),
+ domain,
+ CreateDomainPreEvent.class,
+ CreateDomainEvent.class,
+ CreateDomainFailureEvent.class,
+ OperationType.CREATE_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testCreateSubdomain() {
+ verifyOperation(
+ d ->
+ d.createSubdomain(
+ metalake, parent, name, comment, properties, backingTag, createBackingTag),
+ domain,
+ CreateDomainPreEvent.class,
+ CreateDomainEvent.class,
+ CreateDomainFailureEvent.class,
+ OperationType.CREATE_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testAlterDomain() {
+ verifyOperation(
+ d -> d.alterDomain(metalake, name, changes),
+ domain,
+ AlterDomainPreEvent.class,
+ AlterDomainEvent.class,
+ AlterDomainFailureEvent.class,
+ OperationType.ALTER_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testDeleteDomain() {
+ verifyOperation(
+ d -> d.deleteDomain(metalake, name),
+ true,
+ DeleteDomainPreEvent.class,
+ DeleteDomainEvent.class,
+ DeleteDomainFailureEvent.class,
+ OperationType.DELETE_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testPublishDomain() {
+ verifyOperation(
+ d -> d.publishDomain(metalake, name),
+ domain,
+ PublishDomainPreEvent.class,
+ PublishDomainEvent.class,
+ PublishDomainFailureEvent.class,
+ OperationType.PUBLISH_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testUnpublishDomain() {
+ verifyOperation(
+ d -> d.unpublishDomain(metalake, name),
+ domain,
+ UnpublishDomainPreEvent.class,
+ UnpublishDomainEvent.class,
+ UnpublishDomainFailureEvent.class,
+ OperationType.UNPUBLISH_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testDetachDomain() {
+ verifyOperation(
+ d -> d.detachDomain(metalake, name),
+ domain,
+ DetachDomainPreEvent.class,
+ DetachDomainEvent.class,
+ DetachDomainFailureEvent.class,
+ OperationType.DETACH_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testAttachDomain() {
+ verifyOperation(
+ d -> d.attachDomain(metalake, name, parent),
+ domain,
+ AttachDomainPreEvent.class,
+ AttachDomainEvent.class,
+ AttachDomainFailureEvent.class,
+ OperationType.ATTACH_DOMAIN,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testUpdateBackingTag() {
+ verifyOperation(
+ d -> d.updateBackingTag(metalake, name, backingTag),
+ domain,
+ UpdateDomainBackingTagPreEvent.class,
+ UpdateDomainBackingTagEvent.class,
+ UpdateDomainBackingTagFailureEvent.class,
+ OperationType.UPDATE_DOMAIN_BACKING_TAG,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testListSubdomains() {
+ verifyOperation(
+ d -> d.listSubdomains(metalake, name),
+ new String[] {name},
+ ListSubdomainsPreEvent.class,
+ ListSubdomainsEvent.class,
+ ListSubdomainsFailureEvent.class,
+ OperationType.LIST_SUBDOMAINS,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testListSubdomainInfos() {
+ verifyOperation(
+ d -> d.listSubdomainInfos(metalake, name),
+ new DomainEntity[] {domain},
+ ListSubdomainsInfoPreEvent.class,
+ ListSubdomainsInfoEvent.class,
+ ListSubdomainsInfoFailureEvent.class,
+ OperationType.LIST_SUBDOMAINS_INFO,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testListMembers() {
+ verifyOperation(
+ d -> d.listMembers(metalake, name, filter),
+ new DomainMember[0],
+ ListDomainMembersPreEvent.class,
+ ListDomainMembersEvent.class,
+ ListDomainMembersFailureEvent.class,
+ OperationType.LIST_DOMAIN_MEMBERS,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testListMembersSnapshots() {
+ verifyOperation(
+ d -> d.listMembers(metalake, domain, subdomains, filter),
+ new DomainMember[0],
+ ListDomainMembersPreEvent.class,
+ ListDomainMembersEvent.class,
+ ListDomainMembersFailureEvent.class,
+ OperationType.LIST_DOMAIN_MEMBERS,
+ NameIdentifierUtil.ofDomain(metalake, name));
+ }
+
+ @Test
+ void testListDomainsForMetadataObject() {
+ verifyOperation(
+ d -> d.listDomainsForMetadataObject(metalake, object),
+ new DomainEntity[] {domain},
+ ListDomainsForMetadataObjectPreEvent.class,
+ ListDomainsForMetadataObjectEvent.class,
+ ListDomainsForMetadataObjectFailureEvent.class,
+ OperationType.LIST_DOMAINS_FOR_METADATA_OBJECT,
+ MetadataObjectUtil.toEntityIdent(metalake, object));
+ }
+
+ @Test
+ void testRequestAndResultFields() {
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ when(delegate.createSubdomain(metalake, parent, name, comment, properties, backingTag, false))
+ .thenReturn(domain);
+ DomainEventDispatcher dispatcher = new DomainEventDispatcher(bus, delegate);
+ dispatcher.createSubdomain(metalake, parent, name, comment, properties, backingTag, false);
+ CreateDomainPreEvent pre = (CreateDomainPreEvent) observed.get(0);
+ assertInfo(pre.domainInfo(), Domain.Status.DRAFT, parent, null);
+ assertFalse(pre.createBackingTag());
+ CreateDomainEvent success = (CreateDomainEvent) observed.get(1);
+ assertInfo(success.domainInfo(), Domain.Status.PUBLISHED, parent, domain.auditInfo());
+ assertFalse(success.createBackingTag());
+ observed.clear();
+ DomainEntity unbound =
+ domain.toBuilder()
+ .withBackingTagId(null)
+ .withBackingTagName(null)
+ .withBackingTagValue(null)
+ .build();
+ when(delegate.updateBackingTag(metalake, name, null)).thenReturn(unbound);
+ dispatcher.updateBackingTag(metalake, name, null);
+ assertNull(((UpdateDomainBackingTagPreEvent) observed.get(0)).backingTag());
+ assertNull(((UpdateDomainBackingTagEvent) observed.get(1)).backingTag());
+ assertFalse(
+ ((UpdateDomainBackingTagEvent) observed.get(1)).domainInfo().backingTag().isPresent());
+ observed.clear();
+ when(delegate.attachDomain(metalake, name, parent)).thenReturn(domain);
+ dispatcher.attachDomain(metalake, name, parent);
+ assertEquals(parent, ((AttachDomainPreEvent) observed.get(0)).parent());
+ assertEquals(parent, ((AttachDomainEvent) observed.get(1)).parent());
+ observed.clear();
+ when(delegate.listMembers(metalake, name, filter)).thenReturn(new DomainMember[0]);
+ dispatcher.listMembers(metalake, name, filter);
+ assertSame(filter, ((ListDomainMembersPreEvent) observed.get(0)).filter());
+ assertSame(filter, ((ListDomainMembersEvent) observed.get(1)).filter());
+ observed.clear();
+ when(delegate.listDomainsForMetadataObject(metalake, object))
+ .thenReturn(new DomainEntity[] {domain});
+ dispatcher.listDomainsForMetadataObject(metalake, object);
+ assertSame(object, ((ListDomainsForMetadataObjectPreEvent) observed.get(0)).metadataObject());
+ assertSame(object, ((ListDomainsForMetadataObjectEvent) observed.get(1)).metadataObject());
+ observed.clear();
+ when(delegate.alterDomain(metalake, name, changes)).thenReturn(domain);
+ dispatcher.alterDomain(metalake, name, changes);
+ DomainChange[] copy = ((AlterDomainPreEvent) observed.get(0)).changes();
+ copy[0] = DomainChange.updateComment("mutated");
+ assertEquals(changes[0], ((AlterDomainPreEvent) observed.get(0)).changes()[0]);
+ assertArrayEquals(changes, ((AlterDomainEvent) observed.get(1)).changes());
+ }
+
+ @Test
+ void testMutationChecksRemainInsideEvents() {
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ DomainDispatcher checked = mock(DomainDispatcher.class);
+ Consumer<LockedDomainState> check =
+ state -> {
+ throw new ForbiddenException("denied");
+ };
+ when(delegate.withMutationCheck(check)).thenReturn(checked);
+ ForbiddenException denied = new ForbiddenException("denied");
+ when(checked.publishDomain(metalake, name)).thenThrow(denied);
+ DomainDispatcher scoped = new DomainEventDispatcher(bus, delegate).withMutationCheck(check);
+ assertTrue(observed.isEmpty());
+ assertSame(
+ denied, assertThrows(ForbiddenException.class, () -> scoped.publishDomain(metalake, name)));
+ assertInstanceOf(PublishDomainPreEvent.class, observed.get(0));
+ assertSame(denied, ((PublishDomainFailureEvent) observed.get(1)).exception());
+ verify(delegate, never()).publishDomain(any(), any());
+ }
+
+ @Test
+ void testPreListenerCanPreventMutation() {
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ ForbiddenException denied = new ForbiddenException("listener denied");
+ doThrow(denied).when(listener).onPreEvent(any());
+ assertSame(
+ denied,
+ assertThrows(
+ ForbiddenException.class,
+ () -> new DomainEventDispatcher(bus, delegate).deleteDomain(metalake, name)));
+ verifyNoInteractions(delegate);
+ verify(listener, never()).onPostEvent(any());
+ }
+
+ @Test
+ void testFailureListenerCannotMaskOriginalError() {
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ NoSuchDomainException original = new NoSuchDomainException("hidden draft");
+ when(delegate.getDomain(metalake, name)).thenThrow(original);
+ doThrow(new RuntimeException("listener failed")).when(listener).onPostEvent(any());
+ assertSame(
+ original,
+ assertThrows(
+ NoSuchDomainException.class,
+ () -> new DomainEventDispatcher(bus, delegate).getDomain(metalake, name)));
+ }
+
+ @Test
+ void testSuccessListenerFailureFollowsExistingDispatcherContract() {
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ when(delegate.getDomain(metalake, name)).thenReturn(domain);
+ RuntimeException failed = new RuntimeException("post listener failed");
+ doAnswer(
+ invocation -> {
+ Event event = invocation.getArgument(0);
+ observed.add(event);
+ if (!(event instanceof FailureEvent)) {
+ throw failed;
+ }
+ return null;
+ })
+ .when(listener)
+ .onPostEvent(any());
+ assertSame(
+ failed,
+ assertThrows(
+ RuntimeException.class,
+ () -> new DomainEventDispatcher(bus, delegate).getDomain(metalake, name)));
+ assertEquals(3, observed.size());
+ assertInstanceOf(GetDomainEvent.class, observed.get(1));
+ assertSame(failed, ((GetDomainFailureEvent) observed.get(2)).exception());
+ }
+
+ @Test
+ void testNullListAndAbsentDeleteResults() {
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ DomainEventDispatcher dispatcher = new DomainEventDispatcher(bus, delegate);
+ assertNull(dispatcher.listDomains(metalake));
+ assertEquals(-1, ((ListEvent) observed.get(1)).resultCount());
+ observed.clear();
+ assertFalse(dispatcher.deleteDomain(metalake, name));
+ assertFalse(((DeleteDomainEvent) observed.get(1)).deleted());
+ }
+
+ @Test
+ void testRequestContextIsCapturedForAsyncAudit() throws Exception {
+ RequestContext.setRemoteAddress("192.0.2.10");
+ RequestContext.setRequestQueryParams(Collections.singletonMap("nameContains", "a b&?"));
+ ListDomainMembersEvent event = new ListDomainMembersEvent("user", metalake, name, filter, 0);
+ RequestContext.clear();
+ JsonNode json =
+ JsonUtils.objectMapper().readTree(new JsonAuditFormatter().format(event).toString());
+ assertEquals("192.0.2.10", json.get("remoteAddress").asText());
+ assertEquals("a b&?", json.get("customInfo").get("nameContains").asText());
+ assertEquals(0, json.get("resultCount").asInt());
+ assertTrue(new SimpleFormatterV2().format(event).toString().contains("count=0"));
+ }
+
+ @Test
+ void testDomainInfoIsIndependentOfMutableProperties() {
+ Map<String, String> mutable = new HashMap<>(properties);
+ DomainInfo info = new DomainInfo(name, null, mutable, Domain.Status.DRAFT, null, null, null);
+ mutable.clear();
+ assertEquals(properties, info.properties());
+ assertThrows(UnsupportedOperationException.class, () -> info.properties().clear());
+ assertNull(info.comment());
+ assertFalse(info.parent().isPresent());
+ assertFalse(info.backingTag().isPresent());
+ assertNull(info.auditInfo());
+ assertTrue(
+ new DomainInfo(name, null, null, Domain.Status.DRAFT, null, null, null)
+ .properties()
+ .isEmpty());
+ }
+
+ private void verifyOperation(
+ Function<DomainDispatcher, Object> invoke,
+ Object expected,
+ Class<? extends PreEvent> preType,
+ Class<? extends Event> successType,
+ Class<? extends FailureEvent> failureType,
+ OperationType operation,
+ NameIdentifier identifier) {
+ DomainDispatcher delegate =
+ mock(
+ DomainDispatcher.class,
+ invocation -> {
+ assertEquals(1, observed.size(), "pre-event must precede the delegate");
+ return expected;
+ });
+ Object result = invoke.apply(new DomainEventDispatcher(bus, delegate));
+ assertEquals(expected, result);
+ assertEquals(2, observed.size());
+ assertEvent(observed.get(0), preType, operation, identifier, OperationStatus.UNPROCESSED);
+ assertEvent(observed.get(1), successType, operation, identifier, OperationStatus.SUCCESS);
+ if (observed.get(1) instanceof ListEvent) {
+ assertEquals(
+ expected == null ? -1 : Array.getLength(expected),
+ ((ListEvent) observed.get(1)).resultCount());
+ }
+ assertEquals(1, mockingDetails(delegate).getInvocations().size());
+ observed.clear();
+ NoSuchDomainException failure = new NoSuchDomainException("operation failed");
+ DomainDispatcher failing =
+ mock(
+ DomainDispatcher.class,
+ invocation -> {
+ assertEquals(1, observed.size());
+ throw failure;
+ });
+ assertSame(
+ failure,
+ assertThrows(
+ NoSuchDomainException.class,
+ () -> invoke.apply(new DomainEventDispatcher(bus, failing))));
+ assertEquals(2, observed.size());
+ assertEvent(observed.get(0), preType, operation, identifier, OperationStatus.UNPROCESSED);
+ assertEvent(observed.get(1), failureType, operation, identifier, OperationStatus.FAILURE);
+ assertSame(failure, ((FailureEvent) observed.get(1)).exception());
+ }
+
+ private void assertEvent(
+ BaseEvent event,
+ Class<? extends BaseEvent> type,
+ OperationType operation,
+ NameIdentifier identifier,
+ OperationStatus status) {
+ assertEquals(type, event.getClass());
+ assertEquals(operation, event.operationType());
+ assertEquals(status, event.operationStatus());
+ assertEquals(identifier, event.identifier());
+ assertEquals(PrincipalUtils.getCurrentUserName(), event.user());
+ assertEquals(EventSource.GRAVITINO_SERVER, event.eventSource());
+ if (event instanceof Event) {
+ assertAudit((Event) event);
+ }
+ }
+
+ @SuppressWarnings("deprecation")
+ private void assertAudit(Event event) {
+ assertEquals(
+ event.operationType().name(), new SimpleFormatter().format(event).operation().name());
+ assertEquals(
+ event.operationType().name(), new SimpleFormatterV2().format(event).operation().name());
+ assertEquals(event.operationStatus(), new SimpleFormatterV2().format(event).operationStatus());
+ try {
+ JsonNode json =
+ JsonUtils.objectMapper().readTree(new JsonAuditFormatter().format(event).toString());
+ assertEquals(event.operationType().name(), json.get("operationType").asText());
+ assertEquals(event.operationType().name(), json.get("operation").asText());
+ assertEquals(event.operationStatus().name(), json.get("operationStatus").asText());
+ assertEquals(event.identifier().toString(), json.get("identifier").asText());
+ if (event instanceof ListEvent && ((ListEvent) event).resultCount() >= 0) {
+ assertEquals(((ListEvent) event).resultCount(), json.get("resultCount").asInt());
+ }
+ } catch (Exception e) {
+ throw new AssertionError("Domain audit JSON must be readable", e);
+ }
+ }
+
+ private void assertInfo(
+ DomainInfo info, Domain.Status status, String expectedParent, Audit audit) {
+ assertEquals(name, info.name());
+ assertEquals(comment, info.comment());
+ assertEquals(properties, info.properties());
+ assertEquals(status, info.status());
+ assertEquals(expectedParent, info.parent().orElse(null));
+ assertEquals(backingTag, info.backingTag().orElse(null));
+ assertEquals(audit, info.auditInfo());
+ }
+}
diff --git a/server-common/src/main/java/org/apache/gravitino/server/authorization/DomainAuthzHelper.java b/server-common/src/main/java/org/apache/gravitino/server/authorization/DomainAuthzHelper.java
index 1d58617f6a..1227c3a8df 100644
--- a/server-common/src/main/java/org/apache/gravitino/server/authorization/DomainAuthzHelper.java
+++ b/server-common/src/main/java/org/apache/gravitino/server/authorization/DomainAuthzHelper.java
@@ -310,28 +310,30 @@ public final class DomainAuthzHelper {
return dispatcher.listMembers(metalake, name, filter);
}
AuthorizationRequestContext context = new AuthorizationRequestContext();
- DomainEntity domain = dispatcher.getDomain(metalake, name);
+ DomainDispatcher internal = GravitinoEnv.getInstance().internalDomainDispatcher();
+ DomainEntity domain = internal.getDomain(metalake, name);
requireVisible(metalake, domain, context);
Set<String> visibleNames = new HashSet<>();
visibleNames.add(domain.name());
DomainEntity[] subdomains =
domain.parent().isPresent()
? new DomainEntity[0]
- : filterDomains(metalake, dispatcher.listSubdomainInfos(metalake, name), context);
+ : filterDomains(metalake, internal.listSubdomainInfos(metalake, name), context);
Arrays.stream(subdomains).map(DomainEntity::name).forEach(visibleNames::add);
DomainMemberFilter effectiveFilter = filter;
if (!filter.domains().isEmpty()) {
Set<String> selected = new HashSet<>(filter.domains());
selected.retainAll(visibleNames);
- if (selected.isEmpty()) {
- return new DomainMember[0];
+ // Preserve an unmatched nonempty filter so the dispatcher still emits query events.
+ // Replacing it with an empty filter would incorrectly select the whole scope.
+ if (!selected.isEmpty()) {
+ effectiveFilter =
+ DomainMemberFilter.builder()
+ .withDomains(selected.toArray(new String[0]))
+ .withTypes(filter.types().toArray(new MetadataObject.Type[0]))
+ .withNameContains(filter.nameContains().orElse(null))
+ .build();
}
- effectiveFilter =
- DomainMemberFilter.builder()
- .withDomains(selected.toArray(new String[0]))
- .withTypes(filter.types().toArray(new MetadataObject.Type[0]))
- .withNameContains(filter.nameContains().orElse(null))
- .build();
}
DomainMember[] members = dispatcher.listMembers(metalake, domain, subdomains, effectiveFilter);
Set<MetadataObject> accessible =
diff --git a/server-common/src/test/java/org/apache/gravitino/server/authorization/TestDomainAuthzHelper.java b/server-common/src/test/java/org/apache/gravitino/server/authorization/TestDomainAuthzHelper.java
index 16f0f089a9..1156cb8bfb 100644
--- a/server-common/src/test/java/org/apache/gravitino/server/authorization/TestDomainAuthzHelper.java
+++ b/server-common/src/test/java/org/apache/gravitino/server/authorization/TestDomainAuthzHelper.java
@@ -21,11 +21,14 @@ package org.apache.gravitino.server.authorization;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
@@ -36,10 +39,15 @@ import static org.mockito.Mockito.when;
import java.security.Principal;
import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import javax.servlet.DispatcherType;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import org.apache.gravitino.Config;
import org.apache.gravitino.Configs;
import org.apache.gravitino.GravitinoEnv;
@@ -50,11 +58,24 @@ import org.apache.gravitino.authorization.GravitinoAuthorizer;
import org.apache.gravitino.authorization.Privilege;
import org.apache.gravitino.domain.Domain;
import org.apache.gravitino.domain.DomainDispatcher;
+import org.apache.gravitino.domain.DomainMember;
+import org.apache.gravitino.domain.DomainMemberFilter;
+import org.apache.gravitino.domain.DomainMemberInfo;
+import org.apache.gravitino.domain.DomainRelation;
import org.apache.gravitino.exceptions.ForbiddenException;
import org.apache.gravitino.exceptions.NoSuchDomainException;
+import org.apache.gravitino.listener.DomainEventDispatcher;
+import org.apache.gravitino.listener.EventBus;
+import org.apache.gravitino.listener.api.EventListenerPlugin;
+import org.apache.gravitino.listener.api.event.BaseEvent;
+import org.apache.gravitino.listener.api.event.EventSource;
+import org.apache.gravitino.listener.api.event.domain.ListDomainMembersEvent;
+import org.apache.gravitino.listener.api.event.domain.ListDomainMembersPreEvent;
import org.apache.gravitino.meta.AuditInfo;
import org.apache.gravitino.meta.DomainEntity;
+import org.apache.gravitino.server.web.HttpAuditFilter;
import org.apache.gravitino.utils.NamespaceUtil;
+import org.apache.gravitino.utils.RequestContext;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -95,6 +116,7 @@ class TestDomainAuthzHelper {
@AfterEach
void tearDown() {
environment.close();
+ RequestContext.clear();
}
@ParameterizedTest
@@ -234,6 +256,161 @@ class TestDomainAuthzHelper {
assertEquals(2, contexts.size());
}
+ @ParameterizedTest
+ @ValueSource(strings = {"unknown", "Secret"})
+ void emptyAuthorizedMemberScopeStillEmitsQueryEvents(String scope) throws Exception {
+ allows.add("Finance:USE_DOMAIN");
+ DomainEntity finance = domain("Finance", null, Domain.Status.PUBLISHED);
+ DomainDispatcher delegate = memberDispatcher(finance);
+ DomainMemberFilter filter =
+ DomainMemberFilter.builder()
+ .withDomains(scope)
+ .withTypes(MetadataObject.Type.TABLE)
+ .withNameContains("trades")
+ .build();
+ when(delegate.listMembers(eq("lake"), eq(finance), any(DomainEntity[].class), eq(filter)))
+ .thenReturn(new DomainMember[0]);
+ List<BaseEvent> events = new ArrayList<>();
+ EventListenerPlugin listener = recordingListener(events);
+ EventBus bus = new EventBus(Collections.singletonList(listener));
+ DomainEventDispatcher dispatcher = new DomainEventDispatcher(bus, delegate);
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ when(request.getMethod()).thenReturn("GET");
+ when(request.getRequestURI()).thenReturn("/api/metalakes/lake/domains/Finance/objects");
+ when(request.getDispatcherType()).thenReturn(DispatcherType.REQUEST);
+ new HttpAuditFilter(bus, EventSource.GRAVITINO_SERVER)
+ .doFilter(
+ request,
+ mock(HttpServletResponse.class),
+ (req, response) ->
+ assertEquals(
+ 0,
+ DomainAuthzHelper.listMembers(dispatcher, "lake", "Finance", filter).length));
+ assertEquals(2, events.size());
+ assertSame(filter, ((ListDomainMembersPreEvent) events.get(0)).filter());
+ ListDomainMembersEvent success = (ListDomainMembersEvent) events.get(1);
+ assertSame(filter, success.filter());
+ assertEquals(0, success.resultCount());
+ verify(delegate)
+ .listMembers(
+ eq("lake"),
+ eq(finance),
+ argThat(snapshots -> snapshots.length == 1 && child.equals(snapshots[0])),
+ eq(filter));
+ }
+
+ @Test
+ void mixedMemberScopesKeepOnlyVisibleSnapshotsAndRelations() {
+ allows.addAll(
+ Arrays.asList(
+ "Finance:USE_DOMAIN", "lake:USE_CATALOG", "lake:USE_SCHEMA", "lake:SELECT_TABLE"));
+ DomainEntity finance = domain("Finance", null, Domain.Status.PUBLISHED);
+ DomainDispatcher delegate = memberDispatcher(finance);
+ MetadataObject table = MetadataObjects.parse("cat.db.trades", MetadataObject.Type.TABLE);
+ DomainMember member =
+ new DomainMemberInfo(
+ table,
+ new DomainRelation[] {
+ DomainRelation.viaSubdomain("Trading"), DomainRelation.viaSubdomain("Secret")
+ });
+ DomainMemberFilter requested =
+ DomainMemberFilter.builder()
+ .withDomains("unknown", "Trading", "Secret")
+ .withTypes(MetadataObject.Type.TABLE)
+ .withNameContains("trades")
+ .build();
+ DomainMemberFilter effective =
+ DomainMemberFilter.builder()
+ .withDomains("Trading")
+ .withTypes(MetadataObject.Type.TABLE)
+ .withNameContains("trades")
+ .build();
+ when(delegate.listMembers(eq("lake"), eq(finance), any(DomainEntity[].class), eq(effective)))
+ .thenReturn(new DomainMember[] {member});
+ List<BaseEvent> events = new ArrayList<>();
+ DomainDispatcher dispatcher =
+ new DomainEventDispatcher(
+ new EventBus(Collections.singletonList(recordingListener(events))), delegate);
+ DomainMember[] result = DomainAuthzHelper.listMembers(dispatcher, "lake", "Finance", requested);
+ assertEquals(1, result.length);
+ assertEquals(table, result[0].object());
+ assertEquals(1, result[0].relations().length);
+ assertEquals(DomainRelation.viaSubdomain("Trading"), result[0].relations()[0]);
+ assertEquals(effective, ((ListDomainMembersPreEvent) events.get(0)).filter());
+ assertEquals(1, ((ListDomainMembersEvent) events.get(1)).resultCount());
+ verify(delegate)
+ .listMembers(
+ eq("lake"),
+ eq(finance),
+ argThat(snapshots -> snapshots.length == 1 && child.equals(snapshots[0])),
+ eq(effective));
+ }
+
+ @Test
+ void preListenerCanRejectAnEmptyAuthorizedMemberScope() {
+ allows.add("Finance:USE_DOMAIN");
+ DomainEntity finance = domain("Finance", null, Domain.Status.PUBLISHED);
+ DomainDispatcher delegate = memberDispatcher(finance);
+ List<BaseEvent> events = new ArrayList<>();
+ EventListenerPlugin listener = recordingListener(events);
+ ForbiddenException rejected = new ForbiddenException("member query denied");
+ doAnswer(
+ call -> {
+ BaseEvent event = call.getArgument(0);
+ events.add(event);
+ if (event instanceof ListDomainMembersPreEvent) {
+ throw rejected;
+ }
+ return null;
+ })
+ .when(listener)
+ .onPreEvent(any());
+ DomainDispatcher dispatcher =
+ new DomainEventDispatcher(new EventBus(Collections.singletonList(listener)), delegate);
+ assertSame(
+ rejected,
+ assertThrows(
+ ForbiddenException.class,
+ () ->
+ DomainAuthzHelper.listMembers(
+ dispatcher,
+ "lake",
+ "Finance",
+ DomainMemberFilter.builder().withDomains("unknown").build())));
+ assertEquals(1, events.size());
+ assertInstanceOf(ListDomainMembersPreEvent.class, events.get(0));
+ verify(delegate, never())
+ .listMembers(anyString(), any(DomainEntity.class), any(DomainEntity[].class), any());
+ }
+
+ private DomainDispatcher memberDispatcher(DomainEntity finance) {
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ when(delegate.getDomain("lake", "Finance")).thenReturn(finance);
+ when(delegate.listSubdomainInfos("lake", "Finance"))
+ .thenReturn(new DomainEntity[] {child, domain("Secret", "Finance", Domain.Status.DRAFT)});
+ when(env.internalDomainDispatcher()).thenReturn(delegate);
+ return delegate;
+ }
+
+ private EventListenerPlugin recordingListener(List<BaseEvent> events) {
+ EventListenerPlugin listener = mock(EventListenerPlugin.class);
+ doAnswer(
+ call -> {
+ events.add(call.getArgument(0));
+ return null;
+ })
+ .when(listener)
+ .onPreEvent(any());
+ doAnswer(
+ call -> {
+ events.add(call.getArgument(0));
+ return null;
+ })
+ .when(listener)
+ .onPostEvent(any());
+ return listener;
+ }
+
private boolean permitted(Privilege.Name privilege) {
return DomainAuthzHelper.allowed(
authorizer,
diff --git a/server-common/src/test/java/org/apache/gravitino/server/authorization/TestDomainMembershipAuthorization.java b/server-common/src/test/java/org/apache/gravitino/server/authorization/TestDomainMembershipAuthorization.java
index ba6986a950..8f7c5b45c5 100644
--- a/server-common/src/test/java/org/apache/gravitino/server/authorization/TestDomainMembershipAuthorization.java
+++ b/server-common/src/test/java/org/apache/gravitino/server/authorization/TestDomainMembershipAuthorization.java
@@ -23,6 +23,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
@@ -71,6 +72,7 @@ class TestDomainMembershipAuthorization {
when(config.get(Configs.ENABLE_AUTHORIZATION)).thenReturn(true);
when(config.get(Configs.GRAVITINO_AUTHORIZATION_THREAD_POOL_SIZE)).thenReturn(2);
when(env.config()).thenReturn(config);
+ when(env.internalDomainDispatcher()).thenReturn(dispatcher);
when(env.gravitinoAuthorizer()).thenReturn(authorizer);
environment = mockStatic(GravitinoEnv.class);
environment.when(GravitinoEnv::getInstance).thenReturn(env);
@@ -111,15 +113,14 @@ class TestDomainMembershipAuthorization {
@Test
void hiddenOrUnknownSelectionsCannotWidenResults() {
+ when(dispatcher.listMembers(eq("lake"), eq(parent), any(DomainEntity[].class), any()))
+ .thenReturn(new DomainMember[0]);
for (String selected : new String[] {"Trading", "unknown"}) {
- assertEquals(
- 0,
- DomainAuthzHelper.listMembers(
- dispatcher,
- "lake",
- "Finance",
- DomainMemberFilter.builder().withDomains(selected).build())
- .length);
+ DomainMemberFilter filter = DomainMemberFilter.builder().withDomains(selected).build();
+ assertEquals(0, DomainAuthzHelper.listMembers(dispatcher, "lake", "Finance", filter).length);
+ verify(dispatcher)
+ .listMembers(
+ eq("lake"), eq(parent), argThat(snapshots -> snapshots.length == 0), eq(filter));
}
verify(dispatcher, never()).listMembers(anyString(), anyString(), any());
}
diff --git a/server-common/src/test/java/org/apache/gravitino/server/web/TestDomainHttpAudit.java b/server-common/src/test/java/org/apache/gravitino/server/web/TestDomainHttpAudit.java
new file mode 100644
index 0000000000..8b2cadf821
--- /dev/null
+++ b/server-common/src/test/java/org/apache/gravitino/server/web/TestDomainHttpAudit.java
@@ -0,0 +1,133 @@
+/*
+ * 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.server.web;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doAnswer;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import javax.servlet.DispatcherType;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.gravitino.domain.Domain;
+import org.apache.gravitino.domain.DomainDispatcher;
+import org.apache.gravitino.exceptions.ForbiddenException;
+import org.apache.gravitino.listener.DomainEventDispatcher;
+import org.apache.gravitino.listener.EventBus;
+import org.apache.gravitino.listener.api.EventListenerPlugin;
+import org.apache.gravitino.listener.api.event.Event;
+import org.apache.gravitino.listener.api.event.EventSource;
+import org.apache.gravitino.listener.api.event.domain.GetDomainEvent;
+import org.apache.gravitino.listener.api.event.domain.PublishDomainFailureEvent;
+import org.apache.gravitino.listener.api.event.server.HttpRequestFailureEvent;
+import org.apache.gravitino.meta.AuditInfo;
+import org.apache.gravitino.meta.DomainEntity;
+import org.apache.gravitino.utils.NamespaceUtil;
+import org.apache.gravitino.utils.RequestContext;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+class TestDomainHttpAudit {
+ @AfterEach
+ void clearContext() {
+ RequestContext.clear();
+ }
+
+ @Test
+ void testDomainReadDoesNotSuppressLaterHttpVisibilityDenial() throws Exception {
+ List<Event> events = new ArrayList<>();
+ EventBus bus = eventBus(events);
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ DomainEntity draft =
+ DomainEntity.builder()
+ .withId(1L)
+ .withName("draft")
+ .withNamespace(NamespaceUtil.ofDomain("lake"))
+ .withProperties(Collections.emptyMap())
+ .withStatus(Domain.Status.DRAFT)
+ .withAuditInfo(AuditInfo.builder().withCreator("owner").build())
+ .build();
+ when(delegate.getDomain("lake", "draft")).thenReturn(draft);
+ DomainEventDispatcher dispatcher = new DomainEventDispatcher(bus, delegate);
+ HttpAuditFilter filter = new HttpAuditFilter(bus, EventSource.GRAVITINO_SERVER);
+ filter.doFilter(
+ request(),
+ mock(HttpServletResponse.class),
+ (request, response) -> {
+ dispatcher.getDomain("lake", "draft");
+ // REST visibility checks run after loading the snapshot. The final 404 must still be
+ // audited.
+ ((HttpServletResponse) response).setStatus(404);
+ });
+ assertEquals(2, events.size());
+ assertInstanceOf(GetDomainEvent.class, events.get(0));
+ assertInstanceOf(HttpRequestFailureEvent.class, events.get(1));
+ }
+
+ @Test
+ void testDomainMutationFailureSuppressesDuplicateHttpFailure() throws Exception {
+ List<Event> events = new ArrayList<>();
+ EventBus bus = eventBus(events);
+ DomainDispatcher delegate = mock(DomainDispatcher.class);
+ ForbiddenException denied = new ForbiddenException("manage denied");
+ when(delegate.publishDomain("lake", "draft")).thenThrow(denied);
+ DomainEventDispatcher dispatcher = new DomainEventDispatcher(bus, delegate);
+ HttpAuditFilter filter = new HttpAuditFilter(bus, EventSource.GRAVITINO_SERVER);
+ filter.doFilter(
+ request(),
+ mock(HttpServletResponse.class),
+ (request, response) -> {
+ try {
+ dispatcher.publishDomain("lake", "draft");
+ } catch (ForbiddenException e) {
+ ((HttpServletResponse) response).setStatus(403);
+ }
+ });
+ assertEquals(1, events.size());
+ assertSame(denied, ((PublishDomainFailureEvent) events.get(0)).exception());
+ }
+
+ private EventBus eventBus(List<Event> events) {
+ EventListenerPlugin listener = mock(EventListenerPlugin.class);
+ doAnswer(
+ invocation -> {
+ events.add(invocation.getArgument(0));
+ return null;
+ })
+ .when(listener)
+ .onPostEvent(any());
+ return new EventBus(Collections.singletonList(listener));
+ }
+
+ private HttpServletRequest request() {
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ when(request.getMethod()).thenReturn("GET");
+ when(request.getRequestURI()).thenReturn("/api/metalakes/lake/domains/draft");
+ when(request.getRemoteAddr()).thenReturn("192.0.2.10");
+ when(request.getDispatcherType()).thenReturn(DispatcherType.REQUEST);
+ return request;
+ }
+}
diff --git a/server/src/main/java/org/apache/gravitino/server/web/rest/DomainOperations.java b/server/src/main/java/org/apache/gravitino/server/web/rest/DomainOperations.java
index 25ea5db74f..bdb63baf9b 100644
--- a/server/src/main/java/org/apache/gravitino/server/web/rest/DomainOperations.java
+++ b/server/src/main/java/org/apache/gravitino/server/web/rest/DomainOperations.java
@@ -38,6 +38,7 @@ import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import org.apache.gravitino.Entity;
+import org.apache.gravitino.GravitinoEnv;
import org.apache.gravitino.domain.Domain;
import org.apache.gravitino.domain.DomainChange;
import org.apache.gravitino.domain.DomainDispatcher;
@@ -144,7 +145,10 @@ public class DomainOperations {
DomainCreateRequest.BackingTag tag = request.getBackingTag();
DomainAuthzHelper.requireManage(metalake, null);
if (request.getParent() != null) {
- DomainAuthzHelper.requireManage(domainDispatcher, metalake, request.getParent());
+ DomainAuthzHelper.requireManage(
+ GravitinoEnv.getInstance().internalDomainDispatcher(),
+ metalake,
+ request.getParent());
}
if (tag.isCreate()) {
DomainAuthzHelper.requireBackingTag(metalake, tag.getName(), true);
@@ -335,8 +339,10 @@ public class DomainOperations {
domain,
() -> {
validateRequest(request);
- DomainAuthzHelper.requireManage(domainDispatcher, metalake, domain);
- DomainAuthzHelper.requireManage(domainDispatcher, metalake, request.getParent());
+ DomainAuthzHelper.requireManage(
+ GravitinoEnv.getInstance().internalDomainDispatcher(), metalake, domain);
+ DomainAuthzHelper.requireManage(
+ GravitinoEnv.getInstance().internalDomainDispatcher(), metalake, request.getParent());
return domainResponse(
DomainAuthzHelper.checked(
domainDispatcher,
@@ -401,7 +407,8 @@ public class DomainOperations {
domain,
() -> {
validateRequest(request);
- DomainAuthzHelper.requireManage(domainDispatcher, metalake, domain);
+ DomainAuthzHelper.requireManage(
+ GravitinoEnv.getInstance().internalDomainDispatcher(), metalake, domain);
return domainResponse(
DomainAuthzHelper.checked(
domainDispatcher,
@@ -442,7 +449,8 @@ public class DomainOperations {
metalake,
domain,
() -> {
- DomainAuthzHelper.requireVisible(domainDispatcher, metalake, domain);
+ DomainAuthzHelper.requireVisible(
+ GravitinoEnv.getInstance().internalDomainDispatcher(), metalake, domain);
return details
? listResponse(
DomainAuthzHelper.filterDomains(
diff --git a/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainAuthorizationOperations.java b/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainAuthorizationOperations.java
index e1b4e4d676..1f8f88d6d7 100644
--- a/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainAuthorizationOperations.java
+++ b/server/src/test/java/org/apache/gravitino/server/web/rest/TestDomainAuthorizationOperations.java
@@ -20,6 +20,7 @@ package org.apache.gravitino.server.web.rest;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -34,15 +35,19 @@ import static org.mockito.Mockito.when;
import java.io.IOException;
import java.lang.reflect.Method;
import java.time.Instant;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
import java.util.function.Function;
+import javax.servlet.DispatcherType;
import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.client.Entity;
import javax.ws.rs.core.Application;
import javax.ws.rs.core.MediaType;
@@ -63,6 +68,7 @@ import org.apache.gravitino.authorization.GravitinoAuthorizer;
import org.apache.gravitino.domain.Domain;
import org.apache.gravitino.domain.DomainDispatcher;
import org.apache.gravitino.domain.DomainManager;
+import org.apache.gravitino.dto.requests.DomainParentSetRequest;
import org.apache.gravitino.dto.responses.DomainResponse;
import org.apache.gravitino.dto.responses.DropResponse;
import org.apache.gravitino.dto.responses.ErrorResponse;
@@ -71,12 +77,19 @@ import org.apache.gravitino.exceptions.NoSuchEntityException;
import org.apache.gravitino.exceptions.NoSuchTagException;
import org.apache.gravitino.exceptions.TagAlreadyExistsException;
import org.apache.gravitino.hook.DomainHookDispatcher;
+import org.apache.gravitino.listener.DomainEventDispatcher;
+import org.apache.gravitino.listener.EventBus;
+import org.apache.gravitino.listener.api.EventListenerPlugin;
+import org.apache.gravitino.listener.api.event.Event;
+import org.apache.gravitino.listener.api.event.EventSource;
+import org.apache.gravitino.listener.api.event.server.HttpRequestFailureEvent;
import org.apache.gravitino.meta.AuditInfo;
import org.apache.gravitino.meta.BaseMetalake;
import org.apache.gravitino.meta.DomainEntity;
import org.apache.gravitino.meta.SchemaVersion;
import org.apache.gravitino.meta.TagEntity;
import org.apache.gravitino.rest.RESTUtils;
+import org.apache.gravitino.server.web.HttpAuditFilter;
import org.apache.gravitino.server.web.ObjectMapperProvider;
import org.apache.gravitino.server.web.filter.GravitinoInterceptionService;
import org.apache.gravitino.storage.IdGenerator;
@@ -91,6 +104,8 @@ import org.glassfish.jersey.test.TestProperties;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
/** REST permission tests against the real domain manager with mocked storage transactions. */
public class TestDomainAuthorizationOperations extends BaseOperationsTest {
@@ -104,6 +119,7 @@ public class TestDomainAuthorizationOperations extends BaseOperationsTest {
private final SupportsDomainOperations transactions = mock(SupportsDomainOperations.class);
private final GravitinoAuthorizer authorizer = mock(GravitinoAuthorizer.class);
private final DomainManager manager = new DomainManager(mock(IdGenerator.class), store);
+ private DomainDispatcher savedInternalDomainDispatcher;
private Config savedConfig;
private GravitinoAuthorizer savedAuthorizer;
@@ -147,6 +163,8 @@ public class TestDomainAuthorizationOperations extends BaseOperationsTest {
void configureAuthorization() throws Exception {
GravitinoEnv env = GravitinoEnv.getInstance();
savedConfig = env.config();
+ savedInternalDomainDispatcher = env.internalDomainDispatcher();
+ FieldUtils.writeField(env, "internalDomainDispatcher", manager, true);
savedAuthorizer = env.gravitinoAuthorizer();
Config config = mock(Config.class);
when(config.get(Configs.ENABLE_AUTHORIZATION)).thenReturn(true);
@@ -256,11 +274,112 @@ public class TestDomainAuthorizationOperations extends BaseOperationsTest {
@AfterEach
void restoreAuthorization() throws Exception {
FieldUtils.writeField(GravitinoEnv.getInstance(), "config", savedConfig, true);
+ FieldUtils.writeField(
+ GravitinoEnv.getInstance(),
+ "internalDomainDispatcher",
+ savedInternalDomainDispatcher,
+ true);
GravitinoEnv.getInstance().setGravitinoAuthorizer(savedAuthorizer);
RequestContext.resetOperationFailureFired();
RequestContext.clear();
}
+ @ParameterizedTest
+ @ValueSource(strings = {"missing", "Trading"})
+ void missingParentChangePreflightRetainsHttpAuditContext(String name) throws Exception {
+ allows.add("lake:MANAGE_DOMAIN");
+ doThrow(new NoSuchEntityException("Missing domain"))
+ .when(store)
+ .get(
+ eq(NameIdentifierUtil.ofDomain("lake", "missing")),
+ eq(EntityType.DOMAIN),
+ eq(DomainEntity.class));
+ List<Event> events = new ArrayList<>();
+ EventListenerPlugin listener = mock(EventListenerPlugin.class);
+ doAnswer(
+ call -> {
+ events.add(call.getArgument(0));
+ return null;
+ })
+ .when(listener)
+ .onPostEvent(any());
+ EventBus bus = new EventBus(Collections.singletonList(listener));
+ DomainOperations operations =
+ new DomainOperations(new DomainEventDispatcher(bus, new DomainHookDispatcher(manager)));
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ String uri = "/api" + BASE + "/" + name + "/parent";
+ when(request.getMethod()).thenReturn("PUT");
+ when(request.getRequestURI()).thenReturn(uri);
+ when(request.getRemoteAddr()).thenReturn("192.0.2.10");
+ when(request.getDispatcherType()).thenReturn(DispatcherType.REQUEST);
+ FieldUtils.writeField(operations, "httpRequest", request, true);
+ new HttpAuditFilter(bus, EventSource.GRAVITINO_SERVER)
+ .doFilter(
+ request,
+ mock(HttpServletResponse.class),
+ (req, response) -> {
+ try (Response result =
+ operations.setParent("lake", name, new DomainParentSetRequest("missing"))) {
+ assertEquals(404, result.getStatus());
+ ((HttpServletResponse) response).setStatus(result.getStatus());
+ }
+ });
+ assertEquals(1, events.size());
+ HttpRequestFailureEvent failure =
+ assertInstanceOf(HttpRequestFailureEvent.class, events.get(0));
+ assertEquals("PUT", failure.httpMethod());
+ assertEquals(uri, failure.requestUri());
+ assertEquals(404, failure.statusCode());
+ }
+
+ @Test
+ void missingMemberDomainRetainsHttpAuditContext() throws Exception {
+ allows.add("lake:USE_DOMAIN");
+ doThrow(new NoSuchEntityException("Missing domain"))
+ .when(store)
+ .get(
+ eq(NameIdentifierUtil.ofDomain("lake", "missing")),
+ eq(EntityType.DOMAIN),
+ eq(DomainEntity.class));
+ List<Event> events = new ArrayList<>();
+ EventListenerPlugin listener = mock(EventListenerPlugin.class);
+ doAnswer(
+ call -> {
+ events.add(call.getArgument(0));
+ return null;
+ })
+ .when(listener)
+ .onPostEvent(any());
+ EventBus bus = new EventBus(Collections.singletonList(listener));
+ DomainMembershipOperations operations =
+ new DomainMembershipOperations(
+ new DomainEventDispatcher(bus, new DomainHookDispatcher(manager)));
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ String uri = "/api" + BASE + "/missing/objects";
+ when(request.getMethod()).thenReturn("GET");
+ when(request.getRequestURI()).thenReturn(uri);
+ when(request.getRemoteAddr()).thenReturn("192.0.2.10");
+ when(request.getDispatcherType()).thenReturn(DispatcherType.REQUEST);
+ FieldUtils.writeField(operations, "httpRequest", request, true);
+ new HttpAuditFilter(bus, EventSource.GRAVITINO_SERVER)
+ .doFilter(
+ request,
+ mock(HttpServletResponse.class),
+ (req, response) -> {
+ try (Response result =
+ operations.listMembers("lake", "missing", null, null, Collections.emptyList())) {
+ assertEquals(404, result.getStatus());
+ ((HttpServletResponse) response).setStatus(result.getStatus());
+ }
+ });
+ assertEquals(1, events.size());
+ HttpRequestFailureEvent failure =
+ assertInstanceOf(HttpRequestFailureEvent.class, events.get(0));
+ assertEquals("GET", failure.httpMethod());
+ assertEquals(uri, failure.requestUri());
+ assertEquals(404, failure.statusCode());
+ }
+
@Test
void draftIsNotFoundAndOmittedEvenWithUsage() {
allows.add("Finance:USE_DOMAIN");