eric-maynard commented on code in PR #1264:
URL: https://github.com/apache/polaris/pull/1264#discussion_r2017828989


##########
service/common/src/main/java/org/apache/polaris/service/catalog/generic/GenericTableCatalogHandlerWrapper.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.polaris.service.catalog.generic;
+
+import jakarta.ws.rs.core.SecurityContext;
+import java.util.Map;
+import java.util.TreeSet;
+import org.apache.iceberg.catalog.Namespace;
+import org.apache.iceberg.catalog.TableIdentifier;
+import org.apache.polaris.core.auth.PolarisAuthorizableOperation;
+import org.apache.polaris.core.auth.PolarisAuthorizer;
+import org.apache.polaris.core.config.FeatureConfiguration;
+import org.apache.polaris.core.context.CallContext;
+import org.apache.polaris.core.entity.PolarisEntitySubType;
+import org.apache.polaris.core.entity.table.GenericTableEntity;
+import org.apache.polaris.core.persistence.PolarisEntityManager;
+import org.apache.polaris.core.persistence.PolarisMetaStoreManager;
+import org.apache.polaris.service.catalog.common.CatalogHandlerWrapper;
+import org.apache.polaris.service.types.GenericTable;
+import org.apache.polaris.service.types.ListGenericTablesResponse;
+import org.apache.polaris.service.types.LoadGenericTableResponse;
+
+public class GenericTableCatalogHandlerWrapper extends CatalogHandlerWrapper {
+
+  private PolarisMetaStoreManager metaStoreManager;
+
+  private GenericTableCatalog genericTableCatalog;
+
+  public GenericTableCatalogHandlerWrapper(
+      CallContext callContext,
+      PolarisEntityManager entityManager,
+      PolarisMetaStoreManager metaStoreManager,
+      SecurityContext securityContext,
+      String catalogName,
+      PolarisAuthorizer authorizer) {
+    super(callContext, entityManager, securityContext, catalogName, 
authorizer);
+    this.metaStoreManager = metaStoreManager;
+  }
+
+  public void enforceGenericTablesEnabledOrThrow() {
+    boolean enabled =
+        callContext
+            .getPolarisCallContext()
+            .getConfigurationStore()
+            .getConfiguration(
+                callContext.getPolarisCallContext(), 
FeatureConfiguration.ENABLE_GENERIC_TABLES);
+    if (!enabled) {
+      throw new UnsupportedOperationException("Generic table support is not 
enabled");
+    }
+  }
+
+  @Override
+  protected void initializeCatalog() {
+    enforceGenericTablesEnabledOrThrow();
+    this.genericTableCatalog =
+        new GenericTableCatalog(metaStoreManager, callContext, 
this.resolutionManifest);
+  }
+
+  public ListGenericTablesResponse listGenericTables(Namespace parent) {
+    PolarisAuthorizableOperation op = PolarisAuthorizableOperation.LIST_TABLES;
+    authorizeBasicNamespaceOperationOrThrow(op, parent);
+
+    return ListGenericTablesResponse.builder()
+        .setIdentifiers(new 
TreeSet<>(genericTableCatalog.listGenericTables(parent)))
+        .build();
+  }
+
+  public LoadGenericTableResponse createGenericTable(
+      TableIdentifier identifier, String format, String doc, Map<String, 
String> properties) {
+    PolarisAuthorizableOperation op = 
PolarisAuthorizableOperation.CREATE_TABLE_DIRECT;
+    authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, identifier);
+
+    GenericTableEntity createdEntity =
+        this.genericTableCatalog.createGenericTable(identifier, format, doc, 
properties);
+    GenericTable createdTable =
+        new GenericTable(
+            createdEntity.getName(),
+            createdEntity.getFormat(),
+            createdEntity.getDoc(),
+            createdEntity.getPropertiesAsMap());
+
+    return LoadGenericTableResponse.builder().setTable(createdTable).build();
+  }
+
+  public boolean dropGenericTable(TableIdentifier identifier) {
+    PolarisAuthorizableOperation op = 
PolarisAuthorizableOperation.DROP_TABLE_WITHOUT_PURGE;
+    authorizeCreateTableLikeUnderNamespaceOperationOrThrow(op, identifier);

Review Comment:
   Yeah the tests right now do not try and grant privileges on the tables 
themselves, but I think it would not be possible currently. What's not clear to 
me is if we want to extend privileges like `TABLE_DROP` -- I will do that for 
now, but I'm open to changing this any which way.



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