aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-ws
diff options
context:
space:
mode:
authorTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-11-12 11:33:58 +0100
committerTeryk Bellahsene <teryk.bellahsene@sonarsource.com>2015-11-17 13:41:00 +0100
commit50f694232ddc2f21f3a9e9d91b5662e489c955cf (patch)
tree5d535464c126021505d3db08860673eeb08b59b0 /sonar-ws
parent3c3d60d4e50ce70d7038bf1d2a71e98effc3d458 (diff)
downloadsonarqube-50f694232ddc2f21f3a9e9d91b5662e489c955cf.tar.gz
sonarqube-50f694232ddc2f21f3a9e9d91b5662e489c955cf.zip
SONAR-6947 Create AddUserToTemplateWsRequest and use it
Diffstat (limited to 'sonar-ws')
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddUserToTemplateWsRequest.java71
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsClient.java12
-rw-r--r--sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsParameters.java2
3 files changed, 82 insertions, 3 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddUserToTemplateWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddUserToTemplateWsRequest.java
new file mode 100644
index 00000000000..23d2436eb16
--- /dev/null
+++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddUserToTemplateWsRequest.java
@@ -0,0 +1,71 @@
+/*
+ * 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;
+
+import static java.util.Objects.requireNonNull;
+
+public class AddUserToTemplateWsRequest {
+ private String login;
+ private String permission;
+ private String templateId;
+ private String templateName;
+
+ public String getLogin() {
+ return login;
+ }
+
+ public AddUserToTemplateWsRequest setLogin(String login) {
+ this.login = requireNonNull(login);
+ return this;
+ }
+
+ public String getPermission() {
+ return permission;
+ }
+
+ public AddUserToTemplateWsRequest setPermission(String permission) {
+ this.permission = requireNonNull(permission);
+ return this;
+ }
+
+ @CheckForNull
+ public String getTemplateId() {
+ return templateId;
+ }
+
+ public AddUserToTemplateWsRequest setTemplateId(@Nullable String templateId) {
+ this.templateId = templateId;
+ return this;
+ }
+
+ @CheckForNull
+ public String getTemplateName() {
+ return templateName;
+ }
+
+ public AddUserToTemplateWsRequest 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 ba153a26e3d..ba75a5cef85 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
@@ -30,8 +30,8 @@ import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_G
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_ID;
import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME;
-import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID;
import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN;
public class PermissionsWsClient {
@@ -67,7 +67,7 @@ public class PermissionsWsClient {
.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_ID, request.getTemplateId())
.setParam(PARAM_TEMPLATE_NAME, request.getTemplateName()));
}
@@ -79,6 +79,14 @@ public class PermissionsWsClient {
.setParam(PARAM_PROJECT_KEY, request.getProjectKey()));
}
+ public void addUserToTemplate(AddUserToTemplateWsRequest request) {
+ wsClient.execute(newPostRequest(action("add_user_to_template"))
+ .setParam(PARAM_PERMISSION, request.getPermission())
+ .setParam(PARAM_USER_LOGIN, request.getLogin())
+ .setParam(PARAM_TEMPLATE_ID, request.getTemplateId())
+ .setParam(PARAM_TEMPLATE_NAME, request.getTemplateName()));
+ }
+
private static String action(String 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
index eaf91fd081c..8c9079f674f 100644
--- 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
@@ -29,7 +29,7 @@ public class PermissionsWsParameters {
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_ID = "templateId";
public static final String PARAM_TEMPLATE_NAME = "templateName";
public static final String PARAM_ID = "id";
public static final String PARAM_NAME = "name";