]> source.dussan.org Git - sonarqube.git/commitdiff
Fix creation of administrator
authorSimon Brandhof <simon.brandhof@gmail.com>
Wed, 11 Jul 2012 22:44:58 +0000 (00:44 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Wed, 11 Jul 2012 22:44:58 +0000 (00:44 +0200)
sonar-server/src/main/java/org/sonar/server/ui/JRubyFacade.java
sonar-server/src/main/webapp/WEB-INF/app/models/user.rb

index d2f4a2bb4496903a97b9c419c0d21d1b3a736729..1c3f88c779bad0e5ce725d82569f0bdf3f3c3b73 100644 (file)
@@ -520,10 +520,14 @@ public final class JRubyFacade {
 
   // USERS
   public void onNewUser(Map<String, String> fields) {
-    getContainer().getComponentByType(NewUserNotifier.class).onNewUser(NewUserHandler.Context.builder()
-      .setLogin(fields.get("login"))
-      .setName(fields.get("name"))
-      .setEmail(fields.get("email"))
-      .build());
+    NewUserNotifier notifier = getContainer().getComponentByType(NewUserNotifier.class);
+    // notifier is null when creating the administrator in the migration script 011.
+    if (notifier != null) {
+      notifier.onNewUser(NewUserHandler.Context.builder()
+        .setLogin(fields.get("login"))
+        .setName(fields.get("name"))
+        .setEmail(fields.get("email"))
+        .build());
+    }
   }
 }
index 152900bede970d591ca6af903fcb21d9c6e47154..c70d33985a4cc50f3945d9f64b08ff4d6c928bd9 100644 (file)
@@ -207,10 +207,6 @@ class User < ActiveRecord::Base
   private
 
   def on_create
-    facade = Java::OrgSonarServerUi::JRubyFacade.getInstance()
-    if facade
-      # the facade is null when creating the administration in migration 011
-      facade.onNewUser({'login' => self.login, 'name' => self.name, 'email' => self.email})
-    end
+    Java::OrgSonarServerUi::JRubyFacade.getInstance().onNewUser({'login' => self.login, 'name' => self.name, 'email' => self.email})
   end
 end