aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-11-12 10:09:19 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-11-17 13:40:59 +0100
commit7f4ae2a63fd2e73b347bd2941ae8902512468842 (patch)
treef6f8a6ec00532bcbc8cddb2e7fbb4b224ea0297e /sonar-ws
parente0d34a5e31b7038daa354607c0995a6f2a76e54e (diff)
downloadsonarqube-7f4ae2a63fd2e73b347bd2941ae8902512468842.tar.gz
sonarqube-7f4ae2a63fd2e73b347bd2941ae8902512468842.zip
SONAR-6947 Create and use AddGroupToTemplateWsRequest
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddGroupToTemplateWsRequest.java81
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java19
2 files changed, 98 insertions, 2 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddGroupToTemplateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddGroupToTemplateWsRequest.java
new file mode 100644
index 00000000000..2fff2a6928f
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddGroupToTemplateWsRequest.java
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nullable;
+
+public class AddGroupToTemplateWsRequest {
+ private String groupId;
+ private String groupName;
+ private String permission;
+ private String templateId;
+ private String templateName;
+
+ @CheckForNull
+ public String getGroupId() {
+ return groupId;
+ }
+
+ public AddGroupToTemplateWsRequest setGroupId(@Nullable String groupId) {
+ this.groupId = groupId;
+ return this;
+ }
+
+ @CheckForNull
+ public String getGroupName() {
+ return groupName;
+ }
+
+ public AddGroupToTemplateWsRequest setGroupName(@Nullable String groupName) {
+ this.groupName = groupName;
+ return this;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public AddGroupToTemplateWsRequest setPermission(String permission) {
+ this.permission = permission;
+ return this;
+ }
+
+ @CheckForNull
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public AddGroupToTemplateWsRequest setTemplateId(@Nullable String templateId) {
+ this.templateId = templateId;
+ return this;
+ }
+
+ @CheckForNull
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ public AddGroupToTemplateWsRequest setTemplateName(@Nullable String templateName) {
+ this.templateName = templateName;
+ return this;
+ }
+}
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 ecbb68a06b6..27c898a614b 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
@@ -27,6 +27,8 @@ import static org.sonarqube.ws.client.WsRequest.newGetRequest;
import static org.sonarqube.ws.client.WsRequest.newPostRequest;
public class PermissionsWsClient {
+ private static final String ENDPOINT = "api/permissions/";
+
private final WsClient wsClient;
public PermissionsWsClient(WsClient wsClient) {
@@ -34,7 +36,7 @@ public class PermissionsWsClient {
}
public WsPermissions.WsGroupsResponse groups(GroupsWsRequest request) {
- return wsClient.execute(newGetRequest("api/permissions/groups")
+ return wsClient.execute(newGetRequest(action("groups"))
.setParam("permission", request.getPermission())
.setParam("projectId", request.getProjectId())
.setParam("projectKey", request.getProjectKey())
@@ -46,11 +48,24 @@ public class PermissionsWsClient {
}
public void addGroup(AddGroupWsRequest request) {
- wsClient.execute(newPostRequest("api/permissions/add_group")
+ 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()));
}
+
+ 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()));
+ }
+
+ private static String action(String action) {
+ return ENDPOINT + action;
+ }
}