use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class RuleActivatorContextFactory method create.
RuleActivatorContext create(String profileKey, RuleKey ruleKey, DbSession session) {
RuleActivatorContext context = new RuleActivatorContext();
QualityProfileDto profile = db.qualityProfileDao().selectByKey(session, profileKey);
checkRequest(profile != null, "Quality profile not found: %s", profileKey);
context.setProfile(profile);
return create(ruleKey, session, context);
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class RuleActivatorContextFactory method create.
RuleActivatorContext create(QProfileName profileName, RuleKey ruleKey, DbSession session) {
RuleActivatorContext context = new RuleActivatorContext();
QualityProfileDto profile = db.qualityProfileDao().selectByNameAndLanguage(profileName.getName(), profileName.getLanguage(), session);
checkRequest(profile != null, "Quality profile not found: %s", profileName);
context.setProfile(profile);
return create(ruleKey, session, context);
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class BackupAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
Stream stream = response.stream();
stream.setMediaType(MediaTypes.XML);
try (OutputStreamWriter writer = new OutputStreamWriter(stream.output(), StandardCharsets.UTF_8);
DbSession dbSession = dbClient.openSession(false)) {
QualityProfileDto profile = profileFactory.find(dbSession, QProfileRef.from(request));
response.setHeader("Content-Disposition", String.format("attachment; filename=%s.xml", profile.getKee()));
backuper.backup(profile.getKee(), writer);
}
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class ChangeParentAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
qProfileWsSupport.checkQProfileAdminPermission();
try (DbSession dbSession = dbClient.openSession(false)) {
QualityProfileDto profile = profileFactory.find(dbSession, QProfileRef.from(request));
String parentKey = request.param(PARAM_PARENT_KEY);
String parentName = request.param(PARAM_PARENT_NAME);
if (isEmpty(parentKey) && isEmpty(parentName)) {
ruleActivator.setParent(dbSession, profile.getKey(), null);
} else {
QProfileRef parentRef = QProfileRef.from(parentKey, request.param(QProfileRef.PARAM_LANGUAGE), parentName);
QualityProfileDto parent = profileFactory.find(dbSession, parentRef);
ruleActivator.setParent(dbSession, profile.getKey(), parent.getKey());
}
response.noContent();
}
}
use of org.sonar.db.qualityprofile.QualityProfileDto in project sonarqube by SonarSource.
the class QProfileBackuper method backup.
/**
* @deprecated use {@link #backup(DbSession, QualityProfileDto, Writer)} instead
*/
@Deprecated
public void backup(String key, Writer writer) {
try (DbSession dbSession = db.openSession(false)) {
QualityProfileDto profile = db.qualityProfileDao().selectOrFailByKey(dbSession, key);
backup(dbSession, profile, writer);
}
}
Aggregations