From a5426fe36e91f6647c0dda681962299d5d6fb950 Mon Sep 17 00:00:00 2001 From: Teryk Bellahsene Date: Thu, 12 Nov 2015 10:19:38 +0100 Subject: [PATCH] SONAR-6947 PermissionsWsParameters in sonar-ws --- .../server/component/ws/SearchAction.java | 2 +- .../server/permission/ws/AddGroupAction.java | 18 ++++---- .../server/permission/ws/AddUserAction.java | 6 +-- .../permission/ws/DeleteTemplateAction.java | 2 +- .../server/permission/ws/GroupsAction.java | 10 ++--- .../permission/ws/PermissionRequest.java | 4 +- .../ws/PermissionRequestValidator.java | 6 +-- .../server/permission/ws/PermissionsWs.java | 4 +- ...va => PermissionsWsParametersBuilder.java} | 44 ++++++------------- .../permission/ws/RemoveGroupAction.java | 8 ++-- .../permission/ws/RemoveUserAction.java | 6 +-- .../ws/SearchProjectPermissionsAction.java | 2 +- .../permission/ws/TemplateGroupsAction.java | 6 +-- .../permission/ws/TemplateUsersAction.java | 6 +-- .../server/permission/ws/UsersAction.java | 4 +- .../server/permission/ws/WsProjectRef.java | 4 +- .../server/permission/ws/WsTemplateRef.java | 4 +- .../ws/template/AddGroupToTemplateAction.java | 18 ++++---- .../ws/template/AddUserToTemplateAction.java | 10 ++--- .../ws/template/ApplyTemplateAction.java | 4 +- .../ws/template/CreateTemplateAction.java | 10 ++--- .../RemoveGroupFromTemplateAction.java | 10 ++--- .../RemoveUserFromTemplateAction.java | 10 ++--- .../ws/template/SetDefaultTemplateAction.java | 4 +- .../ws/template/UpdateTemplateAction.java | 14 +++--- .../server/usergroups/ws/WsGroupRef.java | 5 +-- .../permission/ws/AddGroupActionTest.java | 10 ++--- .../permission/ws/AddUserActionTest.java | 8 ++-- .../permission/ws/GroupsActionTest.java | 6 +-- .../permission/ws/PermissionsWsTest.java | 4 +- .../permission/ws/RemoveGroupActionTest.java | 10 ++--- .../permission/ws/RemoveUserActionTest.java | 8 ++-- .../SearchProjectPermissionsActionTest.java | 2 +- .../ws/TemplateGroupsActionTest.java | 6 +-- .../ws/TemplateUsersActionTest.java | 14 +++--- .../server/permission/ws/UsersActionTest.java | 6 +-- .../AddGroupToTemplateActionTest.java | 16 +++---- .../template/AddUserToTemplateActionTest.java | 12 ++--- .../ws/template/ApplyTemplateActionTest.java | 8 ++-- .../ws/template/CreateTemplateActionTest.java | 6 +-- .../ws/template/DeleteTemplateActionTest.java | 4 +- .../RemoveGroupFromTemplateActionTest.java | 16 +++---- .../RemoveUserFromTemplateActionTest.java | 12 ++--- .../SetDefaultTemplateActionTest.java | 6 +-- .../ws/template/UpdateTemplateActionTest.java | 8 ++-- .../permission/PermissionsWsClient.java | 37 +++++++++------- .../permission/PermissionsWsParameters.java | 39 ++++++++++++++++ 47 files changed, 243 insertions(+), 216 deletions(-) rename server/sonar-server/src/main/java/org/sonar/server/permission/ws/{PermissionsWsParameters.java => PermissionsWsParametersBuilder.java} (75%) create mode 100644 sonar-ws/src/main/java/org/sonarqube/ws/client/permission/PermissionsWsParameters.java diff --git a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchAction.java b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchAction.java index ef3d0c9dc9b..5d1ffda5a58 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/component/ws/SearchAction.java @@ -45,7 +45,7 @@ import static com.google.common.collect.Ordering.natural; import static java.lang.String.format; import static org.sonar.server.component.ResourceTypeFunctions.RESOURCE_TYPE_TO_QUALIFIER; import static org.sonar.server.component.ws.WsComponentsParameters.PARAM_QUALIFIERS; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_QUALIFIER; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER; import static org.sonar.server.ws.WsUtils.checkRequest; import static org.sonar.server.ws.WsUtils.writeProtobuf; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java index 37797db2803..6642c58839e 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddGroupAction.java @@ -29,15 +29,15 @@ import org.sonar.server.permission.PermissionChange; import org.sonar.server.permission.PermissionUpdater; import org.sonarqube.ws.client.permission.AddGroupWsRequest; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createGroupIdParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createGroupNameParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectParameter; +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.sonar.server.permission.ws.PermissionsWsParametersBuilder.createGroupIdParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createGroupNameParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameter; import static org.sonar.server.permission.ws.WsProjectRef.newOptionalWsProjectRef; import static org.sonar.server.usergroups.ws.WsGroupRef.newWsGroupRef; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddUserAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddUserAction.java index 5528f880326..367dd9e4c54 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddUserAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/AddUserAction.java @@ -29,9 +29,9 @@ import org.sonar.server.permission.PermissionChange; import org.sonar.server.permission.PermissionUpdater; import org.sonar.server.permission.ws.PermissionRequest.Builder; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createUserLoginParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createUserLoginParameter; public class AddUserAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DeleteTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DeleteTemplateAction.java index 58bcca990e1..2a2b008b5bd 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DeleteTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/DeleteTemplateAction.java @@ -31,7 +31,7 @@ import org.sonar.server.permission.ws.template.DefaultPermissionTemplateFinder; import org.sonar.server.user.UserSession; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; import static org.sonar.server.permission.ws.WsTemplateRef.fromRequest; import static org.sonar.server.ws.WsUtils.checkRequest; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java index 0a98ce631b4..1ca8bf8f4b2 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/GroupsAction.java @@ -45,11 +45,11 @@ import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjec import static org.sonar.server.permission.ws.PermissionQueryParser.fromSelectionModeToMembership; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateGlobalPermission; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectParameter; +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.sonar.server.permission.ws.PermissionsWsParametersBuilder.createPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameter; import static org.sonar.server.permission.ws.WsProjectRef.newOptionalWsProjectRef; import static org.sonar.server.ws.WsUtils.writeProtobuf; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequest.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequest.java index 4650889c0f9..f9a09cce5d7 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequest.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequest.java @@ -31,8 +31,8 @@ import static org.sonar.api.server.ws.WebService.Param.SELECTED; import static org.sonar.api.server.ws.WebService.Param.TEXT_QUERY; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateGlobalPermission; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_USER_LOGIN; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN; class PermissionRequest { private final String permission; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequestValidator.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequestValidator.java index 3a6cf38249d..28678daaae1 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequestValidator.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionRequestValidator.java @@ -33,9 +33,9 @@ import static com.google.common.base.Strings.isNullOrEmpty; import static java.lang.String.format; import static org.apache.commons.lang.StringUtils.isBlank; import static org.sonar.api.security.DefaultGroups.isAnyone; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PATTERN; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_QUALIFIER; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PATTERN; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER; import static org.sonar.server.ws.WsUtils.checkRequest; public class PermissionRequestValidator { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java index a106538f562..ea9e8cfe5da 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWs.java @@ -22,9 +22,9 @@ package org.sonar.server.permission.ws; import org.sonar.api.server.ws.WebService; -public class PermissionsWs implements WebService { +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.ENDPOINT; - public static final String ENDPOINT = "api/permissions"; +public class PermissionsWs implements WebService { private final PermissionsWsAction[] actions; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsParameters.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsParametersBuilder.java similarity index 75% rename from server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsParameters.java rename to server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsParametersBuilder.java index 7c0b865dca6..2d7bdac410b 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsParameters.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/PermissionsWsParametersBuilder.java @@ -27,23 +27,7 @@ import org.sonar.core.util.Uuids; import static java.lang.String.format; -public class PermissionsWsParameters { - - 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"; +public class PermissionsWsParametersBuilder { private static final String PERMISSION_PARAM_DESCRIPTION = format("Permission" + "", ProjectPermissions.ALL_ON_ONE_LINE); - private PermissionsWsParameters() { + private PermissionsWsParametersBuilder() { // static methods only } public static void createPermissionParameter(NewAction action) { - action.createParam(PARAM_PERMISSION) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION) .setDescription(PERMISSION_PARAM_DESCRIPTION) .setRequired(true); } public static void createProjectPermissionParameter(NewAction action) { - action.createParam(PARAM_PERMISSION) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION) .setDescription(PROJECT_PERMISSION_PARAM_DESCRIPTION) .setRequired(true); } public static void createGroupNameParameter(NewAction action) { - action.createParam(PARAM_GROUP_NAME) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_NAME) .setDescription("Group name or 'anyone' (case insensitive)") .setExampleValue("sonar-administrators"); } public static void createGroupIdParameter(NewAction action) { - action.createParam(PARAM_GROUP_ID) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID) .setDescription("Group id") .setExampleValue("42"); } @@ -92,19 +76,19 @@ public class PermissionsWsParameters { } private static void createProjectIdParameter(NewAction action) { - action.createParam(PARAM_PROJECT_ID) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID) .setDescription("Project id") .setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d"); } private static void createProjectKeyParameter(NewAction action) { - action.createParam(PARAM_PROJECT_KEY) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY) .setDescription("Project key") .setExampleValue("org.apache.hbas:hbase"); } public static void createUserLoginParameter(NewAction action) { - action.createParam(PARAM_USER_LOGIN) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN) .setRequired(true) .setDescription("User login") .setExampleValue("g.hopper"); @@ -116,31 +100,31 @@ public class PermissionsWsParameters { } private static void createTemplateIdParameter(NewAction action) { - action.createParam(PARAM_TEMPLATE_UUID) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID) .setDescription("Template id") .setExampleValue(Uuids.UUID_EXAMPLE_01); } private static void createTemplateNameParameter(NewAction action) { - action.createParam(PARAM_TEMPLATE_NAME) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME) .setDescription("Template name") .setExampleValue("Default Permission Template for Projects"); } public static void createTemplateProjectKeyPatternParameter(NewAction action) { - action.createParam(PARAM_PATTERN) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PATTERN) .setDescription("Project key pattern. Must be a valid Java regular expression") .setExampleValue(".*\\.finance\\..*"); } public static void createTemplateDescriptionParameter(NewAction action) { - action.createParam(PARAM_DESCRIPTION) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_DESCRIPTION) .setDescription("Description") .setExampleValue("Permissions for all projects related to the financial service"); } public static void createIdParameter(NewAction action) { - action.createParam(PARAM_ID) + action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_ID) .setRequired(true) .setDescription("Id") .setExampleValue("af8cb8cc-1e78-4c4e-8c00-ee8e814009a5"); diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java index 2a9b0ee5711..de317b88a21 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveGroupAction.java @@ -29,10 +29,10 @@ import org.sonar.server.permission.PermissionChange; import org.sonar.server.permission.PermissionUpdater; import org.sonar.server.permission.ws.PermissionRequest.Builder; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createGroupIdParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createGroupNameParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createGroupIdParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createGroupNameParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameter; public class RemoveGroupAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveUserAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveUserAction.java index 85b1d8b79d6..127307e1513 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveUserAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/RemoveUserAction.java @@ -29,9 +29,9 @@ import org.sonar.server.permission.PermissionChange; import org.sonar.server.permission.PermissionUpdater; import org.sonar.server.permission.ws.PermissionRequest.Builder; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createUserLoginParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createUserLoginParameter; public class RemoveUserAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsAction.java index d0e4ccfabd1..e8d40818fa4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/SearchProjectPermissionsAction.java @@ -39,7 +39,7 @@ import org.sonarqube.ws.WsPermissions.WsSearchProjectPermissionsResponse.Project import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentKey; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentUuid; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameter; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class SearchProjectPermissionsAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateGroupsAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateGroupsAction.java index fee0309378a..10a03a4c346 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateGroupsAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateGroupsAction.java @@ -38,9 +38,9 @@ import org.sonarqube.ws.WsPermissions.WsGroupsResponse; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; import static org.sonar.server.permission.ws.PermissionQueryParser.fromSelectionModeToMembership; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class TemplateGroupsAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateUsersAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateUsersAction.java index 9482612d499..0a2dc2669a6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateUsersAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/TemplateUsersAction.java @@ -39,9 +39,9 @@ import static java.lang.String.format; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; import static org.sonar.server.permission.ws.PermissionQueryParser.fromSelectionModeToMembership; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class TemplateUsersAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/UsersAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/UsersAction.java index 967471638a6..f1462147476 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/UsersAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/UsersAction.java @@ -44,8 +44,8 @@ import static com.google.common.base.Strings.nullToEmpty; import static org.sonar.api.utils.Paging.forPageIndex; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentDto; import static org.sonar.server.permission.ws.PermissionQueryParser.fromSelectionModeToMembership; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameter; import static org.sonar.server.ws.WsUtils.writeProtobuf; public class UsersAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsProjectRef.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsProjectRef.java index d71b6861442..81f3b767bd3 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsProjectRef.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsProjectRef.java @@ -25,8 +25,8 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.server.ws.Request; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; +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.sonar.server.ws.WsUtils.checkRequest; /** diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsTemplateRef.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsTemplateRef.java index 6fa2b2c7f55..40d519e41d6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsTemplateRef.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/WsTemplateRef.java @@ -24,8 +24,8 @@ import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.server.ws.Request; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_UUID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME; import static org.sonar.server.ws.WsUtils.checkRequest; /** diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java index 8aab8b8ec70..eee677ed970 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddGroupToTemplateAction.java @@ -40,15 +40,15 @@ import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateNotAnyoneAndAdminPermission; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_UUID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createGroupIdParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createGroupNameParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; +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_TEMPLATE_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createGroupIdParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createGroupNameParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; import static org.sonar.server.permission.ws.WsTemplateRef.newTemplateRef; import static org.sonar.server.usergroups.ws.WsGroupRef.newWsGroupRef; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddUserToTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddUserToTemplateAction.java index 0d1d8924966..5d29aa33209 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddUserToTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/AddUserToTemplateAction.java @@ -39,11 +39,11 @@ import org.sonar.server.user.UserSession; import static com.google.common.collect.FluentIterable.from; import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_USER_LOGIN; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createUserLoginParameter; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createUserLoginParameter; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; public class AddUserToTemplateAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java index f1a93a983d5..169b1490094 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/ApplyTemplateAction.java @@ -35,8 +35,8 @@ import org.sonar.server.permission.ws.WsProjectRef; import org.sonar.server.permission.ws.WsTemplateRef; import static java.util.Collections.singletonList; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; public class ApplyTemplateAction implements PermissionsWsAction { private final DbClient dbClient; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/CreateTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/CreateTemplateAction.java index 38eb3127239..e2d4c5d4786 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/CreateTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/CreateTemplateAction.java @@ -34,11 +34,11 @@ import org.sonarqube.ws.WsPermissions.WsCreatePermissionTemplateResponse; import static java.lang.String.format; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_DESCRIPTION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PATTERN; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateDescriptionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateProjectKeyPatternParameter; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_DESCRIPTION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PATTERN; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateDescriptionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateProjectKeyPatternParameter; import static org.sonar.server.permission.ws.PermissionRequestValidator.MSG_TEMPLATE_WITH_SAME_NAME; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPattern; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateTemplateNameFormat; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java index 5f1387757d9..a79f6877298 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateAction.java @@ -34,11 +34,11 @@ import org.sonar.server.permission.ws.WsTemplateRef; import org.sonar.server.user.UserSession; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createGroupIdParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createGroupNameParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createGroupIdParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createGroupNameParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; public class RemoveGroupFromTemplateAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateAction.java index c793545c9a2..3a1254cd483 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateAction.java @@ -33,11 +33,11 @@ import org.sonar.server.permission.ws.WsTemplateRef; import org.sonar.server.user.UserSession; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_USER_LOGIN; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createProjectPermissionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createUserLoginParameter; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createProjectPermissionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createUserLoginParameter; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission; public class RemoveUserFromTemplateAction implements PermissionsWsAction { diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java index 82ca38f7153..73d1e8fa284 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/SetDefaultTemplateAction.java @@ -41,8 +41,8 @@ import static com.google.common.collect.Ordering.natural; import static java.lang.String.format; import static org.sonar.server.permission.DefaultPermissionTemplates.defaultRootQualifierTemplateProperty; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_QUALIFIER; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateParameters; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateParameters; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateQualifier; import static org.sonar.server.component.ResourceTypeFunctions.RESOURCE_TYPE_TO_QUALIFIER; diff --git a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/UpdateTemplateAction.java b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/UpdateTemplateAction.java index 5522eae7289..631b881e9d4 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/UpdateTemplateAction.java +++ b/server/sonar-server/src/main/java/org/sonar/server/permission/ws/template/UpdateTemplateAction.java @@ -39,13 +39,13 @@ import org.sonarqube.ws.WsPermissions.WsUpdatePermissionTemplateResponse; import static com.google.common.base.Objects.firstNonNull; import static java.lang.String.format; import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_DESCRIPTION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PATTERN; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createIdParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateDescriptionParameter; -import static org.sonar.server.permission.ws.PermissionsWsParameters.createTemplateProjectKeyPatternParameter; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_ID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_DESCRIPTION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PATTERN; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createIdParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateDescriptionParameter; +import static org.sonar.server.permission.ws.PermissionsWsParametersBuilder.createTemplateProjectKeyPatternParameter; import static org.sonar.server.permission.ws.PermissionRequestValidator.MSG_TEMPLATE_WITH_SAME_NAME; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPattern; import static org.sonar.server.permission.ws.PermissionRequestValidator.validateTemplateNameFormat; diff --git a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/WsGroupRef.java b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/WsGroupRef.java index 153d0637417..a353f45db11 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/WsGroupRef.java +++ b/server/sonar-server/src/main/java/org/sonar/server/usergroups/ws/WsGroupRef.java @@ -23,7 +23,6 @@ package org.sonar.server.usergroups.ws; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import org.sonar.api.server.ws.Request; -import org.sonar.server.permission.ws.PermissionsWsParameters; import static org.sonar.server.ws.WsUtils.checkRequest; @@ -43,8 +42,8 @@ public class WsGroupRef { } public static WsGroupRef newWsGroupRefFromPermissionRequest(Request wsRequest) { - Long id = wsRequest.paramAsLong(PermissionsWsParameters.PARAM_GROUP_ID); - String name = wsRequest.param(PermissionsWsParameters.PARAM_GROUP_NAME); + Long id = wsRequest.paramAsLong(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID); + String name = wsRequest.param(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_NAME); return new WsGroupRef(id, name); } diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java index 63fc66fb51b..dacd4e47dec 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddGroupActionTest.java @@ -54,11 +54,11 @@ import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.component.ComponentTesting.newView; import static org.sonar.server.permission.ws.AddGroupAction.ACTION; import static org.sonar.server.permission.ws.PermissionsWs.ENDPOINT; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; +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; @Category(DbTests.class) public class AddGroupActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java index 08136ea912d..3b8b51cbd57 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/AddUserActionTest.java @@ -54,10 +54,10 @@ import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.component.ComponentTesting.newView; import static org.sonar.server.permission.ws.AddUserAction.ACTION; import static org.sonar.server.permission.ws.PermissionsWs.ENDPOINT; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_USER_LOGIN; +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_USER_LOGIN; @Category(DbTests.class) public class AddUserActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java index 7e77eb15fa1..4d025ce9eec 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/GroupsActionTest.java @@ -58,9 +58,9 @@ import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION; import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.component.ComponentTesting.newView; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; +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.sonar.test.JsonAssert.assertJson; @Category(DbTests.class) diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java index 05d459db6d6..142e448050a 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/PermissionsWsTest.java @@ -63,7 +63,7 @@ public class PermissionsWsTest { assertThat(action.isPost()).isFalse(); assertThat(action.isInternal()).isTrue(); assertThat(action.since()).isEqualTo("5.2"); - assertThat(action.param(PermissionsWsParameters.PARAM_PERMISSION).isRequired()).isTrue(); + assertThat(action.param(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION).isRequired()).isTrue(); } @Test @@ -74,7 +74,7 @@ public class PermissionsWsTest { assertThat(action.isPost()).isFalse(); assertThat(action.isInternal()).isTrue(); assertThat(action.since()).isEqualTo("5.2"); - assertThat(action.param(PermissionsWsParameters.PARAM_PERMISSION).isRequired()).isTrue(); + assertThat(action.param(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION).isRequired()).isTrue(); } private WebService.Controller controller() { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java index e06c769e9f0..fc61fc7e1c9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveGroupActionTest.java @@ -53,11 +53,11 @@ import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.component.ComponentTesting.newView; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; +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_KEY; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID; import static org.sonar.server.permission.ws.RemoveGroupAction.ACTION; @Category(DbTests.class) diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java index f15d13d37c7..c152c42a9a3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/RemoveUserActionTest.java @@ -52,10 +52,10 @@ import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.db.component.ComponentTesting.newFileDto; import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.component.ComponentTesting.newView; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_USER_LOGIN; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_KEY; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN; import static org.sonar.server.permission.ws.PermissionsWs.ENDPOINT; import static org.sonar.server.permission.ws.RemoveUserAction.ACTION; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java index 03bd47c57e5..792392e14e2 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/SearchProjectPermissionsActionTest.java @@ -61,7 +61,7 @@ import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.component.ComponentTesting.newView; import static org.sonar.db.user.GroupTesting.newGroupDto; import static org.sonar.db.user.UserTesting.newUserDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PROJECT_ID; import static org.sonar.test.JsonAssert.assertJson; public class SearchProjectPermissionsActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/TemplateGroupsActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/TemplateGroupsActionTest.java index 4c59eac6fb0..05a88d99cd4 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/TemplateGroupsActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/TemplateGroupsActionTest.java @@ -62,9 +62,9 @@ import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateGroupDto; import static org.sonar.db.user.GroupTesting.newGroupDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_UUID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +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.sonar.test.JsonAssert.assertJson; @Category(DbTests.class) diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/TemplateUsersActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/TemplateUsersActionTest.java index a9902e044dd..28938318660 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/TemplateUsersActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/TemplateUsersActionTest.java @@ -122,7 +122,7 @@ public class TemplateUsersActionTest { @Test public void search_for_users_by_template_name() throws IOException { InputStream responseStream = newRequest(UserRole.USER, null) - .setParam(PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) + .setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) .setMediaType(PROTOBUF) .execute().getInputStream(); @@ -134,7 +134,7 @@ public class TemplateUsersActionTest { @Test public void search_using_text_query() throws IOException { InputStream responseStream = newRequest(UserRole.USER, null) - .setParam(PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) + .setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) .setParam(WebService.Param.TEXT_QUERY, "ame-1") .setMediaType(PROTOBUF) .execute().getInputStream(); @@ -147,7 +147,7 @@ public class TemplateUsersActionTest { @Test public void search_using_selected() throws IOException { InputStream responseStream = newRequest(UserRole.USER, null) - .setParam(PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) + .setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) .setParam(WebService.Param.SELECTED, "all") .setMediaType(PROTOBUF) .execute().getInputStream(); @@ -161,7 +161,7 @@ public class TemplateUsersActionTest { @Test public void search_with_pagination() throws IOException { InputStream responseStream = newRequest(UserRole.USER, null) - .setParam(PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) + .setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) .setParam(WebService.Param.SELECTED, "all") .setParam(WebService.Param.PAGE, "2") .setParam(WebService.Param.PAGE_SIZE, "1") @@ -194,7 +194,7 @@ public class TemplateUsersActionTest { expectedException.expect(BadRequestException.class); newRequest(UserRole.USER, template1.getUuid()) - .setParam(PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) + .setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME, template1.getName()) .execute(); } @@ -236,9 +236,9 @@ public class TemplateUsersActionTest { private TestRequest newRequest(String permission, @Nullable String templateUuid) { TestRequest request = ws.newRequest(); - request.setParam(PermissionsWsParameters.PARAM_PERMISSION, permission); + request.setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION, permission); if (templateUuid != null) { - request.setParam(PermissionsWsParameters.PARAM_TEMPLATE_UUID, templateUuid); + request.setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID, templateUuid); } return request; diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/UsersActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/UsersActionTest.java index b7c41b06173..34999ae0deb 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/UsersActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/UsersActionTest.java @@ -53,9 +53,9 @@ import static org.sonar.core.permission.GlobalPermissions.SCAN_EXECUTION; import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN; import static org.sonar.db.component.ComponentTesting.newProjectDto; import static org.sonar.db.user.UserTesting.newUserDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; +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.sonar.test.JsonAssert.assertJson; @Category(DbTests.class) diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java index d2667d6a788..71c23d05a57 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddGroupToTemplateActionTest.java @@ -47,7 +47,7 @@ import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.permission.ws.PermissionDependenciesFinder; -import org.sonar.server.permission.ws.PermissionsWsParameters; +import org.sonar.server.permission.ws.PermissionsWsParametersBuilder; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.usergroups.ws.UserGroupFinder; import org.sonar.server.ws.TestRequest; @@ -63,11 +63,11 @@ import static org.sonar.api.web.UserRole.ISSUE_ADMIN; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto; import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.db.user.GroupTesting.newGroupDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_UUID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; +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_TEMPLATE_UUID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME; @Category(DbTests.class) public class AddGroupToTemplateActionTest { @@ -217,13 +217,13 @@ public class AddGroupToTemplateActionTest { private void newRequest(@Nullable String groupName, @Nullable String templateKey, @Nullable String permission) { TestRequest request = ws.newRequest(); if (groupName != null) { - request.setParam(PermissionsWsParameters.PARAM_GROUP_NAME, groupName); + request.setParam(PermissionsWsParametersBuilder.PARAM_GROUP_NAME, groupName); } if (templateKey != null) { request.setParam(PARAM_TEMPLATE_UUID, templateKey); } if (permission != null) { - request.setParam(PermissionsWsParameters.PARAM_PERMISSION, permission); + request.setParam(PermissionsWsParametersBuilder.PARAM_PERMISSION, permission); } request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java index 1391b998193..4e5ba547cbc 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/AddUserToTemplateActionTest.java @@ -46,7 +46,7 @@ import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.permission.ws.PermissionDependenciesFinder; -import org.sonar.server.permission.ws.PermissionsWsParameters; +import org.sonar.server.permission.ws.PermissionsWsParametersBuilder; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.usergroups.ws.UserGroupFinder; import org.sonar.server.ws.TestRequest; @@ -60,9 +60,9 @@ import static org.sonar.api.web.UserRole.ISSUE_ADMIN; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto; import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.db.user.UserTesting.newUserDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_USER_LOGIN; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN; @Category(DbTests.class) public class AddUserToTemplateActionTest { @@ -189,10 +189,10 @@ public class AddUserToTemplateActionTest { request.setParam(PARAM_USER_LOGIN, userLogin); } if (templateKey != null) { - request.setParam(PermissionsWsParameters.PARAM_TEMPLATE_UUID, templateKey); + request.setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID, templateKey); } if (permission != null) { - request.setParam(PermissionsWsParameters.PARAM_PERMISSION, permission); + request.setParam(PermissionsWsParametersBuilder.PARAM_PERMISSION, permission); } request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java index eb4ceead794..ed56934385e 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/ApplyTemplateActionTest.java @@ -72,10 +72,10 @@ import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTem import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.db.user.GroupTesting.newGroupDto; import static org.sonar.db.user.UserTesting.newUserDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PROJECT_KEY; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_UUID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; +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_UUID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME; @Category(DbTests.class) public class ApplyTemplateActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/CreateTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/CreateTemplateActionTest.java index 4789e934557..d5296a494f9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/CreateTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/CreateTemplateActionTest.java @@ -43,9 +43,9 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_DESCRIPTION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PATTERN; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_DESCRIPTION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PATTERN; import static org.sonar.test.JsonAssert.assertJson; public class CreateTemplateActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java index 83f56144c54..a9572537741 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/DeleteTemplateActionTest.java @@ -57,8 +57,8 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.mockito.internal.util.collections.Sets.newSet; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_UUID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME; public class DeleteTemplateActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java index 37a89b0457e..c85fcd7a8dc 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveGroupFromTemplateActionTest.java @@ -46,7 +46,7 @@ import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.permission.ws.PermissionDependenciesFinder; -import org.sonar.server.permission.ws.PermissionsWsParameters; +import org.sonar.server.permission.ws.PermissionsWsParametersBuilder; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.usergroups.ws.UserGroupFinder; import org.sonar.server.ws.TestRequest; @@ -60,11 +60,11 @@ import static org.sonar.api.web.UserRole.CODEVIEWER; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto; import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.db.user.GroupTesting.newGroupDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_GROUP_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_UUID; +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_TEMPLATE_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID; @Category(DbTests.class) public class RemoveGroupFromTemplateActionTest { @@ -220,13 +220,13 @@ public class RemoveGroupFromTemplateActionTest { private void newRequest(@Nullable String groupName, @Nullable String templateKey, @Nullable String permission) { TestRequest request = ws.newRequest(); if (groupName != null) { - request.setParam(PermissionsWsParameters.PARAM_GROUP_NAME, groupName); + request.setParam(PermissionsWsParametersBuilder.PARAM_GROUP_NAME, groupName); } if (templateKey != null) { request.setParam(PARAM_TEMPLATE_UUID, templateKey); } if (permission != null) { - request.setParam(PermissionsWsParameters.PARAM_PERMISSION, permission); + request.setParam(PermissionsWsParametersBuilder.PARAM_PERMISSION, permission); } request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateActionTest.java index 538db311444..254dbf9cbe5 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/RemoveUserFromTemplateActionTest.java @@ -46,7 +46,7 @@ import org.sonar.server.exceptions.ForbiddenException; import org.sonar.server.exceptions.NotFoundException; import org.sonar.server.exceptions.UnauthorizedException; import org.sonar.server.permission.ws.PermissionDependenciesFinder; -import org.sonar.server.permission.ws.PermissionsWsParameters; +import org.sonar.server.permission.ws.PermissionsWsParametersBuilder; import org.sonar.server.tester.UserSessionRule; import org.sonar.server.usergroups.ws.UserGroupFinder; import org.sonar.server.ws.TestRequest; @@ -60,9 +60,9 @@ import static org.sonar.api.web.UserRole.ISSUE_ADMIN; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto; import static org.sonar.db.user.GroupMembershipQuery.IN; import static org.sonar.db.user.UserTesting.newUserDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PERMISSION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_USER_LOGIN; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN; @Category(DbTests.class) public class RemoveUserFromTemplateActionTest { @@ -213,10 +213,10 @@ public class RemoveUserFromTemplateActionTest { request.setParam(PARAM_USER_LOGIN, userLogin); } if (templateKey != null) { - request.setParam(PermissionsWsParameters.PARAM_TEMPLATE_UUID, templateKey); + request.setParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID, templateKey); } if (permission != null) { - request.setParam(PermissionsWsParameters.PARAM_PERMISSION, permission); + request.setParam(PermissionsWsParametersBuilder.PARAM_PERMISSION, permission); } request.execute(); diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java index 7925bc707c7..6bc7b584ad9 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/SetDefaultTemplateActionTest.java @@ -62,9 +62,9 @@ import static org.sonar.api.resources.Qualifiers.PROJECT; import static org.sonar.api.resources.Qualifiers.VIEW; import static org.sonar.server.permission.DefaultPermissionTemplates.DEFAULT_TEMPLATE_PROPERTY; import static org.sonar.server.permission.DefaultPermissionTemplates.defaultRootQualifierTemplateProperty; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_QUALIFIER; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_UUID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_TEMPLATE_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_QUALIFIER; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_UUID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_TEMPLATE_NAME; @Category(DbTests.class) public class SetDefaultTemplateActionTest { diff --git a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/UpdateTemplateActionTest.java b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/UpdateTemplateActionTest.java index 8aa7f028c36..5feb5a49bbb 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/UpdateTemplateActionTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/permission/ws/template/UpdateTemplateActionTest.java @@ -51,10 +51,10 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_DESCRIPTION; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_ID; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_NAME; -import static org.sonar.server.permission.ws.PermissionsWsParameters.PARAM_PATTERN; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_DESCRIPTION; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_ID; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_NAME; +import static org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PATTERN; import static org.sonar.test.JsonAssert.assertJson; public class UpdateTemplateActionTest { 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"; +} -- 2.39.5