Skip to content

Commit 99af56a

Browse files
committed
move all functions to PolarisEndpoints
1 parent 07b0e72 commit 99af56a

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

polaris-core/src/main/java/org/apache/polaris/core/rest/PolarisEndpoints.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
import com.google.common.collect.ImmutableSet;
2222
import java.util.Set;
2323
import org.apache.iceberg.rest.Endpoint;
24+
import org.apache.polaris.core.config.FeatureConfiguration;
25+
import org.apache.polaris.core.context.CallContext;
2426

2527
public class PolarisEndpoints {
2628
public static final Endpoint V1_LIST_GENERIC_TABLES =
@@ -39,4 +41,20 @@ public class PolarisEndpoints {
3941
.add(V1_DELETE_GENERIC_TABLE)
4042
.add(V1_LOAD_GENERIC_TABLE)
4143
.build();
44+
45+
/**
46+
* Get the generic table endpoints. Returns GENERIC_TABLE_ENDPOINTS if ENABLE_GENERIC_TABLES is
47+
* set to true, otherwise, returns an empty set.
48+
*/
49+
public static Set<Endpoint> getSupportedGenericTableEndpoints(CallContext callContext) {
50+
// add the generic table endpoints as supported endpoints if generic table feature is enabled.
51+
boolean genericTableEnabled =
52+
callContext
53+
.getPolarisCallContext()
54+
.getConfigurationStore()
55+
.getConfiguration(
56+
callContext.getPolarisCallContext(), FeatureConfiguration.ENABLE_GENERIC_TABLES);
57+
58+
return genericTableEnabled ? PolarisEndpoints.GENERIC_TABLE_ENDPOINTS : ImmutableSet.of();
59+
}
4260
}

service/common/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogAdapter.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
import org.apache.iceberg.rest.responses.LoadTableResponse;
6060
import org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
6161
import org.apache.polaris.core.auth.PolarisAuthorizer;
62-
import org.apache.polaris.core.config.FeatureConfiguration;
6362
import org.apache.polaris.core.context.CallContext;
6463
import org.apache.polaris.core.context.RealmContext;
6564
import org.apache.polaris.core.entity.PolarisEntity;
@@ -705,16 +704,6 @@ public Response getConfig(
705704

706705
String prefix = prefixParser.catalogNameToPrefix(realmContext, warehouse);
707706

708-
// add the generic table endpoints as supported endpoints if generic table feature is enabled.
709-
boolean genericTableEnabled =
710-
callContext
711-
.getPolarisCallContext()
712-
.getConfigurationStore()
713-
.getConfiguration(
714-
callContext.getPolarisCallContext(), FeatureConfiguration.ENABLE_GENERIC_TABLES);
715-
Set<Endpoint> supportedGenericTableEndpoints =
716-
genericTableEnabled ? PolarisEndpoints.GENERIC_TABLE_ENDPOINTS : ImmutableSet.of();
717-
718707
return Response.ok(
719708
ConfigResponse.builder()
720709
.withDefaults(properties) // catalog properties are defaults
@@ -724,7 +713,7 @@ public Response getConfig(
724713
.addAll(DEFAULT_ENDPOINTS)
725714
.addAll(VIEW_ENDPOINTS)
726715
.addAll(COMMIT_ENDPOINT)
727-
.addAll(supportedGenericTableEndpoints)
716+
.addAll(PolarisEndpoints.getSupportedGenericTableEndpoints(callContext))
728717
.build())
729718
.build())
730719
.build();

0 commit comments

Comments
 (0)