Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xunliu committed Jan 8, 2025
1 parent 9aa1bb1 commit 8d6e0a5
Showing 1 changed file with 22 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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");
Expand Down Expand Up @@ -307,7 +307,7 @@ private void doRemoveSchemaMetadataObject(AuthorizationMetadataObject authzMetad
AuthorizationMetadataObject.getLastName(names),
locationPath,
PATH);
doRemoveSchemaMetadataObject(schemaMetadataObject);
removeSchemaMetadataObject(schemaMetadataObject);
});
});
} else {
Expand All @@ -330,33 +330,33 @@ 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<String> 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<String> 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);
});
}
}

/**
* 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");
Expand Down

0 comments on commit 8d6e0a5

Please sign in to comment.