diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2012-01-09 11:51:45 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2012-01-09 12:51:52 +0100 |
commit | 2b8dd23ae0e30516cf8a88eb8dd80cce1bef9f02 (patch) | |
tree | 90abd5b98e594e1df7688017c6c686a70f7e209f /sonar-server | |
parent | e26f40aecb62761069f1e60aa132c0b68c6c1f97 (diff) | |
download | sonarqube-2b8dd23ae0e30516cf8a88eb8dd80cce1bef9f02.tar.gz sonarqube-2b8dd23ae0e30516cf8a88eb8dd80cce1bef9f02.zip |
Add logs when restoring backup of configuration
Diffstat (limited to 'sonar-server')
5 files changed, 13 insertions, 2 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/Backup.java b/sonar-server/src/main/java/org/sonar/server/configuration/Backup.java index b1cc6b5502b..cc2c6f15209 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/Backup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/Backup.java @@ -28,6 +28,7 @@ import com.thoughtworks.xstream.io.xml.XppDriver; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.CharEncoding; import org.apache.commons.lang.StringUtils; +import org.slf4j.LoggerFactory; import org.sonar.api.database.DatabaseSession; import org.sonar.jpa.entity.SchemaMigration; @@ -107,6 +108,7 @@ public class Backup { try { startDb(); doImportXml(xml); + LoggerFactory.getLogger(getClass()).info("Backup restored"); } finally { stopDb(); } diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/MetricsBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/MetricsBackup.java index d4859c546d3..7e16923a48b 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/MetricsBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/MetricsBackup.java @@ -25,6 +25,7 @@ import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext; import com.thoughtworks.xstream.io.HierarchicalStreamReader; import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import org.slf4j.LoggerFactory; import org.sonar.api.database.DatabaseSession; import org.sonar.api.measures.Metric; import org.sonar.jpa.dao.MeasuresDao; @@ -52,16 +53,18 @@ public class MetricsBackup implements Backupable { } public void importXml(SonarConfig sonarConfig) { - disabledUserDefinedMetrics(); + disableUserDefinedMetrics(); registerMetrics(sonarConfig); } - protected void disabledUserDefinedMetrics() { + protected void disableUserDefinedMetrics() { + LoggerFactory.getLogger(getClass()).info("Disable user-defined metrics"); Collection<Metric> dbMetrics = measuresDao.getUserDefinedMetrics(); measuresDao.disabledMetrics(dbMetrics); } protected void registerMetrics(SonarConfig sonarConfig) { + LoggerFactory.getLogger(getClass()).info("Restore metrics"); Collection<Metric> newMetrics = sonarConfig.getMetrics(); measuresDao.registerMetrics(newMetrics); } diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java index daea84804a5..2e5493f70a8 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/ProfilesBackup.java @@ -77,11 +77,13 @@ public class ProfilesBackup implements Backupable { public void importXml(SonarConfig sonarConfig) { if (CollectionUtils.isNotEmpty(sonarConfig.getProfiles())) { + LoggerFactory.getLogger(getClass()).info("Delete profiles"); ProfilesManager profilesManager = new ProfilesManager(session, null); profilesManager.deleteAllProfiles(); RulesDao rulesDao = new RulesDao(session); for (RulesProfile profile : sonarConfig.getProfiles()) { + LoggerFactory.getLogger(getClass()).info("Restore profile " + profile.getName()); importProfile(rulesDao, profile); } } diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/PropertiesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/PropertiesBackup.java index 5b8dbc943f3..d73d3b46151 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/PropertiesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/PropertiesBackup.java @@ -21,6 +21,7 @@ package org.sonar.server.configuration; import com.thoughtworks.xstream.XStream; import org.apache.commons.collections.CollectionUtils; +import org.slf4j.LoggerFactory; import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.configuration.Property; @@ -49,6 +50,7 @@ public class PropertiesBackup implements Backupable { } public void importXml(SonarConfig sonarConfig) { + LoggerFactory.getLogger(getClass()).info("Restore properties"); clearProperties(); if (CollectionUtils.isNotEmpty(sonarConfig.getProperties())) { diff --git a/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java b/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java index 955ceeca8bb..8e1423a881e 100644 --- a/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java +++ b/sonar-server/src/main/java/org/sonar/server/configuration/RulesBackup.java @@ -78,6 +78,7 @@ public class RulesBackup implements Backupable { } private void disableUserRules() { + LoggerFactory.getLogger(getClass()).info("Disable rules created by user"); for (Rule rule : getUserRules()) { rule.setEnabled(false); session.save(rule); @@ -85,6 +86,7 @@ public class RulesBackup implements Backupable { } private void registerUserRules(Collection<Rule> rules) { + LoggerFactory.getLogger(getClass()).info("Restore rules"); for (Rule rule : rules) { Rule parent = rule.getParent(); Rule matchingParentRuleInDb = rulesDao.getRuleByKey(parent.getRepositoryKey(), parent.getKey()); |