From ce7a0f35a776f0bcd5d179a239042bcd97b7e3be Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Thu, 5 Sep 2013 16:49:26 +0200 Subject: [PATCH] SONAR-4602 Evict dryRun cache on profile restore --- .../org/sonar/server/rules/ProfilesConsole.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/rules/ProfilesConsole.java b/sonar-server/src/main/java/org/sonar/server/rules/ProfilesConsole.java index 557da01b302..b662f2bff3c 100644 --- a/sonar-server/src/main/java/org/sonar/server/rules/ProfilesConsole.java +++ b/sonar-server/src/main/java/org/sonar/server/rules/ProfilesConsole.java @@ -32,6 +32,7 @@ import org.sonar.api.profiles.XMLProfileSerializer; import org.sonar.api.rules.ActiveRule; import org.sonar.api.rules.ActiveRuleParam; import org.sonar.api.utils.ValidationMessages; +import org.sonar.core.dryrun.DryRunCache; import org.sonar.jpa.session.DatabaseSessionFactory; import java.io.StringReader; @@ -50,19 +51,21 @@ public final class ProfilesConsole implements ServerComponent { private XMLProfileSerializer xmlProfileSerializer; private List exporters = newArrayList(); private List importers = newArrayList(); + private DryRunCache dryRunCache; - public ProfilesConsole(DatabaseSessionFactory sessionFactory, XMLProfileParser xmlProfileParser, XMLProfileSerializer xmlProfileSerializer) { + public ProfilesConsole(DatabaseSessionFactory sessionFactory, XMLProfileParser xmlProfileParser, XMLProfileSerializer xmlProfileSerializer, DryRunCache dryRunCache) { this.sessionFactory = sessionFactory; this.xmlProfileParser = xmlProfileParser; this.xmlProfileSerializer = xmlProfileSerializer; + this.dryRunCache = dryRunCache; this.exporters = newArrayList(); this.importers = newArrayList(); } public ProfilesConsole(DatabaseSessionFactory sessionFactory, XMLProfileParser xmlProfileParser, XMLProfileSerializer xmlProfileSerializer, - ProfileExporter[] exporters, - ProfileImporter[] importers) { - this(sessionFactory, xmlProfileParser, xmlProfileSerializer); + ProfileExporter[] exporters, + ProfileImporter[] importers, DryRunCache dryRunCache) { + this(sessionFactory, xmlProfileParser, xmlProfileSerializer, dryRunCache); this.exporters.addAll(Arrays.asList(exporters)); this.importers.addAll(Arrays.asList(importers)); } @@ -88,11 +91,12 @@ public final class ProfilesConsole implements ServerComponent { messages.addErrorText("The profile " + profile + " already exists. Please delete it before restoring."); } else { - if (existingProfile!=null) { + if (existingProfile != null) { session.removeWithoutFlush(existingProfile); } session.saveWithoutFlush(profile); session.commit(); + dryRunCache.reportGlobalModification(); } } return messages; -- 2.39.5