From 3d24aa0b1100258b120a4019bd2b1ef60beaebc2 Mon Sep 17 00:00:00 2001 From: Stephane Gamard Date: Fri, 30 May 2014 17:29:32 +0200 Subject: [PATCH] fix quality flaw --- .../server/qualityprofile/RuleActivator.java | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java index 23af402881f..260ed0a9f1c 100644 --- a/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java +++ b/sonar-server/src/main/java/org/sonar/server/qualityprofile/RuleActivator.java @@ -102,8 +102,8 @@ public class RuleActivator implements ServerComponent { DbSession dbSession = db.openSession(false); List changes = Lists.newArrayList(); try { - changes = activate(activation, dbSession); - if (changes.isEmpty()) { + changes.addAll(activate(activation, dbSession)); + if (!changes.isEmpty()) { dbSession.commit(); previewCache.reportGlobalModification(); } @@ -118,16 +118,9 @@ public class RuleActivator implements ServerComponent { */ List activate(RuleActivation activation, DbSession dbSession) { - List changes = Lists.newArrayList(); - RuleActivationContext context = contextFactory.create(activation.getKey(), dbSession); - - System.out.println("Activation for key: " + activation.getKey() + - " -- Inheritance: " + ((context.activeRule() == null) ? "" : context.activeRule().getInheritance()) + - " -- activate by inheritance: " + activation.isCascade()); - + List changes = Lists.newArrayList(); ActiveRuleChange change = null; - if (context.activeRule() == null) { change = new ActiveRuleChange(ActiveRuleChange.Type.ACTIVATED, activation.getKey()); @@ -155,14 +148,11 @@ public class RuleActivator implements ServerComponent { verifyParam(ruleParamDto, value); change.setParameter(ruleParamDto.getName(), StringUtils.defaultIfEmpty(value, ruleParamDto.getDefaultValue())); } + changes.add(change); // TODO filter changes without any differences - //Persist all changes to activeRule - ActiveRuleDto activeRule = persist(change, context, dbSession); - - System.out.println("-- activated key: " + activation.getKey() + - " -- Inheritance: " + activeRule.getInheritance()); + persist(change, context, dbSession); // Execute the cascade on the child if NOT overrides changes.addAll(cascadeActivation(dbSession, activation)); -- 2.39.5