import org.sonar.server.permission.PermissionUpdater;
import org.sonar.server.permission.ws.PermissionRequest.Builder;
-import static org.sonar.server.permission.ws.Parameters.createGroupIdParameter;
-import static org.sonar.server.permission.ws.Parameters.createGroupNameParameter;
-import static org.sonar.server.permission.ws.Parameters.createPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupIdParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupNameParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectParameter;
public class AddGroupAction implements PermissionsWsAction {
import static org.sonar.api.security.DefaultGroups.ANYONE;
import static org.sonar.db.user.GroupMembershipQuery.IN;
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.createGroupIdParameter;
-import static org.sonar.server.permission.ws.Parameters.createGroupNameParameter;
-import static org.sonar.server.permission.ws.Parameters.createProjectPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateParameters;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupIdParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupNameParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateParameters;
import static org.sonar.server.permission.ws.PermissionRequestValidator.validateNotAnyoneAndAdminPermission;
import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission;
import org.sonar.server.permission.PermissionUpdater;
import org.sonar.server.permission.ws.PermissionRequest.Builder;
-import static org.sonar.server.permission.ws.Parameters.createPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
-import static org.sonar.server.permission.ws.Parameters.createUserLoginParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createUserLoginParameter;
public class AddUserAction implements PermissionsWsAction {
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.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_USER_LOGIN;
-import static org.sonar.server.permission.ws.Parameters.createProjectPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateParameters;
-import static org.sonar.server.permission.ws.Parameters.createUserLoginParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_USER_LOGIN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateParameters;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createUserLoginParameter;
import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission;
public class AddUserToTemplateAction implements PermissionsWsAction {
import org.sonar.server.permission.PermissionService;
import static java.util.Collections.singletonList;
-import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateParameters;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.Parameters.PARAM_DESCRIPTION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PATTERN;
-import static org.sonar.server.permission.ws.Parameters.createTemplateDescriptionParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateProjectKeyPatternParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_DESCRIPTION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PATTERN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateDescriptionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.Parameters.createTemplateParameters;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateParameters;
import static org.sonar.server.permission.ws.WsTemplateRef.fromRequest;
import static org.sonar.server.ws.WsUtils.checkRequest;
import static com.google.common.base.Objects.firstNonNull;
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentDto;
import static org.sonar.server.permission.ws.PermissionQueryParser.fromSelectionModeToMembership;
-import static org.sonar.server.permission.ws.Parameters.createPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectParameter;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
public class GroupsAction implements PermissionsWsAction {
+++ /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;
-
-class Parameters {
-
- static final String PARAM_PERMISSION = "permission";
- static final String PARAM_GROUP_NAME = "groupName";
- static final String PARAM_GROUP_ID = "groupId";
- static final String PARAM_PROJECT_ID = "projectId";
- static final String PARAM_PROJECT_KEY = "projectKey";
- static final String PARAM_USER_LOGIN = "login";
- static final String PARAM_TEMPLATE_ID = "templateId";
- static final String PARAM_TEMPLATE_NAME = "templateName";
-
- static final String PARAM_ID = "id";
- static final String PARAM_NAME = "name";
- static final String PARAM_DESCRIPTION = "description";
- static final String PARAM_PATTERN = "projectKeyPattern";
-
- 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 Parameters() {
- // static methods only
- }
-
- static void createPermissionParameter(NewAction action) {
- action.createParam(PARAM_PERMISSION)
- .setDescription(PERMISSION_PARAM_DESCRIPTION)
- .setRequired(true);
- }
-
- static void createProjectPermissionParameter(NewAction action) {
- action.createParam(PARAM_PERMISSION)
- .setDescription(PROJECT_PERMISSION_PARAM_DESCRIPTION)
- .setRequired(true);
- }
-
- static void createGroupNameParameter(NewAction action) {
- action.createParam(PARAM_GROUP_NAME)
- .setDescription("Group name or 'anyone' (case insensitive)")
- .setExampleValue("sonar-administrators");
- }
-
- static void createGroupIdParameter(NewAction action) {
- action.createParam(PARAM_GROUP_ID)
- .setDescription("Group id")
- .setExampleValue("42");
- }
-
- 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");
- }
-
- static void createUserLoginParameter(NewAction action) {
- action.createParam(PARAM_USER_LOGIN)
- .setRequired(true)
- .setDescription("User login")
- .setExampleValue("g.hopper");
- }
-
- static void createTemplateParameters(NewAction action) {
- createTemplateIdParameter(action);
- createTemplateNameParameter(action);
- }
-
- private static void createTemplateIdParameter(NewAction action) {
- action.createParam(PARAM_TEMPLATE_ID)
- .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");
- }
-
- static void createTemplateProjectKeyPatternParameter(NewAction action) {
- action.createParam(PARAM_PATTERN)
- .setDescription("Project key pattern. Must be a valid Java regular expression")
- .setExampleValue(".*\\.finance\\..*");
- }
-
- static void createTemplateDescriptionParameter(NewAction action) {
- action.createParam(PARAM_DESCRIPTION)
- .setDescription("Description")
- .setExampleValue("Permissions for all projects related to the financial service");
- }
-
- static void createIdParameter(NewAction action) {
- action.createParam(PARAM_ID)
- .setRequired(true)
- .setDescription("Id")
- .setExampleValue("af8cb8cc-1e78-4c4e-8c00-ee8e814009a5");
- }
-}
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.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_USER_LOGIN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_QUALIFIER;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PATTERN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_QUALIFIER;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PATTERN;
import static org.sonar.server.ws.WsUtils.checkRequest;
public class PermissionRequestValidator {
import org.sonar.server.permission.PermissionUpdater;
import org.sonar.server.permission.ws.PermissionRequest.Builder;
-import static org.sonar.server.permission.ws.Parameters.createGroupIdParameter;
-import static org.sonar.server.permission.ws.Parameters.createGroupNameParameter;
-import static org.sonar.server.permission.ws.Parameters.createPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupIdParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupNameParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectParameter;
public class RemoveGroupAction implements PermissionsWsAction {
import org.sonar.server.user.UserSession;
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.createGroupIdParameter;
-import static org.sonar.server.permission.ws.Parameters.createGroupNameParameter;
-import static org.sonar.server.permission.ws.Parameters.createProjectPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateParameters;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupIdParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createGroupNameParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateParameters;
import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission;
public class RemoveGroupFromTemplateAction implements PermissionsWsAction {
import org.sonar.server.permission.PermissionUpdater;
import org.sonar.server.permission.ws.PermissionRequest.Builder;
-import static org.sonar.server.permission.ws.Parameters.createPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
-import static org.sonar.server.permission.ws.Parameters.createUserLoginParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createUserLoginParameter;
public class RemoveUserAction implements PermissionsWsAction {
import org.sonar.server.user.UserSession;
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_USER_LOGIN;
-import static org.sonar.server.permission.ws.Parameters.createProjectPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateParameters;
-import static org.sonar.server.permission.ws.Parameters.createUserLoginParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_USER_LOGIN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateParameters;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createUserLoginParameter;
import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPermission;
public class RemoveUserFromTemplateAction 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.Parameters.createProjectParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createProjectParameter;
import static org.sonar.server.ws.WsUtils.writeProtobuf;
public class SearchProjectPermissionsAction 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.Parameters.PARAM_QUALIFIER;
-import static org.sonar.server.permission.ws.Parameters.createTemplateParameters;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_QUALIFIER;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateParameters;
import static org.sonar.server.permission.ws.PermissionRequestValidator.validateQualifier;
import static org.sonar.server.permission.ws.ResourceTypeToQualifier.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.Parameters.PARAM_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_DESCRIPTION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PATTERN;
-import static org.sonar.server.permission.ws.Parameters.createIdParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateDescriptionParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateProjectKeyPatternParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_DESCRIPTION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PATTERN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createIdParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createTemplateDescriptionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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 static com.google.common.base.Strings.nullToEmpty;
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkProjectAdminUserByComponentDto;
import static org.sonar.server.permission.ws.PermissionQueryParser.fromSelectionModeToMembership;
-import static org.sonar.server.permission.ws.Parameters.createPermissionParameter;
-import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.createPermissionParameter;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.Parameters.PARAM_GROUP_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_GROUP_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_NAME;
import static org.sonar.server.ws.WsUtils.checkRequest;
/**
--- /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;
+
+class WsPermissionParameters {
+
+ static final String PARAM_PERMISSION = "permission";
+ static final String PARAM_GROUP_NAME = "groupName";
+ static final String PARAM_GROUP_ID = "groupId";
+ static final String PARAM_PROJECT_ID = "projectId";
+ static final String PARAM_PROJECT_KEY = "projectKey";
+ static final String PARAM_USER_LOGIN = "login";
+ static final String PARAM_TEMPLATE_ID = "templateId";
+ static final String PARAM_TEMPLATE_NAME = "templateName";
+
+ static final String PARAM_ID = "id";
+ static final String PARAM_NAME = "name";
+ static final String PARAM_DESCRIPTION = "description";
+ static final String PARAM_PATTERN = "projectKeyPattern";
+
+ 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 WsPermissionParameters() {
+ // static methods only
+ }
+
+ static void createPermissionParameter(NewAction action) {
+ action.createParam(PARAM_PERMISSION)
+ .setDescription(PERMISSION_PARAM_DESCRIPTION)
+ .setRequired(true);
+ }
+
+ static void createProjectPermissionParameter(NewAction action) {
+ action.createParam(PARAM_PERMISSION)
+ .setDescription(PROJECT_PERMISSION_PARAM_DESCRIPTION)
+ .setRequired(true);
+ }
+
+ static void createGroupNameParameter(NewAction action) {
+ action.createParam(PARAM_GROUP_NAME)
+ .setDescription("Group name or 'anyone' (case insensitive)")
+ .setExampleValue("sonar-administrators");
+ }
+
+ static void createGroupIdParameter(NewAction action) {
+ action.createParam(PARAM_GROUP_ID)
+ .setDescription("Group id")
+ .setExampleValue("42");
+ }
+
+ 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");
+ }
+
+ static void createUserLoginParameter(NewAction action) {
+ action.createParam(PARAM_USER_LOGIN)
+ .setRequired(true)
+ .setDescription("User login")
+ .setExampleValue("g.hopper");
+ }
+
+ static void createTemplateParameters(NewAction action) {
+ createTemplateIdParameter(action);
+ createTemplateNameParameter(action);
+ }
+
+ private static void createTemplateIdParameter(NewAction action) {
+ action.createParam(PARAM_TEMPLATE_ID)
+ .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");
+ }
+
+ static void createTemplateProjectKeyPatternParameter(NewAction action) {
+ action.createParam(PARAM_PATTERN)
+ .setDescription("Project key pattern. Must be a valid Java regular expression")
+ .setExampleValue(".*\\.finance\\..*");
+ }
+
+ static void createTemplateDescriptionParameter(NewAction action) {
+ action.createParam(PARAM_DESCRIPTION)
+ .setDescription("Description")
+ .setExampleValue("Permissions for all projects related to the financial service");
+ }
+
+ static void createIdParameter(NewAction action) {
+ action.createParam(PARAM_ID)
+ .setRequired(true)
+ .setDescription("Id")
+ .setExampleValue("af8cb8cc-1e78-4c4e-8c00-ee8e814009a5");
+ }
+}
import javax.annotation.CheckForNull;
import org.sonar.api.server.ws.Request;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_KEY;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.Parameters.PARAM_TEMPLATE_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_NAME;
import static org.sonar.server.ws.WsUtils.checkRequest;
/**
import static org.sonar.core.permission.GlobalPermissions.SYSTEM_ADMIN;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.server.permission.ws.AddGroupAction.ACTION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_GROUP_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_GROUP_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_KEY;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_KEY;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
import static org.sonar.server.permission.ws.PermissionsWs.ENDPOINT;
@Category(DbTests.class)
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.Parameters.PARAM_GROUP_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_GROUP_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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(Parameters.PARAM_GROUP_NAME, groupName);
+ request.setParam(WsPermissionParameters.PARAM_GROUP_NAME, groupName);
}
if (templateKey != null) {
request.setParam(PARAM_TEMPLATE_ID, templateKey);
}
if (permission != null) {
- request.setParam(Parameters.PARAM_PERMISSION, permission);
+ request.setParam(WsPermissionParameters.PARAM_PERMISSION, permission);
}
request.execute();
import static org.sonar.db.component.ComponentTesting.newFileDto;
import static org.sonar.db.component.ComponentTesting.newProjectDto;
import static org.sonar.server.permission.ws.AddUserAction.ACTION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_KEY;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_USER_LOGIN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_KEY;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_USER_LOGIN;
import static org.sonar.server.permission.ws.PermissionsWs.ENDPOINT;
@Category(DbTests.class)
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.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_USER_LOGIN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_USER_LOGIN;
@Category(DbTests.class)
public class AddUserToTemplateActionTest {
request.setParam(PARAM_USER_LOGIN, userLogin);
}
if (templateKey != null) {
- request.setParam(Parameters.PARAM_TEMPLATE_ID, templateKey);
+ request.setParam(WsPermissionParameters.PARAM_TEMPLATE_ID, templateKey);
}
if (permission != null) {
- request.setParam(Parameters.PARAM_PERMISSION, permission);
+ request.setParam(WsPermissionParameters.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.Parameters.PARAM_PROJECT_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_KEY;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_KEY;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.Parameters.PARAM_DESCRIPTION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PATTERN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_DESCRIPTION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.Parameters.PARAM_TEMPLATE_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_NAME;
public class DeleteTemplateActionTest {
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.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_KEY;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_KEY;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
import static org.sonar.test.JsonAssert.assertJson;
@Category(DbTests.class)
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.server.permission.ws.Parameters.PARAM_GROUP_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_GROUP_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_KEY;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_KEY;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
import static org.sonar.server.permission.ws.RemoveGroupAction.ACTION;
@Category(DbTests.class)
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.Parameters.PARAM_GROUP_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_GROUP_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_GROUP_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_NAME;
@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(Parameters.PARAM_GROUP_NAME, groupName);
+ request.setParam(WsPermissionParameters.PARAM_GROUP_NAME, groupName);
}
if (templateKey != null) {
request.setParam(PARAM_TEMPLATE_ID, templateKey);
}
if (permission != null) {
- request.setParam(Parameters.PARAM_PERMISSION, permission);
+ request.setParam(WsPermissionParameters.PARAM_PERMISSION, permission);
}
request.execute();
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.server.permission.ws.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_KEY;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_USER_LOGIN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_KEY;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.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.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_USER_LOGIN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_USER_LOGIN;
@Category(DbTests.class)
public class RemoveUserFromTemplateActionTest {
request.setParam(PARAM_USER_LOGIN, userLogin);
}
if (templateKey != null) {
- request.setParam(Parameters.PARAM_TEMPLATE_ID, templateKey);
+ request.setParam(WsPermissionParameters.PARAM_TEMPLATE_ID, templateKey);
}
if (permission != null) {
- request.setParam(Parameters.PARAM_PERMISSION, permission);
+ request.setParam(WsPermissionParameters.PARAM_PERMISSION, permission);
}
request.execute();
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.Parameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
import static org.sonar.test.JsonAssert.assertJson;
public class SearchProjectPermissionsActionTest {
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.Parameters.PARAM_QUALIFIER;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_QUALIFIER;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.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.Parameters.PARAM_DESCRIPTION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_ID;
-import static org.sonar.server.permission.ws.Parameters.PARAM_NAME;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PATTERN;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_DESCRIPTION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_NAME;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PATTERN;
import static org.sonar.test.JsonAssert.assertJson;
public class UpdateTemplateActionTest {
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.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_KEY;
-import static org.sonar.server.permission.ws.Parameters.PARAM_PROJECT_ID;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PERMISSION;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_KEY;
+import static org.sonar.server.permission.ws.WsPermissionParameters.PARAM_PROJECT_ID;
import static org.sonar.test.JsonAssert.assertJson;
@Category(DbTests.class)