HonahX commented on code in PR #1438: URL: https://github.com/apache/polaris/pull/1438#discussion_r2059153139
########## service/common/src/main/java/org/apache/polaris/service/catalog/policy/PolicyCatalogAdapter.java: ########## @@ -0,0 +1,241 @@ +/* + * 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.policy; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import java.util.function.Function; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.exceptions.NotAuthorizedException; +import org.apache.iceberg.rest.RESTUtil; +import org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal; +import org.apache.polaris.core.auth.PolarisAuthorizer; +import org.apache.polaris.core.context.CallContext; +import org.apache.polaris.core.context.RealmContext; +import org.apache.polaris.core.persistence.PolarisEntityManager; +import org.apache.polaris.core.persistence.PolarisMetaStoreManager; +import org.apache.polaris.core.policy.PolicyType; +import org.apache.polaris.service.catalog.CatalogPrefixParser; +import org.apache.polaris.service.catalog.api.PolarisCatalogPolicyApiService; +import org.apache.polaris.service.catalog.common.CatalogAdapter; +import org.apache.polaris.service.types.AttachPolicyRequest; +import org.apache.polaris.service.types.CreatePolicyRequest; +import org.apache.polaris.service.types.DetachPolicyRequest; +import org.apache.polaris.service.types.PolicyIdentifier; +import org.apache.polaris.service.types.UpdatePolicyRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@RequestScoped +public class PolicyCatalogAdapter implements PolarisCatalogPolicyApiService, CatalogAdapter { + private static final Logger LOGGER = LoggerFactory.getLogger(PolicyCatalogAdapter.class); + + private final RealmContext realmContext; + private final CallContext callContext; + private final PolarisEntityManager entityManager; + private final PolarisMetaStoreManager metaStoreManager; + private final PolarisAuthorizer polarisAuthorizer; + private final CatalogPrefixParser prefixParser; + + @Inject + public PolicyCatalogAdapter( + RealmContext realmContext, + CallContext callContext, + PolarisEntityManager entityManager, + PolarisMetaStoreManager metaStoreManager, + PolarisAuthorizer polarisAuthorizer, + CatalogPrefixParser prefixParser) { + this.realmContext = realmContext; + this.callContext = callContext; + this.entityManager = entityManager; + this.metaStoreManager = metaStoreManager; + this.polarisAuthorizer = polarisAuthorizer; + this.prefixParser = prefixParser; + } + + private Response withCatalog( + SecurityContext securityContext, + String prefix, + Function<PolicyCatalogHandler, Response> action) { Review Comment: Yes for policy and generic tables we do not need to close anything. Let me update to use `newHandlerWrapper` directly to simplify the logic : ) BTW, I noticed that in generic table https://github.com/apache/polaris/blob/250bdec0f7cd08559ddf1e3bd0f3d9f5cc2ec387/service/common/src/main/java/org/apache/polaris/service/catalog/generic/GenericTableCatalogAdapter.java#L105 it treats `prefix` as `catalogName` without parsing it, is that expected or we need the `prefixParser` at some point? -- 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: issues-unsubscr...@polaris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org