From f3f063e139e19f2cc2fb28fda89657968a027a42 Mon Sep 17 00:00:00 2001
From: srosse <none@none>
Date: Tue, 23 Oct 2012 10:34:00 +0200
Subject: [PATCH] OO-389: make retrieving default value and testing of the
 value more robust

---
 src/main/java/org/olat/user/PreferencesImpl.java | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/main/java/org/olat/user/PreferencesImpl.java b/src/main/java/org/olat/user/PreferencesImpl.java
index 1048d874980..4e83576c364 100644
--- a/src/main/java/org/olat/user/PreferencesImpl.java
+++ b/src/main/java/org/olat/user/PreferencesImpl.java
@@ -26,6 +26,7 @@
 package org.olat.user;
 
 import org.olat.core.id.Preferences;
+import org.olat.core.util.StringHelper;
 import org.olat.core.util.i18n.I18nManager;
 import org.olat.core.util.notifications.NotificationsManager;
 
@@ -38,7 +39,10 @@ import org.olat.core.util.notifications.NotificationsManager;
  *
  * @author guido
  */
-public class PreferencesImpl implements Preferences{
+public class PreferencesImpl implements Preferences {
+
+	private static final long serialVersionUID = -8013230820111033911L;
+	
 	private String language;
 	private String fontsize;
 	private String notificationInterval;
@@ -107,8 +111,12 @@ public class PreferencesImpl implements Preferences{
 	public String getNotificationInterval() {
 		// Always return a valid notification interval
 		NotificationsManager notiMgr = NotificationsManager.getInstance();
-		if (notificationInterval == null || notificationInterval.isEmpty()
-				|| notiMgr == null || !notiMgr.getEnabledNotificationIntervals().contains(notificationInterval)) {
+		if (!StringHelper.containsNonWhitespace(notificationInterval)) {
+			if(notiMgr != null) {
+				notificationInterval = notiMgr.getDefaultNotificationInterval();
+			}
+		} else if(notiMgr != null && notiMgr.getEnabledNotificationIntervals() != null
+			&& !notiMgr.getEnabledNotificationIntervals().contains(notificationInterval)) {
 			notificationInterval = notiMgr.getDefaultNotificationInterval();
 		}
 		return notificationInterval;
@@ -157,7 +165,5 @@ public class PreferencesImpl implements Preferences{
 	 */
 	public void setPresenceMessagesPublic(boolean b) {
 		this.presenceMessagesPublic = b;
-		
 	}
-
 }
\ No newline at end of file
-- 
GitLab