diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-12 10:19:38 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-17 13:40:59 +0100 |
commit | a5426fe36e91f6647c0dda681962299d5d6fb950 (patch) | |
tree | aa5445302b9c6cb9ac0094e531f53a1dd6bedeb4 /sonar-ws | |
parent | 7f4ae2a63fd2e73b347bd2941ae8902512468842 (diff) | |
download | sonarqube-a5426fe36e91f6647c0dda681962299d5d6fb950.tar.gz sonarqube-a5426fe36e91f6647c0dda681962299d5d6fb950.zip |
SONAR-6947 PermissionsWsParameters in sonar-ws
Diffstat (limited to 'sonar-ws')
-rw-r--r-- | sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java | 37 | ||||
-rw-r--r-- | sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsParameters.java | 39 |
2 files changed, 60 insertions, 16 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java index 27c898a614b..ba152378b6b 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java @@ -25,10 +25,15 @@ import org.sonarqube.ws.client.WsClient; import static org.sonarqube.ws.client.WsRequest.newGetRequest; import static org.sonarqube.ws.client.WsRequest.newPostRequest; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID; public class PermissionsWsClient { - private static final String ENDPOINT = "api/permissions/"; - private final WsClient wsClient; public PermissionsWsClient(WsClient wsClient) { @@ -37,9 +42,9 @@ public class PermissionsWsClient { public WsPermissions.WsGroupsResponse groups(GroupsWsRequest request) { return wsClient.execute(newGetRequest(action("groups")) - .setParam("permission", request.getPermission()) - .setParam("projectId", request.getProjectId()) - .setParam("projectKey", request.getProjectKey()) + .setParam(PARAM_PERMISSION, request.getPermission()) + .setParam(PARAM_PROJECT_ID, request.getProjectId()) + .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) .setParam("p", request.getPage()) .setParam("ps", request.getPageSize()) .setParam("selected", request.getSelected()) @@ -49,23 +54,23 @@ public class PermissionsWsClient { public void addGroup(AddGroupWsRequest request) { wsClient.execute(newPostRequest(action("add_group")) - .setParam("permission", request.getPermission()) - .setParam("projectId", request.getProjectId()) - .setParam("projectKey", request.getProjectKey()) - .setParam("groupId", request.getGroupId()) - .setParam("groupName", request.getGroupName())); + .setParam(PARAM_PERMISSION, request.getPermission()) + .setParam(PARAM_PROJECT_ID, request.getProjectId()) + .setParam(PARAM_PROJECT_KEY, request.getProjectKey()) + .setParam(PARAM_GROUP_ID, request.getGroupId()) + .setParam(PARAM_GROUP_NAME, request.getGroupName())); } public void addGroupToTemplate(AddGroupToTemplateWsRequest request) { wsClient.execute(newPostRequest(action("add_group_to_template")) - .setParam("groupId", request.getGroupId()) - .setParam("groupName", request.getGroupName()) - .setParam("permission", request.getPermission()) - .setParam("templateId", request.getTemplateId()) - .setParam("templateName", request.getTemplateName())); + .setParam(PARAM_GROUP_ID, request.getGroupId()) + .setParam(PARAM_GROUP_NAME, request.getGroupName()) + .setParam(PARAM_PERMISSION, request.getPermission()) + .setParam(PARAM_TEMPLATE_UUID, request.getTemplateId()) + .setParam(PARAM_TEMPLATE_NAME, request.getTemplateName())); } private static String action(String action) { - return ENDPOINT + action; + return PermissionsWsParameters.ENDPOINT + "/" + action; } } diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsParameters.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsParameters.java new file mode 100644 index 00000000000..eaf91fd081c --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsParameters.java @@ -0,0 +1,39 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube 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. + * + * SonarQube 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.permission; + +public class PermissionsWsParameters { + public static final String ENDPOINT = "api/permissions"; + + public static final String PARAM_PERMISSION = "permission"; + public static final String PARAM_GROUP_NAME = "groupName"; + public static final String PARAM_GROUP_ID = "groupId"; + public static final String PARAM_PROJECT_ID = "projectId"; + public static final String PARAM_PROJECT_KEY = "projectKey"; + public static final String PARAM_USER_LOGIN = "login"; + public static final String PARAM_TEMPLATE_UUID = "templateId"; + public static final String PARAM_TEMPLATE_NAME = "templateName"; + public static final String PARAM_ID = "id"; + public static final String PARAM_NAME = "name"; + public static final String PARAM_DESCRIPTION = "description"; + public static final String PARAM_PATTERN = "projectKeyPattern"; + public static final String PARAM_QUALIFIER = "qualifier"; +} |