aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-webserver-webapi
diff options
context:
space:
mode:
authorDuarte Meneses <duarte.meneses@sonarsource.com>2020-04-29 12:01:10 -0500
committersonartech <sonartech@sonarsource.com>2020-05-25 20:05:21 +0000
commit85b940dd935f57860f26dff7f1bfaa9de1ba8af2 (patch)
treea84f4075e6b09ec7c697c2990e18cb71fc27c4cf /server/sonar-webserver-webapi
parent79beb640edf1fb0154d318e20aacb6bf003288e4 (diff)
downloadsonarqube-85b940dd935f57860f26dff7f1bfaa9de1ba8af2.tar.gz
sonarqube-85b940dd935f57860f26dff7f1bfaa9de1ba8af2.zip
SONAR-13221 change PK of GROUPS and update FKs
Diffstat (limited to 'server/sonar-webserver-webapi')
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java12
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/GroupsAction.java16
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/TemplateGroupsAction.java12
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/AddGroupAction.java2
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java6
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java10
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsRef.java76
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsSupport.java36
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java4
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java8
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java25
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java6
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java54
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java4
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java8
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java14
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java54
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java30
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java2
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java16
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java30
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/CreateActionTest.java5
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java26
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/GroupWsRefTest.java20
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/RemoveUserActionTest.java26
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java12
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java22
-rw-r--r--server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UsersActionTest.java34
51 files changed, 338 insertions, 344 deletions
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java
index 59baccc69ae..ef1e94e77e9 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChange.java
@@ -23,15 +23,15 @@ import javax.annotation.Nullable;
public class GroupPermissionChange extends PermissionChange {
- private final GroupIdOrAnyone groupId;
+ private final GroupUuidOrAnyone groupId;
public GroupPermissionChange(Operation operation, String permission, @Nullable ProjectUuid projectUuid,
- GroupIdOrAnyone groupId, PermissionService permissionService) {
+ GroupUuidOrAnyone groupId, PermissionService permissionService) {
super(operation, groupId.getOrganizationUuid(), permission, projectUuid, permissionService);
this.groupId = groupId;
}
- public GroupIdOrAnyone getGroupIdOrAnyone() {
+ public GroupUuidOrAnyone getGroupIdOrAnyone() {
return groupId;
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java
index 65f0d401556..90049daf441 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java
@@ -115,13 +115,13 @@ public class GroupPermissionChanger {
.setUuid(uuidFactory.create())
.setRole(change.getPermission())
.setOrganizationUuid(change.getOrganizationUuid())
- .setGroupId(change.getGroupIdOrAnyone().getId())
+ .setGroupUuid(change.getGroupIdOrAnyone().getUuid())
.setComponentUuid(change.getProjectUuid());
dbClient.groupPermissionDao().insert(dbSession, addedDto);
return true;
}
- private static void validateNotAnyoneAndAdminPermission(String permission, GroupIdOrAnyone group) {
+ private static void validateNotAnyoneAndAdminPermission(String permission, GroupUuidOrAnyone group) {
checkRequest(!GlobalPermissions.SYSTEM_ADMIN.equals(permission) || !group.isAnyone(),
format("It is not possible to add the '%s' permission to group 'Anyone'.", permission));
}
@@ -134,7 +134,7 @@ public class GroupPermissionChanger {
dbClient.groupPermissionDao().delete(dbSession,
change.getPermission(),
change.getOrganizationUuid(),
- change.getGroupIdOrAnyone().getId(),
+ change.getGroupIdOrAnyone().getUuid(),
change.getProjectUuid());
return true;
}
@@ -144,12 +144,12 @@ public class GroupPermissionChanger {
if (projectUuid != null) {
return dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession,
change.getOrganizationUuid(),
- change.getGroupIdOrAnyone().getId(),
+ change.getGroupIdOrAnyone().getUuid(),
projectUuid);
}
return dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession,
change.getOrganizationUuid(),
- change.getGroupIdOrAnyone().getId());
+ change.getGroupIdOrAnyone().getUuid());
}
private void checkIfRemainingGlobalAdministrators(DbSession dbSession, GroupPermissionChange change) {
@@ -158,7 +158,7 @@ public class GroupPermissionChanger {
change.getProjectUuid() == null) {
// removing global admin permission from group
int remaining = dbClient.authorizationDao().countUsersWithGlobalPermissionExcludingGroup(dbSession,
- change.getOrganizationUuid(), SYSTEM_ADMIN, change.getGroupIdOrAnyone().getId());
+ change.getOrganizationUuid(), SYSTEM_ADMIN, change.getGroupIdOrAnyone().getUuid());
checkRequest(remaining > 0, "Last group with permission '%s'. Permission cannot be removed.", SYSTEM_ADMIN);
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java
index 577173115e7..e34c5a3343b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/PermissionTemplateService.java
@@ -146,7 +146,7 @@ public class PermissionTemplateService {
GroupPermissionDto dto = new GroupPermissionDto()
.setUuid(uuidFactory.create())
.setOrganizationUuid(organizationUuid)
- .setGroupId(isAnyone(gp.getGroupName()) ? null : gp.getGroupId())
+ .setGroupUuid(isAnyone(gp.getGroupName()) ? null : gp.getGroupUuid())
.setRole(gp.getPermission())
.setComponentUuid(project.uuid());
dbClient.groupPermissionDao().insert(dbSession, dto);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java
index f2213faaa7a..a34f2cb3647 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java
@@ -26,7 +26,7 @@ import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.server.permission.GroupIdOrAnyone;
+import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.GroupPermissionChange;
import org.sonar.server.permission.PermissionChange;
import org.sonar.server.permission.PermissionService;
@@ -87,7 +87,7 @@ public class AddGroupAction implements PermissionsWsAction {
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
- GroupIdOrAnyone group = wsSupport.findGroup(dbSession, request);
+ GroupUuidOrAnyone group = wsSupport.findGroup(dbSession, request);
Optional<ProjectUuid> projectUuid = wsSupport.findProjectUuid(dbSession, request);
checkProjectAdmin(userSession, group.getOrganizationUuid(), projectUuid);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/GroupsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/GroupsAction.java
index b6b8eeff9dd..94f5abb1150 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/GroupsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/GroupsAction.java
@@ -128,18 +128,18 @@ public class GroupsAction implements PermissionsWsAction {
}
private static WsGroupsResponse buildResponse(List<GroupDto> groups, List<GroupPermissionDto> groupPermissions, Paging paging) {
- Multimap<Integer, String> permissionsByGroupId = TreeMultimap.create();
- groupPermissions.forEach(groupPermission -> permissionsByGroupId.put(groupPermission.getGroupId(), groupPermission.getRole()));
+ Multimap<String, String> permissionsByGroupUuid = TreeMultimap.create();
+ groupPermissions.forEach(groupPermission -> permissionsByGroupUuid.put(groupPermission.getGroupUuid(), groupPermission.getRole()));
WsGroupsResponse.Builder response = WsGroupsResponse.newBuilder();
groups.forEach(group -> {
Group.Builder wsGroup = response.addGroupsBuilder()
.setName(group.getName());
- if (group.getId() != 0) {
- wsGroup.setId(String.valueOf(group.getId()));
+ if (group.getUuid() != null) {
+ wsGroup.setId(String.valueOf(group.getUuid()));
}
ofNullable(group.getDescription()).ifPresent(wsGroup::setDescription);
- wsGroup.addAllPermissions(permissionsByGroupId.get(group.getId()));
+ wsGroup.addAllPermissions(permissionsByGroupUuid.get(group.getUuid()));
});
response.getPagingBuilder()
@@ -154,7 +154,7 @@ public class GroupsAction implements PermissionsWsAction {
List<String> orderedNames = dbClient.groupPermissionDao().selectGroupNamesByQuery(dbSession, dbQuery);
List<GroupDto> groups = dbClient.groupDao().selectByNames(dbSession, org.getUuid(), orderedNames);
if (orderedNames.contains(DefaultGroups.ANYONE)) {
- groups.add(0, new GroupDto().setId(0).setName(DefaultGroups.ANYONE).setOrganizationUuid(org.getUuid()));
+ groups.add(0, new GroupDto().setUuid(DefaultGroups.ANYONE).setName(DefaultGroups.ANYONE).setOrganizationUuid(org.getUuid()));
}
return Ordering.explicit(orderedNames).onResultOf(GroupDto::getName).immutableSortedCopy(groups);
}
@@ -163,7 +163,7 @@ public class GroupsAction implements PermissionsWsAction {
if (groups.isEmpty()) {
return emptyList();
}
- List<Integer> ids = groups.stream().map(GroupDto::getId).collect(MoreCollectors.toList(groups.size()));
- return dbClient.groupPermissionDao().selectByGroupIds(dbSession, org.getUuid(), ids, project.map(ProjectUuid::getUuid).orElse(null));
+ List<String> uuids = groups.stream().map(GroupDto::getUuid).collect(MoreCollectors.toList(groups.size()));
+ return dbClient.groupPermissionDao().selectByGroupUuids(dbSession, org.getUuid(), uuids, project.map(ProjectUuid::getUuid).orElse(null));
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java
index 721e4f9dc45..b4c1130de8d 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java
@@ -29,7 +29,7 @@ import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.permission.template.PermissionTemplateDto;
import org.sonar.db.user.UserDto;
import org.sonar.server.component.ComponentFinder;
-import org.sonar.server.permission.GroupIdOrAnyone;
+import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.ProjectUuid;
import org.sonar.server.permission.UserId;
import org.sonar.server.permission.ws.template.WsTemplateRef;
@@ -78,11 +78,11 @@ public class PermissionWsSupport {
return componentFinder.getRootComponentByUuidOrKey(dbSession, projectRef.uuid(), projectRef.key());
}
- public GroupIdOrAnyone findGroup(DbSession dbSession, Request request) {
- Integer groupId = request.paramAsInt(PARAM_GROUP_ID);
+ public GroupUuidOrAnyone findGroup(DbSession dbSession, Request request) {
+ String groupUuid = request.param(PARAM_GROUP_ID);
String orgKey = request.param(PARAM_ORGANIZATION);
String groupName = request.param(PARAM_GROUP_NAME);
- GroupWsRef groupRef = GroupWsRef.create(groupId, orgKey, groupName);
+ GroupWsRef groupRef = GroupWsRef.create(groupUuid, orgKey, groupName);
return groupWsSupport.findGroupOrAnyone(dbSession, groupRef);
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java
index abc7a494723..94518082ae9 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java
@@ -25,7 +25,7 @@ import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
-import org.sonar.server.permission.GroupIdOrAnyone;
+import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.GroupPermissionChange;
import org.sonar.server.permission.PermissionChange;
import org.sonar.server.permission.PermissionService;
@@ -87,7 +87,7 @@ public class RemoveGroupAction implements PermissionsWsAction {
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
- GroupIdOrAnyone group = wsSupport.findGroup(dbSession, request);
+ GroupUuidOrAnyone group = wsSupport.findGroup(dbSession, request);
Optional<ProjectUuid> project = wsSupport.findProjectUuid(dbSession, request);
checkProjectAdmin(userSession, group.getOrganizationUuid(), project);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java
index 6680a866d02..e26bd27d765 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java
@@ -25,7 +25,7 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.permission.template.PermissionTemplateDto;
-import org.sonar.server.permission.GroupIdOrAnyone;
+import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.ws.PermissionWsSupport;
import org.sonar.server.permission.ws.PermissionsWsAction;
import org.sonar.server.permission.ws.WsParameters;
@@ -75,7 +75,7 @@ public class AddGroupToTemplateAction implements PermissionsWsAction {
public void handle(Request request, Response response) {
try (DbSession dbSession = dbClient.openSession(false)) {
String permission = request.mandatoryParam(PARAM_PERMISSION);
- GroupIdOrAnyone groupId = support.findGroup(dbSession, request);
+ GroupUuidOrAnyone groupId = support.findGroup(dbSession, request);
checkRequest(!SYSTEM_ADMIN.equals(permission) || !groupId.isAnyone(),
format("It is not possible to add the '%s' permission to the group 'Anyone'.", permission));
@@ -83,14 +83,14 @@ public class AddGroupToTemplateAction implements PermissionsWsAction {
checkGlobalAdmin(userSession, template.getOrganizationUuid());
if (!groupAlreadyAdded(dbSession, template.getUuid(), permission, groupId)) {
- dbClient.permissionTemplateDao().insertGroupPermission(dbSession, template.getUuid(), groupId.getId(), permission);
+ dbClient.permissionTemplateDao().insertGroupPermission(dbSession, template.getUuid(), groupId.getUuid(), permission);
dbSession.commit();
}
}
response.noContent();
}
- private boolean groupAlreadyAdded(DbSession dbSession, String templateUuid, String permission, GroupIdOrAnyone group) {
- return dbClient.permissionTemplateDao().hasGroupsWithPermission(dbSession, templateUuid, permission, group.getId());
+ private boolean groupAlreadyAdded(DbSession dbSession, String templateUuid, String permission, GroupUuidOrAnyone group) {
+ return dbClient.permissionTemplateDao().hasGroupsWithPermission(dbSession, templateUuid, permission, group.getUuid());
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java
index af80d88a403..3c2de719d2d 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java
@@ -25,7 +25,7 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.permission.template.PermissionTemplateDto;
-import org.sonar.server.permission.GroupIdOrAnyone;
+import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.permission.ws.PermissionWsSupport;
import org.sonar.server.permission.ws.PermissionsWsAction;
import org.sonar.server.permission.ws.WsParameters;
@@ -74,10 +74,10 @@ public class RemoveGroupFromTemplateAction implements PermissionsWsAction {
String permission = request.mandatoryParam(PARAM_PERMISSION);
PermissionTemplateDto template = wsSupport.findTemplate(dbSession, WsTemplateRef.fromRequest(request));
checkGlobalAdmin(userSession, template.getOrganizationUuid());
- GroupIdOrAnyone groupId = wsSupport.findGroup(dbSession, request);
+ GroupUuidOrAnyone groupId = wsSupport.findGroup(dbSession, request);
checkArgument(groupId.getOrganizationUuid().equals(template.getOrganizationUuid()), "Group and template are on different organizations");
- dbClient.permissionTemplateDao().deleteGroupPermission(dbSession, template.getUuid(), groupId.getId(), permission);
+ dbClient.permissionTemplateDao().deleteGroupPermission(dbSession, template.getUuid(), groupId.getUuid(), permission);
dbSession.commit();
}
response.noContent();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/TemplateGroupsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/TemplateGroupsAction.java
index eb6bc4db4c0..fe26fda9152 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/TemplateGroupsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/TemplateGroupsAction.java
@@ -121,18 +121,18 @@ public class TemplateGroupsAction implements PermissionsWsAction {
}
private static Permissions.WsGroupsResponse buildResponse(List<GroupDto> groups, List<PermissionTemplateGroupDto> groupPermissions, Paging paging) {
- Multimap<Integer, String> permissionsByGroupId = TreeMultimap.create();
- groupPermissions.forEach(groupPermission -> permissionsByGroupId.put(groupPermission.getGroupId(), groupPermission.getPermission()));
+ Multimap<String, String> permissionsByGroupUuid = TreeMultimap.create();
+ groupPermissions.forEach(groupPermission -> permissionsByGroupUuid.put(groupPermission.getGroupUuid(), groupPermission.getPermission()));
Permissions.WsGroupsResponse.Builder response = Permissions.WsGroupsResponse.newBuilder();
groups.forEach(group -> {
Permissions.Group.Builder wsGroup = response.addGroupsBuilder()
.setName(group.getName());
- if (group.getId() != 0) {
- wsGroup.setId(String.valueOf(group.getId()));
+ if (group.getUuid() != null) {
+ wsGroup.setId(String.valueOf(group.getUuid()));
}
ofNullable(group.getDescription()).ifPresent(wsGroup::setDescription);
- wsGroup.addAllPermissions(permissionsByGroupId.get(group.getId()));
+ wsGroup.addAllPermissions(permissionsByGroupUuid.get(group.getUuid()));
});
response.getPagingBuilder()
@@ -146,7 +146,7 @@ public class TemplateGroupsAction implements PermissionsWsAction {
List<String> orderedNames = dbClient.permissionTemplateDao().selectGroupNamesByQueryAndTemplate(dbSession, dbQuery, template.getUuid());
List<GroupDto> groups = dbClient.groupDao().selectByNames(dbSession, template.getOrganizationUuid(), orderedNames);
if (orderedNames.contains(DefaultGroups.ANYONE)) {
- groups.add(0, new GroupDto().setId(0).setName(DefaultGroups.ANYONE));
+ groups.add(0, new GroupDto().setUuid(DefaultGroups.ANYONE).setName(DefaultGroups.ANYONE));
}
return Ordering.explicit(orderedNames).onResultOf(GroupDto::getName).immutableSortedCopy(groups);
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java
index ef16e285491..77afd13dcc3 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/project/ws/UpdateVisibilityAction.java
@@ -141,10 +141,10 @@ public class UpdateVisibilityAction implements ProjectsWsAction {
private void updatePermissionsToPrivate(DbSession dbSession, ComponentDto component) {
// delete project permissions for group AnyOne
- dbClient.groupPermissionDao().deleteByRootComponentUuidAndGroupId(dbSession, component.uuid(), null);
+ dbClient.groupPermissionDao().deleteByRootComponentUuidAndGroupUuid(dbSession, component.uuid(), null);
// grant UserRole.CODEVIEWER and UserRole.USER to any group or user with at least one permission on project
PUBLIC_PERMISSIONS.forEach(permission -> {
- dbClient.groupPermissionDao().selectGroupIdsWithPermissionOnProjectBut(dbSession, component.uuid(), permission)
+ dbClient.groupPermissionDao().selectGroupUuidsWithPermissionOnProjectBut(dbSession, component.uuid(), permission)
.forEach(groupId -> insertProjectPermissionOnGroup(dbSession, component, permission, groupId));
dbClient.userPermissionDao().selectUserIdsWithPermissionOnProjectBut(dbSession, component.uuid(), permission)
.forEach(userId -> insertProjectPermissionOnUser(dbSession, component, permission, userId));
@@ -155,12 +155,12 @@ public class UpdateVisibilityAction implements ProjectsWsAction {
dbClient.userPermissionDao().insert(dbSession, new UserPermissionDto(Uuids.create(), component.getOrganizationUuid(), permission, userId, component.uuid()));
}
- private void insertProjectPermissionOnGroup(DbSession dbSession, ComponentDto component, String permission, Integer groupId) {
+ private void insertProjectPermissionOnGroup(DbSession dbSession, ComponentDto component, String permission, String groupUuid) {
dbClient.groupPermissionDao().insert(dbSession, new GroupPermissionDto()
.setUuid(uuidFactory.create())
.setOrganizationUuid(component.getOrganizationUuid())
.setComponentUuid(component.uuid())
- .setGroupId(groupId)
+ .setGroupUuid(groupUuid)
.setRole(permission));
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/AddGroupAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/AddGroupAction.java
index 0f20c7d5da4..07c4f3a469f 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/AddGroupAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/AddGroupAction.java
@@ -108,7 +108,7 @@ public class AddGroupAction implements QProfileWsAction {
dbClient.qProfileEditGroupsDao().insert(dbSession,
new QProfileEditGroupsDto()
.setUuid(uuidFactory.create())
- .setGroupId(group.getId())
+ .setGroupUuid(group.getUuid())
.setQProfileUuid(profile.getKee()));
dbSession.commit();
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java
index 2a44663ce35..8b5c3f1164b 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/qualityprofile/ws/SearchGroupsAction.java
@@ -124,14 +124,14 @@ public class SearchGroupsAction implements QProfileWsAction {
int total = dbClient.qProfileEditGroupsDao().countByQuery(dbSession, query);
List<GroupMembershipDto> groupMemberships = dbClient.qProfileEditGroupsDao().selectByQuery(dbSession, query,
forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize()));
- Map<Integer, GroupDto> groupsById = dbClient.groupDao().selectByIds(dbSession,
- groupMemberships.stream().map(GroupMembershipDto::getGroupId).collect(MoreCollectors.toList()))
+ Map<String, GroupDto> groupsByUuid = dbClient.groupDao().selectByUuids(dbSession,
+ groupMemberships.stream().map(GroupMembershipDto::getGroupUuid).collect(MoreCollectors.toList()))
.stream()
- .collect(MoreCollectors.uniqueIndex(GroupDto::getId));
+ .collect(MoreCollectors.uniqueIndex(GroupDto::getUuid));
writeProtobuf(
Qualityprofiles.SearchGroupsResponse.newBuilder()
.addAllGroups(groupMemberships.stream()
- .map(groupsMembership -> toGroup(groupsById.get(groupsMembership.getGroupId()), groupsMembership.isSelected()))
+ .map(groupsMembership -> toGroup(groupsByUuid.get(groupsMembership.getGroupUuid()), groupsMembership.isSelected()))
.collect(toList()))
.setPaging(buildPaging(wsRequest, total)).build(),
request, response);
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java
index 6c31367514c..32eefecb39a 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/user/ws/GroupsAction.java
@@ -172,10 +172,10 @@ public class GroupsAction implements UsersWsAction {
private static Group toWsGroup(GroupMembershipDto group, GroupDto defaultGroup) {
Group.Builder groupBuilder = Group.newBuilder()
- .setId(group.getId())
+ .setId(group.getUuid())
.setName(group.getName())
.setSelected(group.getUserId() != null)
- .setDefault(defaultGroup.getId().longValue() == group.getId());
+ .setDefault(defaultGroup.getUuid().equals(group.getUuid()));
ofNullable(group.getDescription()).ifPresent(groupBuilder::setDescription);
return groupBuilder.build();
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java
index b5028c67b46..3335565ebb1 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/AddUserAction.java
@@ -85,7 +85,7 @@ public class AddUserAction implements UserGroupsWsAction {
support.checkGroupIsNotDefault(dbSession, group);
if (!isMemberOf(dbSession, user, group)) {
- UserGroupDto membershipDto = new UserGroupDto().setGroupId(group.getId()).setUserId(user.getId());
+ UserGroupDto membershipDto = new UserGroupDto().setGroupUuid(group.getUuid()).setUserId(user.getId());
dbClient.userGroupDao().insert(dbSession, membershipDto);
dbSession.commit();
}
@@ -95,7 +95,7 @@ public class AddUserAction implements UserGroupsWsAction {
}
private boolean isMemberOf(DbSession dbSession, UserDto user, GroupDto groupId) {
- return dbClient.groupMembershipDao().selectGroupIdsByUserId(dbSession, user.getId()).contains(groupId.getId());
+ return dbClient.groupMembershipDao().selectGroupUuidsByUserId(dbSession, user.getId()).contains(groupId.getUuid());
}
private void checkMembership(DbSession dbSession, OrganizationDto organization, UserDto user) {
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java
index 9a900257b5f..29ffb885c39 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/CreateAction.java
@@ -24,6 +24,7 @@ import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService.NewAction;
import org.sonar.api.server.ws.WebService.NewController;
import org.sonar.api.user.UserGroupValidation;
+import org.sonar.core.util.UuidFactory;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.organization.OrganizationDto;
@@ -46,11 +47,13 @@ public class CreateAction implements UserGroupsWsAction {
private final DbClient dbClient;
private final UserSession userSession;
private final GroupWsSupport support;
+ private final UuidFactory uuidFactory;
- public CreateAction(DbClient dbClient, UserSession userSession, GroupWsSupport support) {
+ public CreateAction(DbClient dbClient, UserSession userSession, GroupWsSupport support, UuidFactory uuidFactory) {
this.dbClient = dbClient;
this.userSession = userSession;
this.support = support;
+ this.uuidFactory = uuidFactory;
}
@Override
@@ -89,6 +92,7 @@ public class CreateAction implements UserGroupsWsAction {
OrganizationDto organization = support.findOrganizationByKey(dbSession, request.param(PARAM_ORGANIZATION_KEY));
userSession.checkPermission(ADMINISTER, organization);
GroupDto group = new GroupDto()
+ .setUuid(uuidFactory.create())
.setOrganizationUuid(organization.getUuid())
.setName(request.mandatoryParam(PARAM_GROUP_NAME))
.setDescription(request.param(PARAM_GROUP_DESCRIPTION));
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java
index 8e71735ee30..976a43162a4 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/DeleteAction.java
@@ -73,7 +73,7 @@ public class DeleteAction implements UserGroupsWsAction {
removeFromPermissionTemplates(dbSession, group);
removeGroupMembers(dbSession, group);
dbClient.qProfileEditGroupsDao().deleteByGroup(dbSession, group);
- dbClient.groupDao().deleteById(dbSession, group.getId());
+ dbClient.groupDao().deleteByUuid(dbSession, group.getUuid());
dbSession.commit();
response.noContent();
@@ -82,20 +82,20 @@ public class DeleteAction implements UserGroupsWsAction {
private void checkNotTryingToDeleteLastAdminGroup(DbSession dbSession, GroupDto group) {
int remaining = dbClient.authorizationDao().countUsersWithGlobalPermissionExcludingGroup(dbSession,
- group.getOrganizationUuid(), OrganizationPermission.ADMINISTER.getKey(), group.getId());
+ group.getOrganizationUuid(), OrganizationPermission.ADMINISTER.getKey(), group.getUuid());
checkArgument(remaining > 0, "The last system admin group cannot be deleted");
}
private void removeGroupPermissions(DbSession dbSession, GroupDto groupId) {
- dbClient.roleDao().deleteGroupRolesByGroupId(dbSession, groupId.getId());
+ dbClient.roleDao().deleteGroupRolesByGroupUuid(dbSession, groupId.getUuid());
}
private void removeFromPermissionTemplates(DbSession dbSession, GroupDto groupId) {
- dbClient.permissionTemplateDao().deleteByGroup(dbSession, groupId.getId());
+ dbClient.permissionTemplateDao().deleteByGroup(dbSession, groupId.getUuid());
}
private void removeGroupMembers(DbSession dbSession, GroupDto groupId) {
- dbClient.userGroupDao().deleteByGroupId(dbSession, groupId.getId());
+ dbClient.userGroupDao().deleteByGroupUuid(dbSession, groupId.getUuid());
}
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsRef.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsRef.java
index b4cab056a4a..a2f38972852 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsRef.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsRef.java
@@ -19,14 +19,14 @@
*/
package org.sonar.server.usergroups.ws;
+import java.util.Objects;
import javax.annotation.CheckForNull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.Immutable;
import org.sonar.api.security.DefaultGroups;
-import org.sonar.server.permission.GroupId;
-import org.sonar.server.permission.GroupIdOrAnyone;
+import org.sonar.server.permission.GroupUuid;
+import org.sonar.server.permission.GroupUuidOrAnyone;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
import static org.sonar.server.exceptions.BadRequestException.checkRequest;
@@ -35,71 +35,68 @@ import static org.sonar.server.exceptions.BadRequestException.checkRequest;
* Reference to a user group <b>as declared by web service requests</b>. It is one, and only one,
* of these two options:
* <ul>
- * <li>group id, for instance 1234</li>
+ * <li>group uuid, for instance 1234</li>
* <li>group name and optional organization key</li>
* </ul>
*
- * The reference is then converted to a {@link GroupId} or {@link GroupIdOrAnyone}.
+ * The reference is then converted to a {@link GroupUuid} or {@link GroupUuidOrAnyone}.
*/
@Immutable
public class GroupWsRef {
- private static final int NULL_ID = -1;
-
- private final int id;
+ private final String uuid;
private final String organizationKey;
private final String name;
- private GroupWsRef(int id, @Nullable String organizationKey, @Nullable String name) {
- this.id = id;
+ private GroupWsRef(String uuid, @Nullable String organizationKey, @Nullable String name) {
+ this.uuid = uuid;
this.organizationKey = organizationKey;
this.name = name;
}
/**
- * @return {@code true} if id is defined and {@link #getId()} can be called. If {@code false}, then
+ * @return {@code true} if uuid is defined and {@link #getUuid()} can be called. If {@code false}, then
* the couple {organizationKey, name} is defined and the methods {@link #getOrganizationKey()}/{@link #getName()}
* can be called.
*/
- public boolean hasId() {
- return id != NULL_ID;
+ public boolean hasUuid() {
+ return uuid != null;
}
/**
- * @return the group id
- * @throws IllegalStateException if {@link #getId()} is {@code false}
+ * @return the group uuid
+ * @throws IllegalStateException if {@link #getUuid()} is {@code false}
*/
- public int getId() {
- checkState(hasId(), "Id is not present. Please see hasId().");
- return id;
+ public String getUuid() {
+ checkState(hasUuid(), "Id is not present. Please see hasUuid().");
+ return uuid;
}
/**
* @return the organization key
- * @throws IllegalStateException if {@link #getId()} is {@code true}
+ * @throws IllegalStateException if {@link #getUuid()} is {@code true}
*/
@CheckForNull
public String getOrganizationKey() {
- checkState(!hasId(), "Organization is not present. Please see hasId().");
+ checkState(!hasUuid(), "Organization is not present. Please see hasId().");
return organizationKey;
}
/**
* @return the non-null group name. Can be anyone.
- * @throws IllegalStateException if {@link #getId()} is {@code true}
+ * @throws IllegalStateException if {@link #getUuid()} is {@code true}
*/
public String getName() {
- checkState(!hasId(), "Name is not present. Please see hasId().");
+ checkState(!hasUuid(), "Name is not present. Please see hasId().");
return name;
}
/**
- * Creates a reference to a group by its id. Virtual groups "Anyone" can't be returned
- * as they can't be referenced by an id.
+ * Creates a reference to a group by its uuid. Virtual groups "Anyone" can't be returned
+ * as they can't be referenced by an uuid.
*/
- static GroupWsRef fromId(int id) {
- checkArgument(id > -1, "Group id must be positive: %s", id);
- return new GroupWsRef(id, null, null);
+ static GroupWsRef fromUuid(String uuid) {
+ return new GroupWsRef(uuid, null, null);
}
/**
@@ -110,13 +107,13 @@ public class GroupWsRef {
* @param name non-null name. Can refer to anyone group (case-insensitive {@code "anyone"}).
*/
static GroupWsRef fromName(@Nullable String organizationKey, String name) {
- return new GroupWsRef(NULL_ID, organizationKey, requireNonNull(name));
+ return new GroupWsRef(null, organizationKey, requireNonNull(name));
}
- public static GroupWsRef create(@Nullable Integer id, @Nullable String organizationKey, @Nullable String name) {
- if (id != null) {
+ public static GroupWsRef create(@Nullable String uuid, @Nullable String organizationKey, @Nullable String name) {
+ if (uuid != null) {
checkRequest(organizationKey == null && name == null, "Either group id or couple organization/group name must be set");
- return fromId(id);
+ return fromUuid(uuid);
}
checkRequest(name != null, "Group name or group id must be provided");
@@ -124,7 +121,7 @@ public class GroupWsRef {
}
public boolean isAnyone() {
- return !hasId() && DefaultGroups.isAnyone(name);
+ return !hasUuid() && DefaultGroups.isAnyone(name);
}
@Override
@@ -136,27 +133,18 @@ public class GroupWsRef {
return false;
}
GroupWsRef that = (GroupWsRef) o;
- if (id != that.id) {
- return false;
- }
- if (organizationKey != null ? !organizationKey.equals(that.organizationKey) : (that.organizationKey != null)) {
- return false;
- }
- return name != null ? name.equals(that.name) : (that.name == null);
+ return Objects.equals(uuid, that.uuid) && Objects.equals(organizationKey, that.organizationKey) && Objects.equals(name, that.name);
}
@Override
public int hashCode() {
- int result = id;
- result = 31 * result + (organizationKey != null ? organizationKey.hashCode() : 0);
- result = 31 * result + (name != null ? name.hashCode() : 0);
- return result;
+ return Objects.hash(uuid, organizationKey, name);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("GroupWsRef{");
- sb.append("id=").append(id);
+ sb.append("uuid=").append(uuid);
sb.append(", organizationKey='").append(organizationKey).append('\'');
sb.append(", name='").append(name).append('\'');
sb.append('}');
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsSupport.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsSupport.java
index c60a1262c23..b25a09ac055 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsSupport.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/GroupWsSupport.java
@@ -29,8 +29,8 @@ import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.GroupDto;
import org.sonar.server.exceptions.NotFoundException;
import org.sonar.server.organization.DefaultOrganizationProvider;
-import org.sonar.server.permission.GroupId;
-import org.sonar.server.permission.GroupIdOrAnyone;
+import org.sonar.server.permission.GroupUuid;
+import org.sonar.server.permission.GroupUuidOrAnyone;
import org.sonar.server.usergroups.DefaultGroupFinder;
import org.sonarqube.ws.UserGroups;
@@ -74,21 +74,21 @@ public class GroupWsSupport {
* @throws NotFoundException if parameters are missing/incorrect, if the requested group does not exist
* or if the virtual group "Anyone" is requested.
*/
- public GroupId findGroup(DbSession dbSession, Request request) {
- return GroupId.from(findGroupDto(dbSession, request));
+ public GroupUuid findGroup(DbSession dbSession, Request request) {
+ return GroupUuid.from(findGroupDto(dbSession, request));
}
public GroupDto findGroupDto(DbSession dbSession, Request request) {
- Integer id = request.paramAsInt(PARAM_GROUP_ID);
+ String uuid = request.param(PARAM_GROUP_ID);
String organizationKey = request.param(PARAM_ORGANIZATION_KEY);
String name = request.param(PARAM_GROUP_NAME);
- return findGroupDto(dbSession, GroupWsRef.create(id, organizationKey, name));
+ return findGroupDto(dbSession, GroupWsRef.create(uuid, organizationKey, name));
}
public GroupDto findGroupDto(DbSession dbSession, GroupWsRef ref) {
- if (ref.hasId()) {
- GroupDto group = dbClient.groupDao().selectById(dbSession, ref.getId());
- checkFound(group, "No group with id '%s'", ref.getId());
+ if (ref.hasUuid()) {
+ GroupDto group = dbClient.groupDao().selectByUuid(dbSession, ref.getUuid());
+ checkFound(group, "No group with id '%s'", ref.getUuid());
return group;
}
@@ -98,21 +98,21 @@ public class GroupWsSupport {
return group.get();
}
- public GroupIdOrAnyone findGroupOrAnyone(DbSession dbSession, GroupWsRef ref) {
- if (ref.hasId()) {
- GroupDto group = dbClient.groupDao().selectById(dbSession, ref.getId());
- checkFound(group, "No group with id '%s'", ref.getId());
- return GroupIdOrAnyone.from(group);
+ public GroupUuidOrAnyone findGroupOrAnyone(DbSession dbSession, GroupWsRef ref) {
+ if (ref.hasUuid()) {
+ GroupDto group = dbClient.groupDao().selectByUuid(dbSession, ref.getUuid());
+ checkFound(group, "No group with id '%s'", ref.getUuid());
+ return GroupUuidOrAnyone.from(group);
}
OrganizationDto org = findOrganizationByKey(dbSession, ref.getOrganizationKey());
if (ref.isAnyone()) {
- return GroupIdOrAnyone.forAnyone(org.getUuid());
+ return GroupUuidOrAnyone.forAnyone(org.getUuid());
}
Optional<GroupDto> group = dbClient.groupDao().selectByName(dbSession, org.getUuid(), ref.getName());
checkFoundWithOptional(group, "No group with name '%s' in organization '%s'", ref.getName(), org.getKey());
- return GroupIdOrAnyone.from(group.get());
+ return GroupUuidOrAnyone.from(group.get());
}
/**
@@ -141,12 +141,12 @@ public class GroupWsSupport {
void checkGroupIsNotDefault(DbSession dbSession, GroupDto groupDto) {
GroupDto defaultGroup = defaultGroupFinder.findDefaultGroup(dbSession, groupDto.getOrganizationUuid());
- checkArgument(!defaultGroup.getId().equals(groupDto.getId()), "Default group '%s' cannot be used to perform this action", groupDto.getName());
+ checkArgument(!defaultGroup.getUuid().equals(groupDto.getUuid()), "Default group '%s' cannot be used to perform this action", groupDto.getName());
}
static UserGroups.Group.Builder toProtobuf(OrganizationDto organization, GroupDto group, int membersCount, boolean isDefault) {
UserGroups.Group.Builder wsGroup = UserGroups.Group.newBuilder()
- .setId(group.getId())
+ .setUuid(group.getUuid())
.setOrganization(organization.getKey())
.setName(group.getName())
.setMembersCount(membersCount)
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java
index e201e718161..9ae83d7d720 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/RemoveUserAction.java
@@ -80,7 +80,7 @@ public class RemoveUserAction implements UserGroupsWsAction {
ensureLastAdminIsNotRemoved(dbSession, group, user);
- dbClient.userGroupDao().delete(dbSession, group.getId(), user.getId());
+ dbClient.userGroupDao().delete(dbSession, group.getUuid(), user.getId());
dbSession.commit();
response.noContent();
@@ -92,7 +92,7 @@ public class RemoveUserAction implements UserGroupsWsAction {
*/
private void ensureLastAdminIsNotRemoved(DbSession dbSession, GroupDto group, UserDto user) {
int remainingAdmins = dbClient.authorizationDao().countUsersWithGlobalPermissionExcludingGroupMember(dbSession,
- group.getOrganizationUuid(), OrganizationPermission.ADMINISTER.getKey(), group.getId(), user.getId());
+ group.getOrganizationUuid(), OrganizationPermission.ADMINISTER.getKey(), group.getUuid(), user.getId());
checkRequest(remainingAdmins > 0, "The last administrator user cannot be removed");
}
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java
index b3828aea235..dc456bfff52 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/SearchAction.java
@@ -111,8 +111,8 @@ public class SearchAction implements UserGroupsWsAction {
int limit = dbClient.groupDao().countByQuery(dbSession, organization.getUuid(), query);
Paging paging = forPageIndex(page).withPageSize(pageSize).andTotal(limit);
List<GroupDto> groups = dbClient.groupDao().selectByQuery(dbSession, organization.getUuid(), query, options.getOffset(), pageSize);
- List<Integer> groupIds = groups.stream().map(GroupDto::getId).collect(MoreCollectors.toList(groups.size()));
- Map<String, Integer> userCountByGroup = dbClient.groupMembershipDao().countUsersByGroups(dbSession, groupIds);
+ List<String> groupUuids = groups.stream().map(GroupDto::getUuid).collect(MoreCollectors.toList(groups.size()));
+ Map<String, Integer> userCountByGroup = dbClient.groupMembershipDao().countUsersByGroups(dbSession, groupUuids);
writeProtobuf(buildResponse(groups, userCountByGroup, fields, paging, defaultGroup), request, response);
}
}
@@ -131,7 +131,7 @@ public class SearchAction implements UserGroupsWsAction {
private static SearchWsResponse buildResponse(List<GroupDto> groups, Map<String, Integer> userCountByGroup, Set<String> fields, Paging paging, GroupDto defaultGroup) {
SearchWsResponse.Builder responseBuilder = SearchWsResponse.newBuilder();
groups.forEach(group -> responseBuilder
- .addGroups(toWsGroup(group, userCountByGroup.get(group.getName()), fields, defaultGroup.getId().equals(group.getId()))));
+ .addGroups(toWsGroup(group, userCountByGroup.get(group.getName()), fields, defaultGroup.getUuid().equals(group.getUuid()))));
responseBuilder.getPagingBuilder()
.setPageIndex(paging.pageIndex())
.setPageSize(paging.pageSize())
@@ -142,7 +142,7 @@ public class SearchAction implements UserGroupsWsAction {
private static Group toWsGroup(GroupDto group, Integer memberCount, Set<String> fields, boolean isDefault) {
Group.Builder groupBuilder = Group.newBuilder()
- .setId(group.getId())
+ .setUuid(group.getUuid())
.setDefault(isDefault);
if (fields.contains(FIELD_NAME)) {
groupBuilder.setName(group.getName());
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java
index 7303552ab38..29902c15cd6 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UpdateAction.java
@@ -90,9 +90,9 @@ public class UpdateAction implements UserGroupsWsAction {
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
- int groupId = request.mandatoryParamAsInt(PARAM_GROUP_ID);
- GroupDto group = dbClient.groupDao().selectById(dbSession, groupId);
- checkFound(group, "Could not find a user group with id '%s'.", groupId);
+ String groupUuid = request.mandatoryParam(PARAM_GROUP_ID);
+ GroupDto group = dbClient.groupDao().selectByUuid(dbSession, groupUuid);
+ checkFound(group, "Could not find a user group with id '%s'.", groupUuid);
Optional<OrganizationDto> org = dbClient.organizationDao().selectByUuid(dbSession, group.getOrganizationUuid());
checkFoundWithOptional(org, "Could not find organization with id '%s'.", group.getOrganizationUuid());
userSession.checkPermission(ADMINISTER, org.get());
@@ -124,7 +124,7 @@ public class UpdateAction implements UserGroupsWsAction {
private void writeResponse(DbSession dbSession, Request request, Response response, OrganizationDto organization, GroupDto group) {
UserMembershipQuery query = UserMembershipQuery.builder()
- .groupId(group.getId())
+ .groupUuid(group.getUuid())
.organizationUuid(organization.getUuid())
.membership(UserMembershipQuery.IN)
.build();
diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
index 3c6d88e8ea2..51d59895eca 100644
--- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
+++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/usergroups/ws/UsersAction.java
@@ -33,7 +33,7 @@ import org.sonar.db.DbSession;
import org.sonar.db.permission.OrganizationPermission;
import org.sonar.db.user.UserMembershipDto;
import org.sonar.db.user.UserMembershipQuery;
-import org.sonar.server.permission.GroupId;
+import org.sonar.server.permission.GroupUuid;
import org.sonar.server.user.UserSession;
import static org.sonar.api.utils.Paging.forPageIndex;
@@ -78,11 +78,11 @@ public class UsersAction implements UserGroupsWsAction {
String selected = request.mandatoryParam(Param.SELECTED);
try (DbSession dbSession = dbClient.openSession(false)) {
- GroupId group = support.findGroup(dbSession, request);
+ GroupUuid group = support.findGroup(dbSession, request);
userSession.checkPermission(OrganizationPermission.ADMINISTER, group.getOrganizationUuid());
UserMembershipQuery query = UserMembershipQuery.builder()
- .groupId(group.getId())
+ .groupUuid(group.getUuid())
.organizationUuid(group.getOrganizationUuid())
.memberSearch(queryString)
.membership(getMembership(selected))
@@ -108,7 +108,7 @@ public class UsersAction implements UserGroupsWsAction {
json.beginObject()
.prop(FIELD_LOGIN, user.getLogin())
.prop(FIELD_NAME, user.getName())
- .prop(FIELD_SELECTED, user.getGroupId() != null)
+ .prop(FIELD_SELECTED, user.getGroupUuid() != null)
.endObject();
}
json.endArray();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
index bfcf9261561..8a2242c98e2 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/issue/ws/SearchActionTest.java
@@ -1157,7 +1157,7 @@ public class SearchActionTest {
new GroupPermissionDto()
.setUuid(Uuids.createFast())
.setOrganizationUuid(project.getOrganizationUuid())
- .setGroupId(null)
+ .setGroupUuid(null)
.setComponentUuid(project.uuid())
.setRole(permission));
session.commit();
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
index ba7e5355b8b..0df8147b1e9 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/AddMemberActionTest.java
@@ -268,12 +268,12 @@ public class AddMemberActionTest {
private void assertMember(String organizationUuid, int userId) {
assertThat(dbClient.organizationMemberDao().select(dbSession, organizationUuid, userId)).isPresent();
- Integer defaultGroupId = dbClient.organizationDao().getDefaultGroupId(dbSession, organizationUuid).get();
+ String defaultGroupUuid = dbClient.organizationDao().getDefaultGroupUuid(dbSession, organizationUuid).get();
assertThat(db.getDbClient().groupMembershipDao().selectGroups(db.getSession(), GroupMembershipQuery.builder()
.membership(IN)
.organizationUuid(organizationUuid).build(),
userId, 0, 10))
- .extracting(GroupMembershipDto::getId)
- .containsOnly(defaultGroupId.longValue());
+ .extracting(GroupMembershipDto::getUuid)
+ .containsOnly(defaultGroupUuid);
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
index d5a7d4c31ca..b98c8208bc8 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/CreateActionTest.java
@@ -34,6 +34,7 @@ import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
import org.sonar.api.web.UserRole;
import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.core.util.UuidFactoryFast;
import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
@@ -109,7 +110,7 @@ public class CreateActionTest {
private ResourceTypes resourceTypes = new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT);
private PermissionService permissionService = new PermissionServiceImpl(resourceTypes);
private OrganizationUpdater organizationUpdater = new OrganizationUpdaterImpl(dbClient, system2, UuidFactoryFast.getInstance(), organizationValidation,
- userIndexer, mock(BuiltInQProfileRepository.class), new DefaultGroupCreatorImpl(dbClient), permissionService);
+ userIndexer, mock(BuiltInQProfileRepository.class), new DefaultGroupCreatorImpl(dbClient, new SequenceUuidFactory()), permissionService);
private TestOrganizationFlags organizationFlags = TestOrganizationFlags.standalone().setEnabled(true);
private OrganizationAlmBinding organizationAlmBinding = mock(OrganizationAlmBinding.class);
@@ -159,13 +160,13 @@ public class CreateActionTest {
assertThat(groupDtoOptional).isNotEmpty();
GroupDto groupDto = groupDtoOptional.get();
assertThat(groupDto.getDescription()).isEqualTo("Owners of organization");
- assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, groupDto.getOrganizationUuid(), groupDto.getId()))
+ assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, groupDto.getOrganizationUuid(), groupDto.getUuid()))
.containsOnly(GlobalPermissions.ALL.toArray(new String[GlobalPermissions.ALL.size()]));
List<UserMembershipDto> members = dbClient.groupMembershipDao().selectMembers(
dbSession,
UserMembershipQuery.builder()
.organizationUuid(organization.getUuid())
- .groupId(groupDto.getId())
+ .groupUuid(groupDto.getUuid())
.membership(UserMembershipQuery.IN).build(),
0, Integer.MAX_VALUE);
assertThat(members)
@@ -187,12 +188,12 @@ public class CreateActionTest {
assertThat(groupDtoOptional).isNotEmpty();
GroupDto groupDto = groupDtoOptional.get();
assertThat(groupDto.getDescription()).isEqualTo("All members of the organization");
- assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, groupDto.getOrganizationUuid(), groupDto.getId())).isEmpty();
+ assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, groupDto.getOrganizationUuid(), groupDto.getUuid())).isEmpty();
List<UserMembershipDto> members = dbClient.groupMembershipDao().selectMembers(
dbSession,
UserMembershipQuery.builder()
.organizationUuid(organization.getUuid())
- .groupId(groupDto.getId())
+ .groupUuid(groupDto.getUuid())
.membership(UserMembershipQuery.IN).build(),
0, Integer.MAX_VALUE);
assertThat(members)
@@ -218,14 +219,14 @@ public class CreateActionTest {
assertThat(defaultTemplates.getProjectUuid()).isEqualTo(defaultTemplate.getUuid());
assertThat(defaultTemplates.getApplicationsUuid()).isNull();
assertThat(dbClient.permissionTemplateDao().selectGroupPermissionsByTemplateUuid(dbSession, defaultTemplate.getUuid()))
- .extracting(PermissionTemplateGroupDto::getGroupId, PermissionTemplateGroupDto::getPermission)
+ .extracting(PermissionTemplateGroupDto::getGroupUuid, PermissionTemplateGroupDto::getPermission)
.containsOnly(
- tuple(ownersGroup.getId(), UserRole.ADMIN),
- tuple(ownersGroup.getId(), GlobalPermissions.SCAN_EXECUTION),
- tuple(defaultGroup.getId(), UserRole.USER),
- tuple(defaultGroup.getId(), UserRole.CODEVIEWER),
- tuple(defaultGroup.getId(), UserRole.ISSUE_ADMIN),
- tuple(defaultGroup.getId(), UserRole.SECURITYHOTSPOT_ADMIN));
+ tuple(ownersGroup.getUuid(), UserRole.ADMIN),
+ tuple(ownersGroup.getUuid(), GlobalPermissions.SCAN_EXECUTION),
+ tuple(defaultGroup.getUuid(), UserRole.USER),
+ tuple(defaultGroup.getUuid(), UserRole.CODEVIEWER),
+ tuple(defaultGroup.getUuid(), UserRole.ISSUE_ADMIN),
+ tuple(defaultGroup.getUuid(), UserRole.SECURITYHOTSPOT_ADMIN));
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
index 41dd5dc165b..a5a80e6f2c4 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/DeleteActionTest.java
@@ -405,9 +405,9 @@ public class DeleteActionTest {
sendRequest(org);
verifyOrganizationDoesNotExist(org);
- assertThat(dbClient.groupDao().selectByIds(dbSession, of(group1.getId(), otherGroup1.getId(), group2.getId(), otherGroup2.getId())))
- .extracting(GroupDto::getId)
- .containsOnly(otherGroup1.getId(), otherGroup2.getId());
+ assertThat(dbClient.groupDao().selectByUuids(dbSession, of(group1.getUuid(), otherGroup1.getUuid(), group2.getUuid(), otherGroup2.getUuid())))
+ .extracting(GroupDto::getUuid)
+ .containsOnly(otherGroup1.getUuid(), otherGroup2.getUuid());
assertThat(dbClient.permissionTemplateDao().selectByUuid(dbSession, templateDto.getUuid()))
.isNull();
assertThat(dbClient.permissionTemplateDao().selectByUuid(dbSession, otherTemplateDto.getUuid()))
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java
index 8d096e63b94..90d5e1d9176 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/organization/ws/OrganizationDeleterTest.java
@@ -237,9 +237,9 @@ public class OrganizationDeleterTest {
underTest.delete(dbSession, org);
verifyOrganizationDoesNotExist(org);
- assertThat(dbClient.groupDao().selectByIds(dbSession, of(group1.getId(), otherGroup1.getId(), group2.getId(), otherGroup2.getId())))
- .extracting(GroupDto::getId)
- .containsOnly(otherGroup1.getId(), otherGroup2.getId());
+ assertThat(dbClient.groupDao().selectByUuids(dbSession, of(group1.getUuid(), otherGroup1.getUuid(), group2.getUuid(), otherGroup2.getUuid())))
+ .extracting(GroupDto::getUuid)
+ .containsOnly(otherGroup1.getUuid(), otherGroup2.getUuid());
assertThat(dbClient.permissionTemplateDao().selectByUuid(dbSession, templateDto.getUuid()))
.isNull();
assertThat(dbClient.permissionTemplateDao().selectByUuid(dbSession, otherTemplateDto.getUuid()))
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java
index e2e8a9558ac..d9f392873ad 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java
@@ -72,7 +72,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_adds_organization_permission_to_group() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupId, permissionService));
@@ -81,7 +81,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_adds_organization_permission_to_group_AnyOne() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupId, permissionService));
@@ -90,7 +90,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_fails_with_BadRequestException_when_adding_any_permission_to_group_AnyOne_on_private_project() {
- GroupIdOrAnyone anyOneGroupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone anyOneGroupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
permissionService.getAllProjectPermissions()
.forEach(perm -> {
try {
@@ -107,7 +107,7 @@ public class GroupPermissionChangerTest {
permissionService.getAllProjectPermissions()
.forEach(this::unsafeInsertProjectPermissionOnAnyone);
- GroupIdOrAnyone anyOneGroupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone anyOneGroupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
permissionService.getAllProjectPermissions()
.forEach(perm -> {
apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, perm, new ProjectUuid(privateProject), anyOneGroupId, permissionService));
@@ -142,7 +142,7 @@ public class GroupPermissionChangerTest {
}
private void applyAddsPermissionToGroupOnPrivateProject(String permission) {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectUuid(privateProject), groupId, permissionService));
@@ -176,7 +176,7 @@ public class GroupPermissionChangerTest {
}
private void applyRemovesPermissionFromGroupOnPrivateProject(String permission) {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
db.users().insertProjectPermissionOnGroup(group, permission, privateProject);
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectUuid(privateProject), groupId, permissionService));
@@ -186,7 +186,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_has_no_effect_when_adding_USER_permission_to_group_AnyOne_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectUuid(publicProject), groupId, permissionService));
@@ -195,7 +195,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_has_no_effect_when_adding_CODEVIEWER_permission_to_group_AnyOne_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.CODEVIEWER, new ProjectUuid(publicProject), groupId, permissionService));
@@ -204,7 +204,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_fails_with_BadRequestException_when_adding_permission_ADMIN_to_group_AnyOne_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("It is not possible to add the 'admin' permission to group 'Anyone'");
@@ -214,7 +214,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_adds_permission_ISSUE_ADMIN_to_group_AnyOne_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectUuid(publicProject), groupId, permissionService));
@@ -223,7 +223,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_adds_permission_SCAN_EXECUTION_to_group_AnyOne_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.SCAN_EXECUTION, new ProjectUuid(publicProject), groupId, permissionService));
@@ -232,7 +232,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_fails_with_BadRequestException_when_removing_USER_permission_from_group_AnyOne_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Permission user can't be removed from a public component");
@@ -242,7 +242,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_fails_with_BadRequestException_when_removing_CODEVIEWER_permission_from_group_AnyOne_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Permission codeviewer can't be removed from a public component");
@@ -266,7 +266,7 @@ public class GroupPermissionChangerTest {
}
private void applyRemovesPermissionFromGroupAnyOneOnAPublicProject(String permission) {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(org.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(org.getUuid());
db.users().insertProjectPermissionOnAnyone(permission, publicProject);
apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, permission, new ProjectUuid(publicProject), groupId, permissionService));
@@ -276,7 +276,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_fails_with_BadRequestException_when_removing_USER_permission_from_a_group_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Permission user can't be removed from a public component");
@@ -286,7 +286,7 @@ public class GroupPermissionChangerTest {
@Test
public void apply_fails_with_BadRequestException_when_removing_CODEVIEWER_permission_from_a_group_on_a_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
expectedException.expect(BadRequestException.class);
expectedException.expectMessage("Permission codeviewer can't be removed from a public component");
@@ -297,7 +297,7 @@ public class GroupPermissionChangerTest {
@Test
public void add_permission_to_anyone() {
OrganizationDto defaultOrganization = db.getDefaultOrganization();
- GroupIdOrAnyone groupId = GroupIdOrAnyone.forAnyone(defaultOrganization.getUuid());
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.forAnyone(defaultOrganization.getUuid());
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, null, groupId, permissionService));
@@ -307,7 +307,7 @@ public class GroupPermissionChangerTest {
@Test
public void do_nothing_when_adding_permission_that_already_exists() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
db.users().insertPermissionOnGroup(group, ADMINISTER_QUALITY_GATES);
apply(new GroupPermissionChange(PermissionChange.Operation.ADD, ADMINISTER_QUALITY_GATES.getKey(), null, groupId, permissionService));
@@ -317,7 +317,7 @@ public class GroupPermissionChangerTest {
@Test
public void fail_to_add_global_permission_but_SCAN_and_ADMIN_on_private_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
permissionService.getAllOrganizationPermissions().stream()
.map(OrganizationPermission::getKey)
@@ -335,7 +335,7 @@ public class GroupPermissionChangerTest {
@Test
public void fail_to_add_global_permission_but_SCAN_and_ADMIN_on_public_project() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
permissionService.getAllOrganizationPermissions().stream()
.map(OrganizationPermission::getKey)
@@ -353,7 +353,7 @@ public class GroupPermissionChangerTest {
@Test
public void fail_to_add_project_permission_but_SCAN_and_ADMIN_on_global_group() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
permissionService.getAllProjectPermissions()
.stream()
@@ -370,7 +370,7 @@ public class GroupPermissionChangerTest {
@Test
public void remove_permission_from_group() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
db.users().insertPermissionOnGroup(group, ADMINISTER_QUALITY_GATES);
db.users().insertPermissionOnGroup(group, PROVISION_PROJECTS);
@@ -381,7 +381,7 @@ public class GroupPermissionChangerTest {
@Test
public void remove_project_permission_from_group() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
db.users().insertPermissionOnGroup(group, ADMINISTER_QUALITY_GATES);
db.users().insertProjectPermissionOnGroup(group, UserRole.ISSUE_ADMIN, privateProject);
db.users().insertProjectPermissionOnGroup(group, UserRole.CODEVIEWER, privateProject);
@@ -394,7 +394,7 @@ public class GroupPermissionChangerTest {
@Test
public void do_not_fail_if_removing_a_permission_that_does_not_exist() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectUuid(privateProject), groupId, permissionService));
@@ -404,7 +404,7 @@ public class GroupPermissionChangerTest {
@Test
public void fail_to_remove_admin_permission_if_no_more_admins() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
db.users().insertPermissionOnGroup(group, ADMINISTER);
expectedException.expect(BadRequestException.class);
@@ -415,7 +415,7 @@ public class GroupPermissionChangerTest {
@Test
public void remove_admin_group_if_still_other_admins() {
- GroupIdOrAnyone groupId = GroupIdOrAnyone.from(group);
+ GroupUuidOrAnyone groupId = GroupUuidOrAnyone.from(group);
db.users().insertPermissionOnGroup(group, ADMINISTER);
UserDto admin = db.users().insertUser();
db.users().insertPermissionOnUser(org, admin, ADMINISTER);
@@ -434,7 +434,7 @@ public class GroupPermissionChangerTest {
GroupPermissionDto dto = new GroupPermissionDto()
.setUuid(Uuids.createFast())
.setOrganizationUuid(privateProject.getOrganizationUuid())
- .setGroupId(null)
+ .setGroupUuid(null)
.setRole(perm)
.setComponentUuid(privateProject.uuid());
db.getDbClient().groupPermissionDao().insert(db.getSession(), dto);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java
index 7265a3fa09f..59069ecd31e 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/PermissionTemplateServiceTest.java
@@ -437,7 +437,7 @@ public class PermissionTemplateServiceTest {
private List<String> selectProjectPermissionsOfGroup(OrganizationDto organizationDto, @Nullable GroupDto groupDto, ComponentDto project) {
return dbTester.getDbClient().groupPermissionDao().selectProjectPermissionsOfGroup(session,
- organizationDto.getUuid(), groupDto != null ? groupDto.getId() : null, project.uuid());
+ organizationDto.getUuid(), groupDto != null ? groupDto.getUuid() : null, project.uuid());
}
private List<String> selectProjectPermissionsOfUser(UserDto userDto, ComponentDto project) {
@@ -455,7 +455,7 @@ public class PermissionTemplateServiceTest {
dbTester.organizations().setDefaultTemplates(template, null, null);
templateDb.addProjectCreatorToTemplate(template.getUuid(), SCAN.getKey());
templateDb.addUserToTemplate(template.getUuid(), user.getId(), UserRole.USER);
- templateDb.addGroupToTemplate(template.getUuid(), group.getId(), UserRole.CODEVIEWER);
+ templateDb.addGroupToTemplate(template.getUuid(), group.getUuid(), UserRole.CODEVIEWER);
templateDb.addGroupToTemplate(template.getUuid(), null, UserRole.ISSUE_ADMIN);
// authenticated user
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
index 24cd33f2e1d..143e4977e86 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java
@@ -105,7 +105,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
loginAsAdmin(db.getDefaultOrganization());
newRequest()
- .setParam(PARAM_GROUP_ID, group.getId().toString())
+ .setParam(PARAM_GROUP_ID, group.getUuid().toString())
.setParam(PARAM_PERMISSION, SYSTEM_ADMIN)
.execute();
@@ -302,7 +302,7 @@ public class AddGroupActionTest extends BasePermissionWsTest<AddGroupAction> {
expectedException.expect(ForbiddenException.class);
newRequest()
- .setParam(PARAM_GROUP_ID, group.getId().toString())
+ .setParam(PARAM_GROUP_ID, group.getUuid().toString())
.setParam(PARAM_PERMISSION, PROVISIONING)
.execute();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
index 5e8bae5031c..4f33c807f3d 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java
@@ -96,7 +96,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
loginAsAdmin(db.getDefaultOrganization());
newRequest()
- .setParam(PARAM_GROUP_ID, aGroup.getId().toString())
+ .setParam(PARAM_GROUP_ID, aGroup.getUuid().toString())
.setParam(PARAM_PERMISSION, PROVISION_PROJECTS.getKey())
.execute();
@@ -476,7 +476,7 @@ public class RemoveGroupActionTest extends BasePermissionWsTest<RemoveGroupActio
GroupPermissionDto dto = new GroupPermissionDto()
.setUuid(Uuids.createFast())
.setOrganizationUuid(project.getOrganizationUuid())
- .setGroupId(null)
+ .setGroupUuid(null)
.setRole(perm)
.setComponentUuid(project.uuid());
db.getDbClient().groupPermissionDao().insert(db.getSession(), dto);
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java
index 40f50015054..3af76e20ec7 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java
@@ -99,7 +99,7 @@ public class AddGroupToTemplateActionTest extends BasePermissionWsTest<AddGroupT
newRequest()
.setParam(PARAM_TEMPLATE_ID, template.getUuid())
.setParam(PARAM_PERMISSION, CODEVIEWER)
- .setParam(PARAM_GROUP_ID, String.valueOf(group.getId()))
+ .setParam(PARAM_GROUP_ID, String.valueOf(group.getUuid()))
.execute();
assertThat(getGroupNamesInTemplateAndPermission(template, CODEVIEWER)).containsExactly(group.getName());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java
index b5a79611dc2..dfe00d8a2a5 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java
@@ -212,7 +212,7 @@ public class ApplyTemplateActionTest extends BasePermissionWsTest<ApplyTemplateA
}
private void addGroupToTemplate(GroupDto group, PermissionTemplateDto permissionTemplate, String permission) {
- db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), permissionTemplate.getUuid(), group.getId(), permission);
+ db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), permissionTemplate.getUuid(), group.getUuid(), permission);
db.commit();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java
index 2aa2bc0c7b2..16e26ca06f0 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/BulkApplyTemplateActionTest.java
@@ -350,7 +350,7 @@ public class BulkApplyTemplateActionTest extends BasePermissionWsTest<BulkApplyT
}
private void addGroupToTemplate(GroupDto group, PermissionTemplateDto permissionTemplate, String permission) {
- db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), permissionTemplate.getUuid(), group.getId(), permission);
+ db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), permissionTemplate.getUuid(), group.getUuid(), permission);
db.commit();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java
index ea198a96306..ee951cc4552 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java
@@ -422,7 +422,7 @@ public class DeleteTemplateActionTest {
UserDto user = db.getDbClient().userDao().insert(db.getSession(), UserTesting.newUserDto().setActive(true));
GroupDto group = db.getDbClient().groupDao().insert(db.getSession(), GroupTesting.newGroupDto());
db.getDbClient().permissionTemplateDao().insertUserPermission(db.getSession(), dto.getUuid(), user.getId(), UserRole.ADMIN);
- db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), dto.getUuid(), group.getId(), UserRole.CODEVIEWER);
+ db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), dto.getUuid(), group.getUuid(), UserRole.CODEVIEWER);
db.commit();
return dto;
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java
index ebf04fa91aa..a58014937a1 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java
@@ -71,7 +71,7 @@ public class RemoveGroupFromTemplateActionTest extends BasePermissionWsTest<Remo
group = db.users().insertGroup(db.getDefaultOrganization(), "group-name");
template = db.permissionTemplates().insertTemplate(db.getDefaultOrganization());
- addGroupToTemplate(template, group.getId(), PERMISSION);
+ addGroupToTemplate(template, group.getUuid(), PERMISSION);
}
@Test
@@ -97,7 +97,7 @@ public class RemoveGroupFromTemplateActionTest extends BasePermissionWsTest<Remo
newRequest()
.setParam(PARAM_TEMPLATE_ID, template.getUuid())
.setParam(PARAM_PERMISSION, PERMISSION)
- .setParam(PARAM_GROUP_ID, String.valueOf(group.getId()))
+ .setParam(PARAM_GROUP_ID, String.valueOf(group.getUuid()))
.execute();
assertThat(getGroupNamesInTemplateAndPermission(template, PERMISSION)).isEmpty();
@@ -196,8 +196,8 @@ public class RemoveGroupFromTemplateActionTest extends BasePermissionWsTest<Remo
request.execute();
}
- private void addGroupToTemplate(PermissionTemplateDto template, @Nullable Integer groupId, String permission) {
- db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), template.getUuid(), groupId, permission);
+ private void addGroupToTemplate(PermissionTemplateDto template, @Nullable String groupUuid, String permission) {
+ db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), template.getUuid(), groupUuid, permission);
db.commit();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java
index c6d5598b089..c5482f55dae 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/SearchTemplatesActionTest.java
@@ -97,7 +97,7 @@ public class SearchTemplatesActionTest extends BasePermissionWsTest<SearchTempla
addUserToTemplate(projectTemplate.getUuid(), user2.getId(), UserRole.ISSUE_ADMIN);
addUserToTemplate(projectTemplate.getUuid(), user3.getId(), UserRole.ISSUE_ADMIN);
addUserToTemplate(projectTemplate.getUuid(), user1.getId(), UserRole.CODEVIEWER);
- addGroupToTemplate(projectTemplate.getUuid(), group1.getId(), UserRole.ADMIN);
+ addGroupToTemplate(projectTemplate.getUuid(), group1.getUuid(), UserRole.ADMIN);
addPermissionTemplateWithProjectCreator(projectTemplate.getUuid(), UserRole.ADMIN);
db.organizations().setDefaultTemplates(projectTemplate, null, null);
@@ -128,14 +128,14 @@ public class SearchTemplatesActionTest extends BasePermissionWsTest<SearchTempla
addUserToTemplate(projectTemplate.getUuid(), user2.getId(), UserRole.ISSUE_ADMIN);
addUserToTemplate(projectTemplate.getUuid(), user3.getId(), UserRole.ISSUE_ADMIN);
addUserToTemplate(projectTemplate.getUuid(), user1.getId(), UserRole.CODEVIEWER);
- addGroupToTemplate(projectTemplate.getUuid(), group1.getId(), UserRole.ADMIN);
+ addGroupToTemplate(projectTemplate.getUuid(), group1.getUuid(), UserRole.ADMIN);
addPermissionTemplateWithProjectCreator(projectTemplate.getUuid(), UserRole.ADMIN);
addUserToTemplate(portfoliosTemplate.getUuid(), user1.getId(), UserRole.USER);
addUserToTemplate(portfoliosTemplate.getUuid(), user2.getId(), UserRole.USER);
- addGroupToTemplate(portfoliosTemplate.getUuid(), group1.getId(), UserRole.ISSUE_ADMIN);
- addGroupToTemplate(portfoliosTemplate.getUuid(), group2.getId(), UserRole.ISSUE_ADMIN);
- addGroupToTemplate(portfoliosTemplate.getUuid(), group3.getId(), UserRole.ISSUE_ADMIN);
+ addGroupToTemplate(portfoliosTemplate.getUuid(), group1.getUuid(), UserRole.ISSUE_ADMIN);
+ addGroupToTemplate(portfoliosTemplate.getUuid(), group2.getUuid(), UserRole.ISSUE_ADMIN);
+ addGroupToTemplate(portfoliosTemplate.getUuid(), group3.getUuid(), UserRole.ISSUE_ADMIN);
db.organizations().setDefaultTemplates(projectTemplate, applicationsTemplate, portfoliosTemplate);
@@ -377,8 +377,8 @@ public class SearchTemplatesActionTest extends BasePermissionWsTest<SearchTempla
return insert;
}
- private void addGroupToTemplate(String templateUuid, @Nullable Integer groupId, String permission) {
- dbClient.permissionTemplateDao().insertGroupPermission(db.getSession(), templateUuid, groupId, permission);
+ private void addGroupToTemplate(String templateUuid, @Nullable String groupUuid, String permission) {
+ dbClient.permissionTemplateDao().insertGroupPermission(db.getSession(), templateUuid, groupUuid, permission);
db.getSession().commit();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java
index 9f1265c5a40..1c3951eba67 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/permission/ws/template/TemplateGroupsActionTest.java
@@ -89,8 +89,8 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
GroupDto userGroup = insertGroupOnDefaultOrganization("sonar-users", "Any new users created will automatically join this group");
PermissionTemplateDto template = addTemplateToDefaultOrganization();
- addGroupToTemplate(newPermissionTemplateGroup(ISSUE_ADMIN, template.getUuid(), adminGroup.getId()));
- addGroupToTemplate(newPermissionTemplateGroup(ISSUE_ADMIN, template.getUuid(), userGroup.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(ISSUE_ADMIN, template.getUuid(), adminGroup.getUuid()));
+ addGroupToTemplate(newPermissionTemplateGroup(ISSUE_ADMIN, template.getUuid(), userGroup.getUuid()));
// Anyone group
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), null));
addGroupToTemplate(newPermissionTemplateGroup(ISSUE_ADMIN, template.getUuid(), null));
@@ -114,8 +114,8 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
String groupName = "group-name";
GroupDto group1 = db.users().insertGroup(db.getDefaultOrganization(), groupName);
- addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getUuid(), group1.getId()));
- addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group1.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getUuid(), group1.getUuid()));
+ addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group1.getUuid()));
OrganizationDto otherOrganization = db.organizations().insert();
db.users().insertGroup(otherOrganization, groupName);
@@ -123,10 +123,10 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
loginAsAdmin(db.getDefaultOrganization());
newRequest()
- .setMediaType(PROTOBUF)
- .setParam(PARAM_TEMPLATE_ID, template.getUuid())
- .setParam(TEXT_QUERY, "-nam")
- .execute();
+ .setMediaType(PROTOBUF)
+ .setParam(PARAM_TEMPLATE_ID, template.getUuid())
+ .setParam(TEXT_QUERY, "-nam")
+ .execute();
}
@Test
@@ -134,12 +134,12 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group1 = db.users().insertGroup(db.getDefaultOrganization(), "group-1-name");
- addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getUuid(), group1.getId()));
- addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group1.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getUuid(), group1.getUuid()));
+ addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group1.getUuid()));
GroupDto group2 = db.users().insertGroup(db.getDefaultOrganization(), "group-2-name");
- addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group2.getId()));
- addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group2.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group2.getUuid()));
+ addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group2.getUuid()));
GroupDto group3 = db.users().insertGroup(db.getDefaultOrganization(), "group-3-name");
@@ -149,8 +149,8 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
PermissionTemplateDto anotherTemplate = addTemplateToDefaultOrganization();
GroupDto group4 = db.users().insertGroup(db.getDefaultOrganization(), "group-4-name");
- addGroupToTemplate(newPermissionTemplateGroup(ADMIN, anotherTemplate.getUuid(), group3.getId()));
- addGroupToTemplate(newPermissionTemplateGroup(ADMIN, anotherTemplate.getUuid(), group4.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(ADMIN, anotherTemplate.getUuid(), group3.getUuid()));
+ addGroupToTemplate(newPermissionTemplateGroup(ADMIN, anotherTemplate.getUuid(), group4.getUuid()));
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
@@ -169,11 +169,11 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group1 = db.users().insertGroup(db.getDefaultOrganization(), "group-1-name");
- addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group1.getId()));
- addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getUuid(), group1.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group1.getUuid()));
+ addGroupToTemplate(newPermissionTemplateGroup(CODEVIEWER, template.getUuid(), group1.getUuid()));
GroupDto group2 = db.users().insertGroup(db.getDefaultOrganization(), "group-2-name");
- addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group2.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group2.getUuid()));
GroupDto group3 = db.users().insertGroup(db.getDefaultOrganization(), "group-3-name");
@@ -181,7 +181,7 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), null));
PermissionTemplateDto anotherTemplate = addTemplateToDefaultOrganization();
- addGroupToTemplate(newPermissionTemplateGroup(ADMIN, anotherTemplate.getUuid(), group3.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(ADMIN, anotherTemplate.getUuid(), group3.getUuid()));
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
@@ -202,12 +202,12 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
GroupDto group3 = db.users().insertGroup(defaultOrg, "group-3-name");
PermissionTemplateDto template = addTemplateToDefaultOrganization();
- addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group1.getId()));
- addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group2.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group1.getUuid()));
+ addGroupToTemplate(newPermissionTemplateGroup(ADMIN, template.getUuid(), group2.getUuid()));
addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), null));
PermissionTemplateDto anotherTemplate = addTemplateToDefaultOrganization();
- addGroupToTemplate(newPermissionTemplateGroup(USER, anotherTemplate.getUuid(), group1.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(USER, anotherTemplate.getUuid(), group1.getUuid()));
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
@@ -222,9 +222,9 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
OrganizationDto defaultOrg = db.getDefaultOrganization();
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group1 = db.users().insertGroup(defaultOrg, "group-1-name");
- addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group1.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group1.getUuid()));
GroupDto group2 = db.users().insertGroup(defaultOrg, "group-2-name");
- addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group2.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group2.getUuid()));
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
@@ -242,7 +242,7 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
OrganizationDto defaultOrg = db.getDefaultOrganization();
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group1 = db.users().insertGroup(defaultOrg, "group-1-name");
- addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group1.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group1.getUuid()));
GroupDto group2 = db.users().insertGroup(defaultOrg, "group-2-name");
GroupDto group3 = db.users().insertGroup(defaultOrg, "group-3");
loginAsAdmin(db.getDefaultOrganization());
@@ -279,7 +279,7 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
public void search_with_text_query_return_anyone_group_even_when_no_permission_set() {
PermissionTemplateDto template = addTemplateToDefaultOrganization();
GroupDto group = db.users().insertGroup(db.getDefaultOrganization(), "group");
- addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group.getId()));
+ addGroupToTemplate(newPermissionTemplateGroup(USER, template.getUuid(), group.getUuid()));
loginAsAdmin(db.getDefaultOrganization());
WsGroupsResponse response = newRequest()
@@ -399,11 +399,11 @@ public class TemplateGroupsActionTest extends BasePermissionWsTest<TemplateGroup
db.commit();
}
- private static PermissionTemplateGroupDto newPermissionTemplateGroup(String permission, String templateUuid, @Nullable Integer groupId) {
+ private static PermissionTemplateGroupDto newPermissionTemplateGroup(String permission, String templateUuid, @Nullable String groupUuid) {
return newPermissionTemplateGroupDto()
.setPermission(permission)
.setTemplateUuid(templateUuid)
- .setGroupId(groupId);
+ .setGroupUuid(groupUuid);
}
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java
index 44654eb54e4..bbbe522c1c5 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/project/ws/UpdateVisibilityActionTest.java
@@ -495,11 +495,11 @@ public class UpdateVisibilityActionTest {
.setParam(PARAM_VISIBILITY, PRIVATE)
.execute();
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group1.getId(), project.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group1.getUuid(), project.uuid()))
.containsOnly(UserRole.USER, UserRole.CODEVIEWER, "p1", "p2");
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group2.getId(), project.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group2.getUuid(), project.uuid()))
.containsOnly(UserRole.USER, UserRole.CODEVIEWER, "p2");
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group3.getId(), project.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group3.getUuid(), project.uuid()))
.isEmpty();
}
@@ -518,7 +518,7 @@ public class UpdateVisibilityActionTest {
.execute();
assertThat(dbClient.componentDao().selectByUuid(dbSession, portfolio.uuid()).get().isPrivate()).isTrue();
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group.getId(), portfolio.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group.getUuid(), portfolio.uuid()))
.containsOnly(UserRole.USER, UserRole.CODEVIEWER, UserRole.ISSUE_ADMIN);
assertThat(dbClient.userPermissionDao().selectProjectPermissionsOfUser(dbSession, user.getId(), portfolio.uuid()))
.containsOnly(UserRole.USER, UserRole.CODEVIEWER, UserRole.ADMIN);
@@ -543,7 +543,7 @@ public class UpdateVisibilityActionTest {
.execute();
assertThat(dbClient.componentDao().selectByUuid(dbSession, portfolio.uuid()).get().isPrivate()).isFalse();
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group.getId(), portfolio.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group.getUuid(), portfolio.uuid()))
.containsOnly(UserRole.ISSUE_ADMIN);
assertThat(dbClient.userPermissionDao().selectProjectPermissionsOfUser(dbSession, user.getId(), portfolio.uuid()))
.containsOnly(UserRole.ADMIN);
@@ -564,7 +564,7 @@ public class UpdateVisibilityActionTest {
.execute();
assertThat(dbClient.componentDao().selectByUuid(dbSession, application.uuid()).get().isPrivate()).isTrue();
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group.getId(), application.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group.getUuid(), application.uuid()))
.containsOnly(UserRole.USER, UserRole.CODEVIEWER, UserRole.ISSUE_ADMIN);
assertThat(dbClient.userPermissionDao().selectProjectPermissionsOfUser(dbSession, user.getId(), application.uuid()))
.containsOnly(UserRole.USER, UserRole.CODEVIEWER, UserRole.ADMIN);
@@ -589,7 +589,7 @@ public class UpdateVisibilityActionTest {
.execute();
assertThat(dbClient.componentDao().selectByUuid(dbSession, portfolio.uuid()).get().isPrivate()).isFalse();
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group.getId(), portfolio.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, organization.getUuid(), group.getUuid(), portfolio.uuid()))
.containsOnly(UserRole.ISSUE_ADMIN);
assertThat(dbClient.userPermissionDao().selectProjectPermissionsOfUser(dbSession, user.getId(), portfolio.uuid()))
.containsOnly(UserRole.ADMIN);
@@ -659,7 +659,7 @@ public class UpdateVisibilityActionTest {
GroupPermissionDto dto = new GroupPermissionDto()
.setUuid(Uuids.createFast())
.setOrganizationUuid(component.getOrganizationUuid())
- .setGroupId(null)
+ .setGroupUuid(null)
.setRole(permission)
.setComponentUuid(component.uuid());
dbTester.getDbClient().groupPermissionDao().insert(dbTester.getSession(), dto);
@@ -670,7 +670,7 @@ public class UpdateVisibilityActionTest {
GroupPermissionDto dto = new GroupPermissionDto()
.setUuid(Uuids.createFast())
.setOrganizationUuid(group.getOrganizationUuid())
- .setGroupId(group.getId())
+ .setGroupUuid(group.getUuid())
.setRole(permission)
.setComponentUuid(component.uuid());
dbTester.getDbClient().groupPermissionDao().insert(dbTester.getSession(), dto);
@@ -686,13 +686,13 @@ public class UpdateVisibilityActionTest {
private void verifyHasAllPermissionsButProjectPermissionsToGroupAnyOne(ComponentDto component, UserDto user, GroupDto group) {
assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), null))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
- assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getId()))
+ assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getUuid()))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
assertThat(dbClient.userPermissionDao().selectGlobalPermissionsOfUser(dbSession, user.getId(), component.getOrganizationUuid()))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, component.getOrganizationUuid(), null, component.uuid()))
.isEmpty();
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getId(), component.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getUuid(), component.uuid()))
.containsAll(permissionService.getAllProjectPermissions());
assertThat(dbClient.userPermissionDao().selectProjectPermissionsOfUser(dbSession, user.getId(), component.uuid()))
.containsAll(permissionService.getAllProjectPermissions());
@@ -701,7 +701,7 @@ public class UpdateVisibilityActionTest {
private void verifyHasAllPermissionsButProjectPermissionsUserAndBrowse(ComponentDto component, UserDto user, GroupDto group) {
assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), null))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
- assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getId()))
+ assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getUuid()))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
assertThat(dbClient.userPermissionDao().selectGlobalPermissionsOfUser(dbSession, user.getId(), component.getOrganizationUuid()))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
@@ -709,7 +709,7 @@ public class UpdateVisibilityActionTest {
.doesNotContain(UserRole.USER)
.doesNotContain(UserRole.CODEVIEWER)
.containsAll(PROJECT_PERMISSIONS_BUT_USER_AND_CODEVIEWER);
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getId(), component.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getUuid(), component.uuid()))
.doesNotContain(UserRole.USER)
.doesNotContain(UserRole.CODEVIEWER)
.containsAll(PROJECT_PERMISSIONS_BUT_USER_AND_CODEVIEWER);
@@ -722,13 +722,13 @@ public class UpdateVisibilityActionTest {
private void verifyStillHasAllPermissions(ComponentDto component, UserDto user, GroupDto group) {
assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), null))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
- assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getId()))
+ assertThat(dbClient.groupPermissionDao().selectGlobalPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getUuid()))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
assertThat(dbClient.userPermissionDao().selectGlobalPermissionsOfUser(dbSession, user.getId(), component.getOrganizationUuid()))
.containsAll(ORGANIZATION_PERMISSIONS_NAME_SET);
assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, component.getOrganizationUuid(), null, component.uuid()))
.containsAll(permissionService.getAllProjectPermissions());
- assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getId(), component.uuid()))
+ assertThat(dbClient.groupPermissionDao().selectProjectPermissionsOfGroup(dbSession, component.getOrganizationUuid(), group.getUuid(), component.uuid()))
.containsAll(permissionService.getAllProjectPermissions());
assertThat(dbClient.userPermissionDao().selectProjectPermissionsOfUser(dbSession, user.getId(), component.uuid()))
.containsAll(permissionService.getAllProjectPermissions());
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
index 94b2fb5d5a2..c0e91ea4469 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/CreateActionTest.java
@@ -126,7 +126,7 @@ public class CreateActionTest {
assertThat(dbUser.get().isRoot()).isFalse();
// member of default group in default organization
- assertThat(db.users().selectGroupIdsOfUser(dbUser.get())).containsOnly(defaultGroupInDefaultOrg.getId());
+ assertThat(db.users().selectGroupUuidsOfUser(dbUser.get())).containsOnly(defaultGroupInDefaultOrg.getUuid());
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
index da7042356d4..1e1258bdf60 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/DeactivateActionTest.java
@@ -120,7 +120,7 @@ public class DeactivateActionTest {
deactivate(user.getLogin());
- assertThat(db.getDbClient().groupMembershipDao().selectGroupIdsByUserId(dbSession, user.getId())).isEmpty();
+ assertThat(db.getDbClient().groupMembershipDao().selectGroupUuidsByUserId(dbSession, user.getId())).isEmpty();
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java
index 6339d0786d4..807d9be192b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/user/ws/GroupsActionTest.java
@@ -89,8 +89,8 @@ public class GroupsActionTest {
assertThat(response.getGroupsList())
.extracting(GroupsWsResponse.Group::getId, GroupsWsResponse.Group::getName, GroupsWsResponse.Group::getDescription, GroupsWsResponse.Group::getSelected)
.containsOnly(
- tuple(usersGroup.getId().longValue(), usersGroup.getName(), usersGroup.getDescription(), true),
- tuple(adminGroup.getId().longValue(), adminGroup.getName(), adminGroup.getDescription(), false));
+ tuple(usersGroup.getUuid(), usersGroup.getName(), usersGroup.getDescription(), true),
+ tuple(adminGroup.getUuid(), adminGroup.getName(), adminGroup.getDescription(), false));
}
@Test
@@ -104,7 +104,7 @@ public class GroupsActionTest {
assertThat(response.getGroupsList())
.extracting(GroupsWsResponse.Group::getId, GroupsWsResponse.Group::getName, GroupsWsResponse.Group::getDescription, GroupsWsResponse.Group::getSelected)
- .containsOnly(tuple(usersGroup.getId().longValue(), usersGroup.getName(), usersGroup.getDescription(), true));
+ .containsOnly(tuple(usersGroup.getUuid(), usersGroup.getName(), usersGroup.getDescription(), true));
}
@Test
@@ -118,7 +118,7 @@ public class GroupsActionTest {
assertThat(response.getGroupsList())
.extracting(GroupsWsResponse.Group::getId, GroupsWsResponse.Group::getName, GroupsWsResponse.Group::getDescription, GroupsWsResponse.Group::getSelected)
- .containsOnly(tuple(usersGroup.getId().longValue(), usersGroup.getName(), usersGroup.getDescription(), true));
+ .containsOnly(tuple(usersGroup.getUuid(), usersGroup.getName(), usersGroup.getDescription(), true));
}
@Test
@@ -132,7 +132,7 @@ public class GroupsActionTest {
assertThat(response.getGroupsList())
.extracting(GroupsWsResponse.Group::getId, GroupsWsResponse.Group::getName, GroupsWsResponse.Group::getDescription, GroupsWsResponse.Group::getSelected)
- .containsOnly(tuple(adminGroup.getId().longValue(), adminGroup.getName(), adminGroup.getDescription(), false));
+ .containsOnly(tuple(adminGroup.getUuid(), adminGroup.getName(), adminGroup.getDescription(), false));
}
@Test
@@ -191,8 +191,8 @@ public class GroupsActionTest {
assertThat(response.getGroupsList())
.extracting(GroupsWsResponse.Group::getId, GroupsWsResponse.Group::getName, GroupsWsResponse.Group::getDefault)
.containsOnly(
- tuple(usersGroup.getId().longValue(), usersGroup.getName(), true),
- tuple(adminGroup.getId().longValue(), adminGroup.getName(), false));
+ tuple(usersGroup.getUuid(), usersGroup.getName(), true),
+ tuple(adminGroup.getUuid(), adminGroup.getName(), false));
}
@Test
@@ -213,7 +213,7 @@ public class GroupsActionTest {
assertThat(response.getGroupsList())
.extracting(GroupsWsResponse.Group::getId, GroupsWsResponse.Group::getName, GroupsWsResponse.Group::getDescription, GroupsWsResponse.Group::getSelected,
GroupsWsResponse.Group::getDefault)
- .containsOnly(tuple(group.getId().longValue(), group.getName(), group.getDescription(), true, true));
+ .containsOnly(tuple(group.getUuid(), group.getName(), group.getDescription(), true, true));
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java
index 2efb791a3a9..bfba587dd9b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/AddUserActionTest.java
@@ -66,11 +66,11 @@ public class AddUserActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("login", user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).containsOnly(group.getId());
+ assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(group.getUuid());
}
@Test
@@ -86,7 +86,7 @@ public class AddUserActionTest {
.setParam(PARAM_LOGIN, user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).containsOnly(group.getId());
+ assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(group.getUuid());
}
@Test
@@ -104,7 +104,7 @@ public class AddUserActionTest {
.setParam(PARAM_LOGIN, user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).containsOnly(group.getId());
+ assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(group.getUuid());
}
@Test
@@ -119,11 +119,11 @@ public class AddUserActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", admins.getId().toString())
+ .setParam("id", admins.getUuid().toString())
.setParam("login", user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).containsOnly(admins.getId(), users.getId());
+ assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(admins.getUuid(), users.getUuid());
}
@Test
@@ -136,12 +136,12 @@ public class AddUserActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", users.getId().toString())
+ .setParam("id", users.getUuid().toString())
.setParam("login", user.getLogin())
.execute();
// do not insert duplicated row
- assertThat(db.users().selectGroupIdsOfUser(user)).hasSize(1).containsOnly(users.getId());
+ assertThat(db.users().selectGroupUuidsOfUser(user)).hasSize(1).containsOnly(users.getUuid());
}
@Test
@@ -156,12 +156,12 @@ public class AddUserActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", users.getId().toString())
+ .setParam("id", users.getUuid().toString())
.setParam("login", user2.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user1)).containsOnly(users.getId());
- assertThat(db.users().selectGroupIdsOfUser(user2)).containsOnly(users.getId());
+ assertThat(db.users().selectGroupUuidsOfUser(user1)).containsOnly(users.getUuid());
+ assertThat(db.users().selectGroupUuidsOfUser(user2)).containsOnly(users.getUuid());
}
@Test
@@ -173,7 +173,7 @@ public class AddUserActionTest {
loginAsAdminOnDefaultOrganization();
TestResponse response = newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("login", user.getLogin())
.execute();
@@ -204,7 +204,7 @@ public class AddUserActionTest {
expectedException.expectMessage("Could not find a user with login 'my-admin'");
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("login", "my-admin")
.execute();
}
@@ -285,7 +285,7 @@ public class AddUserActionTest {
expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
newRequest()
- .setParam("id", Integer.toString(defaultGroup.getId()))
+ .setParam("id", defaultGroup.getUuid())
.setParam(PARAM_LOGIN, user.getLogin())
.execute();
}
@@ -310,7 +310,7 @@ public class AddUserActionTest {
private void executeRequest(GroupDto groupDto, UserDto userDto) {
newRequest()
- .setParam("id", groupDto.getId().toString())
+ .setParam("id", groupDto.getUuid())
.setParam("login", userDto.getLogin())
.execute();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/CreateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/CreateActionTest.java
index 0efe3a72de7..43e58a54fb6 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/CreateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/CreateActionTest.java
@@ -25,6 +25,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.server.ws.WebService;
import org.sonar.api.utils.System2;
+import org.sonar.core.util.SequenceUuidFactory;
import org.sonar.db.DbTester;
import org.sonar.db.organization.OrganizationDto;
import org.sonar.db.user.GroupDto;
@@ -49,7 +50,7 @@ public class CreateActionTest {
public ExpectedException expectedException = ExpectedException.none();
private TestDefaultOrganizationProvider defaultOrganizationProvider = TestDefaultOrganizationProvider.from(db);
- private CreateAction underTest = new CreateAction(db.getDbClient(), userSession, newGroupWsSupport());
+ private CreateAction underTest = new CreateAction(db.getDbClient(), userSession, newGroupWsSupport(), new SequenceUuidFactory());
private WsActionTester tester = new WsActionTester(underTest);
@Test
@@ -102,7 +103,7 @@ public class CreateActionTest {
"}");
GroupDto createdGroup = db.users().selectGroup(org, "some-product-bu").get();
- assertThat(createdGroup.getId()).isNotNull();
+ assertThat(createdGroup.getUuid()).isNotNull();
assertThat(createdGroup.getOrganizationUuid()).isEqualTo(org.getUuid());
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java
index 22f33ff4ade..90cec02053a 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/DeleteActionTest.java
@@ -70,7 +70,7 @@ public class DeleteActionTest {
loginAsAdminOnDefaultOrganization();
TestResponse response = newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.execute();
assertThat(response.getStatus()).isEqualTo(204);
@@ -84,10 +84,10 @@ public class DeleteActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.execute();
- assertThat(db.users().selectGroupById(group.getId())).isNull();
+ assertThat(db.users().selectGroupByUuid(group.getUuid())).isNull();
}
@Test
@@ -101,7 +101,7 @@ public class DeleteActionTest {
.setParam(PARAM_GROUP_NAME, group.getName())
.execute();
- assertThat(db.users().selectGroupById(group.getId())).isNull();
+ assertThat(db.users().selectGroupByUuid(group.getUuid())).isNull();
}
@Test
@@ -117,7 +117,7 @@ public class DeleteActionTest {
.setParam(PARAM_GROUP_NAME, group.getName())
.execute();
- assertThat(db.users().selectGroupById(group.getId())).isNull();
+ assertThat(db.users().selectGroupByUuid(group.getUuid())).isNull();
}
@Test
@@ -145,7 +145,7 @@ public class DeleteActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.execute();
assertThat(db.countRowsOfTable("groups_users")).isEqualTo(0);
@@ -161,7 +161,7 @@ public class DeleteActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.execute();
assertThat(db.countRowsOfTable("group_roles")).isEqualTo(0);
@@ -173,13 +173,13 @@ public class DeleteActionTest {
insertDefaultGroupOnDefaultOrganization();
GroupDto group = db.users().insertGroup();
PermissionTemplateDto template = db.getDbClient().permissionTemplateDao().insert(db.getSession(), PermissionTemplateTesting.newPermissionTemplateDto());
- db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), template.getUuid(), group.getId(), "perm");
+ db.getDbClient().permissionTemplateDao().insertGroupPermission(db.getSession(), template.getUuid(), group.getUuid(), "perm");
db.commit();
loginAsAdminOnDefaultOrganization();
assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(1);
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.execute();
assertThat(db.countRowsOfTable("perm_templates_groups")).isEqualTo(0);
@@ -195,7 +195,7 @@ public class DeleteActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.execute();
assertThat(db.countRowsOfTable("qprofile_edit_groups")).isZero();
@@ -224,7 +224,7 @@ public class DeleteActionTest {
expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
newRequest()
- .setParam("id", defaultGroup.getId().toString())
+ .setParam("id", defaultGroup.getUuid())
.execute();
}
@@ -239,7 +239,7 @@ public class DeleteActionTest {
expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
newRequest()
- .setParam("id", defaultGroup.getId().toString())
+ .setParam("id", defaultGroup.getUuid())
.execute();
}
@@ -294,7 +294,7 @@ public class DeleteActionTest {
private void executeDeleteGroupRequest(GroupDto adminGroup1) {
newRequest()
- .setParam(PARAM_GROUP_ID, adminGroup1.getId().toString())
+ .setParam(PARAM_GROUP_ID, adminGroup1.getUuid())
.execute();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/GroupWsRefTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/GroupWsRefTest.java
index 95437bca7f1..86c9d2ad904 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/GroupWsRefTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/GroupWsRefTest.java
@@ -33,16 +33,16 @@ public class GroupWsRefTest {
@Test
public void test_ref_by_id() {
- GroupWsRef ref = GroupWsRef.fromId(10);
- assertThat(ref.hasId()).isTrue();
- assertThat(ref.getId()).isEqualTo(10);
+ GroupWsRef ref = GroupWsRef.fromUuid("10");
+ assertThat(ref.hasUuid()).isTrue();
+ assertThat(ref.getUuid()).isEqualTo("10");
assertThat(ref.isAnyone()).isFalse();
}
@Test
public void test_ref_by_name() {
GroupWsRef ref = fromName("ORG1", "the-group");
- assertThat(ref.hasId()).isFalse();
+ assertThat(ref.hasUuid()).isFalse();
assertThat(ref.getOrganizationKey()).isEqualTo("ORG1");
assertThat(ref.getName()).isEqualTo("the-group");
assertThat(ref.isAnyone()).isFalse();
@@ -50,11 +50,11 @@ public class GroupWsRefTest {
@Test
public void test_equals_and_hashCode() {
- GroupWsRef refId1 = GroupWsRef.fromId(10);
- GroupWsRef refId2 = GroupWsRef.fromId(11);
+ GroupWsRef refId1 = GroupWsRef.fromUuid("10");
+ GroupWsRef refId2 = GroupWsRef.fromUuid("11");
assertThat(refId1.equals(refId1)).isTrue();
- assertThat(refId1.equals(GroupWsRef.fromId(10))).isTrue();
- assertThat(refId1.hashCode()).isEqualTo(GroupWsRef.fromId(10).hashCode());
+ assertThat(refId1.equals(GroupWsRef.fromUuid("10"))).isTrue();
+ assertThat(refId1.hashCode()).isEqualTo(GroupWsRef.fromUuid("10").hashCode());
assertThat(refId1.equals(refId2)).isFalse();
GroupWsRef refName1 = fromName("ORG1", "the-group");
@@ -69,8 +69,8 @@ public class GroupWsRefTest {
@Test
public void test_toString() {
- GroupWsRef refId = GroupWsRef.fromId(10);
- assertThat(refId.toString()).isEqualTo("GroupWsRef{id=10, organizationKey='null', name='null'}");
+ GroupWsRef refId = GroupWsRef.fromUuid("10");
+ assertThat(refId.toString()).isEqualTo("GroupWsRef{uuid=10, organizationKey='null', name='null'}");
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/RemoveUserActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/RemoveUserActionTest.java
index 6bd357cf708..fc9a952fe4b 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/RemoveUserActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/RemoveUserActionTest.java
@@ -69,11 +69,11 @@ public class RemoveUserActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("login", user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).isEmpty();
+ assertThat(db.users().selectGroupUuidsOfUser(user)).isEmpty();
}
@Test
@@ -87,11 +87,11 @@ public class RemoveUserActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", users.getId().toString())
+ .setParam("id", users.getUuid())
.setParam("login", user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).isEmpty();
+ assertThat(db.users().selectGroupUuidsOfUser(user)).isEmpty();
}
@Test
@@ -108,7 +108,7 @@ public class RemoveUserActionTest {
.setParam(PARAM_LOGIN, user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).isEmpty();
+ assertThat(db.users().selectGroupUuidsOfUser(user)).isEmpty();
}
@Test
@@ -129,7 +129,7 @@ public class RemoveUserActionTest {
.setParam(PARAM_LOGIN, user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).isEmpty();
+ assertThat(db.users().selectGroupUuidsOfUser(user)).isEmpty();
}
@Test
@@ -147,11 +147,11 @@ public class RemoveUserActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", admins.getId().toString())
+ .setParam("id", admins.getUuid())
.setParam("login", user.getLogin())
.execute();
- assertThat(db.users().selectGroupIdsOfUser(user)).containsOnly(users.getId());
+ assertThat(db.users().selectGroupUuidsOfUser(user)).containsOnly(users.getUuid());
}
@Test
@@ -165,7 +165,7 @@ public class RemoveUserActionTest {
loginAsAdminOnDefaultOrganization();
TestResponse response = newRequest()
- .setParam("id", users.getId().toString())
+ .setParam("id", users.getUuid())
.setParam("login", user.getLogin())
.execute();
@@ -194,7 +194,7 @@ public class RemoveUserActionTest {
loginAsAdminOnDefaultOrganization();
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("login", "my-admin")
.execute();
}
@@ -211,7 +211,7 @@ public class RemoveUserActionTest {
expectedException.expectMessage("Insufficient privileges");
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("login", user.getLogin())
.execute();
}
@@ -230,7 +230,7 @@ public class RemoveUserActionTest {
expectedException.expectMessage("The last administrator user cannot be removed");
newRequest()
- .setParam("id", adminGroup.getId().toString())
+ .setParam("id", adminGroup.getUuid())
.setParam("login", adminUser.getLogin())
.execute();
}
@@ -247,7 +247,7 @@ public class RemoveUserActionTest {
expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
newRequest()
- .setParam("id", Integer.toString(defaultGroup.getId()))
+ .setParam("id", defaultGroup.getUuid())
.setParam(PARAM_LOGIN, user.getLogin())
.execute();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java
index 28882b03a96..6c280aebeef 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/SearchActionTest.java
@@ -161,15 +161,15 @@ public class SearchActionTest {
insertDefaultGroup(db.getDefaultOrganization(), "sonar-users", 0);
loginAsDefaultOrgAdmin();
- assertThat(call(ws.newRequest()).getGroupsList()).extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount)
+ assertThat(call(ws.newRequest()).getGroupsList()).extracting(Group::hasUuid, Group::hasName, Group::hasDescription, Group::hasMembersCount)
.containsOnly(tuple(true, true, true, true));
- assertThat(call(ws.newRequest().setParam(FIELDS, "")).getGroupsList()).extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount)
+ assertThat(call(ws.newRequest().setParam(FIELDS, "")).getGroupsList()).extracting(Group::hasUuid, Group::hasName, Group::hasDescription, Group::hasMembersCount)
.containsOnly(tuple(true, true, true, true));
- assertThat(call(ws.newRequest().setParam(FIELDS, "name")).getGroupsList()).extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount)
+ assertThat(call(ws.newRequest().setParam(FIELDS, "name")).getGroupsList()).extracting(Group::hasUuid, Group::hasName, Group::hasDescription, Group::hasMembersCount)
.containsOnly(tuple(true, true, false, false));
- assertThat(call(ws.newRequest().setParam(FIELDS, "description")).getGroupsList()).extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount)
+ assertThat(call(ws.newRequest().setParam(FIELDS, "description")).getGroupsList()).extracting(Group::hasUuid, Group::hasName, Group::hasDescription, Group::hasMembersCount)
.containsOnly(tuple(true, false, true, false));
- assertThat(call(ws.newRequest().setParam(FIELDS, "membersCount")).getGroupsList()).extracting(Group::hasId, Group::hasName, Group::hasDescription, Group::hasMembersCount)
+ assertThat(call(ws.newRequest().setParam(FIELDS, "membersCount")).getGroupsList()).extracting(Group::hasUuid, Group::hasName, Group::hasDescription, Group::hasMembersCount)
.containsOnly(tuple(true, false, false, true));
}
@@ -184,7 +184,7 @@ public class SearchActionTest {
SearchWsResponse response = call(ws.newRequest().setParam("organization", org.getKey()));
- assertThat(response.getGroupsList()).extracting(Group::getId, Group::getName).containsOnly(tuple(group.getId().longValue(), "users"));
+ assertThat(response.getGroupsList()).extracting(Group::getUuid, Group::getName).containsOnly(tuple(group.getUuid(), "users"));
}
@Test
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java
index 334158310d8..d13692ce1ff 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UpdateActionTest.java
@@ -62,7 +62,7 @@ public class UpdateActionTest {
loginAsAdminOnDefaultOrganization();
String result = newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("name", "new-name")
.setParam("description", "New Description")
.execute().getInput();
@@ -83,7 +83,7 @@ public class UpdateActionTest {
loginAsAdminOnDefaultOrganization();
String result = newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("name", "new-name")
.execute().getInput();
@@ -103,7 +103,7 @@ public class UpdateActionTest {
loginAsAdminOnDefaultOrganization();
String result = newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("description", "New Description")
.execute().getInput();
@@ -123,7 +123,7 @@ public class UpdateActionTest {
loginAsAdminOnDefaultOrganization();
String result = newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("name", "new-name")
.execute().getInput();
@@ -146,7 +146,7 @@ public class UpdateActionTest {
expectedException.expect(ForbiddenException.class);
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("name", "some-product-bu")
.setParam("description", "Business Unit for Some Awesome Product")
.execute();
@@ -164,7 +164,7 @@ public class UpdateActionTest {
expectedException.expect(ForbiddenException.class);
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("name", "some-product-bu")
.setParam("description", "Business Unit for Some Awesome Product")
.execute();
@@ -180,7 +180,7 @@ public class UpdateActionTest {
expectedException.expectMessage("Group name cannot be empty");
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("name", "")
.execute();
}
@@ -195,7 +195,7 @@ public class UpdateActionTest {
expectedException.expectMessage("Anyone group cannot be used");
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("name", "AnYoNe")
.execute();
}
@@ -213,7 +213,7 @@ public class UpdateActionTest {
expectedException.expectMessage("Group 'new-name' already exists");
newRequest()
- .setParam("id", groupToBeRenamed.getId().toString())
+ .setParam("id", groupToBeRenamed.getUuid().toString())
.setParam("name", newName)
.execute();
}
@@ -239,7 +239,7 @@ public class UpdateActionTest {
expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("name", "new name")
.execute();
}
@@ -253,7 +253,7 @@ public class UpdateActionTest {
expectedException.expectMessage("Default group 'default' cannot be used to perform this action");
newRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid().toString())
.setParam("description", "new description")
.execute();
}
diff --git a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UsersActionTest.java b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UsersActionTest.java
index 3b75f4245ef..cfce3877ed3 100644
--- a/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UsersActionTest.java
+++ b/server/sonar-webserver-webapi/src/test/java/org/sonar/server/usergroups/ws/UsersActionTest.java
@@ -56,7 +56,7 @@ public class UsersActionTest {
new UsersAction(db.getDbClient(), userSession, new GroupWsSupport(db.getDbClient(), defaultOrganizationProvider, new DefaultGroupFinder(db.getDbClient()))));
@Test
- public void fail_if_unknown_group_id() {
+ public void fail_if_unknown_group_uuid() {
loginAsAdminOnDefaultOrganization();
expectedException.expect(NotFoundException.class);
@@ -75,7 +75,7 @@ public class UsersActionTest {
expectedException.expect(ForbiddenException.class);
newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("login", "john").execute();
}
@@ -89,7 +89,7 @@ public class UsersActionTest {
expectedException.expect(ForbiddenException.class);
newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("login", "john").execute();
}
@@ -100,7 +100,7 @@ public class UsersActionTest {
String result = newUsersRequest()
.setParam("login", "john")
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.execute()
.getInput();
@@ -112,7 +112,7 @@ public class UsersActionTest {
}
@Test
- public void return_members_by_group_id() {
+ public void return_members_by_group_uuid() {
GroupDto group = db.users().insertGroup();
UserDto lovelace = db.users().insertUser(newUserDto().setLogin("ada.login").setName("Ada Lovelace"));
db.organizations().addMember(db.getDefaultOrganization(), lovelace);
@@ -122,7 +122,7 @@ public class UsersActionTest {
loginAsAdminOnDefaultOrganization();
String result = newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam(Param.SELECTED, SelectionMode.ALL.value())
.execute()
.getInput();
@@ -196,7 +196,7 @@ public class UsersActionTest {
db.users().insertMember(group, graceHopper);
loginAsAdminOnDefaultOrganization();
- String response = newUsersRequest().setParam(PARAM_GROUP_ID, group.getId().toString()).execute().getInput();
+ String response = newUsersRequest().setParam(PARAM_GROUP_ID, group.getUuid()).execute().getInput();
assertThat(response).contains("Ada Lovelace", "Grace Hopper");
}
@@ -212,7 +212,7 @@ public class UsersActionTest {
loginAsAdminOnDefaultOrganization();
assertJson(newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.execute()
.getInput()).isSimilarTo("{\n" +
" \"users\": [\n" +
@@ -221,7 +221,7 @@ public class UsersActionTest {
"}");
assertJson(newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam(Param.SELECTED, SelectionMode.SELECTED.value())
.execute()
.getInput()).isSimilarTo("{\n" +
@@ -242,7 +242,7 @@ public class UsersActionTest {
loginAsAdminOnDefaultOrganization();
String result = newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam(Param.SELECTED, SelectionMode.DESELECTED.value())
.execute()
.getInput();
@@ -265,7 +265,7 @@ public class UsersActionTest {
loginAsAdminOnDefaultOrganization();
assertJson(newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("ps", "1")
.setParam(Param.SELECTED, SelectionMode.ALL.value())
.execute()
@@ -279,7 +279,7 @@ public class UsersActionTest {
"}");
assertJson(newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("ps", "1")
.setParam("p", "2")
.setParam(Param.SELECTED, SelectionMode.ALL.value())
@@ -305,7 +305,7 @@ public class UsersActionTest {
loginAsAdminOnDefaultOrganization();
assertJson(newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam("q", "ace")
.setParam(Param.SELECTED, SelectionMode.ALL.value())
.execute()
@@ -316,7 +316,7 @@ public class UsersActionTest {
" ]\n" +
"}\n");
- assertJson(newUsersRequest().setParam("id", group.getId().toString())
+ assertJson(newUsersRequest().setParam("id", group.getUuid())
.setParam("q", ".logi")
.execute()
.getInput()).isSimilarTo("{\n" +
@@ -329,7 +329,7 @@ public class UsersActionTest {
" ]\n" +
"}\n");
- assertJson(newUsersRequest().setParam("id", group.getId().toString())
+ assertJson(newUsersRequest().setParam("id", group.getUuid())
.setParam("q", "OvE")
.execute()
.getInput()).isSimilarTo("{\n" +
@@ -342,7 +342,7 @@ public class UsersActionTest {
" ]\n" +
"}\n");
- assertJson(newUsersRequest().setParam("id", group.getId().toString())
+ assertJson(newUsersRequest().setParam("id", group.getUuid())
.setParam("q", "mail")
.execute()
.getInput()).isSimilarTo("{\n" +
@@ -368,7 +368,7 @@ public class UsersActionTest {
loginAsAdminOnDefaultOrganization();
String result = newUsersRequest()
- .setParam("id", group.getId().toString())
+ .setParam("id", group.getUuid())
.setParam(Param.SELECTED, SelectionMode.ALL.value())
.execute()
.getInput();