@@ -43,12 +43,10 @@ import org.sonar.server.platform.ServerImpl; | |||
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; | |||
@@ -114,8 +112,6 @@ public class PlatformLevel1 extends PlatformLevel { | |||
ActiveRuleIndex2.class, | |||
RuleNormalizer.class, | |||
ActiveRuleNormalizer.class, | |||
RuleIndex.class, | |||
ActiveRuleIndex.class, | |||
// issues | |||
IssueIndex.class, |
@@ -43,25 +43,25 @@ import org.codehaus.staxmate.in.SMInputCursor; | |||
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) { | |||
@@ -72,12 +72,12 @@ public class QProfileBackuper { | |||
} 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()); |
@@ -75,7 +75,9 @@ public class RuleService { | |||
} | |||
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 "); | |||
} | |||
/** |
@@ -27,7 +27,6 @@ public class EsSearchModule extends Module { | |||
protected void configureModule() { | |||
add( | |||
SearchClient.class, | |||
IndexClient.class, | |||
EsClient.class); | |||
} | |||
} |
@@ -25,6 +25,7 @@ import org.junit.ClassRule; | |||
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; | |||
@@ -32,6 +33,7 @@ import org.sonar.server.es.EsTester; | |||
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; | |||
@@ -45,7 +47,11 @@ import static org.assertj.core.api.Assertions.assertThat; | |||
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); |
@@ -29,7 +29,7 @@ public class EsSearchModuleTest { | |||
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); | |||
} | |||
} |
@@ -35,22 +35,28 @@ public class DbSession implements SqlSession { | |||
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; | |||
} | |||
@@ -58,14 +64,12 @@ public class DbSession implements SqlSession { | |||
@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(); | |||
} | |||