aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-10-15 10:24:46 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-10-16 19:10:48 +0200
commitcc2e1acfe9ce1e7daae0afd2ad4c1c0782c30dc5 (patch)
treede2244d880d7bc1194cf9c7966768038e29688cf /server
parent63ce1a3671fb71e25f77915c6db201eccd766d5e (diff)
downloadsonarqube-cc2e1acfe9ce1e7daae0afd2ad4c1c0782c30dc5.tar.gz
sonarqube-cc2e1acfe9ce1e7daae0afd2ad4c1c0782c30dc5.zip
SONAR-8134 isolate deletion of permissions
Diffstat (limited to 'server')
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java8
1 files changed, 7 insertions, 1 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java b/server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java
index 87f26dc7c59..5de1bd1521a 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java
@@ -19,6 +19,7 @@
*/
package org.sonar.server.permission;
+import java.util.Optional;
import java.util.Set;
import org.sonar.core.permission.GlobalPermissions;
import org.sonar.db.DbClient;
@@ -47,7 +48,12 @@ public class UserPermissionChanger {
break;
case REMOVE:
checkOtherAdminUsersExist(dbSession, change);
- dbClient.userPermissionDao().delete(dbSession, change.getUserId().getLogin(), change.getProjectUuid(), change.getPermission());
+ Optional<ProjectId> projectId = change.getProjectId();
+ if (projectId.isPresent()) {
+ dbClient.userPermissionDao().deleteProjectPermission(dbSession, change.getUserId().getId(), change.getPermission(), projectId.get().getId());
+ } else {
+ dbClient.userPermissionDao().deleteGlobalPermission(dbSession, change.getUserId().getId(), change.getPermission(), change.getOrganizationUuid());
+ }
break;
default:
throw new UnsupportedOperationException("Unsupported permission change: " + change.getOperation());