From 6aee9324f60d9b78bcfec6e4eca15b94a9b83aa1 Mon Sep 17 00:00:00 2001 From: Honah J Date: Thu, 25 Sep 2025 21:13:28 -0500 Subject: [PATCH 1/2] remove unused name param --- .../service/admin/PolarisAdminService.java | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) 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 bd8a1d6a49..a6078d0c7c 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 @@ -190,7 +190,7 @@ private UserSecretsManager getUserSecretsManager() { return userSecretsManager; } - private Optional findCatalogByName(String name) { + private Optional findCatalog() { return Optional.ofNullable(resolutionManifest.getResolvedReferenceCatalogEntity()) .map(path -> CatalogEntity.of(path.getRawLeafEntity())); } @@ -513,7 +513,7 @@ private void authorizeGrantOnTableLikeOperationOrThrow( CatalogEntity catalogEntity = CatalogEntity.of( - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Catalog %s not found", catalogName))); PolarisResolvedPathWrapper tableLikeWrapper = resolutionManifest.getResolvedPath( @@ -797,8 +797,7 @@ public void deleteCatalog(String name) { authorizeBasicTopLevelEntityOperationOrThrow(op, name, PolarisEntityType.CATALOG); PolarisEntity entity = - findCatalogByName(name) - .orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); + findCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); // TODO: Handle return value in case of concurrent modification boolean cleanup = realmConfig.getConfig(FeatureConfiguration.CLEANUP_ON_CATALOG_DROP); DropEntityResult dropEntityResult = @@ -823,8 +822,7 @@ public void deleteCatalog(String name) { PolarisAuthorizableOperation op = PolarisAuthorizableOperation.GET_CATALOG; authorizeBasicTopLevelEntityOperationOrThrow(op, name, PolarisEntityType.CATALOG); - return findCatalogByName(name) - .orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); + return findCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); } /** @@ -883,8 +881,7 @@ private void validateUpdateCatalogDiffOrThrow( authorizeBasicTopLevelEntityOperationOrThrow(op, name, PolarisEntityType.CATALOG); CatalogEntity currentCatalogEntity = - findCatalogByName(name) - .orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); + findCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); if (currentCatalogEntity.getEntityVersion() != updateRequest.getCurrentEntityVersion()) { throw new CommitConflictException( @@ -1321,7 +1318,7 @@ public PolarisEntity createCatalogRole(String catalogName, PolarisEntity entity) checkArgument(entity.getId() == -1, "Entity to be created must have no ID assigned"); PolarisEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity returnedEntity = @@ -1386,8 +1383,7 @@ public void deleteCatalogRole(String catalogName, String name) { authorizeBasicCatalogRoleOperationOrThrow(op, catalogName, name); CatalogEntity catalogEntity = - findCatalogByName(catalogName) - .orElseThrow(() -> new NotFoundException("Catalog %s not found", catalogName)); + findCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", catalogName)); CatalogRoleEntity currentCatalogRoleEntity = findCatalogRoleByName(catalogName, name) .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", name)); @@ -1427,7 +1423,7 @@ public List listCatalogRoles(String catalogName) { authorizeBasicTopLevelEntityOperationOrThrow(op, catalogName, PolarisEntityType.CATALOG); PolarisEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); List catalogPath = PolarisEntity.toCoreList(List.of(catalogEntity)); return metaStoreManager @@ -1509,7 +1505,7 @@ public PrivilegeResult assignCatalogRoleToPrincipalRole( .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); PolarisEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1531,7 +1527,7 @@ public PrivilegeResult revokeCatalogRoleFromPrincipalRole( .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); PolarisEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1597,7 +1593,7 @@ public List listCatalogRolesForPrincipalRole( op, principalRoleName, PolarisEntityType.PRINCIPAL_ROLE, catalogName); PolarisEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity principalRoleEntity = findPrincipalRoleByName(principalRoleName) @@ -1659,7 +1655,7 @@ public PrivilegeResult grantPrivilegeOnCatalogToRole( authorizeGrantOnCatalogOperationOrThrow(op, catalogName, catalogRoleName); PolarisEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1681,7 +1677,7 @@ public PrivilegeResult revokePrivilegeOnCatalogFromRole( authorizeGrantOnCatalogOperationOrThrow(op, catalogName, catalogRoleName); PolarisEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1703,7 +1699,7 @@ public PrivilegeResult grantPrivilegeOnNamespaceToRole( authorizeGrantOnNamespaceOperationOrThrow(op, catalogName, namespace, catalogRoleName); CatalogEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1965,7 +1961,7 @@ public List listAssigneePrincipalRolesForCatalogRole( PolarisAuthorizableOperation.LIST_ASSIGNEE_PRINCIPAL_ROLES_FOR_CATALOG_ROLE; authorizeBasicCatalogRoleOperationOrThrow(op, catalogName, catalogRoleName); - if (findCatalogByName(catalogName).isEmpty()) { + if (findCatalog().isEmpty()) { throw new NotFoundException("Parent catalog %s not found", catalogName); } PolarisEntity catalogRoleEntity = @@ -2129,7 +2125,7 @@ private PrivilegeResult grantPrivilegeOnTableLikeToRole( List subTypes, PolarisPrivilege privilege) { CatalogEntity catalogEntity = - findCatalogByName(catalogName) + findCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -2253,7 +2249,7 @@ private PrivilegeResult revokePrivilegeOnTableLikeFromRole( TableIdentifier identifier, List subTypes, PolarisPrivilege privilege) { - if (findCatalogByName(catalogName).isEmpty()) { + if (findCatalog().isEmpty()) { throw new NotFoundException("Parent catalog %s not found", catalogName); } PolarisEntity catalogRoleEntity = @@ -2283,7 +2279,7 @@ private PrivilegeResult grantPrivilegeOnPolicyEntityToRole( String catalogRoleName, PolicyIdentifier identifier, PolarisPrivilege privilege) { - if (findCatalogByName(catalogName).isEmpty()) { + if (findCatalog().isEmpty()) { throw new NotFoundException("Parent catalog %s not found", catalogName); } PolarisEntity catalogRoleEntity = @@ -2311,7 +2307,7 @@ private PrivilegeResult revokePrivilegeOnPolicyEntityFromRole( String catalogRoleName, PolicyIdentifier identifier, PolarisPrivilege privilege) { - if (findCatalogByName(catalogName).isEmpty()) { + if (findCatalog().isEmpty()) { throw new NotFoundException("Parent catalog %s not found", catalogName); } PolarisEntity catalogRoleEntity = From bf64ac948fb8ee47bf55880a9f51d8c35821bc31 Mon Sep 17 00:00:00 2001 From: Honah J Date: Fri, 26 Sep 2025 15:11:08 -0500 Subject: [PATCH 2/2] Rename for better readability --- .../service/admin/PolarisAdminService.java | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) 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 a6078d0c7c..651920a001 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 @@ -190,7 +190,7 @@ private UserSecretsManager getUserSecretsManager() { return userSecretsManager; } - private Optional findCatalog() { + private Optional currentCatalog() { return Optional.ofNullable(resolutionManifest.getResolvedReferenceCatalogEntity()) .map(path -> CatalogEntity.of(path.getRawLeafEntity())); } @@ -513,7 +513,7 @@ private void authorizeGrantOnTableLikeOperationOrThrow( CatalogEntity catalogEntity = CatalogEntity.of( - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Catalog %s not found", catalogName))); PolarisResolvedPathWrapper tableLikeWrapper = resolutionManifest.getResolvedPath( @@ -797,7 +797,7 @@ public void deleteCatalog(String name) { authorizeBasicTopLevelEntityOperationOrThrow(op, name, PolarisEntityType.CATALOG); PolarisEntity entity = - findCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); + currentCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); // TODO: Handle return value in case of concurrent modification boolean cleanup = realmConfig.getConfig(FeatureConfiguration.CLEANUP_ON_CATALOG_DROP); DropEntityResult dropEntityResult = @@ -822,7 +822,7 @@ public void deleteCatalog(String name) { PolarisAuthorizableOperation op = PolarisAuthorizableOperation.GET_CATALOG; authorizeBasicTopLevelEntityOperationOrThrow(op, name, PolarisEntityType.CATALOG); - return findCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); + return currentCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); } /** @@ -881,7 +881,7 @@ private void validateUpdateCatalogDiffOrThrow( authorizeBasicTopLevelEntityOperationOrThrow(op, name, PolarisEntityType.CATALOG); CatalogEntity currentCatalogEntity = - findCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); + currentCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", name)); if (currentCatalogEntity.getEntityVersion() != updateRequest.getCurrentEntityVersion()) { throw new CommitConflictException( @@ -1318,7 +1318,7 @@ public PolarisEntity createCatalogRole(String catalogName, PolarisEntity entity) checkArgument(entity.getId() == -1, "Entity to be created must have no ID assigned"); PolarisEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity returnedEntity = @@ -1383,7 +1383,8 @@ public void deleteCatalogRole(String catalogName, String name) { authorizeBasicCatalogRoleOperationOrThrow(op, catalogName, name); CatalogEntity catalogEntity = - findCatalog().orElseThrow(() -> new NotFoundException("Catalog %s not found", catalogName)); + currentCatalog() + .orElseThrow(() -> new NotFoundException("Catalog %s not found", catalogName)); CatalogRoleEntity currentCatalogRoleEntity = findCatalogRoleByName(catalogName, name) .orElseThrow(() -> new NotFoundException("CatalogRole %s not found", name)); @@ -1423,7 +1424,7 @@ public List listCatalogRoles(String catalogName) { authorizeBasicTopLevelEntityOperationOrThrow(op, catalogName, PolarisEntityType.CATALOG); PolarisEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); List catalogPath = PolarisEntity.toCoreList(List.of(catalogEntity)); return metaStoreManager @@ -1505,7 +1506,7 @@ public PrivilegeResult assignCatalogRoleToPrincipalRole( .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); PolarisEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1527,7 +1528,7 @@ public PrivilegeResult revokeCatalogRoleFromPrincipalRole( .orElseThrow( () -> new NotFoundException("PrincipalRole %s not found", principalRoleName)); PolarisEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1593,7 +1594,7 @@ public List listCatalogRolesForPrincipalRole( op, principalRoleName, PolarisEntityType.PRINCIPAL_ROLE, catalogName); PolarisEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity principalRoleEntity = findPrincipalRoleByName(principalRoleName) @@ -1655,7 +1656,7 @@ public PrivilegeResult grantPrivilegeOnCatalogToRole( authorizeGrantOnCatalogOperationOrThrow(op, catalogName, catalogRoleName); PolarisEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1677,7 +1678,7 @@ public PrivilegeResult revokePrivilegeOnCatalogFromRole( authorizeGrantOnCatalogOperationOrThrow(op, catalogName, catalogRoleName); PolarisEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1699,7 +1700,7 @@ public PrivilegeResult grantPrivilegeOnNamespaceToRole( authorizeGrantOnNamespaceOperationOrThrow(op, catalogName, namespace, catalogRoleName); CatalogEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -1961,7 +1962,7 @@ public List listAssigneePrincipalRolesForCatalogRole( PolarisAuthorizableOperation.LIST_ASSIGNEE_PRINCIPAL_ROLES_FOR_CATALOG_ROLE; authorizeBasicCatalogRoleOperationOrThrow(op, catalogName, catalogRoleName); - if (findCatalog().isEmpty()) { + if (currentCatalog().isEmpty()) { throw new NotFoundException("Parent catalog %s not found", catalogName); } PolarisEntity catalogRoleEntity = @@ -2125,7 +2126,7 @@ private PrivilegeResult grantPrivilegeOnTableLikeToRole( List subTypes, PolarisPrivilege privilege) { CatalogEntity catalogEntity = - findCatalog() + currentCatalog() .orElseThrow(() -> new NotFoundException("Parent catalog %s not found", catalogName)); PolarisEntity catalogRoleEntity = findCatalogRoleByName(catalogName, catalogRoleName) @@ -2249,7 +2250,7 @@ private PrivilegeResult revokePrivilegeOnTableLikeFromRole( TableIdentifier identifier, List subTypes, PolarisPrivilege privilege) { - if (findCatalog().isEmpty()) { + if (currentCatalog().isEmpty()) { throw new NotFoundException("Parent catalog %s not found", catalogName); } PolarisEntity catalogRoleEntity = @@ -2279,7 +2280,7 @@ private PrivilegeResult grantPrivilegeOnPolicyEntityToRole( String catalogRoleName, PolicyIdentifier identifier, PolarisPrivilege privilege) { - if (findCatalog().isEmpty()) { + if (currentCatalog().isEmpty()) { throw new NotFoundException("Parent catalog %s not found", catalogName); } PolarisEntity catalogRoleEntity = @@ -2307,7 +2308,7 @@ private PrivilegeResult revokePrivilegeOnPolicyEntityFromRole( String catalogRoleName, PolicyIdentifier identifier, PolarisPrivilege privilege) { - if (findCatalog().isEmpty()) { + if (currentCatalog().isEmpty()) { throw new NotFoundException("Parent catalog %s not found", catalogName); } PolarisEntity catalogRoleEntity =