From 64a00ab3bfc0edc3f11c7893be3e90abaec717aa Mon Sep 17 00:00:00 2001 From: minwoox Date: Mon, 23 Dec 2024 11:34:06 +0900 Subject: [PATCH] Address the comment from @jrhee17 --- .../server/metadata/MetadataService.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/server/src/main/java/com/linecorp/centraldogma/server/metadata/MetadataService.java b/server/src/main/java/com/linecorp/centraldogma/server/metadata/MetadataService.java index fcca4b2dc..2ab51c74f 100644 --- a/server/src/main/java/com/linecorp/centraldogma/server/metadata/MetadataService.java +++ b/server/src/main/java/com/linecorp/centraldogma/server/metadata/MetadataService.java @@ -903,7 +903,7 @@ private CompletableFuture findRepositoryRole0(String projectName @Nullable private static RepositoryRole repositoryRole(Roles roles, @Nullable RepositoryRole repositoryRole, ProjectRole projectRole) { - if (repositoryRole == RepositoryRole.ADMIN || projectRole == ProjectRole.OWNER) { + if (projectRole == ProjectRole.OWNER) { return RepositoryRole.ADMIN; } @@ -911,20 +911,23 @@ private static RepositoryRole repositoryRole(Roles roles, @Nullable RepositoryRo if (projectRole == ProjectRole.MEMBER) { memberOrGuestRole = roles.projectRoles().member(); } else { + assert projectRole == ProjectRole.GUEST; memberOrGuestRole = roles.projectRoles().guest(); } - if (repositoryRole == null) { - return memberOrGuestRole; - } - if (memberOrGuestRole == null) { - return repositoryRole; + if (repositoryRole == RepositoryRole.ADMIN || memberOrGuestRole == RepositoryRole.ADMIN) { + return RepositoryRole.ADMIN; } - if (memberOrGuestRole == RepositoryRole.WRITE || repositoryRole == RepositoryRole.WRITE) { + + if (repositoryRole == RepositoryRole.WRITE || memberOrGuestRole == RepositoryRole.WRITE) { return RepositoryRole.WRITE; } - return RepositoryRole.READ; + if (repositoryRole == RepositoryRole.READ || memberOrGuestRole == RepositoryRole.READ) { + return RepositoryRole.READ; + } + + return null; } /**