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;
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;
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 {
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;
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;
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;
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 {
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;
+++ /dev/null
-/*
- * 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.sonar.server.permission.ws;
-
-import org.sonar.api.server.ws.WebService.NewAction;
-import org.sonar.core.permission.GlobalPermissions;
-import org.sonar.core.permission.ProjectPermissions;
-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";
-
- private static final String PERMISSION_PARAM_DESCRIPTION = format("Permission" +
- "<ul>" +
- "<li>Possible values for global permissions: %s</li>" +
- "<li>Possible values for project permissions %s</li>" +
- "</ul>",
- GlobalPermissions.ALL_ON_ONE_LINE,
- ProjectPermissions.ALL_ON_ONE_LINE);
- private static final String PROJECT_PERMISSION_PARAM_DESCRIPTION = format("Permission" +
- "<ul>" +
- "<li>Possible values for project permissions %s</li>" +
- "</ul>",
- ProjectPermissions.ALL_ON_ONE_LINE);
-
- private PermissionsWsParameters() {
- // static methods only
- }
-
- public static void createPermissionParameter(NewAction action) {
- action.createParam(PARAM_PERMISSION)
- .setDescription(PERMISSION_PARAM_DESCRIPTION)
- .setRequired(true);
- }
-
- public static void createProjectPermissionParameter(NewAction action) {
- action.createParam(PARAM_PERMISSION)
- .setDescription(PROJECT_PERMISSION_PARAM_DESCRIPTION)
- .setRequired(true);
- }
-
- public static void createGroupNameParameter(NewAction action) {
- action.createParam(PARAM_GROUP_NAME)
- .setDescription("Group name or 'anyone' (case insensitive)")
- .setExampleValue("sonar-administrators");
- }
-
- public static void createGroupIdParameter(NewAction action) {
- action.createParam(PARAM_GROUP_ID)
- .setDescription("Group id")
- .setExampleValue("42");
- }
-
- public static void createProjectParameter(NewAction action) {
- createProjectIdParameter(action);
- createProjectKeyParameter(action);
- }
-
- private static void createProjectIdParameter(NewAction action) {
- action.createParam(PARAM_PROJECT_ID)
- .setDescription("Project id")
- .setExampleValue("ce4c03d6-430f-40a9-b777-ad877c00aa4d");
- }
-
- private static void createProjectKeyParameter(NewAction action) {
- action.createParam(PARAM_PROJECT_KEY)
- .setDescription("Project key")
- .setExampleValue("org.apache.hbas:hbase");
- }
-
- public static void createUserLoginParameter(NewAction action) {
- action.createParam(PARAM_USER_LOGIN)
- .setRequired(true)
- .setDescription("User login")
- .setExampleValue("g.hopper");
- }
-
- public static void createTemplateParameters(NewAction action) {
- createTemplateIdParameter(action);
- createTemplateNameParameter(action);
- }
-
- private static void createTemplateIdParameter(NewAction action) {
- action.createParam(PARAM_TEMPLATE_UUID)
- .setDescription("Template id")
- .setExampleValue(Uuids.UUID_EXAMPLE_01);
- }
-
- private static void createTemplateNameParameter(NewAction action) {
- action.createParam(PARAM_TEMPLATE_NAME)
- .setDescription("Template name")
- .setExampleValue("Default Permission Template for Projects");
- }
-
- public static void createTemplateProjectKeyPatternParameter(NewAction action) {
- action.createParam(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)
- .setDescription("Description")
- .setExampleValue("Permissions for all projects related to the financial service");
- }
-
- public static void createIdParameter(NewAction action) {
- action.createParam(PARAM_ID)
- .setRequired(true)
- .setDescription("Id")
- .setExampleValue("af8cb8cc-1e78-4c4e-8c00-ee8e814009a5");
- }
-}
--- /dev/null
+/*
+ * 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.sonar.server.permission.ws;
+
+import org.sonar.api.server.ws.WebService.NewAction;
+import org.sonar.core.permission.GlobalPermissions;
+import org.sonar.core.permission.ProjectPermissions;
+import org.sonar.core.util.Uuids;
+
+import static java.lang.String.format;
+
+public class PermissionsWsParametersBuilder {
+
+ private static final String PERMISSION_PARAM_DESCRIPTION = format("Permission" +
+ "<ul>" +
+ "<li>Possible values for global permissions: %s</li>" +
+ "<li>Possible values for project permissions %s</li>" +
+ "</ul>",
+ GlobalPermissions.ALL_ON_ONE_LINE,
+ ProjectPermissions.ALL_ON_ONE_LINE);
+ private static final String PROJECT_PERMISSION_PARAM_DESCRIPTION = format("Permission" +
+ "<ul>" +
+ "<li>Possible values for project permissions %s</li>" +
+ "</ul>",
+ ProjectPermissions.ALL_ON_ONE_LINE);
+
+ private PermissionsWsParametersBuilder() {
+ // static methods only
+ }
+
+ public static void createPermissionParameter(NewAction action) {
+ action.createParam(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_PERMISSION)
+ .setDescription(PERMISSION_PARAM_DESCRIPTION)
+ .setRequired(true);
+ }
+
+ public static void createProjectPermissionParameter(NewAction action) {
+ 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(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(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_GROUP_ID)
+ .setDescription("Group id")
+ .setExampleValue("42");
+ }
+
+ public static void createProjectParameter(NewAction action) {
+ createProjectIdParameter(action);
+ createProjectKeyParameter(action);
+ }
+
+ private static void createProjectIdParameter(NewAction action) {
+ 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(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(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_USER_LOGIN)
+ .setRequired(true)
+ .setDescription("User login")
+ .setExampleValue("g.hopper");
+ }
+
+ public static void createTemplateParameters(NewAction action) {
+ createTemplateIdParameter(action);
+ createTemplateNameParameter(action);
+ }
+
+ private static void createTemplateIdParameter(NewAction action) {
+ 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(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(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(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(org.sonarqube.ws.client.permission.PermissionsWsParameters.PARAM_ID)
+ .setRequired(true)
+ .setDescription("Id")
+ .setExampleValue("af8cb8cc-1e78-4c4e-8c00-ee8e814009a5");
+ }
+}
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 {
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 {
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 {
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 {
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 {
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 {
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;
/**
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;
/**
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;
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 {
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;
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;
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 {
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 {
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;
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;
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;
}
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);
}
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 {
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 {
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)
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
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() {
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)
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;
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 {
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)
@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();
@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();
@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();
@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")
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();
}
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;
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)
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;
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 {
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();
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;
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 {
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();
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 {
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 {
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 {
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;
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 {
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();
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;
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 {
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();
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 {
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 {
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) {
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())
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;
}
}
--- /dev/null
+/*
+ * 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";
+}