use of org.sonar.server.permission.GroupPermissionChange in project sonarqube by SonarSource.
the class AddGroupAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
GroupIdOrAnyone group = support.findGroup(dbSession, request);
Optional<ProjectId> projectId = support.findProjectId(dbSession, request);
checkProjectAdmin(userSession, group.getOrganizationUuid(), projectId);
PermissionChange change = new GroupPermissionChange(PermissionChange.Operation.ADD, request.mandatoryParam(PARAM_PERMISSION), projectId.orElse(null), group);
permissionUpdater.apply(dbSession, asList(change));
}
response.noContent();
}
use of org.sonar.server.permission.GroupPermissionChange in project sonarqube by SonarSource.
the class SearchActionMediumTest method setProjectPermission.
private void setProjectPermission(ComponentDto project, String... permissions) {
// project can be seen by anyone and by code viewer
userSessionRule.logIn("admin");
Arrays.stream(permissions).forEach(permission -> userSessionRule.addProjectUuidPermissions(permission, project.uuid()));
tester.get(PermissionUpdater.class).apply(session, Arrays.stream(permissions).map(permission -> new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectId(project), GroupIdOrAnyone.forAnyone(project.getOrganizationUuid()))).collect(Collectors.toList()));
}
use of org.sonar.server.permission.GroupPermissionChange in project sonarqube by SonarSource.
the class RemoveGroupAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
GroupIdOrAnyone group = support.findGroup(dbSession, request);
Optional<ProjectId> projectId = support.findProjectId(dbSession, request);
checkProjectAdmin(userSession, group.getOrganizationUuid(), projectId);
PermissionChange change = new GroupPermissionChange(PermissionChange.Operation.REMOVE, request.mandatoryParam(PARAM_PERMISSION), projectId.orElse(null), group);
permissionUpdater.apply(dbSession, asList(change));
}
response.noContent();
}
use of org.sonar.server.permission.GroupPermissionChange in project sonarqube by SonarSource.
the class IssueServiceMediumTest method newProject.
private ComponentDto newProject() {
OrganizationDto organization = OrganizationTesting.newOrganizationDto();
tester.get(OrganizationDao.class).insert(session, organization);
ComponentDto project = ComponentTesting.newProjectDto(organization);
tester.get(ComponentDao.class).insert(session, project);
userSessionRule.logIn().addProjectUuidPermissions(UserRole.USER, project.uuid());
session.commit();
// project can be seen by group "anyone"
// TODO correctly feed default organization. Not a problem as long as issues search does not support "anyone"
// for each organization
GroupPermissionChange permissionChange = new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectId(project), GroupIdOrAnyone.forAnyone(organization.getUuid()));
tester.get(PermissionUpdater.class).apply(session, asList(permissionChange));
userSessionRule.logIn();
return project;
}
use of org.sonar.server.permission.GroupPermissionChange in project sonarqube by SonarSource.
the class SearchActionMediumTest method setDefaultProjectPermission.
private void setDefaultProjectPermission(ComponentDto project) {
// project can be seen by anyone and by code viewer
userSessionRule.logIn().addProjectUuidPermissions(UserRole.USER, project.uuid());
// TODO correctly feed default organization. Not a problem as long as issues search does not support "anyone"
// for each organization
GroupPermissionChange permissionChange = new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectId(project), GroupIdOrAnyone.forAnyone(project.getOrganizationUuid()));
tester.get(PermissionUpdater.class).apply(session, asList(permissionChange));
}
Aggregations