import org.sonar.server.platform.ServerSettings;
import org.sonar.server.platform.TempFolderProvider;
import org.sonar.server.qualityprofile.db.ActiveRuleDao;
-import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
import org.sonar.server.qualityprofile.index.ActiveRuleIndex2;
import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer;
import org.sonar.server.ruby.PlatformRackBridge;
import org.sonar.server.rule.db.RuleDao;
-import org.sonar.server.rule.index.RuleIndex;
import org.sonar.server.rule.index.RuleIndex2;
import org.sonar.server.rule.index.RuleNormalizer;
import org.sonar.server.search.EsSearchModule;
ActiveRuleIndex2.class,
RuleNormalizer.class,
ActiveRuleNormalizer.class,
- RuleIndex.class,
- ActiveRuleIndex.class,
// issues
IssueIndex.class,
import org.sonar.api.rule.RuleKey;
import org.sonar.api.server.ServerSide;
import org.sonar.api.utils.text.XmlWriter;
+import org.sonar.db.DbClient;
import org.sonar.db.DbSession;
import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.db.DbClient;
-import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
-import org.sonar.server.search.IndexClient;
+import org.sonar.server.qualityprofile.index.ActiveRuleDoc;
+import org.sonar.server.qualityprofile.index.ActiveRuleIndex2;
@ServerSide
public class QProfileBackuper {
private final QProfileReset reset;
private final DbClient db;
- private final IndexClient index;
+ private final ActiveRuleIndex2 activeRuleIndex;
private static final Joiner RULEKEY_JOINER = Joiner.on(", ").skipNulls();
- public QProfileBackuper(QProfileReset reset, DbClient db, IndexClient index) {
+ public QProfileBackuper(QProfileReset reset, DbClient db, ActiveRuleIndex2 activeRuleIndex) {
this.reset = reset;
this.db = db;
- this.index = index;
+ this.activeRuleIndex = activeRuleIndex;
}
public void backup(String key, Writer writer) {
} finally {
dbSession.close();
}
- List<ActiveRule> activeRules = Lists.newArrayList(index.get(ActiveRuleIndex.class).findByProfile(profile.getKey()));
+ List<ActiveRuleDoc> activeRules = Lists.newArrayList(activeRuleIndex.findByProfile(profile.getKey()));
Collections.sort(activeRules, BackupActiveRuleComparator.INSTANCE);
writeXml(writer, profile, activeRules.iterator());
}
- private static void writeXml(Writer writer, QualityProfileDto profile, Iterator<ActiveRule> activeRules) {
+ private static void writeXml(Writer writer, QualityProfileDto profile, Iterator<ActiveRuleDoc> activeRules) {
XmlWriter xml = XmlWriter.of(writer).declaration();
xml.begin("profile");
xml.prop("name", profile.getName());
}
public Result<Rule> search(RuleQuery query, QueryContext options) {
- return index.search(query, options);
+ // TODO replace QueryContext by SearchOptions
+ // return index.search(query, options);
+ throw new UnsupportedOperationException("Wait for replacement of QueryContext by SearchOptions ");
}
/**
protected void configureModule() {
add(
SearchClient.class,
- IndexClient.class,
EsClient.class);
}
}
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
+import org.sonar.api.config.Settings;
import org.sonar.api.utils.System2;
import org.sonar.db.DbTester;
import org.sonar.db.rule.RuleTesting;
import org.sonar.server.issue.IssueTesting;
import org.sonar.server.issue.index.IssueIndexDefinition;
import org.sonar.server.rule.index.RuleDoc;
+import org.sonar.server.rule.index.RuleIndexDefinition;
import org.sonar.server.rule.index.RuleNormalizer;
import org.sonar.server.search.IndexDefinition;
import org.sonar.server.view.index.ViewDoc;
public class BackendCleanupMediumTest {
@ClassRule
- public static EsTester esTester = new EsTester();
+ public static EsTester esTester = new EsTester().addDefinitions(
+ new RuleIndexDefinition(new Settings()),
+ new IssueIndexDefinition(new Settings()),
+ new ViewIndexDefinition(new Settings())
+ );
@Rule
public DbTester dbTester = DbTester.create(System2.INSTANCE);
public void verify_count_of_added_components() {
ComponentContainer container = new ComponentContainer();
new EsSearchModule().configure(container);
- assertThat(container.size()).isEqualTo(5);
+ assertThat(container.size()).isEqualTo(4);
}
}
private List<ClusterAction> actions;
- private WorkQueue queue;
private SqlSession session;
private int actionCount;
public DbSession(WorkQueue queue, SqlSession session) {
this.actionCount = 0;
this.session = session;
- this.queue = queue;
this.actions = new ArrayList<>();
}
+ /**
+ * @deprecated since 5.5, not used anymore
+ */
+ @Deprecated
public void enqueue(ClusterAction action) {
actionCount++;
this.actions.add(action);
}
+ /**
+ * @deprecated since 5.5, not used anymore
+ */
+ @Deprecated
public int getActionCount() {
return actionCount;
}
@Override
public void commit() {
session.commit();
- queue.enqueue(actions);
actions.clear();
}
@Override
public void commit(boolean force) {
session.commit(force);
- queue.enqueue(actions);
actions.clear();
}