diff options
author | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-11 15:46:18 +0100 |
---|---|---|
committer | Teryk Bellahsene <teryk.bellahsene@sonarsource.com> | 2015-11-17 13:40:58 +0100 |
commit | e0d34a5e31b7038daa354607c0995a6f2a76e54e (patch) | |
tree | 3d9d834f4400096a14ef0328ea343449fab91847 /sonar-ws | |
parent | 1a0fdb1c93d6e0ebd01bdbaa3994b7bc04406f00 (diff) | |
download | sonarqube-e0d34a5e31b7038daa354607c0995a6f2a76e54e.tar.gz sonarqube-e0d34a5e31b7038daa354607c0995a6f2a76e54e.zip |
SONAR-6947 Add and use AddGroupWsRequest
Diffstat (limited to 'sonar-ws')
5 files changed, 152 insertions, 21 deletions
diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsConnector.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsConnector.java index 0f55b0dcc2a..c4f282744ed 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/WsConnector.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/WsConnector.java @@ -1,30 +1,27 @@ /* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com * - * 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 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. + * 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; import com.google.protobuf.Message; import com.google.protobuf.Parser; -import org.sonarqube.ws.client.WsRequest; public interface WsConnector { String execute(WsRequest wsRequest); diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddGroupWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddGroupWsRequest.java new file mode 100644 index 00000000000..975580862fb --- /dev/null +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/AddGroupWsRequest.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 AddGroupWsRequest { + private String permission; + private Long groupId; + private String groupName; + private String projectId; + private String projectKey; + + public String getPermission() { + return permission; + } + + public AddGroupWsRequest setPermission(String permission) { + this.permission = permission; + return this; + } + + @CheckForNull + public Long getGroupId() { + return groupId; + } + + public AddGroupWsRequest setGroupId(@Nullable Long groupId) { + this.groupId = groupId; + return this; + } + + @CheckForNull + public String getGroupName() { + return groupName; + } + + public AddGroupWsRequest setGroupName(@Nullable String groupName) { + this.groupName = groupName; + return this; + } + + @CheckForNull + public String getProjectId() { + return projectId; + } + + public AddGroupWsRequest setProjectId(@Nullable String projectId) { + this.projectId = projectId; + return this; + } + + @CheckForNull + public String getProjectKey() { + return projectKey; + } + + public AddGroupWsRequest setProjectKey(@Nullable String projectKey) { + this.projectKey = projectKey; + return this; + } +} diff --git a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/GroupsWsRequest.java b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/GroupsWsRequest.java index e43fb445862..535ed11ce37 100644 --- a/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/GroupsWsRequest.java +++ b/sonar-ws/src/main/java/org/sonarqube/ws/client/permission/GroupsWsRequest.java @@ -1,3 +1,22 @@ +/* + * 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; 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 2f84930e96f..ecbb68a06b6 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 @@ -1,9 +1,30 @@ +/* + * 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 org.sonarqube.ws.WsPermissions; import org.sonarqube.ws.client.WsClient; import static org.sonarqube.ws.client.WsRequest.newGetRequest; +import static org.sonarqube.ws.client.WsRequest.newPostRequest; public class PermissionsWsClient { private final WsClient wsClient; @@ -14,9 +35,22 @@ public class PermissionsWsClient { public WsPermissions.WsGroupsResponse groups(GroupsWsRequest request) { return wsClient.execute(newGetRequest("api/permissions/groups") - .setParam("permission", request.getPermission()) - .setParam("projectId", request.getProjectId()) - .setParam("projectKey", request.getProjectKey()), + .setParam("permission", request.getPermission()) + .setParam("projectId", request.getProjectId()) + .setParam("projectKey", request.getProjectKey()) + .setParam("p", request.getPage()) + .setParam("ps", request.getPageSize()) + .setParam("selected", request.getSelected()) + .setParam("q", request.getQuery()), WsPermissions.WsGroupsResponse.parser()); } + + public void addGroup(AddGroupWsRequest request) { + wsClient.execute(newPostRequest("api/permissions/add_group") + .setParam("permission", request.getPermission()) + .setParam("projectId", request.getProjectId()) + .setParam("projectKey", request.getProjectKey()) + .setParam("groupId", request.getGroupId()) + .setParam("groupName", request.getGroupName())); + } } diff --git a/sonar-ws/src/main/protobuf/ws-batch.proto b/sonar-ws/src/main/protobuf/ws-batch.proto index d6d050668a0..2885f2f5c55 100644 --- a/sonar-ws/src/main/protobuf/ws-batch.proto +++ b/sonar-ws/src/main/protobuf/ws-batch.proto @@ -25,7 +25,7 @@ option java_outer_classname = "WsBatch"; option optimize_for = SPEED; -// WS api/batch/project +// WS batch/project message WsProjectResponse { optional int64 timestamp = 1; map<string, Settings> settingsByModule = 2; |