use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddGroupAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, request.mandatoryParam(PARAM_QUALITY_PROFILE), request.mandatoryParam(PARAM_LANGUAGE));
wsSupport.checkCanEdit(dbSession, profile);
GroupDto user = wsSupport.getGroup(dbSession, request.mandatoryParam(PARAM_GROUP));
addGroup(dbSession, profile, user);
}
response.noContent();
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class AddUserAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, request.mandatoryParam(PARAM_QUALITY_PROFILE), request.mandatoryParam(PARAM_LANGUAGE));
wsSupport.checkCanEdit(dbSession, profile);
UserDto user = wsSupport.getUser(dbSession, request.mandatoryParam(PARAM_LOGIN));
addUser(dbSession, profile, user);
}
response.noContent();
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class RestoreAction method writeResponse.
private void writeResponse(JsonWriter json, QProfileRestoreSummary summary) {
QProfileDto profile = summary.getProfile();
String languageKey = profile.getLanguage();
Language language = languages.get(languageKey);
JsonWriter jsonProfile = json.beginObject().name("profile").beginObject();
jsonProfile.prop("key", profile.getKee()).prop("name", profile.getName()).prop("language", languageKey).prop("isDefault", false).prop("isInherited", false);
if (language != null) {
jsonProfile.prop("languageName", language.getName());
}
jsonProfile.endObject();
BulkChangeResult ruleChanges = summary.getRuleChanges();
json.prop("ruleSuccesses", ruleChanges.countSucceeded());
json.prop("ruleFailures", ruleChanges.countFailed());
json.endObject().close();
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class ChangelogAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
QProfileReference reference = QProfileReference.fromName(request);
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, reference);
QProfileChangeQuery query = new QProfileChangeQuery(profile.getKee());
Date since = parseStartingDateOrDateTime(request.param(PARAM_SINCE));
if (since != null) {
query.setFromIncluded(since.getTime());
}
Date to = parseEndingDateOrDateTime(request.param(PARAM_TO));
if (to != null) {
query.setToExcluded(to.getTime());
}
int page = request.mandatoryParamAsInt(Param.PAGE);
int pageSize = request.mandatoryParamAsInt(Param.PAGE_SIZE);
query.setPage(page, pageSize);
int total = dbClient.qProfileChangeDao().countByQuery(dbSession, query);
List<Change> changelogs = load(dbSession, query);
Map<String, UserDto> usersByUuid = getUsersByUserUuid(dbSession, changelogs);
Map<String, RuleDefinitionDto> rulesByRuleIds = getRulesByRuleUuids(dbSession, changelogs);
writeResponse(response.newJsonWriter(), total, page, pageSize, changelogs, usersByUuid, rulesByRuleIds);
}
}
use of org.sonar.db.qualityprofile.QProfileDto in project sonarqube by SonarSource.
the class DeleteAction method handle.
@Override
public void handle(Request request, Response response) {
userSession.checkLoggedIn();
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, QProfileReference.fromName(request));
wsSupport.checkCanEdit(dbSession, profile);
Collection<QProfileDto> descendants = selectDescendants(dbSession, profile);
ensureNoneIsMarkedAsDefault(dbSession, profile, descendants);
profileFactory.delete(dbSession, merge(profile, descendants));
dbSession.commit();
}
response.noContent();
}
Aggregations