use of org.sonar.api.utils.text.XmlWriter in project sonarqube by SonarSource.
the class QProfileBackuper method writeXml.
private void writeXml(DbSession dbSession, Writer writer, QualityProfileDto profile, Iterator<ActiveRuleDto> activeRules) {
XmlWriter xml = XmlWriter.of(writer).declaration();
xml.begin("profile");
xml.prop("name", profile.getName());
xml.prop("language", profile.getLanguage());
xml.begin("rules");
while (activeRules.hasNext()) {
ActiveRuleDto activeRule = activeRules.next();
xml.begin("rule");
xml.prop("repositoryKey", activeRule.getKey().ruleKey().repository());
xml.prop("key", activeRule.getKey().ruleKey().rule());
xml.prop("priority", activeRule.getSeverityString());
xml.begin("parameters");
for (ActiveRuleParamDto param : db.activeRuleDao().selectParamsByActiveRuleId(dbSession, activeRule.getId())) {
xml.begin("parameter").prop("key", param.getKey()).prop("value", param.getValue()).end();
}
xml.end("parameters");
xml.end("rule");
}
xml.end("rules").end("profile").close();
}
use of org.sonar.api.utils.text.XmlWriter in project sonarqube by SonarSource.
the class QProfileParser method writeXml.
public void writeXml(Writer writer, QProfileDto profile, Iterator<ExportRuleDto> rulesToExport) {
XmlWriter xml = XmlWriter.of(writer).declaration();
xml.begin(ATTRIBUTE_PROFILE);
xml.prop(ATTRIBUTE_NAME, profile.getName());
xml.prop(ATTRIBUTE_LANGUAGE, profile.getLanguage());
xml.begin(ATTRIBUTE_RULES);
while (rulesToExport.hasNext()) {
ExportRuleDto ruleToExport = rulesToExport.next();
xml.begin(ATTRIBUTE_RULE);
xml.prop(ATTRIBUTE_REPOSITORY_KEY, ruleToExport.getRuleKey().repository());
xml.prop(ATTRIBUTE_KEY, ruleToExport.getRuleKey().rule());
xml.prop(ATTRIBUTE_TYPE, ruleToExport.getRuleType().name());
xml.prop(ATTRIBUTE_PRIORITY, ruleToExport.getSeverityString());
if (ruleToExport.isCustomRule()) {
xml.prop(ATTRIBUTE_NAME, ruleToExport.getName());
xml.prop(ATTRIBUTE_TEMPLATE_KEY, ruleToExport.getTemplateRuleKey().rule());
xml.prop(ATTRIBUTE_DESCRIPTION, ruleToExport.getDescription());
}
xml.begin(ATTRIBUTE_PARAMETERS);
for (ExportRuleParamDto param : ruleToExport.getParams()) {
xml.begin(ATTRIBUTE_PARAMETER).prop(ATTRIBUTE_PARAMETER_KEY, param.getKey()).prop(ATTRIBUTE_PARAMETER_VALUE, param.getValue()).end();
}
xml.end(ATTRIBUTE_PARAMETERS);
xml.end(ATTRIBUTE_RULE);
}
xml.end(ATTRIBUTE_RULES).end(ATTRIBUTE_PROFILE).close();
}
Aggregations