Skip to content

Commit a3d850f

Browse files
authored
Prefer RealmConfig fields (#2971)
minor cleanup of verbose code
1 parent 361b7e9 commit a3d850f

File tree

4 files changed

+9
-19
lines changed

4 files changed

+9
-19
lines changed

runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,8 @@ private PolarisResolutionManifest authorizeGrantOnTableLikeOperationOrThrow(
518518
resolutionManifest.getResolvedPath(
519519
identifier, PolarisEntityType.TABLE_LIKE, PolarisEntitySubType.ANY_SUBTYPE, true);
520520
boolean rbacForFederatedCatalogsEnabled =
521-
getCurrentPolarisContext()
522-
.getRealmConfig()
523-
.getConfig(
524-
FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS, catalogEntity);
521+
realmConfig.getConfig(
522+
FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS, catalogEntity);
525523
if (!(resolutionManifest.getIsPassthroughFacade() && rbacForFederatedCatalogsEnabled)
526524
&& !subTypes.contains(tableLikeWrapper.getRawLeafEntity().getSubType())) {
527525
CatalogHandler.throwNotFoundExceptionForTableLikeEntity(identifier, subTypes);
@@ -1698,11 +1696,8 @@ public PrivilegeResult grantPrivilegeOnNamespaceToRole(
16981696
if (resolvedPathWrapper == null
16991697
|| !resolvedPathWrapper.isFullyResolvedNamespace(catalogName, namespace)) {
17001698
boolean rbacForFederatedCatalogsEnabled =
1701-
getCurrentPolarisContext()
1702-
.getRealmConfig()
1703-
.getConfig(
1704-
FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS,
1705-
catalogEntity);
1699+
realmConfig.getConfig(
1700+
FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS, catalogEntity);
17061701
if (resolutionManifest.getIsPassthroughFacade() && rbacForFederatedCatalogsEnabled) {
17071702
resolvedPathWrapper =
17081703
createSyntheticNamespaceEntities(
@@ -2140,11 +2135,8 @@ private PrivilegeResult grantPrivilegeOnTableLikeToRole(
21402135
if (resolvedPathWrapper == null
21412136
|| !subTypes.contains(resolvedPathWrapper.getRawLeafEntity().getSubType())) {
21422137
boolean rbacForFederatedCatalogsEnabled =
2143-
getCurrentPolarisContext()
2144-
.getRealmConfig()
2145-
.getConfig(
2146-
FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS,
2147-
catalogEntity);
2138+
realmConfig.getConfig(
2139+
FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS, catalogEntity);
21482140
if (resolutionManifest.getIsPassthroughFacade() && rbacForFederatedCatalogsEnabled) {
21492141
resolvedPathWrapper =
21502142
createSyntheticTableLikeEntities(

runtime/service/src/main/java/org/apache/polaris/service/catalog/generic/GenericTableCatalogHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ protected void initializeCatalog() {
8787
.addKeyValue("remoteUrl", connectionConfigInfoDpo.getUri())
8888
.log("Initializing federated catalog");
8989
FeatureConfiguration.enforceFeatureEnabledOrThrow(
90-
callContext.getRealmConfig(), FeatureConfiguration.ENABLE_CATALOG_FEDERATION);
90+
realmConfig, FeatureConfiguration.ENABLE_CATALOG_FEDERATION);
9191

9292
GenericTableCatalog federatedCatalog;
9393
ConnectionType connectionType =

runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -806,9 +806,7 @@ protected ViewOperations newViewOps(TableIdentifier identifier) {
806806
@Override
807807
public boolean dropView(TableIdentifier identifier) {
808808
boolean purge =
809-
callContext
810-
.getRealmConfig()
811-
.getConfig(FeatureConfiguration.PURGE_VIEW_METADATA_ON_DROP, catalogEntity);
809+
realmConfig.getConfig(FeatureConfiguration.PURGE_VIEW_METADATA_ON_DROP, catalogEntity);
812810

813811
return dropTableLike(PolarisEntitySubType.ICEBERG_VIEW, identifier, Map.of(), purge)
814812
.isSuccess();

runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAdminServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public class PolarisAdminServiceTest {
8383
void setUp() throws Exception {
8484
MockitoAnnotations.openMocks(this);
8585
when(callContext.getPolarisCallContext()).thenReturn(polarisCallContext);
86-
when(polarisCallContext.getRealmConfig()).thenReturn(realmConfig);
86+
when(callContext.getRealmConfig()).thenReturn(realmConfig);
8787

8888
// Default feature configuration - enabled by default
8989
when(realmConfig.getConfig(FeatureConfiguration.ENABLE_SUB_CATALOG_RBAC_FOR_FEDERATED_CATALOGS))

0 commit comments

Comments
 (0)