]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10134 Remove 'organization' parameter from project_status ws
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 20 Dec 2017 12:26:40 +0000 (13:26 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 20 Dec 2017 13:56:05 +0000 (14:56 +0100)
server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java
server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/ProjectStatusRequest.java
sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java

index 7e2c818de9daf7b13f00a7abf3d7ad0e2eb18813..d8fa0c73f9c53cf34e27643cd5090c9a8ec1834f 100644 (file)
@@ -37,7 +37,6 @@ import org.sonar.db.component.ComponentDto;
 import org.sonar.db.component.SnapshotDto;
 import org.sonar.db.measure.LiveMeasureDto;
 import org.sonar.db.measure.MeasureDto;
-import org.sonar.db.organization.OrganizationDto;
 import org.sonar.server.component.ComponentFinder;
 import org.sonar.server.component.ComponentFinder.ParamNames;
 import org.sonar.server.exceptions.BadRequestException;
@@ -105,8 +104,6 @@ public class ProjectStatusAction implements QualityGatesWsAction {
       .setSince("5.4")
       .setDescription("Project key")
       .setExampleValue(KeyExamples.KEY_PROJECT_EXAMPLE_001);
-
-    wsSupport.createOrganizationParam(action);
   }
 
   @Override
@@ -121,15 +118,13 @@ public class ProjectStatusAction implements QualityGatesWsAction {
       MSG_ONE_PARAMETER_ONLY);
 
     try (DbSession dbSession = dbClient.openSession(false)) {
-      OrganizationDto organization = wsSupport.getOrganization(dbSession, request);
-      ProjectStatusResponse projectStatusResponse = doHandle(dbSession, organization, analysisId, projectId, projectKey);
+      ProjectStatusResponse projectStatusResponse = doHandle(dbSession, analysisId, projectId, projectKey);
       writeProtobuf(projectStatusResponse, request, response);
     }
   }
 
-  private ProjectStatusResponse doHandle(DbSession dbSession, OrganizationDto organization, @Nullable String analysisId, @Nullable String projectId, @Nullable String projectKey) {
+  private ProjectStatusResponse doHandle(DbSession dbSession, @Nullable String analysisId, @Nullable String projectId, @Nullable String projectKey) {
     ProjectAndSnapshot projectAndSnapshot = getProjectAndSnapshot(dbSession, analysisId, projectId, projectKey);
-    wsSupport.checkProjectBelongsToOrganization(organization, projectAndSnapshot.project);
     checkPermission(projectAndSnapshot.project);
     Optional<String> measureData = loadQualityGateDetails(dbSession, projectAndSnapshot, analysisId != null);
 
index a1a0d00be910ba7f8e92d222acfcf4c751a6c9d2..8d5e287abf4bc43f8dcc933afc2c1a526b3b743d 100644 (file)
@@ -85,8 +85,7 @@ public class ProjectStatusActionTest {
       .containsExactlyInAnyOrder(
         tuple("analysisId", false),
         tuple("projectKey", false),
-        tuple("projectId", false),
-        tuple("organization", false));
+        tuple("projectId", false));
   }
 
   @Test
@@ -107,7 +106,6 @@ public class ProjectStatusActionTest {
 
     String response = ws.newRequest()
       .setParam("analysisId", snapshot.getUuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute().getInput();
 
     assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
@@ -139,7 +137,6 @@ public class ProjectStatusActionTest {
 
     String response = ws.newRequest()
       .setParam(PARAM_ANALYSIS_ID, pastAnalysis.getUuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute().getInput();
 
     assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
@@ -162,7 +159,6 @@ public class ProjectStatusActionTest {
 
     String response = ws.newRequest()
       .setParam(PARAM_PROJECT_ID, project.uuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute().getInput();
 
     assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
@@ -185,7 +181,6 @@ public class ProjectStatusActionTest {
 
     String response = ws.newRequest()
       .setParam(PARAM_PROJECT_KEY, project.getKey())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute().getInput();
 
     assertJson(response).isSimilarTo(getClass().getResource("project_status-example.json"));
@@ -201,7 +196,6 @@ public class ProjectStatusActionTest {
 
     ProjectStatusResponse result = ws.newRequest()
       .setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .executeProtobuf(ProjectStatusResponse.class);
 
     assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
@@ -216,7 +210,6 @@ public class ProjectStatusActionTest {
 
     ProjectStatusResponse result = ws.newRequest()
       .setParam(PARAM_PROJECT_ID, project.uuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .executeProtobuf(ProjectStatusResponse.class);
 
     assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
@@ -233,7 +226,6 @@ public class ProjectStatusActionTest {
 
     ws.newRequest()
       .setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .executeProtobuf(ProjectStatusResponse.class);
   }
 
@@ -247,7 +239,6 @@ public class ProjectStatusActionTest {
 
     ws.newRequest()
       .setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .executeProtobuf(ProjectStatusResponse.class);
   }
 
@@ -264,24 +255,6 @@ public class ProjectStatusActionTest {
     assertThat(result.getProjectStatus().getStatus()).isEqualTo(Status.NONE);
   }
 
-  @Test
-  public void fail_when_project_does_not_not_belong_to_organization() {
-    OrganizationDto organization = db.organizations().insert();
-    OrganizationDto otherOrganization = db.organizations().insert();
-    ComponentDto project = db.components().insertPrivateProject(otherOrganization);
-    SnapshotDto snapshot = dbClient.snapshotDao().insert(dbSession, newAnalysis(project));
-    dbSession.commit();
-    userSession.addProjectPermission(UserRole.ADMIN, project);
-
-    expectedException.expect(NotFoundException.class);
-    expectedException.expectMessage(String.format("Project '%s' doesn't exist in organization '%s'", project.getKey(), organization.getKey()));
-
-    ws.newRequest()
-      .setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
-      .executeProtobuf(ProjectStatusResponse.class);
-  }
-
   @Test
   public void fail_if_no_snapshot_id_found() {
     OrganizationDto organization = db.organizations().insert();
@@ -292,7 +265,6 @@ public class ProjectStatusActionTest {
 
     ws.newRequest()
       .setParam(PARAM_ANALYSIS_ID, ANALYSIS_ID)
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .executeProtobuf(ProjectStatusResponse.class);
   }
 
@@ -308,7 +280,6 @@ public class ProjectStatusActionTest {
 
     ws.newRequest()
       .setParam(PARAM_ANALYSIS_ID, snapshot.getUuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .executeProtobuf(ProjectStatusResponse.class);
   }
 
@@ -370,7 +341,6 @@ public class ProjectStatusActionTest {
 
     ws.newRequest()
       .setParam("projectId", branch.uuid())
-      .setParam(PARAM_ORGANIZATION, organization.getKey())
       .execute();
   }
 
index 65423484335271af08494a43815ef4dd2100636d..153d237bb3250d75e6704ac30d3f368f58a68f7b 100644 (file)
@@ -31,7 +31,6 @@ import javax.annotation.Generated;
 public class ProjectStatusRequest {
 
   private String analysisId;
-  private String organization;
   private String projectId;
   private String projectKey;
 
@@ -47,18 +46,6 @@ public class ProjectStatusRequest {
     return analysisId;
   }
 
-  /**
-   * Example value: "my-org"
-   */
-  public ProjectStatusRequest setOrganization(String organization) {
-    this.organization = organization;
-    return this;
-  }
-
-  public String getOrganization() {
-    return organization;
-  }
-
   /**
    * Example value: "AU-Tpxb--iU5OvuD2FLy"
    */
index 362479b2f436599c197bff70758caca6f820c39a..2fd40438691e299c29ba49bac28c9153d175324a 100644 (file)
@@ -185,7 +185,6 @@ public class QualitygatesService extends BaseService {
     return call(
       new GetRequest(path("project_status"))
         .setParam("analysisId", request.getAnalysisId())
-        .setParam("organization", request.getOrganization())
         .setParam("projectId", request.getProjectId())
         .setParam("projectKey", request.getProjectKey()),
       ProjectStatusResponse.parser());