adam-christian-software commented on code in PR #4816: URL: https://github.com/apache/polaris/pull/4816#discussion_r3454600761
########## runtime/service/src/main/java/org/apache/polaris/service/catalog/semanticmodel/SemanticModelCatalogAdapter.java: ########## @@ -0,0 +1,116 @@ +/* + * 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.semanticmodel; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.inject.Inject; +import jakarta.ws.rs.core.Response; +import jakarta.ws.rs.core.SecurityContext; +import org.apache.polaris.core.config.FeatureConfiguration; +import org.apache.polaris.core.config.RealmConfig; +import org.apache.polaris.core.context.CallContext; +import org.apache.polaris.core.context.RealmContext; +import org.apache.polaris.service.catalog.api.PolarisCatalogSemanticModelApiService; +import org.apache.polaris.service.catalog.common.CatalogAdapter; +import org.apache.polaris.service.types.CreateSemanticModelRequest; +import org.apache.polaris.service.types.UpdateSemanticModelRequest; + +/** + * Stub adapter for the OSI semantic-model API. The endpoints are wired and gated by {@link + * FeatureConfiguration#ENABLE_SEMANTIC_MODELS}, but every operation returns {@code 501 Not + * Implemented}. Persistence, validation, authorization, and source-link resolution land in + * subsequent phases. + */ +@RequestScoped +public class SemanticModelCatalogAdapter + implements PolarisCatalogSemanticModelApiService, CatalogAdapter { + + private final RealmConfig realmConfig; + + @Inject + public SemanticModelCatalogAdapter(CallContext callContext) { + this.realmConfig = callContext.getRealmConfig(); + } + + private void ensureEnabled() { + FeatureConfiguration.enforceFeatureEnabledOrThrow( + realmConfig, FeatureConfiguration.ENABLE_SEMANTIC_MODELS); + } + + private static Response notImplemented() { + return Response.status(Response.Status.NOT_IMPLEMENTED).build(); + } + + @Override + public Response createSemanticModel( + String prefix, + String namespace, + CreateSemanticModelRequest createSemanticModelRequest, + RealmContext realmContext, + SecurityContext securityContext) { + ensureEnabled(); + return notImplemented(); Review Comment: I appreciate that you are showing us how you are going to be moving forward with building this feature, however I would appreciate TODOs here. While the code does a fantastic job at documenting what the code does, it does not do a good enough job (in this case) for why it is doing that. Could you add TODOs to mark that you will be following up here? -- 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]
