private void updatePermissionsToPrivate(DbSession dbSession, ComponentDto component) {
// delete project permissions for group AnyOne
dbClient.groupPermissionDao().deleteByRootComponentIdAndGroupId(dbSession, component.getId(), null);
- // grant UserRole.CODEVIEWER and UserRole.USER
+ // 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.getId(), permission)
.forEach(groupId -> insertProjectPermissionOnGroup(dbSession, component, permission, groupId));
.setParam(PAGE_SIZE, request.getPageSize());
return call(get, SearchWsResponse.parser());
}
+
+ public void updateVisibility(UpdateVisibilityRequest request) {
+ PostRequest post = new PostRequest(path("update_visibility"))
+ .setParam(PARAM_PROJECT, request.getProject())
+ .setParam("visibility", request.getVisibility());
+
+ call(post);
+ }
}
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.sonarqube.ws.client.project;
+
+public class UpdateVisibilityRequest {
+ private final String project;
+ private final String visibility;
+
+ public enum Visibility {
+ PUBLIC, PRIVATE
+ }
+
+ public UpdateVisibilityRequest(String project, Visibility visibility) {
+ this.project = project;
+ this.visibility = visibility == Visibility.PUBLIC ? "public" : "private";
+ }
+
+ public String getProject() {
+ return project;
+ }
+
+ public String getVisibility() {
+ return visibility;
+ }
+}