diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-07-21 11:45:41 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-07-22 18:52:15 +0400 |
commit | 957e62ce77e23d31d59f9369657e91a9dd616c84 (patch) | |
tree | b78bf8831d41c82fa34cd071a3783f756f08d745 /sonar-core | |
parent | e0e528211faad3fdf469c83bcbc7aecf6c25a234 (diff) | |
download | sonarqube-957e62ce77e23d31d59f9369657e91a9dd616c84.tar.gz sonarqube-957e62ce77e23d31d59f9369657e91a9dd616c84.zip |
SONAR-2607 Provide email notifications on review changes
* Add email templates.
* Add server component - UserFinder.
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/components/DefaultUserFinder.java | 43 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/jpa/entity/NotificationQueueElement.java | 7 |
2 files changed, 47 insertions, 3 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/components/DefaultUserFinder.java b/sonar-core/src/main/java/org/sonar/core/components/DefaultUserFinder.java new file mode 100644 index 00000000000..648aa104fb5 --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/components/DefaultUserFinder.java @@ -0,0 +1,43 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.core.components; + +import org.sonar.api.database.DatabaseSession; +import org.sonar.api.database.model.User; +import org.sonar.api.security.UserFinder; +import org.sonar.jpa.session.DatabaseSessionFactory; + +/** + * @since 2.10 + */ +public class DefaultUserFinder implements UserFinder { + + private DatabaseSessionFactory sessionFactory; + + public DefaultUserFinder(DatabaseSessionFactory sessionFactory) { + this.sessionFactory = sessionFactory; + } + + public User findByLogin(String login) { + DatabaseSession session = sessionFactory.getSession(); + return session.getSingleResult(User.class, "login", login); + } + +} diff --git a/sonar-core/src/main/java/org/sonar/jpa/entity/NotificationQueueElement.java b/sonar-core/src/main/java/org/sonar/jpa/entity/NotificationQueueElement.java index 198cd0871ce..ac80cec95e6 100644 --- a/sonar-core/src/main/java/org/sonar/jpa/entity/NotificationQueueElement.java +++ b/sonar-core/src/main/java/org/sonar/jpa/entity/NotificationQueueElement.java @@ -20,6 +20,7 @@ package org.sonar.jpa.entity; import org.sonar.api.notifications.Notification; +import org.sonar.api.utils.SonarException; import java.io.*; import java.util.Date; @@ -65,7 +66,7 @@ public class NotificationQueueElement { objectOutputStream.close(); this.data = byteArrayOutputStream.toByteArray(); } catch (IOException e) { - throw new RuntimeException(e); + throw new SonarException(e); } } @@ -80,9 +81,9 @@ public class NotificationQueueElement { objectInputStream.close(); return (Notification) result; } catch (IOException e) { - throw new RuntimeException(e); + throw new SonarException(e); } catch (ClassNotFoundException e) { - throw new RuntimeException(e); + throw new SonarException(e); } } |