activate.createParam(PARAM_KEY)
.setDescription("Quality Profile key. Can be obtained through <code>api/qualityprofiles/search</code>")
- .setDeprecatedKey("profile_key", "6.5")
.setRequired(true)
.setExampleValue(UUID_EXAMPLE_01);
activate.createParam(PARAM_RULE)
.setDescription("Rule key")
- .setDeprecatedKey("rule_key", "6.5")
.setRequired(true)
.setExampleValue("squid:AvoidCycles");
activate.createParam(PARAM_TARGET_KEY)
.setDescription("Quality Profile key on which the rule activation is done. To retrieve a quality profile key please see <code>api/qualityprofiles/search</code>")
- .setDeprecatedKey("profile_key", "6.5")
.setRequired(true)
.setExampleValue(UUID_EXAMPLE_03);
activate.createParam(PARAM_TARGET_SEVERITY)
.setDescription("Severity to set on the activated rules")
- .setDeprecatedKey("activation_severity", "6.5")
.setPossibleValues(Severity.ALL);
}
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.user.UserSession;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_08;
-import static org.sonar.server.component.ComponentFinder.ParamNames.PROJECT_UUID_AND_KEY;
import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_ADD_PROJECT;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_UUID;
public class AddProjectAction implements QProfileWsAction {
action.createParam(PARAM_PROJECT)
.setDescription("Project key")
- .setDeprecatedKey("projectKey", "6.5")
+ .setRequired(true)
.setExampleValue(KEY_PROJECT_EXAMPLE_001);
-
- action.createParam(PARAM_PROJECT_UUID)
- .setDescription("Project ID. Either this parameter or '%s' must be set.", PARAM_PROJECT)
- .setDeprecatedSince("6.5")
- .setExampleValue(UUID_EXAMPLE_08);
}
@Override
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentDto project = loadProject(dbSession, request);
- QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
+ QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
checkPermissions(dbSession, organization, profile, project);
}
private ComponentDto loadProject(DbSession dbSession, Request request) {
- String projectKey = request.param(PARAM_PROJECT);
- String projectUuid = request.param(PARAM_PROJECT_UUID);
- return componentFinder.getByUuidOrKey(dbSession, projectUuid, projectKey, PROJECT_UUID_AND_KEY);
+ String projectKey = request.mandatoryParam(PARAM_PROJECT);
+ return componentFinder.getByKey(dbSession, projectKey);
}
private void checkPermissions(DbSession dbSession, OrganizationDto organization, QProfileDto profile, ComponentDto project) {
try (OutputStreamWriter writer = new OutputStreamWriter(stream.output(), UTF_8);
DbSession dbSession = dbClient.openSession(false)) {
- QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
+ QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
response.setHeader("Content-Disposition", String.format("attachment; filename=%s.xml", profile.getKee()));
backuper.backup(dbSession, profile, writer);
}
import org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters;
import static org.apache.commons.lang.StringUtils.isEmpty;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_02;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY;
public class ChangeParentAction implements QProfileWsAction {
.setSince("6.4");
QProfileReference.defineParams(inheritance, languages);
- inheritance.createParam(PARAM_PARENT_KEY)
- .setDescription("New parent profile key.<br> " +
- "If no profile is provided, the inheritance link with current parent profile (if any) is broken, which deactivates all rules " +
- "which come from the parent and are not overridden.")
- .setDeprecatedSince("6.6")
- .setExampleValue(UUID_EXAMPLE_02);
-
inheritance.createParam(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE)
- .setDescription("Quality profile name. If this parameter is set, '%s' must not be set and '%s' must be set to disambiguate.", PARAM_PARENT_KEY, PARAM_LANGUAGE)
+ .setDescription("New parent profile name. <br> " +
+ "If no profile is provided, the inheritance link with current parent profile (if any) is broken, which deactivates all rules " +
+ "which come from the parent and are not overridden.")
.setExampleValue("Sonar way");
}
@Override
public void handle(Request request, Response response) throws Exception {
userSession.checkLoggedIn();
- QProfileReference reference = QProfileReference.from(request);
+ QProfileReference reference = QProfileReference.fromName(request);
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, reference);
OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
wsSupport.checkCanEdit(dbSession, organization, profile);
- String parentKey = request.param(PARAM_PARENT_KEY);
String parentName = request.param(QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE);
- if (isEmpty(parentKey) && isEmpty(parentName)) {
+ if (isEmpty(parentName)) {
ruleActivator.removeParentAndCommit(dbSession, profile);
} else {
- String parentOrganizationKey = parentKey == null ? organization.getKey() : null;
- String parentLanguage = parentKey == null ? request.param(PARAM_LANGUAGE) : null;
- QProfileReference parentRef = QProfileReference.from(parentKey, parentOrganizationKey, parentLanguage, parentName);
+ String parentLanguage = request.mandatoryParam(PARAM_LANGUAGE);
+ QProfileReference parentRef = QProfileReference.fromName(organization.getKey(), parentLanguage, parentName);
QProfileDto parent = wsSupport.getProfile(dbSession, parentRef);
ruleActivator.setParentAndCommit(dbSession, profile, parent);
}
@Override
public void handle(Request request, Response response) throws Exception {
- QProfileReference reference = QProfileReference.from(request);
+ QProfileReference reference = QProfileReference.fromName(request);
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, reference);
.setRequired(true)
.setMaximumLength(NAME_MAXIMUM_LENGTH)
.setDescription("Quality profile name")
- .setExampleValue("My Sonar way")
- .setDeprecatedKey("profileName", "6.6");
+ .setExampleValue("My Sonar way");
create.createParam(PARAM_LANGUAGE)
.setRequired(true)
deactivate.createParam(PARAM_KEY)
.setDescription("Quality Profile key. Can be obtained through <code>api/qualityprofiles/search</code>")
- .setDeprecatedKey("profile_key", "6.5")
.setRequired(true)
.setExampleValue(UUID_EXAMPLE_01);
deactivate.createParam(PARAM_RULE)
.setDescription("Rule key")
- .setDeprecatedKey("rule_key", "6.5")
.setRequired(true)
.setExampleValue("squid:AvoidCycles");
}
deactivate.createParam(PARAM_TARGET_KEY)
.setDescription("Quality Profile key on which the rule deactivation is done. To retrieve a profile key please see <code>api/qualityprofiles/search</code>")
- .setDeprecatedKey("profile_key", "6.5")
.setRequired(true)
.setExampleValue(UUID_EXAMPLE_04);
}
userSession.checkLoggedIn();
try (DbSession dbSession = dbClient.openSession(false)) {
- QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
+ QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
wsSupport.checkCanEdit(dbSession, organization, profile);
import org.sonarqube.ws.MediaTypes;
import static java.nio.charset.StandardCharsets.UTF_8;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
-import static org.sonar.server.exceptions.BadRequestException.checkRequest;
import static org.sonar.server.exceptions.NotFoundException.checkFound;
import static org.sonar.server.qualityprofile.ws.QProfileWsSupport.createOrganizationParam;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
.setResponseExample(getClass().getResource("export-example.xml"))
.setHandler(this);
- action.createParam(PARAM_KEY)
- .setDescription("Quality profile key")
- .setSince("6.5")
- .setDeprecatedSince("6.6")
- .setExampleValue(UUID_EXAMPLE_01);
-
action.createParam(PARAM_QUALITY_PROFILE)
.setDescription("Quality profile name to export. If left empty, the default profile for the language is exported.")
- .setDeprecatedKey("name", "6.6")
.setExampleValue("My Sonar way");
action.createParam(PARAM_LANGUAGE)
.setDescription("Quality profile language")
+ .setRequired(true)
.setExampleValue(LanguageParamUtils.getExampleValue(languages))
.setPossibleValues(LanguageParamUtils.getOrderedLanguageKeys(languages));
@Override
public void handle(Request request, Response response) throws Exception {
- String key = request.param(PARAM_KEY);
String name = request.param(PARAM_QUALITY_PROFILE);
- String language = request.param(PARAM_LANGUAGE);
- checkRequest(key != null ^ language != null, "Either '%s' or '%s' must be provided.", PARAM_KEY, PARAM_LANGUAGE);
+ String language = request.mandatoryParam(PARAM_LANGUAGE);
try (DbSession dbSession = dbClient.openSession(false)) {
OrganizationDto organization = wsSupport.getOrganizationByKey(dbSession, request.param(PARAM_ORGANIZATION));
- QProfileDto profile = loadProfile(dbSession, organization, key, language, name);
+ QProfileDto profile = loadProfile(dbSession, organization, language, name);
String exporterKey = exporters.exportersForLanguage(profile.getLanguage()).isEmpty() ? null : request.param(PARAM_EXPORTER_KEY);
writeResponse(dbSession, profile, exporterKey, response);
}
IOUtils.write(bufferStream.toByteArray(), output);
}
- private QProfileDto loadProfile(DbSession dbSession, OrganizationDto organization, @Nullable String key, @Nullable String language, @Nullable String name) {
+ private QProfileDto loadProfile(DbSession dbSession, OrganizationDto organization, String language, @Nullable String name) {
QProfileDto profile;
- if (key != null) {
- profile = dbClient.qualityProfileDao().selectByUuid(dbSession, key);
- return checkFound(profile, "Could not find profile with key '%s'", key);
- }
- checkRequest(language != null, "Parameter '%s' must be provided", PARAM_LANGUAGE);
if (name == null) {
// return the default profile
profile = dbClient.qualityProfileDao().selectDefaultProfile(dbSession, organization, language);
@Override
public void handle(Request request, Response response) throws Exception {
- QProfileReference reference = QProfileReference.from(request);
+ QProfileReference reference = QProfileReference.fromName(request);
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, reference);
OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
.setExampleValue(UUID_EXAMPLE_01);
action.addSelectionModeParam();
- action.createSearchQuery("sonar", "projects")
- .setDeprecatedKey("query", "6.5");
+ action.createSearchQuery("sonar", "projects");
- action.createPageParam()
- .setDeprecatedKey("page", "6.5");
+ action.createPageParam();
action.createPageSize(100, MAX_PAGE_SIZE);
}
import org.sonar.api.server.ws.WebService;
import org.sonar.core.util.stream.MoreCollectors;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
-import static org.apache.commons.lang.StringUtils.isEmpty;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_01;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
return result;
}
- public static QProfileReference from(Request request) {
- String key = request.param(PARAM_KEY);
+ public static QProfileReference fromName(Request request) {
String organizationKey = request.param(PARAM_ORGANIZATION);
- String lang = request.param(PARAM_LANGUAGE);
- String name = request.param(PARAM_QUALITY_PROFILE);
- return from(key, organizationKey, lang, name);
- }
-
- public static QProfileReference from(@Nullable String key, @Nullable String organizationKey, @Nullable String lang, @Nullable String name) {
- if (key != null) {
- checkArgument(isEmpty(organizationKey) && isEmpty(lang) && isEmpty(name),
- "When a quality profile key is set, '%s' '%s' and '%s' can't be set", PARAM_ORGANIZATION, PARAM_LANGUAGE, PARAM_QUALITY_PROFILE);
- return fromKey(key);
- }
- checkArgument(!isEmpty(lang) && !isEmpty(name),
- "If '%s' is not specified, '%s' and '%s' must be set", PARAM_KEY, PARAM_QUALITY_PROFILE, PARAM_LANGUAGE);
+ String lang = request.mandatoryParam(PARAM_LANGUAGE);
+ String name = request.mandatoryParam(PARAM_QUALITY_PROFILE);
return fromName(organizationKey, lang, name);
}
}
public static void defineParams(WebService.NewAction action, Languages languages) {
- action.createParam(PARAM_KEY)
- .setDescription("Quality profile key. Mandatory unless 'qualityProfile' and 'language' are specified.")
- .setDeprecatedKey("profileKey", "6.5")
- .setDeprecatedSince("6.6")
- .setExampleValue(UUID_EXAMPLE_01);
-
action.createParam(PARAM_QUALITY_PROFILE)
- .setDescription("Quality profile name. Mandatory if 'key' is not set.")
- .setDeprecatedKey("profileName", "6.6")
+ .setDescription("Quality profile name.")
+ .setRequired(true)
.setExampleValue("Sonar way");
action.createParam(PARAM_LANGUAGE)
- .setDescription("Quality profile language. Mandatory if 'key' is not set.")
+ .setDescription("Quality profile language.")
+ .setRequired(true)
.setPossibleValues(Arrays.stream(languages.all()).map(Language::getKey).collect(MoreCollectors.toSet()));
}
}
import static com.google.common.base.Preconditions.checkState;
import static java.util.Objects.requireNonNull;
import static org.sonar.db.organization.OrganizationDto.Subscription.PAID;
-import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
+import static org.sonar.server.exceptions.BadRequestException.checkRequest;
import static org.sonar.server.exceptions.NotFoundException.checkFound;
import static org.sonar.server.exceptions.NotFoundException.checkFoundWithOptional;
-import static org.sonar.server.exceptions.BadRequestException.checkRequest;
+import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
@ServerSide
import org.sonar.server.component.ComponentFinder;
import org.sonar.server.user.UserSession;
-import static org.sonar.core.util.Uuids.UUID_EXAMPLE_09;
import static org.sonar.server.user.AbstractUserSession.insufficientPrivilegesException;
import static org.sonar.server.ws.KeyExamples.KEY_PROJECT_EXAMPLE_001;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.ACTION_REMOVE_PROJECT;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_UUID;
public class RemoveProjectAction implements QProfileWsAction {
action.createParam(PARAM_PROJECT)
.setDescription("Project key")
- .setDeprecatedKey("projectKey", "6.5")
+ .setRequired(true)
.setExampleValue(KEY_PROJECT_EXAMPLE_001);
-
- action.createParam(PARAM_PROJECT_UUID)
- .setDescription("Project ID. Either this parameter, or '%s' must be set.", PARAM_PROJECT)
- .setDeprecatedSince("6.5")
- .setExampleValue(UUID_EXAMPLE_09);
}
@Override
try (DbSession dbSession = dbClient.openSession(false)) {
ComponentDto project = loadProject(dbSession, request);
- QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.from(request));
+ QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
OrganizationDto organization = wsSupport.getOrganization(dbSession, profile);
checkPermissions(dbSession, organization, profile, project);
if (!profile.getOrganizationUuid().equals(project.getOrganizationUuid())) {
}
private ComponentDto loadProject(DbSession dbSession, Request request) {
- String projectKey = request.param(PARAM_PROJECT);
- String projectUuid = request.param(PARAM_PROJECT_UUID);
- return componentFinder.getByUuidOrKey(dbSession, projectUuid, projectKey, ComponentFinder.ParamNames.PROJECT_UUID_AND_PROJECT);
+ String projectKey = request.mandatoryParam(PARAM_PROJECT);
+ return componentFinder.getByKey(dbSession, projectKey);
}
private void checkPermissions(DbSession dbSession, OrganizationDto organization, QProfileDto profile, ComponentDto project) {
action.createParam(PARAM_PROJECT)
.setDescription("Project key")
- .setDeprecatedKey("projectKey", "6.5")
.setExampleValue(KEY_PROJECT_EXAMPLE_001);
action
action.createParam(PARAM_QUALITY_PROFILE)
.setDescription("Quality profile name")
- .setDeprecatedKey("profileName", "6.6")
.setExampleValue("SonarQube Way");
}
@Override
public void handle(Request request, Response response) {
userSession.checkLoggedIn();
- QProfileReference reference = QProfileReference.from(request);
+ QProfileReference reference = QProfileReference.fromName(request);
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto qualityProfile = qProfileWsSupport.getProfile(dbSession, reference);
dbClient.organizationDao().selectByUuid(dbSession, qualityProfile.getOrganizationUuid())
show.createParam(PARAM_KEY)
.setDescription("Quality profile key")
.setExampleValue(UUID_EXAMPLE_01)
- .setDeprecatedKey("profile", "6.6")
.setRequired(true);
show.createParam(PARAM_COMPARE_TO_SONAR_WAY)
assertThat(definition).isNotNull();
assertThat(definition.isPost()).isTrue();
assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("severity", "key", "reset", "rule", "params");
- WebService.Param profileKey = definition.param("key");
- assertThat(profileKey.deprecatedKey()).isEqualTo("profile_key");
- WebService.Param ruleKey = definition.param("rule");
- assertThat(ruleKey.deprecatedKey()).isEqualTo("rule_key");
}
@Test
"owaspTop10",
"sansTop25",
"sonarsourceSecurity");
- WebService.Param targetProfile = definition.param("targetKey");
- assertThat(targetProfile.deprecatedKey()).isEqualTo("profile_key");
- WebService.Param targetSeverity = definition.param("targetSeverity");
- assertThat(targetSeverity.deprecatedKey()).isEqualTo("activation_severity");
}
@Test
// parameters
assertThat(definition.params()).extracting(WebService.Param::key)
- .containsExactlyInAnyOrder("key", "qualityProfile", "project", "language", "projectUuid", "organization");
- WebService.Param profile = definition.param("key");
- assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- assertThat(profile.deprecatedSince()).isEqualTo("6.6");
+ .containsExactlyInAnyOrder("qualityProfile", "project", "language", "organization");
+ WebService.Param project = definition.param("project");
+ assertThat(project.isRequired()).isTrue();
WebService.Param languageParam = definition.param("language");
assertThat(languageParam.possibleValues()).containsOnly(LANGUAGE_1, LANGUAGE_2);
assertThat(languageParam.exampleValue()).isNull();
- WebService.Param project = definition.param("project");
- assertThat(project.deprecatedKey()).isEqualTo("projectKey");
- WebService.Param projectUuid = definition.param("projectUuid");
- assertThat(projectUuid.deprecatedSince()).isEqualTo("6.5");
WebService.Param organizationParam = definition.param("organization");
assertThat(organizationParam.since()).isEqualTo("6.4");
assertThat(organizationParam.isInternal()).isTrue();
public void add_project_on_profile_of_default_organization() {
logInAsProfileAdmin(db.getDefaultOrganization());
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
- QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+ QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
TestResponse response = call(project, profile);
assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
@Test
public void project_administrator_can_change_profile() {
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
- QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+ QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
call(project, profile);
public void throw_ForbiddenException_if_not_project_nor_organization_administrator() {
userSession.logIn(db.users().insertUser());
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
- QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+ QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("Insufficient privileges");
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Component id 'unknown' not found");
+ expectedException.expectMessage("Component key 'unknown' not found");
tester.newRequest()
- .setParam("projectUuid", "unknown")
+ .setParam("project", "unknown")
.setParam("profileKey", profile.getKee())
.execute();
}
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Quality Profile with key 'unknown' does not exist");
+ expectedException.expectMessage("Quality Profile for language 'xoo' and name 'unknown' does not exist");
tester.newRequest()
- .setParam("projectUuid", project.uuid())
- .setParam("profileKey", "unknown")
+ .setParam("project", project.getKey())
+ .setParam("language", "xoo")
+ .setParam("qualityProfile", "unknown")
.execute();
}
@Test
- public void fail_when_using_branch_db_key() throws Exception {
+ public void fail_when_using_branch_db_key() {
OrganizationDto organization = db.organizations().insert();
ComponentDto project = db.components().insertMainBranch(organization);
userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
.execute();
}
- @Test
- public void fail_when_using_branch_uuid() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertMainBranch(organization);
- userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
- ComponentDto branch = db.components().insertProjectBranch(project);
- QProfileDto profile = db.qualityProfiles().insert(organization);
-
- expectedException.expect(NotFoundException.class);
- expectedException.expectMessage(format("Component id '%s' not found", branch.uuid()));
-
- tester.newRequest()
- .setParam("projectUuid", branch.uuid())
- .setParam("profileKey", profile.getKee())
- .execute();
- }
-
private void assertProjectIsAssociatedToProfile(ComponentDto project, QProfileDto profile) {
QProfileDto loaded = dbClient.qualityProfileDao().selectAssociatedToProjectAndLanguage(db.getSession(), project, profile.getLanguage());
assertThat(loaded.getKee()).isEqualTo(profile.getKee());
private TestResponse call(ComponentDto project, QProfileDto qualityProfile) {
TestRequest request = tester.newRequest()
- .setParam("projectUuid", project.uuid())
- .setParam("key", qualityProfile.getKee());
+ .setParam("project", project.getKey())
+ .setParam("language", qualityProfile.getLanguage())
+ .setParam("qualityProfile", qualityProfile.getName());
return request.execute();
}
private TestResponse call(OrganizationDto organization, ComponentDto project, QProfileDto qualityProfile) {
TestRequest request = tester.newRequest()
.setParam("organization", organization.getKey())
- .setParam("projectUuid", project.uuid())
+ .setParam("project", project.getKey())
.setParam("language", qualityProfile.getLanguage())
.setParam("qualityProfile", qualityProfile.getName());
return request.execute();
@Test
public void returns_backup_of_profile_with_specified_key() {
- QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+ QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
- TestResponse response = tester.newRequest().setParam(PARAM_KEY, profile.getKee()).execute();
+ TestResponse response = tester.newRequest()
+ .setParam("language", profile.getLanguage())
+ .setParam("qualityProfile", profile.getName())
+ .execute();
assertThat(response.getMediaType()).isEqualTo("application/xml");
assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile));
assertThat(response.getHeader("Content-Disposition")).isEqualTo("attachment; filename=" + profile.getKee() + ".xml");
assertThat(response.getInput()).isXmlEqualTo(xmlForProfileWithoutRules(profile));
}
- @Test
- public void throws_NotFoundException_if_profile_with_specified_key_does_not_exist() {
- expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Quality Profile with key 'missing' does not exist");
-
- tester.newRequest().setParam(PARAM_KEY, "missing").execute();
- }
-
@Test
public void throws_NotFoundException_if_specified_organization_does_not_exist() {
expectedException.expect(NotFoundException.class);
.execute();
}
- @Test
- public void fail_on_paid_organization_when_not_member_using_deprecated_profile_key() {
- OrganizationDto organization = db.organizations().insert(o -> o.setSubscription(PAID));
- QProfileDto profile = db.qualityProfiles().insert(organization, p -> p.setLanguage(A_LANGUAGE));
- userSession.logIn();
-
- expectedException.expect(ForbiddenException.class);
- expectedException.expectMessage(format("You're not member of organization '%s'", organization.getKey()));
-
- tester.newRequest()
- .setParam("key", profile.getKee())
- .execute();
- }
-
@Test
public void test_definition() {
WebService.Action definition = tester.getDef();
assertThat(definition.isPost()).isFalse();
// parameters
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "organization", "qualityProfile", "language");
- Param key = definition.param("key");
- assertThat(key.deprecatedKey()).isEqualTo("profileKey");
- assertThat(key.deprecatedSince()).isEqualTo("6.6");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("organization", "qualityProfile", "language");
Param language = definition.param("language");
assertThat(language.deprecatedSince()).isNullOrEmpty();
- Param profileName = definition.param("qualityProfile");
Param orgParam = definition.param("organization");
assertThat(orgParam.since()).isEqualTo("6.4");
}
import static org.sonarqube.ws.client.component.ComponentsWsParameters.PARAM_ORGANIZATION;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_KEY;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PARENT_QUALITY_PROFILE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
WebService.Action definition = ws.getDef();
assertThat(definition.isPost()).isTrue();
assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder(
- "organization", "key", "qualityProfile", "language", "parentKey", "parentQualityProfile");
+ "organization", "qualityProfile", "language", "parentQualityProfile");
assertThat(definition.param("organization").since()).isEqualTo("6.4");
- Param profile = definition.param("key");
- assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- assertThat(profile.deprecatedSince()).isEqualTo("6.6");
- Param parentProfile = definition.param("parentKey");
- assertThat(parentProfile.deprecatedKey()).isNullOrEmpty();
}
@Test
// Set parent
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, child.getKee())
- .setParam(PARAM_PARENT_KEY, parent1.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
+ .setParam(PARAM_PARENT_QUALITY_PROFILE, parent1.getName())
.execute();
// Check rule 1 enabled
// Set parent 2 through WS
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, child.getKee())
- .setParam(PARAM_PARENT_KEY, parent2.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
+ .setParam(PARAM_PARENT_QUALITY_PROFILE, parent2.getName())
.execute();
// Check rule 2 enabled
// Remove parent through WS
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, child.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
.execute();
// Check no rule enabled
// Remove parent
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, child.getKee())
- .setParam(PARAM_PARENT_KEY, "")
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
+ .setParam(PARAM_PARENT_QUALITY_PROFILE, "")
.execute();
// Check no rule enabled
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, child.getKee())
- .setParam(PARAM_PARENT_KEY, parent2.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
+ .setParam(PARAM_PARENT_QUALITY_PROFILE, parent2.getName())
.execute();
List<OrgActiveRuleDto> activeRules2 = dbClient.activeRuleDao().selectByProfile(dbSession, child);
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, child.getKee())
- .setParam(PARAM_PARENT_KEY, "palap");
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
+ .setParam(PARAM_PARENT_QUALITY_PROFILE, "palap");
expectedException.expect(BadRequestException.class);
request.execute();
}
- @Test
- public void fail_if_parent_key_and_name_both_set() {
- QProfileDto child = createProfile();
-
- assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, child.getKee())).isEmpty();
- assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfile(child), new SearchOptions()).getIds()).isEmpty();
-
- TestRequest request = ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_KEY, child.getKee())
- .setParam(PARAM_PARENT_QUALITY_PROFILE, "polop")
- .setParam(PARAM_PARENT_KEY, "palap");
- expectedException.expect(IllegalArgumentException.class);
- request
- .execute();
- }
-
- @Test
- public void fail_if_profile_key_and_name_both_set() {
- QProfileDto child = createProfile();
-
- assertThat(dbClient.activeRuleDao().selectByProfileUuid(dbSession, child.getKee())).isEmpty();
- assertThat(ruleIndex.search(new RuleQuery().setActivation(true).setQProfile(child), new SearchOptions()).getIds()).isEmpty();
-
- TestRequest request = ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_KEY, child.getKee())
- .setParam(PARAM_QUALITY_PROFILE, child.getName())
- .setParam(PARAM_ORGANIZATION, organization.getKey())
- .setParam(PARAM_PARENT_KEY, "palap");
-
- expectedException.expect(IllegalArgumentException.class);
- request.execute();
- }
-
@Test
public void fail_if_missing_permission() {
userSession.logIn(db.users().insertUser());
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, child.getKee());
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName());
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("Insufficient privileges");
TestRequest request = ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, child.getKee());
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName());
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("Insufficient privileges");
"param_bar", "bar_value"));
String response = ws.newRequest()
- .setParam(PARAM_KEY, profile.getKee())
+ .setParam(PARAM_LANGUAGE, profile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInput();
"severity", "MINOR"));
String response = ws.newRequest()
- .setParam(PARAM_KEY, profile.getKee())
+ .setParam(PARAM_LANGUAGE, profile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInput();
QProfileDto qualityProfile = db.qualityProfiles().insert(organization);
String response = ws.newRequest()
- .setParam(PARAM_KEY, qualityProfile.getKee())
+ .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInput();
"severity", "MINOR"));
assertJson(ws.newRequest()
- .setParam(PARAM_KEY, qualityProfile.getKee())
+ .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.setParam(PARAM_SINCE, "2011-04-25T01:15:42+0100")
.execute()
.getInput()).isSimilarTo("{\n" +
"}");
assertJson(ws.newRequest()
- .setParam(PARAM_KEY, qualityProfile.getKee())
+ .setParam(PARAM_LANGUAGE, qualityProfile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, qualityProfile.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.setParam(PARAM_SINCE, "2011-04-25T01:15:43+0100")
.execute()
.getInput()).isSimilarTo("{\n" +
ImmutableMap.of("ruleId", valueOf(rule2.getId())));
String response = ws.newRequest()
- .setParam(PARAM_KEY, profile.getKee())
+ .setParam(PARAM_LANGUAGE, profile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInput();
String response = ws.newRequest()
.setMethod("GET")
- .setParam(PARAM_KEY, profile.getKee())
+ .setParam(PARAM_LANGUAGE, profile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.setParam("ps", "10")
.execute()
.getInput();
assertThat(definition.isPost()).isFalse();
assertThat(definition.responseExampleAsString()).isNotEmpty();
assertThat(definition.params()).extracting(WebService.Param::key)
- .containsExactlyInAnyOrder("key", "qualityProfile", "language", "organization", "since", "to", "p", "ps");
+ .containsExactlyInAnyOrder("qualityProfile", "language", "organization", "since", "to", "p", "ps");
WebService.Param profileName = definition.param("qualityProfile");
assertThat(profileName.deprecatedSince()).isNullOrEmpty();
WebService.Param language = definition.param("language");
assertThat(definition.isPost()).isTrue();
assertThat(definition.params()).extracting(Param::key)
.containsExactlyInAnyOrder("language", "organization", "name", "backup_with_messages", "backup_with_errors", "backup_xoo_lint");
- Param name = definition.param("name");
- assertThat(name.deprecatedKey()).isEqualTo("profileName");
- assertThat(name.deprecatedKeySince()).isEqualTo("6.6");
}
@Test
assertThat(definition).isNotNull();
assertThat(definition.isPost()).isTrue();
assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("key", "rule");
- WebService.Param profileKey = definition.param("key");
- assertThat(profileKey.deprecatedKey()).isEqualTo("profile_key");
- WebService.Param ruleKey = definition.param("rule");
- assertThat(ruleKey.deprecatedKey()).isEqualTo("rule_key");
}
@Test
"owaspTop10",
"sansTop25",
"sonarsourceSecurity");
- WebService.Param targetProfile = definition.param("targetKey");
- assertThat(targetProfile.deprecatedKey()).isEqualTo("profile_key");
}
@Test
new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db)));
private WsActionTester ws = new WsActionTester(underTest);
- @Test
- public void delete_profile_by_key() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertPrivateProject(organization);
- QProfileDto profile1 = createProfile(organization);
- QProfileDto profile2 = createProfile(organization);
- db.qualityProfiles().associateWithProject(project, profile1);
-
- logInAsQProfileAdministrator(organization);
-
- TestResponse response = ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_KEY, profile1.getKee())
- .execute();
- assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
-
- verifyProfileDoesNotExist(profile1, organization);
- verifyProfileExists(profile2);
- }
-
@Test
public void delete_profile_by_language_and_name_in_default_organization() {
OrganizationDto organization = db.getDefaultOrganization();
@Test
public void fail_if_built_in_profile() {
OrganizationDto organization = db.organizations().insert();
- QProfileDto profile1 = db.qualityProfiles().insert(organization, p -> p.setIsBuiltIn(true));
+ QProfileDto profile1 = db.qualityProfiles().insert(organization, p -> p.setIsBuiltIn(true).setLanguage(A_LANGUAGE));
logInAsQProfileAdministrator(organization);
expectedException.expect(BadRequestException.class);
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, profile1.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, profile1.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, profile1.getName())
.execute();
}
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, qprofile.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, qprofile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, qprofile.getName())
.execute();
}
userSession.logIn();
expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("If 'key' is not specified, 'qualityProfile' and 'language' must be set");
+ expectedException.expectMessage("The 'language' parameter is missing");
ws.newRequest()
.setMethod("POST")
logInAsQProfileAdministrator(organization);
expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("If 'key' is not specified, 'qualityProfile' and 'language' must be set");
+ expectedException.expectMessage("The 'language' parameter is missing");
ws.newRequest()
.setMethod("POST")
logInAsQProfileAdministrator(organization);
expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("If 'key' is not specified, 'qualityProfile' and 'language' must be set");
+ expectedException.expectMessage("The 'qualityProfile' parameter is missing");
ws.newRequest()
.setMethod("POST")
.execute();
}
- @Test
- public void fail_if_too_many_parameters_to_reference_profile() {
- OrganizationDto organization = db.organizations().insert();
- QProfileDto profile = createProfile(organization);
- logInAsQProfileAdministrator(organization);
-
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("When a quality profile key is set, 'organization' 'language' and 'qualityProfile' can't be set");
-
- ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_ORGANIZATION, organization.getKey())
- .setParam(PARAM_LANGUAGE, profile.getLanguage())
- .setParam("profileName", profile.getName())
- .setParam(PARAM_KEY, profile.getKee())
- .execute();
- }
-
@Test
public void fail_if_profile_does_not_exist() {
userSession.logIn();
expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Quality Profile with key 'does_not_exist' does not exist");
+ expectedException.expectMessage("Quality Profile for language 'xoo' and name 'does_not_exist' does not exist");
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, "does_not_exist")
+ .setParam(PARAM_QUALITY_PROFILE, "does_not_exist")
+ .setParam(PARAM_LANGUAGE, "xoo")
.execute();
}
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, profile.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, profile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, profile.getName())
.execute();
}
ws.newRequest()
.setMethod("POST")
- .setParam(PARAM_KEY, parentProfile.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_LANGUAGE, parentProfile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, parentProfile.getName())
.execute();
}
WebService.Action definition = ws.getDef();
assertThat(definition.isPost()).isTrue();
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "organization", "key", "qualityProfile");
- Param key = definition.param("key");
- assertThat(key.deprecatedKey()).isEqualTo("profileKey");
- assertThat(key.deprecatedSince()).isEqualTo("6.6");
- Param profileName = definition.param("qualityProfile");
- assertThat(profileName.deprecatedSince()).isNullOrEmpty();
- Param language = definition.param("language");
- assertThat(language.deprecatedSince()).isNullOrEmpty();
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "organization", "qualityProfile");
}
private void logInAsQProfileAdministrator(OrganizationDto organization) {
private QProfileBackuper backuper = new TestBackuper();
private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
- @Test
- public void export_profile_with_key() {
- QProfileDto profile = createProfile(db.getDefaultOrganization(), false);
-
- WsActionTester tester = newWsActionTester(newExporter("polop"), newExporter("palap"));
- String result = tester.newRequest()
- .setParam(PARAM_KEY, profile.getKee())
- .setParam("exporterKey", "polop")
- .execute()
- .getInput();
-
- assertThat(result).isEqualTo("Profile " + profile.getLanguage() + "/" + profile.getName() + " exported by polop");
- }
-
@Test
public void export_profile_in_default_organization() {
QProfileDto profile = createProfile(db.getDefaultOrganization(), false);
.execute();
}
- @Test
- public void fail_if_profile_key_is_unknown() {
- expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Could not find profile with key 'PROFILE-KEY-404'");
-
- WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap"));
- ws.newRequest()
- .setParam(PARAM_KEY, "PROFILE-KEY-404")
- .setParam("exporterKey", "polop").execute()
- .getInput();
- }
-
- @Test
- public void fail_if_profile_key_and_language_provided() {
- QProfileDto profile = createProfile(db.getDefaultOrganization(), false);
-
- expectedException.expect(BadRequestException.class);
- expectedException.expectMessage("Either 'key' or 'language' must be provided");
-
- WsActionTester ws = newWsActionTester(newExporter("polop"), newExporter("palap"));
- ws.newRequest()
- .setParam(PARAM_KEY, profile.getKee())
- .setParam(PARAM_LANGUAGE, profile.getLanguage())
- .setParam("exporterKey", "polop").execute()
- .getInput();
- }
-
@Test
public void fail_on_paid_organization_when_not_member() {
WsActionTester tester = newWsActionTester(newExporter("foo"));
assertThat(definition.isPost()).isFalse();
assertThat(definition.isInternal()).isFalse();
- assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization");
+ assertThat(definition.params()).extracting(WebService.Param::key).containsExactlyInAnyOrder("language", "qualityProfile", "organization");
WebService.Param organizationParam = definition.param("organization");
assertThat(organizationParam.since()).isEqualTo("6.4");
assertThat(organizationParam.isInternal()).isTrue();
- WebService.Param key = definition.param("key");
- assertThat(key.since()).isEqualTo("6.5");
- assertThat(key.deprecatedSince()).isEqualTo("6.6");
-
WebService.Param name = definition.param("qualityProfile");
assertThat(name.deprecatedSince()).isNullOrEmpty();
- assertThat(name.deprecatedKey()).isEqualTo("name");
WebService.Param language = definition.param("language");
assertThat(language.deprecatedSince()).isNullOrEmpty();
assertThat(definition.isPost()).isFalse();
assertThat(definition.isInternal()).isFalse();
- assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization", "exporterKey");
+ assertThat(definition.params()).extracting("key").containsExactlyInAnyOrder("language", "qualityProfile", "organization", "exporterKey");
WebService.Param exportersParam = definition.param("exporterKey");
assertThat(exportersParam.possibleValues()).containsOnly("polop", "palap");
assertThat(exportersParam.deprecatedKey()).isEqualTo("format");
overrideActiveRuleSeverity(rule2, forProject2, Severity.CRITICAL);
String response = ws.newRequest()
- .setParam(PARAM_KEY, buWide.getKee())
+ .setParam(PARAM_LANGUAGE, buWide.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, buWide.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInput();
InputStream response = ws.newRequest()
.setMediaType(PROTOBUF)
- .setParam(PARAM_KEY, child.getKee())
+ .setParam(PARAM_LANGUAGE, child.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, child.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInputStream();
InputStream response = ws.newRequest()
.setMediaType(PROTOBUF)
- .setParam(PARAM_KEY, profile.getKee())
+ .setParam(PARAM_LANGUAGE, profile.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, profile.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInputStream();
QProfileDto remi = createProfile(organization,"xoo", "Nobodys Boy", "xoo-nobody-s-boy-01234");
String response = ws.newRequest()
- .setParam(PARAM_KEY, remi.getKee())
+ .setParam(PARAM_LANGUAGE, remi.getLanguage())
+ .setParam(PARAM_QUALITY_PROFILE, remi.getName())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
.execute()
.getInput();
@Test(expected = NotFoundException.class)
public void fail_if_not_found() {
- ws.newRequest().setParam(PARAM_KEY, "polop").execute();
+ ws.newRequest()
+ .setParam(PARAM_LANGUAGE, "xoo")
+ .setParam(PARAM_QUALITY_PROFILE, "asd")
+ .execute();
}
@Test
WebService.Action definition = ws.getDef();
assertThat(definition.key()).isEqualTo("inheritance");
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "language", "qualityProfile", "organization");
- Param key = definition.param("key");
- assertThat(key.deprecatedKey()).isEqualTo("profileKey");
- assertThat(key.deprecatedSince()).isEqualTo("6.6");
- Param profileName = definition.param("qualityProfile");
- assertThat(profileName.deprecatedSince()).isNullOrEmpty();
- Param language = definition.param("language");
- assertThat(language.deprecatedSince()).isNullOrEmpty();
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("language", "qualityProfile", "organization");
}
private QProfileDto createProfile(OrganizationDto organization, String lang, String name, String key) {
assertThat(definition.param("p")).isNotNull();
assertThat(definition.param("ps")).isNotNull();
Param query = definition.param("q");
- assertThat(query.deprecatedKey()).isEqualTo("query");
}
private void associateProjectsWithProfile(QProfileDto profile, ComponentDto... projects) {
}
@Test
- public void from_reads_request_parameters_and_creates_reference_by_key() {
- SimpleGetRequest req = new SimpleGetRequest();
- req.setParam("key", "foo");
-
- QProfileReference ref = QProfileReference.from(req);
- assertThat(ref.getKey()).isEqualTo("foo");
- }
-
- @Test
- public void from_reads_request_parameters_and_creates_reference_by_name_on_default_organization() {
+ public void fromName_reads_request_parameters_and_creates_reference_by_name_on_default_organization() {
SimpleGetRequest req = new SimpleGetRequest();
req.setParam("language", "js");
req.setParam("qualityProfile", "Sonar way");
- QProfileReference ref = QProfileReference.from(req);
+ QProfileReference ref = QProfileReference.fromName(req);
assertThat(ref.getOrganizationKey()).isEmpty();
assertThat(ref.getLanguage()).isEqualTo("js");
assertThat(ref.getName()).isEqualTo("Sonar way");
}
@Test
- public void from_reads_request_parameters_and_creates_reference_by_name_on_specified_organization() {
+ public void fromName_reads_request_parameters_and_creates_reference_by_name_on_specified_organization() {
SimpleGetRequest req = new SimpleGetRequest();
req.setParam("organization", "my-org");
req.setParam("language", "js");
req.setParam("qualityProfile", "Sonar way");
- QProfileReference ref = QProfileReference.from(req);
+ QProfileReference ref = QProfileReference.fromName(req);
assertThat(ref.getOrganizationKey()).hasValue("my-org");
assertThat(ref.getLanguage()).isEqualTo("js");
assertThat(ref.getName()).isEqualTo("Sonar way");
}
- @Test
- public void from_reads_request_parameters_and_throws_IAE_if_language_is_missing() {
- SimpleGetRequest req = new SimpleGetRequest();
- req.setParam("profileName", "the name");
-
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("If 'key' is not specified, 'qualityProfile' and 'language' must be set");
-
- QProfileReference.from(req);
- }
-
@Test
public void throw_IAE_if_request_does_not_define_ref() {
SimpleGetRequest req = new SimpleGetRequest();
expectedException.expect(IllegalArgumentException.class);
- QProfileReference.from(req);
+ QProfileReference.fromName(req);
}
@Test
WebService.Action action = context.controller("api/qualityprofiles").action("do");
assertThat(action.param("language")).isNotNull();
assertThat(action.param("language").possibleValues()).containsOnly("java", "js");
- assertThat(action.param("key")).isNotNull();
assertThat(action.param("qualityProfile")).isNotNull();
}
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new QProfilesWsModule().configure(container);
- assertThat(container.size()).isEqualTo(32 + 2);
+ assertThat(container.size()).isEqualTo(31 + 2);
}
}
private QProfileWsSupport wsSupport = new QProfileWsSupport(dbClient, userSession, TestDefaultOrganizationProvider.from(db));
private RemoveProjectAction underTest = new RemoveProjectAction(dbClient, userSession, languages,
- new ComponentFinder(dbClient, new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)), wsSupport);
+ new ComponentFinder(dbClient, new ResourceTypesRule().setRootQualifiers(Qualifiers.PROJECT)), wsSupport);
private WsActionTester ws = new WsActionTester(underTest);
@Test
assertThat(definition.isPost()).isTrue();
assertThat(definition.key()).isEqualTo("remove_project");
- assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("key", "qualityProfile", "project", "language", "projectUuid", "organization");
+ assertThat(definition.params()).extracting(WebService.Param::key).containsOnly("qualityProfile", "project", "language", "organization");
WebService.Param languageParam = definition.param("language");
assertThat(languageParam.possibleValues()).containsOnly(LANGUAGE_1, LANGUAGE_2);
assertThat(languageParam.exampleValue()).isNull();
WebService.Param organizationParam = definition.param("organization");
assertThat(organizationParam.since()).isEqualTo("6.4");
assertThat(organizationParam.isInternal()).isTrue();
- WebService.Param profile = definition.param("key");
- assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
WebService.Param profileName = definition.param("qualityProfile");
assertThat(profileName.deprecatedSince()).isNullOrEmpty();
- WebService.Param project = definition.param("project");
- assertThat(project.deprecatedKey()).isEqualTo("projectKey");
- WebService.Param projectUuid = definition.param("projectUuid");
- assertThat(projectUuid.deprecatedSince()).isEqualTo("6.5");
}
@Test
logInAsProfileAdmin();
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
- QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+ QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
- TestResponse response = call(project, profile);
+ TestResponse response = call(db.getDefaultOrganization(), project, profile);
assertThat(response.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT);
assertProjectIsNotAssociatedToProfile(project, profile);
@Test
public void project_administrator_can_remove_profile() {
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
- QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+ QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
db.qualityProfiles().associateWithProject(project, profile);
userSession.logIn(db.users().insertUser()).addProjectPermission(UserRole.ADMIN, project);
- call(project, profile);
+ call(db.getDefaultOrganization(), project, profile);
assertProjectIsNotAssociatedToProfile(project, profile);
}
db.qualityProfiles().addUserPermission(profile, user);
userSession.logIn(user);
- call(project, profile);
+ call(organization, project, profile);
assertProjectIsNotAssociatedToProfile(project, profile);
}
public void fail_if_not_enough_permissions() {
userSession.logIn(db.users().insertUser());
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
- QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
+ QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization(), qp -> qp.setLanguage("xoo"));
expectedException.expect(ForbiddenException.class);
expectedException.expectMessage("Insufficient privileges");
QProfileDto profile = db.qualityProfiles().insert(db.getDefaultOrganization());
expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Component id 'unknown' not found");
+ expectedException.expectMessage("Component key 'unknown' not found");
ws.newRequest()
- .setParam("projectUuid", "unknown")
+ .setParam("project", "unknown")
.setParam("profileKey", profile.getKee())
.execute();
}
ComponentDto project = db.components().insertPrivateProject(db.getDefaultOrganization());
expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Quality Profile with key 'unknown' does not exist");
+ expectedException.expectMessage("Quality Profile for language 'xoo' and name 'unknown' does not exist");
ws.newRequest()
- .setParam("projectUuid", project.uuid())
- .setParam("profileKey", "unknown")
+ .setParam("project", project.getDbKey())
+ .setParam("language", "xoo")
+ .setParam("qualityProfile", "unknown")
.execute();
}
ws.newRequest()
.setParam("project", branch.getDbKey())
- .setParam("profileKey", profile.getKee())
- .execute();
- }
-
- @Test
- public void fail_when_using_branch_uuid() {
- OrganizationDto organization = db.organizations().insert();
- ComponentDto project = db.components().insertMainBranch(organization);
- userSession.logIn().addProjectPermission(UserRole.ADMIN, project);
- ComponentDto branch = db.components().insertProjectBranch(project);
- QProfileDto profile = db.qualityProfiles().insert(organization);
-
- expectedException.expect(NotFoundException.class);
- expectedException.expectMessage(format("Component id '%s' not found", branch.uuid()));
-
- ws.newRequest()
- .setParam("projectUuid", branch.uuid())
- .setParam("profileKey", profile.getKee())
+ .setParam("language", profile.getLanguage())
+ .setParam("qualityProfile", profile.getName())
.execute();
}
private TestResponse call(ComponentDto project, QProfileDto qualityProfile) {
TestRequest request = ws.newRequest()
- .setParam("projectUuid", project.uuid())
- .setParam("profileKey", qualityProfile.getKee());
+ .setParam("project", project.getDbKey())
+ .setParam("language", qualityProfile.getLanguage())
+ .setParam("qualityProfile", qualityProfile.getName());
+ return request.execute();
+ }
+
+ private TestResponse call(OrganizationDto organization, ComponentDto project, QProfileDto qualityProfile) {
+ TestRequest request = ws.newRequest()
+ .setParam("project", project.getDbKey())
+ .setParam("organization", organization.getKey())
+ .setParam("language", qualityProfile.getLanguage())
+ .setParam("qualityProfile", qualityProfile.getName());
return request.execute();
}
}
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_DEFAULTS;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
-import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_PROJECT;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
public class SearchActionTest {
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
- SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, project.getDbKey()));
+ SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT, project.getDbKey()));
assertThat(result.getProfilesList())
.extracting(QualityProfile::getKey)
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
- SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT_KEY, module.getDbKey()));
+ SearchWsResponse result = call(ws.newRequest().setParam(PARAM_PROJECT, module.getDbKey()));
assertThat(result.getProfilesList())
.extracting(QualityProfile::getKey)
db.qualityProfiles().setAsDefault(defaultProfileOnXoo1, defaultProfileOnXoo2);
SearchWsResponse result = call(ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+ .setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_DEFAULTS, "true"));
assertThat(result.getProfilesList())
db.qualityProfiles().associateWithProject(project, profileOnXoo1);
SearchWsResponse result = call(ws.newRequest()
- .setParam(PARAM_PROJECT_KEY, project.getDbKey())
+ .setParam(PARAM_PROJECT, project.getDbKey())
.setParam(PARAM_DEFAULTS, "true"));
assertThat(result.getProfilesList()).isEmpty();
expectedException.expect(NotFoundException.class);
expectedException.expectMessage("Component key 'unknown-project' not found");
- call(ws.newRequest().setParam(PARAM_PROJECT_KEY, "unknown-project"));
+ call(ws.newRequest().setParam(PARAM_PROJECT, "unknown-project"));
}
@Test
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage(format("Project uuid of component uuid '%s' does not exist", module.uuid()));
- call(ws.newRequest().setParam(PARAM_PROJECT_KEY, module.getDbKey()));
+ call(ws.newRequest().setParam(PARAM_PROJECT, module.getDbKey()));
}
@Test
call(ws.newRequest()
.setParam(PARAM_ORGANIZATION, organization.getKey())
- .setParam(PARAM_PROJECT_KEY, project.getDbKey()));
+ .setParam(PARAM_PROJECT, project.getDbKey()));
}
@Test
WebService.Param projectKey = definition.param("project");
assertThat(projectKey.description()).isEqualTo("Project key");
- assertThat(projectKey.deprecatedKey()).isEqualTo("projectKey");
WebService.Param language = definition.param("language");
assertThat(language.possibleValues()).containsExactly("xoo1", "xoo2");
import static org.assertj.core.api.Assertions.assertThat;
import static org.sonar.db.permission.OrganizationPermission.ADMINISTER_QUALITY_PROFILES;
import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_KEY;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_LANGUAGE;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_ORGANIZATION;
+import static org.sonarqube.ws.client.qualityprofile.QualityProfileWsParameters.PARAM_QUALITY_PROFILE;
public class SetDefaultActionTest {
assertThat(definition).isNotNull();
assertThat(definition.isPost()).isTrue();
- assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("key", "qualityProfile", "language", "organization");
+ assertThat(definition.params()).extracting(Param::key).containsExactlyInAnyOrder("qualityProfile", "language", "organization");
assertThat(definition.param("organization").since()).isEqualTo("6.4");
- Param profile = definition.param("key");
- assertThat(profile.deprecatedKey()).isEqualTo("profileKey");
- assertThat(definition.param("qualityProfile").deprecatedSince()).isNullOrEmpty();
- assertThat(definition.param("language").deprecatedSince()).isNullOrEmpty();
- }
-
- @Test
- public void set_default_profile_using_key() {
- logInAsQProfileAdministrator();
-
- checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
- checkDefaultProfile(organization, XOO_2_KEY, xoo2Profile2.getKee());
-
- TestResponse response = ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_KEY, xoo2Profile.getKee()).execute();
-
- assertThat(response.getInput()).isEmpty();
-
- checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
- checkDefaultProfile(organization, XOO_2_KEY, xoo2Profile.getKee());
-
- // One more time!
- TestResponse response2 = ws.newRequest()
- .setMethod("POST")
- .setParam(PARAM_KEY, xoo2Profile.getKee()).execute();
-
- assertThat(response2.getInput()).isEmpty();
- checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
- checkDefaultProfile(organization, XOO_2_KEY, xoo2Profile.getKee());
}
@Test
checkDefaultProfile(organization2, XOO_1_KEY, profileOrg2.getKee());
}
- @Test
- public void fail_to_set_default_profile_using_invalid_key() {
- logInAsQProfileAdministrator();
-
- expectedException.expect(NotFoundException.class);
- expectedException.expectMessage("Quality Profile with key 'unknown-profile-666' does not exist");
-
- ws.newRequest().setMethod("POST")
- .setParam(PARAM_KEY, "unknown-profile-666")
- .execute();
-
- checkDefaultProfile(organization, XOO_1_KEY, xoo1Profile.getKee());
- checkDefaultProfile(organization, XOO_2_KEY, xoo2Profile2.getKee());
- }
-
@Test
public void fail_to_set_default_profile_using_language_and_invalid_name() {
logInAsQProfileAdministrator();
}
}
- @Test
- public void fail_if_parameter_profile_key_is_combined_with_parameter_organization() {
- userSessionRule.logIn();
-
- expectedException.expect(IllegalArgumentException.class);
- expectedException.expectMessage("When a quality profile key is set, 'organization' 'language' and 'qualityProfile' can't be set");
-
- ws.newRequest().setMethod("POST")
- .setParam(PARAM_KEY, xoo2Profile.getKee())
- .setParam("organization", organization.getKey())
- .execute();
- }
-
@Test
public void throw_ForbiddenException_if_not_profile_administrator() {
userSessionRule.logIn();
expectedException.expectMessage("Insufficient privileges");
ws.newRequest().setMethod("POST")
- .setParam(PARAM_KEY, xoo2Profile.getKee())
+ .setParam(PARAM_ORGANIZATION, organization.getKey())
+ .setParam(PARAM_QUALITY_PROFILE, xoo2Profile.getName())
+ .setParam(PARAM_LANGUAGE, xoo2Profile.getLanguage())
.execute();
}
@Override
public List<QualityProfile> load(String projectKey) {
- StringBuilder url = new StringBuilder(WS_URL + "?projectKey=").append(encodeForUrl(projectKey));
+ StringBuilder url = new StringBuilder(WS_URL + "?project=").append(encodeForUrl(projectKey));
return handleErrors(url, () -> String.format("Failed to load the quality profiles of project '%s'", projectKey), true);
}
public void load_gets_all_profiles_for_specified_project() throws IOException {
prepareCallWithResults();
underTest.load("foo");
- verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo");
+ verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo");
}
@Test
public void load_encodes_url_parameters() throws IOException {
- WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?projectKey=foo%232", createStreamOfProfiles("qp"));
+ WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?project=foo%232", createStreamOfProfiles("qp"));
underTest.load("foo#2");
- verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo%232");
+ verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo%232");
}
@Test
when(properties.organizationKey()).thenReturn(Optional.of("my-org"));
prepareCallWithResults();
underTest.load("foo");
- verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo&organization=my-org");
+ verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo&organization=my-org");
}
@Test
public void load_tries_default_if_no_profiles_found_for_project() throws IOException {
HttpException e = new HttpException("", 404, "{\"errors\":[{\"msg\":\"No project found with key 'foo'\"}]}");
- WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?projectKey=foo", e);
+ WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?project=foo", e);
WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?defaults=true", createStreamOfProfiles("qp"));
underTest.load("foo");
- verifyCalledPath("/api/qualityprofiles/search.protobuf?projectKey=foo");
+ verifyCalledPath("/api/qualityprofiles/search.protobuf?project=foo");
verifyCalledPath("/api/qualityprofiles/search.protobuf?defaults=true");
}
when(properties.organizationKey()).thenReturn(Optional.of("my-org"));
HttpException e = new HttpException("", 404, "{\"errors\":[{\"msg\":\"No organization with key 'myorg'\"}]}");
- WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?projectKey=foo&organization=my-org", e);
+ WsTestUtil.mockException(wsClient, "/api/qualityprofiles/search.protobuf?project=foo&organization=my-org", e);
WsTestUtil.mockStream(wsClient, "/api/qualityprofiles/search.protobuf?defaults=true&organization=my-org", createStreamOfProfiles("qp"));
underTest.load("foo");
public static final String PARAM_LOGIN = "login";
public static final String PARAM_NAME = "name";
public static final String PARAM_PARAMS = "params";
- public static final String PARAM_PARENT_KEY = "parentKey";
public static final String PARAM_PARENT_QUALITY_PROFILE = "parentQualityProfile";
public static final String PARAM_KEY = "key";
public static final String PARAM_QUALITY_PROFILE = "qualityProfile";
public static final String PARAM_PROJECT = "project";
- public static final String PARAM_PROJECT_KEY = "projectKey";
- public static final String PARAM_PROJECT_UUID = "projectUuid";
public static final String PARAM_QUERY = "q";
public static final String PARAM_RESET = "reset";
public static final String PARAM_RULE = "rule";