From 8d6e0a534d7644af892700d059b604262d1f70ac Mon Sep 17 00:00:00 2001 From: Xun Date: Wed, 8 Jan 2025 11:39:55 +0800 Subject: [PATCH] fix --- .../ranger/RangerAuthorizationHDFSPlugin.java | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationHDFSPlugin.java b/authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationHDFSPlugin.java index 48734d90d4a..162a1bf308a 100644 --- a/authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationHDFSPlugin.java +++ b/authorizations/authorization-ranger/src/main/java/org/apache/gravitino/authorization/ranger/RangerAuthorizationHDFSPlugin.java @@ -257,9 +257,9 @@ protected void updatePolicyByMetadataObject( @Override protected void removeMetadataObject(AuthorizationMetadataObject authzMetadataObject) { if (authzMetadataObject.type().equals(SCHEMA)) { - doRemoveSchemaMetadataObject(authzMetadataObject); + removeSchemaMetadataObject(authzMetadataObject); } else if (authzMetadataObject.type().equals(TABLE)) { - doRemoveTableMetadataObject(authzMetadataObject); + removeTableMetadataObject(authzMetadataObject); } else if (authzMetadataObject.type().equals(COLUMN) || authzMetadataObject.type().equals(PATH)) { removePolicyByMetadataObject(authzMetadataObject); @@ -273,7 +273,7 @@ protected void removeMetadataObject(AuthorizationMetadataObject authzMetadataObj * Remove the SCHEMA, Need to remove these the relevant policies, `{schema}`, `{schema}.*`, * `{schema}.*.*` permissions. */ - private void doRemoveSchemaMetadataObject(AuthorizationMetadataObject authzMetadataObject) { + private void removeSchemaMetadataObject(AuthorizationMetadataObject authzMetadataObject) { Preconditions.checkArgument( authzMetadataObject instanceof PathBasedMetadataObject, "The metadata object must be a PathBasedMetadataObject"); @@ -307,7 +307,7 @@ private void doRemoveSchemaMetadataObject(AuthorizationMetadataObject authzMetad AuthorizationMetadataObject.getLastName(names), locationPath, PATH); - doRemoveSchemaMetadataObject(schemaMetadataObject); + removeSchemaMetadataObject(schemaMetadataObject); }); }); } else { @@ -330,25 +330,25 @@ private void doRemoveSchemaMetadataObject(AuthorizationMetadataObject authzMetad AuthorizationMetadataObject tableMetadataObject = new PathBasedMetadataObject( authzMetadataObject.name(), table.name(), locationPath, PATH); - doRemoveTableMetadataObject(tableMetadataObject); - }); - // Remove schema - Schema schema = - GravitinoEnv.getInstance() - .schemaDispatcher() - .loadSchema(NameIdentifier.of(authzMetadataObject.name())); - List schemaLocations = - AuthorizationUtils.getMetadataObjectLocation( - identifier, Entity.EntityType.SCHEMA); - schemaLocations.stream() - .forEach( - locationPath -> { - AuthorizationMetadataObject schemaMetadataObject = - new PathBasedMetadataObject( - authzMetadataObject.name(), schema.name(), locationPath, PATH); - removePolicyByMetadataObject(schemaMetadataObject); + removeTableMetadataObject(tableMetadataObject); }); }); + // Remove schema + Schema schema = + GravitinoEnv.getInstance() + .schemaDispatcher() + .loadSchema(NameIdentifier.of(authzMetadataObject.name())); + List schemaLocations = + AuthorizationUtils.getMetadataObjectLocation( + NameIdentifier.parse(authzMetadataObject.fullName()), Entity.EntityType.SCHEMA); + schemaLocations.stream() + .forEach( + locationPath -> { + AuthorizationMetadataObject schemaMetadataObject = + new PathBasedMetadataObject( + authzMetadataObject.name(), schema.name(), locationPath, PATH); + removePolicyByMetadataObject(schemaMetadataObject); + }); } } @@ -356,7 +356,7 @@ private void doRemoveSchemaMetadataObject(AuthorizationMetadataObject authzMetad * Remove the TABLE, Need to remove these the relevant policies, `*.{table}`, `*.{table}.{column}` * permissions. */ - private void doRemoveTableMetadataObject(AuthorizationMetadataObject authzMetadataObject) { + private void removeTableMetadataObject(AuthorizationMetadataObject authzMetadataObject) { Preconditions.checkArgument( authzMetadataObject instanceof PathBasedMetadataObject, "The metadata object must be a PathBasedMetadataObject");