]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-8134 Rename ProjectRef to ProjectId
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 13 Oct 2016 15:35:00 +0000 (17:35 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Sun, 16 Oct 2016 17:10:20 +0000 (19:10 +0200)
for consistency with org.sonar.server.usergroups.ws.ProjectId

21 files changed:
server/sonar-server/src/main/java/org/sonar/server/permission/GroupPermissionChange.java
server/sonar-server/src/main/java/org/sonar/server/permission/GroupPermissionChanger.java
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionChange.java
server/sonar-server/src/main/java/org/sonar/server/permission/PermissionUpdater.java
server/sonar-server/src/main/java/org/sonar/server/permission/ProjectId.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/permission/ProjectRef.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChange.java
server/sonar-server/src/main/java/org/sonar/server/permission/UserPermissionChanger.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddUserAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionWsSupport.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveUserAction.java
server/sonar-server/src/main/java/org/sonar/server/permission/ws/UsersAction.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueBulkChangeServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueCommentServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/IssueServiceMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionComponentsMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/issue/ws/SearchActionMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/permission/GroupPermissionChangerTest.java

index 6f51ee15b6b0be82435cb633fafdf548990dd26e..cbb999d2e9f9fb76f80bba8e2d2109a62c8da9b8 100644 (file)
@@ -26,9 +26,9 @@ public class GroupPermissionChange extends PermissionChange {
 
   private final GroupIdOrAnyone groupId;
 
-  public GroupPermissionChange(Operation operation, String permission, @Nullable ProjectRef projectRef,
+  public GroupPermissionChange(Operation operation, String permission, @Nullable ProjectId projectId,
     GroupIdOrAnyone groupId) {
-    super(operation, groupId.getOrganizationUuid(), permission, projectRef);
+    super(operation, groupId.getOrganizationUuid(), permission, projectId);
     this.groupId = groupId;
   }
 
index f2c382a5463a32b4ad31232de9a8eab56b5fc525..c0f09291e0d1e97722bffed0ff3cf9e99fa024b9 100644 (file)
@@ -89,7 +89,7 @@ public class GroupPermissionChanger {
 
   private void checkAdminUsersExistOutsideTheRemovedGroup(DbSession dbSession, GroupPermissionChange change) {
     if (GlobalPermissions.SYSTEM_ADMIN.equals(change.getPermission()) &&
-      !change.getProjectRef().isPresent() &&
+      !change.getProjectId().isPresent() &&
       // TODO support organizations
       dbClient.roleDao().countUserPermissions(dbSession, change.getPermission(), change.getGroupIdOrAnyone().getId()) <= 0) {
       throw new BadRequestException(String.format("Last group with '%s' permission. Permission cannot be removed.", GlobalPermissions.SYSTEM_ADMIN));
index b109b4c9932adbc0cac0d61bcc4646c526897154..07a372f63209e1d6f668ef93be13ad331fb7cfd0 100644 (file)
@@ -37,14 +37,14 @@ public abstract class PermissionChange {
   private final Operation operation;
   private final String organizationUuid;
   private final String permission;
-  private final ProjectRef projectRef;
+  private final ProjectId projectId;
 
-  public PermissionChange(Operation operation, String organizationUuid, String permission, @Nullable ProjectRef projectRef) {
+  public PermissionChange(Operation operation, String organizationUuid, String permission, @Nullable ProjectId projectId) {
     this.operation = requireNonNull(operation);
     this.organizationUuid = requireNonNull(organizationUuid);
     this.permission = requireNonNull(permission);
-    this.projectRef = projectRef;
-    if (projectRef == null) {
+    this.projectId = projectId;
+    if (projectId == null) {
       checkRequest(GlobalPermissions.ALL.contains(permission), "Invalid global permission '%s'. Valid values are %s", permission, GlobalPermissions.ALL);
     } else {
       checkRequest(ProjectPermissions.ALL.contains(permission), "Invalid project permission '%s'. Valid values are %s", permission, ProjectPermissions.ALL);
@@ -63,23 +63,23 @@ public abstract class PermissionChange {
     return permission;
   }
 
-  public Optional<ProjectRef> getProjectRef() {
-    return Optional.ofNullable(projectRef);
+  public Optional<ProjectId> getProjectId() {
+    return Optional.ofNullable(projectId);
   }
 
   /**
-   * Shortcut based on {@link #getProjectRef()}
+   * Shortcut based on {@link #getProjectId()}
    */
   @CheckForNull
   public String getProjectUuid() {
-    return projectRef == null ? null : projectRef.getUuid();
+    return projectId == null ? null : projectId.getUuid();
   }
 
   /**
-   * Shortcut based on {@link #getProjectRef()}
+   * Shortcut based on {@link #getProjectId()}
    */
   @CheckForNull
   public Long getNullableProjectId() {
-    return projectRef == null ? null : projectRef.getId();
+    return projectId == null ? null : projectId.getId();
   }
 }
index cd804f44e24032c6556f4473001ab1118fa0899f..1d110b929dae9e007fef90f4478af6aa0345ec9e 100644 (file)
@@ -46,7 +46,7 @@ public class PermissionUpdater {
     Set<Long> projectIds = new HashSet<>();
     for (PermissionChange change : changes) {
       boolean changed = doApply(dbSession, change);
-      Optional<ProjectRef> projectId = change.getProjectRef();
+      Optional<ProjectId> projectId = change.getProjectId();
       if (changed && projectId.isPresent()) {
         projectIds.add(projectId.get().getId());
       }
diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ProjectId.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ProjectId.java
new file mode 100644 (file)
index 0000000..a30387a
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2016 SonarSource SA
+ * mailto:contact 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.sonar.server.permission;
+
+import javax.annotation.concurrent.Immutable;
+import org.sonar.db.component.ComponentDto;
+
+import static java.util.Objects.requireNonNull;
+
+/**
+ * Reference to a project by its db id or uuid. The field "id" should
+ * be removed as soon as backend is fully based on uuids.
+ *
+ * @see org.sonar.server.permission.ws.WsProjectRef
+ */
+@Immutable
+public class ProjectId {
+
+  private final long id;
+  private final String uuid;
+
+  public ProjectId(long projectId, String projectUuid) {
+    this.id = projectId;
+    this.uuid = requireNonNull(projectUuid);
+  }
+
+  public ProjectId(ComponentDto dto) {
+    this(requireNonNull(dto.getId()), dto.uuid());
+  }
+
+  public long getId() {
+    return id;
+  }
+
+  public String getUuid() {
+    return uuid;
+  }
+}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ProjectRef.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ProjectRef.java
deleted file mode 100644 (file)
index 5c1642a..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2016 SonarSource SA
- * mailto:contact 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.sonar.server.permission;
-
-import javax.annotation.concurrent.Immutable;
-import org.sonar.db.component.ComponentDto;
-
-import static java.util.Objects.requireNonNull;
-
-/**
- * Reference to a project by its db id or uuid. Temporarily
- * as long as permissions do not use only uuids.
- */
-@Immutable
-public class ProjectRef {
-
-  private final long id;
-  private final String uuid;
-
-  public ProjectRef(long projectId, String projectUuid) {
-    this.id = projectId;
-    this.uuid = requireNonNull(projectUuid);
-  }
-
-  public ProjectRef(ComponentDto dto) {
-    this(requireNonNull(dto.getId()), dto.uuid());
-  }
-
-  public long getId() {
-    return id;
-  }
-
-  public String getUuid() {
-    return uuid;
-  }
-}
index 9eb3ddad8fac0af104228296e64997fa3ab30196..4fa7014784ac397a0872717b76dcfb365b6e0f27 100644 (file)
@@ -27,9 +27,9 @@ public class UserPermissionChange extends PermissionChange {
 
   private final UserId userId;
 
-  public UserPermissionChange(Operation operation, String organizationUuid, String permission, @Nullable ProjectRef projectRef,
+  public UserPermissionChange(Operation operation, String organizationUuid, String permission, @Nullable ProjectId projectId,
     UserId userId) {
-    super(operation, organizationUuid, permission, projectRef);
+    super(operation, organizationUuid, permission, projectId);
     this.userId = requireNonNull(userId);
   }
 
index 41cb61d63ce388431d4625c98391cfef2b77bc5e..bdc0e8f0409021b8f615f7dc3139511966426e51 100644 (file)
@@ -70,7 +70,7 @@ public class UserPermissionChanger {
 
   private void checkOtherAdminUsersExist(DbSession session, PermissionChange change) {
     if (GlobalPermissions.SYSTEM_ADMIN.equals(change.getPermission()) &&
-      !change.getProjectRef().isPresent() &&
+      !change.getProjectId().isPresent() &&
       dbClient.roleDao().countUserPermissions(session, change.getPermission(), null) <= 1) {
       throw new BadRequestException(String.format("Last user with '%s' permission. Permission cannot be removed.", GlobalPermissions.SYSTEM_ADMIN));
     }
index be58720ede0ab343e3f0e544238e0b3cc95028de..88461d536e9b16d7abcddba3370e98fa18aaf9d8 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.db.DbSession;
 import org.sonar.server.permission.GroupPermissionChange;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.usergroups.ws.GroupIdOrAnyone;
 
 import static java.util.Arrays.asList;
@@ -73,7 +73,7 @@ public class AddGroupAction implements PermissionsWsAction {
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
       GroupIdOrAnyone group = support.findGroup(dbSession, request);
-      Optional<ProjectRef> projectId = support.findProject(dbSession, request);
+      Optional<ProjectId> projectId = support.findProject(dbSession, request);
 
       PermissionChange change = new GroupPermissionChange(
         PermissionChange.Operation.ADD,
index f7f99ab6d6943fe7188234dc7c78a8fddce740eb..bb189138ad78d155c7bf3f33c92a4c95810ce392 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.permission.UserId;
 import org.sonar.server.permission.UserPermissionChange;
 
@@ -75,7 +75,7 @@ public class AddUserAction implements PermissionsWsAction {
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
       UserId user = support.findUser(dbSession, request.mandatoryParam(PARAM_USER_LOGIN));
-      Optional<ProjectRef> projectId = support.findProject(dbSession, request);
+      Optional<ProjectId> projectId = support.findProject(dbSession, request);
       OrganizationDto org = support.findOrganization(dbSession, request.param(PARAM_ORGANIZATION_KEY));
       PermissionChange change = new UserPermissionChange(
         PermissionChange.Operation.ADD,
index 02835924d130a06fb07cd8d66c9b37860d2f7f3b..0b4047486739e78ff96653e38d8e13797879da92 100644 (file)
@@ -37,7 +37,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.permission.GroupPermissionDto;
 import org.sonar.db.permission.PermissionQuery;
 import org.sonar.db.user.GroupDto;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.WsPermissions.Group;
 import org.sonarqube.ws.WsPermissions.WsGroupsResponse;
@@ -86,7 +86,7 @@ public class GroupsAction implements PermissionsWsAction {
   @Override
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
-      Optional<ProjectRef> projectId = support.findProject(dbSession, request);
+      Optional<ProjectId> projectId = support.findProject(dbSession, request);
       checkProjectAdminUserByComponentUuid(userSession, projectId.isPresent() ? projectId.get().getUuid() : null);
 
       PermissionQuery query = buildPermissionQuery(request, projectId);
@@ -100,7 +100,7 @@ public class GroupsAction implements PermissionsWsAction {
     }
   }
 
-  private static PermissionQuery buildPermissionQuery(Request request, Optional<ProjectRef> project) {
+  private static PermissionQuery buildPermissionQuery(Request request, Optional<ProjectId> project) {
     String textQuery = request.param(Param.TEXT_QUERY);
     PermissionQuery.Builder permissionQuery = PermissionQuery.builder()
       .setPermission(request.param(PARAM_PERMISSION))
@@ -151,7 +151,7 @@ public class GroupsAction implements PermissionsWsAction {
     return Ordering.explicit(orderedNames).onResultOf(GroupDto::getName).immutableSortedCopy(groups);
   }
 
-  private List<GroupPermissionDto> findGroupPermissions(DbSession dbSession, List<GroupDto> groups, Optional<ProjectRef> project) {
+  private List<GroupPermissionDto> findGroupPermissions(DbSession dbSession, List<GroupDto> groups, Optional<ProjectId> project) {
     if (groups.isEmpty()) {
       return emptyList();
     }
index b47c604e89ab5fbf3da63e04acaca6a516312234..7fad14f64c08405f244f04a5824256e1d3daae86 100644 (file)
@@ -30,7 +30,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.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.permission.UserId;
 import org.sonar.server.permission.ws.template.WsTemplateRef;
 import org.sonar.server.usergroups.ws.GroupIdOrAnyone;
@@ -64,12 +64,12 @@ public class PermissionWsSupport {
   /**
    * @throws org.sonar.server.exceptions.NotFoundException if a project does not exist
    */
-  public ProjectRef findProject(DbSession dbSession, WsProjectRef ref) {
+  public ProjectId findProject(DbSession dbSession, WsProjectRef ref) {
     ComponentDto project = componentFinder.getRootComponentOrModuleByUuidOrKey(dbSession, ref.uuid(), ref.key(), resourceTypes);
-    return new ProjectRef(project.getId(), project.uuid());
+    return new ProjectId(project.getId(), project.uuid());
   }
 
-  public Optional<ProjectRef> findProject(DbSession dbSession, Request request) {
+  public Optional<ProjectId> findProject(DbSession dbSession, Request request) {
     String uuid = request.param(PermissionsWsParameters.PARAM_PROJECT_ID);
     String key = request.param(PermissionsWsParameters.PARAM_PROJECT_KEY);
     if (uuid != null || key != null) {
index 308effa61eddfb5318c611326c393295fb383dee..e45c817deb9e1722c196da2190378db86a85953c 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.db.DbSession;
 import org.sonar.server.permission.GroupPermissionChange;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.usergroups.ws.GroupIdOrAnyone;
 
 import static java.util.Arrays.asList;
@@ -73,7 +73,7 @@ public class RemoveGroupAction implements PermissionsWsAction {
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
       GroupIdOrAnyone group = support.findGroup(dbSession, request);
-      Optional<ProjectRef> projectId = support.findProject(dbSession, request);
+      Optional<ProjectId> projectId = support.findProject(dbSession, request);
 
       PermissionChange change = new GroupPermissionChange(
         PermissionChange.Operation.REMOVE,
index a2d41b27444f2e1baa4ec298378eece3515b5b72..8ec84d1fac831fba455f03c2c61ca013e7bfa76a 100644 (file)
@@ -28,7 +28,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.permission.UserId;
 import org.sonar.server.permission.UserPermissionChange;
 
@@ -75,7 +75,7 @@ public class RemoveUserAction implements PermissionsWsAction {
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
       UserId user = support.findUser(dbSession, request.mandatoryParam(PARAM_USER_LOGIN));
-      Optional<ProjectRef> projectId = support.findProject(dbSession, request);
+      Optional<ProjectId> projectId = support.findProject(dbSession, request);
       OrganizationDto org = support.findOrganization(dbSession, request.param(PARAM_ORGANIZATION_KEY));
 
       PermissionChange change = new UserPermissionChange(
index 944445064c99b4a641632973a08cb1102271ad95..3de7d0a7b214cf57cfe1e86968d1301e93f2ef30 100644 (file)
@@ -35,7 +35,7 @@ import org.sonar.db.DbSession;
 import org.sonar.db.permission.ExtendedUserPermissionDto;
 import org.sonar.db.permission.PermissionQuery;
 import org.sonar.db.user.UserDto;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.user.UserSession;
 import org.sonarqube.ws.WsPermissions;
 import org.sonarqube.ws.WsPermissions.UsersWsResponse;
@@ -89,7 +89,7 @@ public class UsersAction implements PermissionsWsAction {
   @Override
   public void handle(Request request, Response response) throws Exception {
     try (DbSession dbSession = dbClient.openSession(false)) {
-      Optional<ProjectRef> projectId = support.findProject(dbSession, request);
+      Optional<ProjectId> projectId = support.findProject(dbSession, request);
       checkProjectAdminUserByComponentUuid(userSession, projectId.isPresent() ? projectId.get().getUuid() : null);
 
       PermissionQuery query = buildPermissionQuery(request, projectId);
@@ -102,7 +102,7 @@ public class UsersAction implements PermissionsWsAction {
     }
   }
 
-  private static PermissionQuery buildPermissionQuery(Request request, Optional<ProjectRef> project) {
+  private static PermissionQuery buildPermissionQuery(Request request, Optional<ProjectId> project) {
     String textQuery = request.param(Param.TEXT_QUERY);
     String permission = request.param(PARAM_PERMISSION);
     PermissionQuery.Builder permissionQuery = PermissionQuery.builder()
@@ -161,7 +161,7 @@ public class UsersAction implements PermissionsWsAction {
     return Ordering.explicit(orderedLogins).onResultOf(UserDto::getLogin).immutableSortedCopy(dbClient.userDao().selectByLogins(dbSession, orderedLogins));
   }
 
-  private List<ExtendedUserPermissionDto> findUserPermissions(DbSession dbSession, List<UserDto> users, Optional<ProjectRef> project) {
+  private List<ExtendedUserPermissionDto> findUserPermissions(DbSession dbSession, List<UserDto> users, Optional<ProjectId> project) {
     if (users.isEmpty()) {
       return emptyList();
     }
index e86192989908e5ad93f37b7c3325720cf8e77f09..c80cea48b4065efce5bf4139d6658e2f9c7386f6 100644 (file)
@@ -49,7 +49,7 @@ import org.sonar.server.issue.index.IssueIndexer;
 import org.sonar.server.permission.GroupPermissionChange;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.user.UserSession;
@@ -101,7 +101,7 @@ public class IssueBulkChangeServiceMediumTest {
     userSessionRule.login("admin").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
     // 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 ProjectRef(project), GroupIdOrAnyone.forAnyone("TODO"));
+    GroupPermissionChange permissionChange = new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectId(project), GroupIdOrAnyone.forAnyone("TODO"));
     tester.get(PermissionUpdater.class).apply(session, asList(permissionChange));
 
     userSession = userSessionRule.login("john")
index 94aa534f3307779b36558160e8a126420accb78c..40272299207d655616df20f600adfcf46be8f079 100644 (file)
@@ -48,7 +48,7 @@ import org.sonar.server.issue.index.IssueIndexer;
 import org.sonar.server.permission.GroupPermissionChange;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.usergroups.ws.GroupIdOrAnyone;
@@ -95,7 +95,7 @@ public class IssueCommentServiceMediumTest {
     userSessionRule.login("admin").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
     // 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 ProjectRef(project), GroupIdOrAnyone.forAnyone("TODO"));
+    GroupPermissionChange permissionChange = new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectId(project), GroupIdOrAnyone.forAnyone("TODO"));
     tester.get(PermissionUpdater.class).apply(session, asList(permissionChange));
 
     userSessionRule.login("gandalf");
index 6eef148051d7fa7bfcd0b3adfb5a0590bd8d8a73..f0b605833d7afdbad5fa4267b0ad1c448de335ea 100644 (file)
@@ -51,7 +51,7 @@ import org.sonar.server.issue.workflow.Transition;
 import org.sonar.server.permission.GroupPermissionChange;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.rule.index.RuleIndexer;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
@@ -340,7 +340,7 @@ public class IssueServiceMediumTest {
     // 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 ProjectRef(project), GroupIdOrAnyone.forAnyone("TODO"));
+    GroupPermissionChange permissionChange = new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectId(project), GroupIdOrAnyone.forAnyone("TODO"));
     tester.get(PermissionUpdater.class).apply(session, asList(permissionChange));
     userSessionRule.login();
 
index 16c766ad42856fc2af3621b212c359bb0f7e36b1..1379e73366c66833d62a9df4b54d4d678cb908c2 100644 (file)
@@ -45,7 +45,7 @@ import org.sonar.server.issue.index.IssueIndexer;
 import org.sonar.server.permission.GroupPermissionChange;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
 import org.sonar.server.usergroups.ws.GroupIdOrAnyone;
@@ -655,7 +655,7 @@ public class SearchActionComponentsMediumTest {
     userSessionRule.login("admin").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
     // 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, permission, new ProjectRef(project), GroupIdOrAnyone.forAnyone("TODO"));
+    GroupPermissionChange permissionChange = new GroupPermissionChange(PermissionChange.Operation.ADD, permission, new ProjectId(project), GroupIdOrAnyone.forAnyone("TODO"));
     tester.get(PermissionUpdater.class).apply(session, asList(permissionChange));
   }
 
index 9a8c375901fa53fd8200c1022c29b428e3f39c03..6f64b9e9d2a8d1e3dca3955a81b7fadf1f3bdf7d 100644 (file)
@@ -49,7 +49,7 @@ import org.sonar.server.issue.index.IssueIndexer;
 import org.sonar.server.permission.GroupPermissionChange;
 import org.sonar.server.permission.PermissionChange;
 import org.sonar.server.permission.PermissionUpdater;
-import org.sonar.server.permission.ProjectRef;
+import org.sonar.server.permission.ProjectId;
 import org.sonar.server.search.QueryContext;
 import org.sonar.server.tester.ServerTester;
 import org.sonar.server.tester.UserSessionRule;
@@ -650,7 +650,7 @@ public class SearchActionMediumTest {
     userSessionRule.login("admin").setGlobalPermissions(GlobalPermissions.SYSTEM_ADMIN);
     // 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 ProjectRef(project), GroupIdOrAnyone.forAnyone("TODO"));
+    GroupPermissionChange permissionChange = new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.USER, new ProjectId(project), GroupIdOrAnyone.forAnyone("TODO"));
     tester.get(PermissionUpdater.class).apply(session, asList(permissionChange));
   }
 
index d3fcf478c800a40145249921edb7a6e2b5604469..09dc5971f43c62d7ba28c366f988dc96ea0ea8e2 100644 (file)
@@ -77,7 +77,7 @@ public class GroupPermissionChangerTest {
     GroupIdOrAnyone groupId = new GroupIdOrAnyone(group);
 
     loginAsAdmin();
-    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectRef(project), groupId));
+    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
 
     assertThat(db.users().selectGroupPermissions(group, null)).isEmpty();
     assertThat(db.users().selectGroupPermissions(group, project)).containsOnly(UserRole.ISSUE_ADMIN);
@@ -99,7 +99,7 @@ public class GroupPermissionChangerTest {
     GroupIdOrAnyone groupId = new GroupIdOrAnyone(db.getDefaultOrganization().getUuid(), null);
 
     loginAsAdmin();
-    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectRef(project), groupId));
+    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
 
     assertThat(db.users().selectAnyonePermissions(null)).isEmpty();
     assertThat(db.users().selectAnyonePermissions(project)).containsOnly(UserRole.ISSUE_ADMIN);
@@ -112,7 +112,7 @@ public class GroupPermissionChangerTest {
     expectedException.expect(ForbiddenException.class);
 
     userSession.login("a_guy");
-    underTest.apply(db.getSession(), new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectRef(project), groupId));
+    underTest.apply(db.getSession(), new GroupPermissionChange(PermissionChange.Operation.ADD, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
   }
 
   @Test
@@ -134,7 +134,7 @@ public class GroupPermissionChangerTest {
     expectedException.expectMessage("Invalid project permission 'gateadmin'. Valid values are [admin, codeviewer, issueadmin, scan, user]");
 
     loginAsAdmin();
-    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, new ProjectRef(project), groupId));
+    apply(new GroupPermissionChange(PermissionChange.Operation.ADD, GlobalPermissions.QUALITY_GATE_ADMIN, new ProjectId(project), groupId));
   }
 
   @Test
@@ -168,7 +168,7 @@ public class GroupPermissionChangerTest {
     db.users().insertProjectPermissionOnGroup(group, UserRole.CODEVIEWER, project);
 
     loginAsAdmin();
-    apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectRef(project), groupId));
+    apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
 
     assertThat(db.users().selectGroupPermissions(group, null)).containsOnly(GlobalPermissions.QUALITY_GATE_ADMIN);
     assertThat(db.users().selectGroupPermissions(group, project)).containsOnly(UserRole.CODEVIEWER);
@@ -179,7 +179,7 @@ public class GroupPermissionChangerTest {
     GroupIdOrAnyone groupId = new GroupIdOrAnyone(group);
 
     loginAsAdmin();
-    apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectRef(project), groupId));
+    apply(new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
 
     assertThat(db.users().selectGroupPermissions(group, null)).isEmpty();
     assertThat(db.users().selectGroupPermissions(group, project)).isEmpty();
@@ -192,7 +192,7 @@ public class GroupPermissionChangerTest {
     expectedException.expect(ForbiddenException.class);
 
     userSession.login("a_guy");
-    underTest.apply(db.getSession(), new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectRef(project), groupId));
+    underTest.apply(db.getSession(), new GroupPermissionChange(PermissionChange.Operation.REMOVE, UserRole.ISSUE_ADMIN, new ProjectId(project), groupId));
   }
 
   @Test