xunliu commented on code in PR #4429:
URL: https://github.com/apache/gravitino/pull/4429#discussion_r1708798481


##########
core/src/main/java/org/apache/gravitino/hook/CatalogHookDispatcher.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.hook;
+
+import com.google.common.collect.Lists;
+import java.util.List;
+import java.util.Map;
+import org.apache.gravitino.Catalog;
+import org.apache.gravitino.CatalogChange;
+import org.apache.gravitino.NameIdentifier;
+import org.apache.gravitino.Namespace;
+import org.apache.gravitino.catalog.CatalogDispatcher;
+import org.apache.gravitino.exceptions.CatalogAlreadyExistsException;
+import org.apache.gravitino.exceptions.NoSuchCatalogException;
+import org.apache.gravitino.exceptions.NoSuchMetalakeException;
+
+public class CatalogHookDispatcher implements CatalogDispatcher {
+  private final CatalogDispatcher dispatcher;
+  private final List<CatalogCreatePostHook> createPostHooks;
+
+  public CatalogHookDispatcher(CatalogDispatcher dispatcher) {
+    this.dispatcher = dispatcher;
+    this.createPostHooks = Lists.newArrayList();
+  }
+
+  @Override
+  public NameIdentifier[] listCatalogs(Namespace namespace) throws 
NoSuchMetalakeException {
+    return dispatcher.listCatalogs(namespace);
+  }
+
+  @Override
+  public Catalog[] listCatalogsInfo(Namespace namespace) throws 
NoSuchMetalakeException {
+    return dispatcher.listCatalogsInfo(namespace);
+  }
+
+  @Override
+  public Catalog loadCatalog(NameIdentifier ident) throws 
NoSuchCatalogException {
+    return dispatcher.loadCatalog(ident);
+  }
+
+  @Override
+  public Catalog createCatalog(
+      NameIdentifier ident,
+      Catalog.Type type,
+      String provider,
+      String comment,
+      Map<String, String> properties)
+      throws NoSuchMetalakeException, CatalogAlreadyExistsException {
+    Catalog catalog = dispatcher.createCatalog(ident, type, provider, comment, 
properties);
+    for (CatalogCreatePostHook hook : createPostHooks) {
+      hook.execute(ident);
+    }

Review Comment:
   I think we can directly execute the here, didn't need to call 
`hook.execute()`.
   ```
           ownerManager.setOwner(
               ident.name(),
               NameIdentifierUtil.toMetadataObject(ident, 
Entity.EntityType.METALAKE),
               PrincipalUtils.getCurrentUserName(),
               Owner.Type.USER);
   ```
   
   
   



##########
core/src/main/java/org/apache/gravitino/authorization/AuthorizationHookRegistry.java:
##########


Review Comment:
   I think we didn't need this class.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to