This is an automated email from the ASF dual-hosted git repository.

yufei pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/polaris.git


The following commit(s) were added to refs/heads/main by this push:
     new c165249f1 Replace CallContext with RealmConfig in CatalogEntity (#2336)
c165249f1 is described below

commit c165249f1d1d92a435ee9b85d13f92fe14fcf2bb
Author: Christopher Lambert <xn...@gmx.de>
AuthorDate: Fri Aug 15 00:45:33 2025 +0200

    Replace CallContext with RealmConfig in CatalogEntity (#2336)
---
 .../apache/polaris/core/entity/CatalogEntity.java  | 16 ++++----
 .../storage/PolarisStorageConfigurationInfo.java   |  9 ++---
 .../polaris/service/admin/PolarisAdminService.java |  5 ++-
 .../service/catalog/iceberg/IcebergCatalog.java    |  2 +-
 .../service/admin/PolarisAuthzTestBase.java        |  5 ++-
 .../catalog/AbstractIcebergCatalogTest.java        | 15 ++++---
 .../catalog/AbstractIcebergCatalogViewTest.java    |  5 ++-
 .../AbstractPolarisGenericTableCatalogTest.java    |  6 ++-
 .../service/catalog/AbstractPolicyCatalogTest.java | 18 ++++-----
 .../catalog/IcebergCatalogHandlerAuthzTest.java    |  2 +-
 .../polaris/service/entity/CatalogEntityTest.java  | 46 +++++++++-------------
 11 files changed, 61 insertions(+), 68 deletions(-)

diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java 
b/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java
index 01e79b466..bd87d6024 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/entity/CatalogEntity.java
@@ -40,8 +40,8 @@ import 
org.apache.polaris.core.admin.model.GcpStorageConfigInfo;
 import org.apache.polaris.core.admin.model.PolarisCatalog;
 import org.apache.polaris.core.admin.model.StorageConfigInfo;
 import org.apache.polaris.core.config.BehaviorChangeConfiguration;
+import org.apache.polaris.core.config.RealmConfig;
 import org.apache.polaris.core.connection.ConnectionConfigInfoDpo;
-import org.apache.polaris.core.context.CallContext;
 import org.apache.polaris.core.secrets.UserSecretReference;
 import org.apache.polaris.core.storage.FileStorageConfigurationInfo;
 import org.apache.polaris.core.storage.PolarisStorageConfigurationInfo;
@@ -79,7 +79,7 @@ public class CatalogEntity extends PolarisEntity implements 
LocationBasedEntity
     return null;
   }
 
-  public static CatalogEntity fromCatalog(CallContext callContext, Catalog 
catalog) {
+  public static CatalogEntity fromCatalog(RealmConfig realmConfig, Catalog 
catalog) {
     Builder builder =
         new Builder()
             .setName(catalog.getName())
@@ -89,7 +89,7 @@ public class CatalogEntity extends PolarisEntity implements 
LocationBasedEntity
     internalProperties.put(CATALOG_TYPE_PROPERTY, catalog.getType().name());
     builder.setInternalProperties(internalProperties);
     builder.setStorageConfigurationInfo(
-        callContext, catalog.getStorageConfigInfo(), getBaseLocation(catalog));
+        realmConfig, catalog.getStorageConfigInfo(), getBaseLocation(catalog));
     return builder.build();
   }
 
@@ -250,7 +250,7 @@ public class CatalogEntity extends PolarisEntity implements 
LocationBasedEntity
     }
 
     public Builder setStorageConfigurationInfo(
-        CallContext callContext, StorageConfigInfo storageConfigModel, String 
defaultBaseLocation) {
+        RealmConfig realmConfig, StorageConfigInfo storageConfigModel, String 
defaultBaseLocation) {
       if (storageConfigModel != null) {
         PolarisStorageConfigurationInfo config;
         Set<String> allowedLocations = new 
HashSet<>(storageConfigModel.getAllowedLocations());
@@ -264,7 +264,7 @@ public class CatalogEntity extends PolarisEntity implements 
LocationBasedEntity
           throw new BadRequestException("Must specify default base location");
         }
         allowedLocations.add(defaultBaseLocation);
-        validateMaxAllowedLocations(callContext, allowedLocations);
+        validateMaxAllowedLocations(realmConfig, allowedLocations);
         switch (storageConfigModel.getStorageType()) {
           case S3:
             AwsStorageConfigInfo awsConfigModel = (AwsStorageConfigInfo) 
storageConfigModel;
@@ -315,11 +315,9 @@ public class CatalogEntity extends PolarisEntity 
implements LocationBasedEntity
 
     /** Validate the number of allowed locations not exceeding the max value. 
*/
     private void validateMaxAllowedLocations(
-        CallContext callContext, Collection<String> allowedLocations) {
+        RealmConfig realmConfig, Collection<String> allowedLocations) {
       int maxAllowedLocations =
-          callContext
-              .getRealmConfig()
-              
.getConfig(BehaviorChangeConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS);
+          
realmConfig.getConfig(BehaviorChangeConfiguration.STORAGE_CONFIGURATION_MAX_LOCATIONS);
       if (maxAllowedLocations != -1 && allowedLocations.size() > 
maxAllowedLocations) {
         throw new IllegalArgumentException(
             String.format(
diff --git 
a/polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java
 
b/polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java
index a587bc051..e3947a20b 100644
--- 
a/polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java
+++ 
b/polaris-core/src/main/java/org/apache/polaris/core/storage/PolarisStorageConfigurationInfo.java
@@ -34,9 +34,9 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Optional;
 import java.util.Set;
-import org.apache.polaris.core.PolarisCallContext;
 import org.apache.polaris.core.admin.model.Catalog;
 import org.apache.polaris.core.config.FeatureConfiguration;
+import org.apache.polaris.core.config.RealmConfig;
 import org.apache.polaris.core.entity.CatalogEntity;
 import org.apache.polaris.core.entity.PolarisEntity;
 import org.apache.polaris.core.entity.PolarisEntityConstants;
@@ -117,7 +117,7 @@ public abstract class PolarisStorageConfigurationInfo {
   }
 
   public static Optional<PolarisStorageConfigurationInfo> forEntityPath(
-      PolarisCallContext callContext, List<PolarisEntity> entityPath) {
+      RealmConfig realmConfig, List<PolarisEntity> entityPath) {
     return findStorageInfoFromHierarchy(entityPath)
         .map(
             storageInfo ->
@@ -142,9 +142,8 @@ public abstract class PolarisStorageConfigurationInfo {
                       .orElse(null);
               CatalogEntity catalog = CatalogEntity.of(entityPath.get(0));
               boolean allowEscape =
-                  callContext
-                      .getRealmConfig()
-                      
.getConfig(FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION, catalog);
+                  realmConfig.getConfig(
+                      FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION, 
catalog);
               if (!allowEscape
                   && catalog.getCatalogType() != Catalog.TypeEnum.EXTERNAL
                   && baseLocation != null) {
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
index 1f47e4937..6353aa0cf 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/admin/PolarisAdminService.java
@@ -755,7 +755,8 @@ public class PolarisAdminService {
     PolarisAuthorizableOperation op = 
PolarisAuthorizableOperation.CREATE_CATALOG;
     authorizeBasicRootOperationOrThrow(op);
 
-    CatalogEntity entity = CatalogEntity.fromCatalog(callContext, 
catalogRequest.getCatalog());
+    CatalogEntity entity =
+        CatalogEntity.fromCatalog(callContext.getRealmConfig(), 
catalogRequest.getCatalog());
 
     checkArgument(entity.getId() == -1, "Entity to be created must have no ID 
assigned");
 
@@ -960,7 +961,7 @@ public class PolarisAdminService {
     }
     if (updateRequest.getStorageConfigInfo() != null) {
       updateBuilder.setStorageConfigurationInfo(
-          callContext, updateRequest.getStorageConfigInfo(), 
defaultBaseLocation);
+          callContext.getRealmConfig(), updateRequest.getStorageConfigInfo(), 
defaultBaseLocation);
     }
     CatalogEntity updatedEntity = updateBuilder.build();
 
diff --git 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
index dcc493e0d..9d37dd32d 100644
--- 
a/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
+++ 
b/runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalog.java
@@ -1007,7 +1007,7 @@ public class IcebergCatalog extends 
BaseMetastoreViewCatalog
       PolarisResolvedPathWrapper resolvedStorageEntity) {
     Optional<PolarisStorageConfigurationInfo> optStorageConfiguration =
         PolarisStorageConfigurationInfo.forEntityPath(
-            callContext.getPolarisCallContext(), 
resolvedStorageEntity.getRawFullPath());
+            callContext.getRealmConfig(), 
resolvedStorageEntity.getRawFullPath());
 
     optStorageConfiguration.ifPresentOrElse(
         storageConfigInfo -> {
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java
index 5e2b349d1..5308a905d 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/admin/PolarisAuthzTestBase.java
@@ -55,6 +55,7 @@ import 
org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
 import org.apache.polaris.core.auth.PolarisAuthorizer;
 import org.apache.polaris.core.auth.PolarisAuthorizerImpl;
 import org.apache.polaris.core.config.PolarisConfigurationStore;
+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.core.entity.CatalogEntity;
@@ -199,6 +200,7 @@ public abstract class PolarisAuthzTestBase {
   protected PolarisBaseEntity catalogEntity;
   protected PrincipalEntity principalEntity;
   protected CallContext callContext;
+  protected RealmConfig realmConfig;
   protected AuthenticatedPolarisPrincipal authenticatedRoot;
   protected PolarisAuthorizer polarisAuthorizer;
 
@@ -234,6 +236,7 @@ public abstract class PolarisAuthzTestBase {
             configurationStore);
 
     callContext = polarisContext;
+    realmConfig = polarisContext.getRealmConfig();
 
     PrincipalEntity rootPrincipal =
         metaStoreManager.findRootPrincipal(polarisContext).orElseThrow();
@@ -262,7 +265,7 @@ public abstract class PolarisAuthzTestBase {
                     .setName(CATALOG_NAME)
                     .setCatalogType("INTERNAL")
                     .setDefaultBaseLocation(storageLocation)
-                    .setStorageConfigurationInfo(callContext, 
storageConfigModel, storageLocation)
+                    .setStorageConfigurationInfo(realmConfig, 
storageConfigModel, storageLocation)
                     .build()
                     .asCatalog()));
 
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractIcebergCatalogTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractIcebergCatalogTest.java
index b37447616..352a5276f 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractIcebergCatalogTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractIcebergCatalogTest.java
@@ -235,6 +235,7 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
   private PolarisMetaStoreManager metaStoreManager;
   private UserSecretsManager userSecretsManager;
   private PolarisCallContext polarisContext;
+  private RealmConfig realmConfig;
   private PolarisAdminService adminService;
   private ResolverFactory resolverFactory;
   private ResolutionManifestFactory resolutionManifestFactory;
@@ -279,8 +280,9 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             diagServices,
             configurationStore);
+    realmConfig = polarisContext.getRealmConfig();
 
-    EntityCache entityCache = 
createEntityCache(polarisContext.getRealmConfig(), metaStoreManager);
+    EntityCache entityCache = createEntityCache(realmConfig, metaStoreManager);
     resolverFactory =
         (callContext, securityContext, referenceCatalogName) ->
             new Resolver(
@@ -337,8 +339,7 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
                         "true")
                     .addProperty(
                         
FeatureConfiguration.DROP_WITH_PURGE_ENABLED.catalogConfig(), "true")
-                    .setStorageConfigurationInfo(
-                        polarisContext, storageConfigModel, storageLocation)
+                    .setStorageConfigurationInfo(realmConfig, 
storageConfigModel, storageLocation)
                     .build()
                     .asCatalog()));
 
@@ -1327,8 +1328,7 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
         metadataLocation,
         
TableMetadataParser.toJson(createSampleTableMetadata(metadataLocation)).getBytes(UTF_8));
 
-    if (!polarisContext
-        .getRealmConfig()
+    if (!realmConfig
         .getConfig(FeatureConfiguration.SUPPORTED_CATALOG_STORAGE_TYPES)
         .contains("FILE")) {
       Assertions.assertThatThrownBy(() -> catalog.sendNotification(table, 
request))
@@ -1380,8 +1380,7 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
         metadataLocation,
         
TableMetadataParser.toJson(createSampleTableMetadata(metadataLocation)).getBytes(UTF_8));
 
-    if (!polarisContext
-        .getRealmConfig()
+    if (!realmConfig
         .getConfig(FeatureConfiguration.SUPPORTED_CATALOG_STORAGE_TYPES)
         .contains("FILE")) {
       Assertions.assertThatThrownBy(() -> catalog.sendNotification(table, 
request))
@@ -1871,7 +1870,7 @@ public abstract class AbstractIcebergCatalogTest extends 
CatalogTests<IcebergCat
                     
FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(), "true")
                 
.addProperty(FeatureConfiguration.DROP_WITH_PURGE_ENABLED.catalogConfig(), 
"false")
                 .setStorageConfigurationInfo(
-                    polarisContext, noPurgeStorageConfigModel, storageLocation)
+                    realmConfig, noPurgeStorageConfigModel, storageLocation)
                 .build()
                 .asCatalog()));
     IcebergCatalog noPurgeCatalog =
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractIcebergCatalogViewTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractIcebergCatalogViewTest.java
index b7ad58930..67a112bd0 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractIcebergCatalogViewTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractIcebergCatalogViewTest.java
@@ -44,6 +44,7 @@ import 
org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
 import org.apache.polaris.core.auth.PolarisAuthorizerImpl;
 import org.apache.polaris.core.config.FeatureConfiguration;
 import org.apache.polaris.core.config.PolarisConfigurationStore;
+import org.apache.polaris.core.config.RealmConfig;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.CatalogEntity;
 import org.apache.polaris.core.entity.PrincipalEntity;
@@ -120,6 +121,7 @@ public abstract class AbstractIcebergCatalogViewTest 
extends ViewCatalogTests<Ic
   private PolarisMetaStoreManager metaStoreManager;
   private UserSecretsManager userSecretsManager;
   private PolarisCallContext polarisContext;
+  private RealmConfig realmConfig;
 
   private TestPolarisEventListener testPolarisEventListener;
 
@@ -160,6 +162,7 @@ public abstract class AbstractIcebergCatalogViewTest 
extends ViewCatalogTests<Ic
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             diagServices,
             configurationStore);
+    realmConfig = polarisContext.getRealmConfig();
 
     PrincipalEntity rootPrincipal =
         metaStoreManager.findRootPrincipal(polarisContext).orElseThrow();
@@ -192,7 +195,7 @@ public abstract class AbstractIcebergCatalogViewTest 
extends ViewCatalogTests<Ic
                 
.addProperty(FeatureConfiguration.DROP_WITH_PURGE_ENABLED.catalogConfig(), 
"true")
                 .setDefaultBaseLocation("file://tmp")
                 .setStorageConfigurationInfo(
-                    polarisContext,
+                    realmConfig,
                     new FileStorageConfigInfo(
                         StorageConfigInfo.StorageTypeEnum.FILE, 
List.of("file://", "/", "*")),
                     "file://tmp")
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractPolarisGenericTableCatalogTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractPolarisGenericTableCatalogTest.java
index f2524798f..ef2046b82 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractPolarisGenericTableCatalogTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractPolarisGenericTableCatalogTest.java
@@ -45,6 +45,7 @@ import 
org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
 import org.apache.polaris.core.auth.PolarisAuthorizerImpl;
 import org.apache.polaris.core.config.FeatureConfiguration;
 import org.apache.polaris.core.config.PolarisConfigurationStore;
+import org.apache.polaris.core.config.RealmConfig;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.CatalogEntity;
 import org.apache.polaris.core.entity.PolarisEntity;
@@ -110,6 +111,7 @@ public abstract class 
AbstractPolarisGenericTableCatalogTest {
   private PolarisMetaStoreManager metaStoreManager;
   private UserSecretsManager userSecretsManager;
   private PolarisCallContext polarisContext;
+  private RealmConfig realmConfig;
   private PolarisAdminService adminService;
   private FileIOFactory fileIOFactory;
   private AuthenticatedPolarisPrincipal authenticatedRoot;
@@ -152,6 +154,7 @@ public abstract class 
AbstractPolarisGenericTableCatalogTest {
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             diagServices,
             configurationStore);
+    realmConfig = polarisContext.getRealmConfig();
 
     PrincipalEntity rootPrincipal =
         metaStoreManager.findRootPrincipal(polarisContext).orElseThrow();
@@ -196,8 +199,7 @@ public abstract class 
AbstractPolarisGenericTableCatalogTest {
                         "true")
                     .addProperty(
                         
FeatureConfiguration.DROP_WITH_PURGE_ENABLED.catalogConfig(), "true")
-                    .setStorageConfigurationInfo(
-                        polarisContext, storageConfigModel, storageLocation)
+                    .setStorageConfigurationInfo(realmConfig, 
storageConfigModel, storageLocation)
                     .build()
                     .asCatalog()));
 
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractPolicyCatalogTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractPolicyCatalogTest.java
index dbfab7da2..dd26c7275 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractPolicyCatalogTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/AbstractPolicyCatalogTest.java
@@ -52,7 +52,7 @@ import 
org.apache.polaris.core.auth.AuthenticatedPolarisPrincipal;
 import org.apache.polaris.core.auth.PolarisAuthorizerImpl;
 import org.apache.polaris.core.config.FeatureConfiguration;
 import org.apache.polaris.core.config.PolarisConfigurationStore;
-import org.apache.polaris.core.context.CallContext;
+import org.apache.polaris.core.config.RealmConfig;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.CatalogEntity;
 import org.apache.polaris.core.entity.PolarisEntity;
@@ -132,12 +132,12 @@ public abstract class AbstractPolicyCatalogTest {
 
   private PolicyCatalog policyCatalog;
   private IcebergCatalog icebergCatalog;
-  private CallContext callContext;
   private AwsStorageConfigInfo storageConfigModel;
   private String realmName;
   private PolarisMetaStoreManager metaStoreManager;
   private UserSecretsManager userSecretsManager;
   private PolarisCallContext polarisContext;
+  private RealmConfig realmConfig;
   private PolarisAdminService adminService;
   private FileIOFactory fileIOFactory;
   private AuthenticatedPolarisPrincipal authenticatedRoot;
@@ -175,8 +175,7 @@ public abstract class AbstractPolicyCatalogTest {
             metaStoreManagerFactory.getOrCreateSession(realmContext),
             diagServices,
             configurationStore);
-
-    callContext = polarisContext;
+    realmConfig = polarisContext.getRealmConfig();
 
     PrincipalEntity rootPrincipal =
         metaStoreManager.findRootPrincipal(polarisContext).orElseThrow();
@@ -190,7 +189,7 @@ public abstract class AbstractPolicyCatalogTest {
 
     adminService =
         new PolarisAdminService(
-            callContext,
+            polarisContext,
             resolutionManifestFactory,
             metaStoreManager,
             userSecretsManager,
@@ -219,14 +218,13 @@ public abstract class AbstractPolicyCatalogTest {
                     .addProperty(
                         
FeatureConfiguration.ALLOW_UNSTRUCTURED_TABLE_LOCATION.catalogConfig(),
                         "true")
-                    .setStorageConfigurationInfo(
-                        polarisContext, storageConfigModel, storageLocation)
+                    .setStorageConfigurationInfo(realmConfig, 
storageConfigModel, storageLocation)
                     .build()
                     .asCatalog()));
 
     PolarisPassthroughResolutionView passthroughView =
         new PolarisPassthroughResolutionView(
-            callContext, resolutionManifestFactory, securityContext, 
CATALOG_NAME);
+            polarisContext, resolutionManifestFactory, securityContext, 
CATALOG_NAME);
     TaskExecutor taskExecutor = Mockito.mock();
     this.fileIOFactory = new DefaultFileIOFactory(storageCredentialCache, 
metaStoreManagerFactory);
 
@@ -250,13 +248,13 @@ public abstract class AbstractPolicyCatalogTest {
             isA(AwsStorageConfigurationInfo.class)))
         .thenReturn((PolarisStorageIntegration) storageIntegration);
 
-    this.policyCatalog = new PolicyCatalog(metaStoreManager, callContext, 
passthroughView);
+    this.policyCatalog = new PolicyCatalog(metaStoreManager, polarisContext, 
passthroughView);
     this.icebergCatalog =
         new IcebergCatalog(
             storageCredentialCache,
             resolverFactory,
             metaStoreManager,
-            callContext,
+            polarisContext,
             passthroughView,
             securityContext,
             taskExecutor,
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/IcebergCatalogHandlerAuthzTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/IcebergCatalogHandlerAuthzTest.java
index 90d7341a9..aaae14005 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/catalog/IcebergCatalogHandlerAuthzTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/catalog/IcebergCatalogHandlerAuthzTest.java
@@ -1735,7 +1735,7 @@ public class IcebergCatalogHandlerAuthzTest extends 
PolarisAuthzTestBase {
             new CatalogEntity.Builder()
                 .setName(externalCatalog)
                 .setDefaultBaseLocation(storageLocation)
-                .setStorageConfigurationInfo(callContext, storageConfigModel, 
storageLocation)
+                .setStorageConfigurationInfo(realmConfig, storageConfigModel, 
storageLocation)
                 .setCatalogType("EXTERNAL")
                 .build()
                 .asCatalog()));
diff --git 
a/runtime/service/src/test/java/org/apache/polaris/service/entity/CatalogEntityTest.java
 
b/runtime/service/src/test/java/org/apache/polaris/service/entity/CatalogEntityTest.java
index 4d774f8b3..fceeaa54e 100644
--- 
a/runtime/service/src/test/java/org/apache/polaris/service/entity/CatalogEntityTest.java
+++ 
b/runtime/service/src/test/java/org/apache/polaris/service/entity/CatalogEntityTest.java
@@ -22,12 +22,8 @@ import static org.assertj.core.api.Assertions.assertThat;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.ObjectMapper;
-import java.time.Clock;
 import java.util.List;
 import java.util.stream.Stream;
-import org.apache.polaris.core.PolarisCallContext;
-import org.apache.polaris.core.PolarisDefaultDiagServiceImpl;
-import org.apache.polaris.core.PolarisDiagnostics;
 import org.apache.polaris.core.admin.model.AwsStorageConfigInfo;
 import org.apache.polaris.core.admin.model.AzureStorageConfigInfo;
 import org.apache.polaris.core.admin.model.Catalog;
@@ -35,12 +31,11 @@ import 
org.apache.polaris.core.admin.model.CatalogProperties;
 import org.apache.polaris.core.admin.model.GcpStorageConfigInfo;
 import org.apache.polaris.core.admin.model.PolarisCatalog;
 import org.apache.polaris.core.admin.model.StorageConfigInfo;
-import org.apache.polaris.core.context.CallContext;
+import org.apache.polaris.core.config.PolarisConfigurationStore;
+import org.apache.polaris.core.config.RealmConfig;
+import org.apache.polaris.core.config.RealmConfigImpl;
 import org.apache.polaris.core.context.RealmContext;
 import org.apache.polaris.core.entity.CatalogEntity;
-import org.apache.polaris.core.persistence.BasePersistence;
-import org.apache.polaris.core.persistence.MetaStoreManagerFactory;
-import 
org.apache.polaris.service.persistence.InMemoryPolarisMetaStoreManagerFactory;
 import org.assertj.core.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -52,17 +47,12 @@ import org.junit.jupiter.params.provider.ValueSource;
 public class CatalogEntityTest {
   private static final ObjectMapper MAPPER = new ObjectMapper();
 
-  private final Clock clock = Clock.systemUTC();
-  private final PolarisDiagnostics diagnostics = new 
PolarisDefaultDiagServiceImpl();
-  private CallContext callContext;
+  private RealmConfig realmConfig;
 
   @BeforeEach
   public void setup() {
     RealmContext realmContext = () -> "realm";
-    MetaStoreManagerFactory metaStoreManagerFactory =
-        new InMemoryPolarisMetaStoreManagerFactory(clock, diagnostics, null);
-    BasePersistence metaStore = 
metaStoreManagerFactory.getOrCreateSession(realmContext);
-    this.callContext = new PolarisCallContext(realmContext, metaStore, 
diagnostics);
+    this.realmConfig = new RealmConfigImpl(new PolarisConfigurationStore() {}, 
realmContext);
   }
 
   @ParameterizedTest
@@ -85,7 +75,7 @@ public class CatalogEntityTest {
             .setProperties(props)
             .setStorageConfigInfo(awsStorageConfigModel)
             .build();
-    Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(callContext, 
awsCatalog))
+    Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(realmConfig, 
awsCatalog))
         .isInstanceOf(IllegalArgumentException.class)
         .hasMessageContaining(
             "Location prefix not allowed: 'unsupportPrefix://mybucket/path', 
expected prefixes");
@@ -111,7 +101,7 @@ public class CatalogEntityTest {
                 new 
CatalogProperties("abfs://contai...@storageaccount.blob.windows.net/path"))
             .setStorageConfigInfo(azureStorageConfigModel)
             .build();
-    Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(callContext, 
azureCatalog))
+    Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(realmConfig, 
azureCatalog))
         .isInstanceOf(IllegalArgumentException.class)
         .hasMessageContaining("Invalid azure location uri 
unsupportPrefix://mybucket/path");
 
@@ -128,7 +118,7 @@ public class CatalogEntityTest {
             .setProperties(new 
CatalogProperties("gs://externally-owned-bucket"))
             .setStorageConfigInfo(gcpStorageConfigModel)
             .build();
-    Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(callContext, 
gcpCatalog))
+    Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(realmConfig, 
gcpCatalog))
         .isInstanceOf(IllegalArgumentException.class)
         .hasMessageContaining(
             "Location prefix not allowed: 'unsupportPrefix://mybucket/path', 
expected prefixes");
@@ -161,7 +151,7 @@ public class CatalogEntityTest {
             .setProperties(prop)
             .setStorageConfigInfo(awsStorageConfigModel)
             .build();
-    Assertions.assertThatCode(() -> CatalogEntity.fromCatalog(callContext, 
awsCatalog))
+    Assertions.assertThatCode(() -> CatalogEntity.fromCatalog(realmConfig, 
awsCatalog))
         .doesNotThrowAnyException();
   }
 
@@ -187,7 +177,7 @@ public class CatalogEntityTest {
             .setStorageConfigInfo(awsStorageConfigModel)
             .build();
     Assertions.assertThatNoException()
-        .isThrownBy(() -> CatalogEntity.fromCatalog(callContext, awsCatalog));
+        .isThrownBy(() -> CatalogEntity.fromCatalog(realmConfig, awsCatalog));
   }
 
   @Test
@@ -208,7 +198,7 @@ public class CatalogEntityTest {
             .setStorageConfigInfo(azureStorageConfigModel)
             .build();
     Assertions.assertThatNoException()
-        .isThrownBy(() -> CatalogEntity.fromCatalog(callContext, awsCatalog));
+        .isThrownBy(() -> CatalogEntity.fromCatalog(realmConfig, awsCatalog));
     prop.put(CatalogEntity.DEFAULT_BASE_LOCATION_KEY, basedLocation);
 
     Catalog azureCatalog =
@@ -219,7 +209,7 @@ public class CatalogEntityTest {
             .setStorageConfigInfo(azureStorageConfigModel)
             .build();
     Assertions.assertThatNoException()
-        .isThrownBy(() -> CatalogEntity.fromCatalog(callContext, 
azureCatalog));
+        .isThrownBy(() -> CatalogEntity.fromCatalog(realmConfig, 
azureCatalog));
 
     basedLocation = "gs://externally-owned-bucket";
     prop.put(CatalogEntity.DEFAULT_BASE_LOCATION_KEY, basedLocation);
@@ -236,7 +226,7 @@ public class CatalogEntityTest {
             .setStorageConfigInfo(gcpStorageConfigModel)
             .build();
     Assertions.assertThatNoException()
-        .isThrownBy(() -> CatalogEntity.fromCatalog(callContext, gcpCatalog));
+        .isThrownBy(() -> CatalogEntity.fromCatalog(realmConfig, gcpCatalog));
   }
 
   @ParameterizedTest
@@ -265,7 +255,7 @@ public class CatalogEntityTest {
           case "aws-cn" -> "AWS China is temporarily not supported";
           default -> "Invalid role ARN format: arn:aws:iam::0123456:role/jdoe";
         };
-    Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(callContext, 
awsCatalog))
+    Assertions.assertThatThrownBy(() -> CatalogEntity.fromCatalog(realmConfig, 
awsCatalog))
         .isInstanceOf(IllegalArgumentException.class)
         .hasMessage(expectedMessage);
   }
@@ -285,7 +275,7 @@ public class CatalogEntityTest {
         new CatalogEntity.Builder()
             .setName("test-catalog")
             .setDefaultBaseLocation(baseLocation)
-            .setStorageConfigurationInfo(callContext, storageConfigModel, 
baseLocation)
+            .setStorageConfigurationInfo(realmConfig, storageConfigModel, 
baseLocation)
             .build();
 
     Catalog catalog = catalogEntity.asCatalog();
@@ -308,7 +298,7 @@ public class CatalogEntityTest {
             .setName("test-external-catalog")
             .setDefaultBaseLocation(baseLocation)
             .setCatalogType(Catalog.TypeEnum.EXTERNAL.name())
-            .setStorageConfigurationInfo(callContext, storageConfigModel, 
baseLocation)
+            .setStorageConfigurationInfo(realmConfig, storageConfigModel, 
baseLocation)
             .build();
 
     Catalog catalog = catalogEntity.asCatalog();
@@ -331,7 +321,7 @@ public class CatalogEntityTest {
             .setName("test-internal-catalog")
             .setDefaultBaseLocation(baseLocation)
             .setCatalogType(Catalog.TypeEnum.INTERNAL.name())
-            .setStorageConfigurationInfo(callContext, storageConfigModel, 
baseLocation)
+            .setStorageConfigurationInfo(realmConfig, storageConfigModel, 
baseLocation)
             .build();
 
     Catalog catalog = catalogEntity.asCatalog();
@@ -367,7 +357,7 @@ public class CatalogEntityTest {
             .setDefaultBaseLocation(config.getAllowedLocations().getFirst())
             .setCatalogType(Catalog.TypeEnum.INTERNAL.name())
             .setStorageConfigurationInfo(
-                callContext,
+                realmConfig,
                 MAPPER.readValue(configStr, StorageConfigInfo.class),
                 config.getAllowedLocations().getFirst())
             .build();

Reply via email to