Skip to content

Commit

Permalink
RevokeRolePrivilegeParam support dbName parameter (#1234)
Browse files Browse the repository at this point in the history
Signed-off-by: lentitude2tk <[email protected]>
  • Loading branch information
lentitude2tk authored Dec 16, 2024
1 parent f29741b commit 9b60b20
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2557,15 +2557,19 @@ public R<RpcStatus> revokeRolePrivilege(RevokeRolePrivilegeParam requestParam) {
String title = String.format("RevokeRolePrivilegeRequest roleName:%s", requestParam.getRoleName());

try {
GrantEntity.Builder builder = GrantEntity.newBuilder()
.setRole(RoleEntity.newBuilder().setName(requestParam.getRoleName()).build())
.setObjectName(requestParam.getObjectName())
.setObject(ObjectEntity.newBuilder().setName(requestParam.getObject()).build())
.setGrantor(GrantorEntity.newBuilder()
.setPrivilege(PrivilegeEntity.newBuilder().setName(requestParam.getPrivilege()).build()).build());
if (StringUtils.isNotEmpty(requestParam.getDatabaseName())) {
builder.setDbName(requestParam.getDatabaseName());
}

OperatePrivilegeRequest request = OperatePrivilegeRequest.newBuilder()
.setType(OperatePrivilegeType.Revoke)
.setEntity(GrantEntity.newBuilder()
.setRole(RoleEntity.newBuilder().setName(requestParam.getRoleName()).build())
.setObjectName(requestParam.getObjectName())
.setObject(ObjectEntity.newBuilder().setName(requestParam.getObject()).build())
.setGrantor(GrantorEntity.newBuilder()
.setPrivilege(PrivilegeEntity.newBuilder().setName(requestParam.getPrivilege()).build()).build())
.build())
.setEntity(builder.build())
.build();

Status response = blockingStub().operatePrivilege(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ public class RevokeRolePrivilegeParam {

private final String privilege;

private final String databaseName;

private RevokeRolePrivilegeParam(@NonNull RevokeRolePrivilegeParam.Builder builder) {
this.roleName = builder.roleName;
this.object = builder.object;
this.objectName = builder.objectName;
this.privilege = builder.privilege;
this.databaseName = builder.databaseName;
}

public static RevokeRolePrivilegeParam.Builder newBuilder() {
Expand All @@ -56,11 +59,23 @@ public static final class Builder {
private String object;
private String objectName;
private String privilege;
private String databaseName;


private Builder() {
}

/**
* Sets the databaseName. databaseName cannot be null.
*
* @param databaseName databaseName
* @return <code>Builder</code>
*/
public RevokeRolePrivilegeParam.Builder withDatabaseName(String databaseName) {
this.databaseName = databaseName;
return this;
}

/**
* Sets the roleName. RoleName cannot be empty or null.
*
Expand Down

0 comments on commit 9b60b20

Please sign in to comment.