diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-12-20 13:26:40 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2017-12-20 14:56:05 +0100 |
commit | bc027f57cdaa5bd33776d09d56652e7cf15c7ebf (patch) | |
tree | 6e22388561d30cd8155d5cf9c94d4e7c162eae0a | |
parent | 5ab22e4c6a0ef38da5481f7e9aa45c823e68deff (diff) | |
download | sonarqube-bc027f57cdaa5bd33776d09d56652e7cf15c7ebf.tar.gz sonarqube-bc027f57cdaa5bd33776d09d56652e7cf15c7ebf.zip |
SONAR-10134 Remove 'organization' parameter from project_status ws
4 files changed, 3 insertions, 52 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java index 7e2c818de9d..d8fa0c73f9c 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/qualitygate/ws/ProjectStatusAction.java @@ -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); diff --git a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java index a1a0d00be91..8d5e287abf4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/qualitygate/ws/ProjectStatusActionTest.java @@ -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); } @@ -265,24 +256,6 @@ public class ProjectStatusActionTest { } @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(); logInAsSystemAdministrator(); @@ -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(); } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/ProjectStatusRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/ProjectStatusRequest.java index 65423484335..153d237bb32 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/ProjectStatusRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/ProjectStatusRequest.java @@ -31,7 +31,6 @@ import javax.annotation.Generated; public class ProjectStatusRequest { private String analysisId; - private String organization; private String projectId; private String projectKey; @@ -48,18 +47,6 @@ public class ProjectStatusRequest { } /** - * Example value: "my-org" - */ - public ProjectStatusRequest setOrganization(String organization) { - this.organization = organization; - return this; - } - - public String getOrganization() { - return organization; - } - - /** * Example value: "AU-Tpxb--iU5OvuD2FLy" */ public ProjectStatusRequest setProjectId(String projectId) { diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java index 362479b2f43..2fd40438691 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/qualitygates/QualitygatesService.java @@ -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()); |