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.Parameters.PARAM_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID_EXPLICIT;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
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.createExplicitTemplateId;
+import static org.sonar.server.permission.ws.Parameters.createTemplateIdParameter;
public class AddGroupToTemplateAction implements PermissionsWsAction {
private final DbClient dbClient;
"It requires administration permissions to access.")
.setHandler(this);
- createExplicitTemplateId(action);
+ createTemplateIdParameter(action);
createProjectPermissionParameter(action);
createGroupIdParameter(action);
createGroupNameParameter(action);
public void handle(Request wsRequest, Response wsResponse) throws Exception {
checkGlobalAdminUser(userSession);
- String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID_EXPLICIT);
+ String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID);
String permission = wsRequest.mandatoryParam(PARAM_PERMISSION);
WsGroupRef group = WsGroupRef.fromRequest(wsRequest);
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
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_TEMPLATE_ID_EXPLICIT;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
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.createExplicitTemplateId;
+import static org.sonar.server.permission.ws.Parameters.createTemplateIdParameter;
import static org.sonar.server.permission.ws.Parameters.createUserLoginParameter;
public class AddUserToTemplateAction implements PermissionsWsAction {
"It requires administration permissions to access.")
.setHandler(this);
- createExplicitTemplateId(action);
+ createTemplateIdParameter(action);
createProjectPermissionParameter(action);
createUserLoginParameter(action);
}
public void handle(Request wsRequest, Response wsResponse) throws Exception {
checkGlobalAdminUser(userSession);
- String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID_EXPLICIT);
+ String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID);
String permission = wsRequest.mandatoryParam(PARAM_PERMISSION);
final String userLogin = wsRequest.mandatoryParam(PARAM_USER_LOGIN);
import org.sonar.server.permission.PermissionService;
import static java.util.Collections.singletonList;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID_EXPLICIT;
-import static org.sonar.server.permission.ws.Parameters.createExplicitTemplateId;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.Parameters.createTemplateIdParameter;
import static org.sonar.server.permission.ws.Parameters.createProjectParameter;
public class ApplyTemplateAction implements PermissionsWsAction {
.setSince("5.2")
.setHandler(this);
- createExplicitTemplateId(action);
+ createTemplateIdParameter(action);
createProjectParameter(action);
}
@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
- String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID_EXPLICIT);
+ String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID);
DbSession dbSession = dbClient.openSession(false);
try {
import org.sonar.server.user.UserSession;
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
-import static org.sonar.server.permission.ws.Parameters.createTemplateIdParameter;
+import static org.sonar.server.permission.ws.Parameters.PARAM_ID;
+import static org.sonar.server.permission.ws.Parameters.createIdParameter;
import static org.sonar.server.ws.WsUtils.checkRequest;
public class DeleteTemplateAction implements PermissionsWsAction {
.setPost(true)
.setHandler(this);
- createTemplateIdParameter(action);
+ createIdParameter(action);
}
@Override
public void handle(Request wsRequest, Response wsResponse) throws Exception {
checkGlobalAdminUser(userSession);
- String uuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID);
+ String uuid = wsRequest.mandatoryParam(PARAM_ID);
checkTemplateUuidIsNotDefault(uuid);
deleteTemplate(uuid);
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_EXPLICIT = "templateId";
+ static final String PARAM_TEMPLATE_ID = "templateId";
- static final String PARAM_TEMPLATE_ID = "id";
+ static final String PARAM_ID = "id";
static final String PARAM_TEMPLATE_NAME = "name";
static final String PARAM_TEMPLATE_DESCRIPTION = "description";
static final String PARAM_TEMPLATE_PATTERN = "projectKeyPattern";
.setExampleValue("g.hopper");
}
- static void createExplicitTemplateId(NewAction action) {
- action.createParam(PARAM_TEMPLATE_ID_EXPLICIT)
+ static void createTemplateIdParameter(NewAction action) {
+ action.createParam(PARAM_TEMPLATE_ID)
.setRequired(true)
.setDescription("Template id")
.setExampleValue("617f3501-3d32-41bd-a7ac-18315d2e3c7a");
.setExampleValue("Permissions for all projects related to the financial service");
}
- static void createTemplateIdParameter(NewAction action) {
- action.createParam(PARAM_TEMPLATE_ID)
+ static void createIdParameter(NewAction action) {
+ action.createParam(PARAM_ID)
.setRequired(true)
- .setDescription("Key")
+ .setDescription("Id")
.setExampleValue("af8cb8cc-1e78-4c4e-8c00-ee8e814009a5");
}
}
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
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_TEMPLATE_ID_EXPLICIT;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
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.createExplicitTemplateId;
+import static org.sonar.server.permission.ws.Parameters.createTemplateIdParameter;
public class RemoveGroupFromTemplateAction implements PermissionsWsAction {
private final DbClient dbClient;
"It requires administration permissions to access.")
.setHandler(this);
- createExplicitTemplateId(action);
+ createTemplateIdParameter(action);
createProjectPermissionParameter(action);
createGroupIdParameter(action);
createGroupNameParameter(action);
public void handle(Request wsRequest, Response wsResponse) throws Exception {
checkGlobalAdminUser(userSession);
- String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID_EXPLICIT);
+ String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID);
String permission = wsRequest.mandatoryParam(PARAM_PERMISSION);
WsGroupRef group = WsGroupRef.fromRequest(wsRequest);
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
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_TEMPLATE_ID_EXPLICIT;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
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.createExplicitTemplateId;
+import static org.sonar.server.permission.ws.Parameters.createTemplateIdParameter;
import static org.sonar.server.permission.ws.Parameters.createUserLoginParameter;
public class RemoveUserFromTemplateAction implements PermissionsWsAction {
"It requires administration permissions to access.")
.setHandler(this);
- createExplicitTemplateId(action);
+ createTemplateIdParameter(action);
createProjectPermissionParameter(action);
createUserLoginParameter(action);
}
public void handle(Request wsRequest, Response wsResponse) throws Exception {
checkGlobalAdminUser(userSession);
- String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID_EXPLICIT);
+ String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID);
String permission = wsRequest.mandatoryParam(PARAM_PERMISSION);
String userLogin = wsRequest.mandatoryParam(PARAM_USER_LOGIN);
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.PARAM_TEMPLATE_ID_EXPLICIT;
-import static org.sonar.server.permission.ws.Parameters.createExplicitTemplateId;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.Parameters.createTemplateIdParameter;
import static org.sonar.server.permission.ws.PermissionRequestValidator.validateQualifier;
import static org.sonar.server.permission.ws.ResourceTypeToQualifier.RESOURCE_TYPE_TO_QUALIFIER;
.setSince("5.2")
.setHandler(this);
- createExplicitTemplateId(action);
+ createTemplateIdParameter(action);
action.createParam(PARAM_QUALIFIER)
.setDescription("Project qualifier. Possible values are:")
public void handle(Request wsRequest, Response wsResponse) throws Exception {
checkGlobalAdminUser(userSession);
- String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID_EXPLICIT);
+ String templateUuid = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID);
String qualifier = wsRequest.mandatoryParam(PARAM_QUALIFIER);
checkTemplateExists(templateUuid);
import static java.lang.String.format;
import static org.sonar.server.permission.PermissionPrivilegeChecker.checkGlobalAdminUser;
import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_DESCRIPTION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.Parameters.PARAM_ID;
import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_PATTERN;
import static org.sonar.server.permission.ws.Parameters.createTemplateDescriptionParameter;
-import static org.sonar.server.permission.ws.Parameters.createTemplateIdParameter;
+import static org.sonar.server.permission.ws.Parameters.createIdParameter;
import static org.sonar.server.permission.ws.Parameters.createTemplateProjectKeyPatternParameter;
import static org.sonar.server.permission.ws.PermissionRequestValidator.MSG_TEMPLATE_WITH_SAME_NAME;
import static org.sonar.server.permission.ws.PermissionRequestValidator.validateProjectPattern;
.setPost(true)
.setHandler(this);
- createTemplateIdParameter(action);
+ createIdParameter(action);
action.createParam(PARAM_TEMPLATE_NAME)
.setDescription("Name")
public void handle(Request wsRequest, Response wsResponse) throws Exception {
checkGlobalAdminUser(userSession);
- String key = wsRequest.mandatoryParam(PARAM_TEMPLATE_ID);
+ String key = wsRequest.mandatoryParam(PARAM_ID);
String nameParam = wsRequest.param(PARAM_TEMPLATE_NAME);
String descriptionParam = wsRequest.param(PARAM_TEMPLATE_DESCRIPTION);
String projectPatternParam = wsRequest.param(PARAM_TEMPLATE_PATTERN);
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_TEMPLATE_ID_EXPLICIT;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
import static org.sonar.server.permission.ws.Parameters.PARAM_PERMISSION;
@Category(DbTests.class)
@Test
public void add_with_group_id() {
ws.newRequest()
- .setParam(PARAM_TEMPLATE_ID_EXPLICIT, permissionTemplate.getKee())
+ .setParam(PARAM_TEMPLATE_ID, permissionTemplate.getKee())
.setParam(PARAM_PERMISSION, CODEVIEWER)
.setParam(PARAM_GROUP_ID, String.valueOf(group.getId()))
.execute();
request.setParam(Parameters.PARAM_GROUP_NAME, groupName);
}
if (templateKey != null) {
- request.setParam(PARAM_TEMPLATE_ID_EXPLICIT, templateKey);
+ request.setParam(PARAM_TEMPLATE_ID, templateKey);
}
if (permission != null) {
request.setParam(Parameters.PARAM_PERMISSION, permission);
request.setParam(Parameters.PARAM_USER_LOGIN, userLogin);
}
if (templateKey != null) {
- request.setParam(Parameters.PARAM_TEMPLATE_ID_EXPLICIT, templateKey);
+ request.setParam(Parameters.PARAM_TEMPLATE_ID, templateKey);
}
if (permission != null) {
request.setParam(Parameters.PARAM_PERMISSION, permission);
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_EXPLICIT;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
@Category(DbTests.class)
public class ApplyTemplateActionTest {
private TestResponse newRequest(@Nullable String templateUuid, @Nullable String projectUuid, @Nullable String projectKey) {
TestRequest request = ws.newRequest();
if (templateUuid != null) {
- request.setParam(PARAM_TEMPLATE_ID_EXPLICIT, templateUuid);
+ request.setParam(PARAM_TEMPLATE_ID, templateUuid);
}
if (projectUuid != null) {
request.setParam(PARAM_PROJECT_ID, projectUuid);
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_ID;
public class DeleteTemplateActionTest {
private TestResponse newRequest(@Nullable String id) {
TestRequest request = ws.newRequest();
if (id != null) {
- request.setParam(PARAM_TEMPLATE_ID, id);
+ request.setParam(PARAM_ID, id);
}
TestResponse result = executeRequest(request);
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_PERMISSION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID_EXPLICIT;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
@Category(DbTests.class)
public class RemoveGroupFromTemplateActionTest {
commit();
ws.newRequest()
- .setParam(PARAM_TEMPLATE_ID_EXPLICIT, permissionTemplate.getKee())
+ .setParam(PARAM_TEMPLATE_ID, permissionTemplate.getKee())
.setParam(PARAM_PERMISSION, PERMISSION)
.setParam(PARAM_GROUP_ID, String.valueOf(group.getId()))
.execute();
request.setParam(Parameters.PARAM_GROUP_NAME, groupName);
}
if (templateKey != null) {
- request.setParam(PARAM_TEMPLATE_ID_EXPLICIT, templateKey);
+ request.setParam(PARAM_TEMPLATE_ID, templateKey);
}
if (permission != null) {
request.setParam(Parameters.PARAM_PERMISSION, permission);
request.setParam(Parameters.PARAM_USER_LOGIN, userLogin);
}
if (templateKey != null) {
- request.setParam(Parameters.PARAM_TEMPLATE_ID_EXPLICIT, templateKey);
+ request.setParam(Parameters.PARAM_TEMPLATE_ID, templateKey);
}
if (permission != null) {
request.setParam(Parameters.PARAM_PERMISSION, permission);
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_EXPLICIT;
+import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
@Category(DbTests.class)
public class SetDefaultTemplateActionTest {
private String newRequest(@Nullable String templateUuid, @Nullable String qualifier) {
TestRequest request = ws.newRequest();
if (templateUuid != null) {
- request.setParam(PARAM_TEMPLATE_ID_EXPLICIT, templateUuid);
+ request.setParam(PARAM_TEMPLATE_ID, templateUuid);
}
if (qualifier != null) {
request.setParam(PARAM_QUALIFIER, qualifier);
import static org.mockito.Mockito.when;
import static org.sonar.db.permission.PermissionTemplateTesting.newPermissionTemplateDto;
import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_DESCRIPTION;
-import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_ID;
+import static org.sonar.server.permission.ws.Parameters.PARAM_ID;
import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_NAME;
import static org.sonar.server.permission.ws.Parameters.PARAM_TEMPLATE_PATTERN;
import static org.sonar.test.JsonAssert.assertJson;
private TestResponse newRequest(@Nullable String key, @Nullable String name, @Nullable String description, @Nullable String projectPattern) {
TestRequest request = ws.newRequest();
if (key != null) {
- request.setParam(PARAM_TEMPLATE_ID, key);
+ request.setParam(PARAM_ID, key);
}
if (name != null) {
request.setParam(PARAM_TEMPLATE_NAME, name);