]> source.dussan.org Git - sonarqube.git/commitdiff
Remove dead code in QProfileService
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 13 Sep 2016 12:58:09 +0000 (14:58 +0200)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Tue, 13 Sep 2016 14:02:02 +0000 (16:02 +0200)
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileService.java
server/sonar-server/src/test/java/org/sonar/server/qualityprofile/QProfileServiceMediumTest.java

index 3423ef53fd162850d44b2257cdd4e908b027af31..d6b69f64ce7b1c0f6f90a0bcc75704275a37a7af 100644 (file)
  */
 package org.sonar.server.qualityprofile;
 
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.util.Collection;
 import java.util.List;
 import java.util.Map;
-import javax.annotation.CheckForNull;
 import javax.annotation.Nullable;
 import org.sonar.api.server.ServerSide;
 import org.sonar.core.permission.GlobalPermissions;
@@ -45,21 +39,17 @@ public class QProfileService {
   private final ActiveRuleIndexer activeRuleIndexer;
   private final RuleActivator ruleActivator;
   private final QProfileFactory factory;
-  private final QProfileBackuper backuper;
-  private final QProfileCopier copier;
   private final QProfileReset reset;
   private final QProfileExporters exporters;
   private final UserSession userSession;
 
   public QProfileService(DbClient db, ActiveRuleIndexer activeRuleIndexer, RuleActivator ruleActivator, QProfileFactory factory,
-    QProfileBackuper backuper, QProfileCopier copier, QProfileReset reset, QProfileExporters exporters,
+    QProfileReset reset, QProfileExporters exporters,
     UserSession userSession) {
     this.db = db;
     this.activeRuleIndexer = activeRuleIndexer;
     this.ruleActivator = ruleActivator;
     this.factory = factory;
-    this.backuper = backuper;
-    this.copier = copier;
     this.reset = reset;
     this.exporters = exporters;
     this.userSession = userSession;
@@ -121,95 +111,11 @@ public class QProfileService {
     return ruleActivator.bulkDeactivate(ruleQuery, profile);
   }
 
-  public void backup(String profileKey, Writer writer) {
-    // Allowed to non-admin users (see http://jira.sonarsource.com/browse/SONAR-2039)
-    backuper.backup(profileKey, writer);
-  }
-
-  /**
-   * @deprecated used only by Ruby on Rails. Use {@link #backup(String, java.io.Writer)}
-   */
-  @Deprecated
-  public String backup(String profileKey) {
-    StringWriter output = new StringWriter();
-    backup(profileKey, output);
-    return output.toString();
-  }
-
-  public void restore(Reader backup) {
-    verifyAdminPermission();
-    backuper.restore(backup, null);
-  }
-
-  /**
-   * @deprecated used only by Ruby on Rails. Use {@link #restore(java.io.Reader)}
-   */
-  @Deprecated
-  public void restore(String backup) {
-    restore(new StringReader(backup));
-  }
-
   public void restoreBuiltInProfilesForLanguage(String lang) {
     verifyAdminPermission();
     reset.resetLanguage(lang);
   }
 
-  /**
-   * Currently used by Ruby on Rails
-   */
-  public Collection<String> builtInProfileNamesForLanguage(String lang) {
-    return reset.builtInProfileNamesForLanguage(lang);
-  }
-
-  public void copyToName(String fromKey, String toName) {
-    verifyAdminPermission();
-    copier.copyToName(fromKey, toName);
-  }
-
-  public void delete(String key) {
-    verifyAdminPermission();
-    DbSession session = db.openSession(false);
-    try {
-      List<ActiveRuleChange> changes = factory.delete(session, key, false);
-      session.commit();
-      activeRuleIndexer.index(changes);
-    } finally {
-      db.closeSession(session);
-    }
-  }
-
-  public void rename(String key, String newName) {
-    verifyAdminPermission();
-    factory.rename(key, newName);
-  }
-
-//  /**
-//   * Set or unset parent profile.
-//   *
-//   * @param key       key of existing profile
-//   * @param parentKey key of parent profile to be inherited from. Or <code>null</code> to unset the parent.
-//   */
-//  public void setParent(String key, @Nullable String parentKey) {
-//    verifyAdminPermission();
-//    ruleActivator.setParent(key, parentKey);
-//  }
-
-  /**
-   * Set the given quality profile as default for the related language
-   */
-  public void setDefault(String key) {
-    verifyAdminPermission();
-    factory.setDefault(key);
-  }
-
-  /**
-   * Used in /api/profiles and in /profiles/export
-   */
-  @CheckForNull
-  public QualityProfileDto getDefault(String language) {
-    return factory.getDefault(language);
-  }
-
   private void verifyAdminPermission() {
     userSession.checkLoggedIn();
     userSession.checkPermission(GlobalPermissions.QUALITY_PROFILE_ADMIN);
index c85811c55c0bdacec9e7af8b9a03a8c4bfee6cc9..e569698ba30d1dc14d9961f742b652f7eedbec36 100644 (file)
@@ -212,18 +212,6 @@ public class QProfileServiceMediumTest {
     assertThat(loader.countDeprecatedActiveRulesByProfile(XOO_P1_KEY)).isEqualTo(1);
   }
 
-  @Test
-  public void set_default() {
-    userSessionRule.login().setGlobalPermissions(GlobalPermissions.QUALITY_PROFILE_ADMIN);
-
-    assertThat(service.getDefault("xoo")).isNull();
-
-    service.setDefault(XOO_P1_KEY);
-    dbSession.clearCache();
-
-    assertThat(service.getDefault("xoo").getKey()).isEqualTo(XOO_P1_KEY);
-  }
-
   public static class XooExporter extends ProfileExporter {
     public XooExporter() {
       super("xootool", "Xoo Tool");