Skip to content

Commit

Permalink
Keyi/fix permission type conversion (#9374)
Browse files Browse the repository at this point in the history
  • Loading branch information
keyihuang committed Oct 18, 2023
1 parent b9157d2 commit 3b98363
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,8 @@ public PermissionPersistence(final Database database) {

public void writePermission(final Permission permission) throws IOException {
final OffsetDateTime timestamp = OffsetDateTime.now();
io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType permissionTypeAllowedInDB;
if (permission.getPermissionType() != null) {
if (permission.getPermissionType().equals(PermissionType.WORKSPACE_OWNER)) {
permissionTypeAllowedInDB = io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType.workspace_admin;
} else {
permissionTypeAllowedInDB = Enums.toEnum(permission.getPermissionType().value(),
io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType.class).orElseThrow();
}
} else {
permissionTypeAllowedInDB = null;
}
final io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType permissionTypeAllowedInDB =
PermissionPersistenceHelper.convertConfigPermissionTypeToJooqPermissionType(permission.getPermissionType());
database.transaction(ctx -> {
final boolean isExistingConfig = ctx.fetchExists(select()
.from(PERMISSION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public static io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType
.toArray(new io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType[0]);
}

private static io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType convertConfigPermissionTypeToJooqPermissionType(final PermissionType permissionType) {
public static io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType convertConfigPermissionTypeToJooqPermissionType(final PermissionType permissionType) {
if (permissionType == null) {
return null;
}
// workspace owner is deprecated and doesn't exist in OSS jooq. it is equivalent to workspace admin.
if (permissionType.equals(PermissionType.WORKSPACE_OWNER)) {
return io.airbyte.db.instance.configs.jooq.generated.enums.PermissionType.workspace_admin;
Expand Down

0 comments on commit 3b98363

Please sign in to comment.