Skip to content
Snippets Groups Projects
Commit f3f063e1 authored by srosse's avatar srosse
Browse files

OO-389: make retrieving default value and testing of the value more robust

parent 0a576ef4
No related branches found
No related tags found
No related merge requests found
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
package org.olat.user; package org.olat.user;
import org.olat.core.id.Preferences; import org.olat.core.id.Preferences;
import org.olat.core.util.StringHelper;
import org.olat.core.util.i18n.I18nManager; import org.olat.core.util.i18n.I18nManager;
import org.olat.core.util.notifications.NotificationsManager; import org.olat.core.util.notifications.NotificationsManager;
...@@ -38,7 +39,10 @@ import org.olat.core.util.notifications.NotificationsManager; ...@@ -38,7 +39,10 @@ import org.olat.core.util.notifications.NotificationsManager;
* *
* @author guido * @author guido
*/ */
public class PreferencesImpl implements Preferences{ public class PreferencesImpl implements Preferences {
private static final long serialVersionUID = -8013230820111033911L;
private String language; private String language;
private String fontsize; private String fontsize;
private String notificationInterval; private String notificationInterval;
...@@ -107,8 +111,12 @@ public class PreferencesImpl implements Preferences{ ...@@ -107,8 +111,12 @@ public class PreferencesImpl implements Preferences{
public String getNotificationInterval() { public String getNotificationInterval() {
// Always return a valid notification interval // Always return a valid notification interval
NotificationsManager notiMgr = NotificationsManager.getInstance(); NotificationsManager notiMgr = NotificationsManager.getInstance();
if (notificationInterval == null || notificationInterval.isEmpty() if (!StringHelper.containsNonWhitespace(notificationInterval)) {
|| notiMgr == null || !notiMgr.getEnabledNotificationIntervals().contains(notificationInterval)) { if(notiMgr != null) {
notificationInterval = notiMgr.getDefaultNotificationInterval();
}
} else if(notiMgr != null && notiMgr.getEnabledNotificationIntervals() != null
&& !notiMgr.getEnabledNotificationIntervals().contains(notificationInterval)) {
notificationInterval = notiMgr.getDefaultNotificationInterval(); notificationInterval = notiMgr.getDefaultNotificationInterval();
} }
return notificationInterval; return notificationInterval;
...@@ -157,7 +165,5 @@ public class PreferencesImpl implements Preferences{ ...@@ -157,7 +165,5 @@ public class PreferencesImpl implements Preferences{
*/ */
public void setPresenceMessagesPublic(boolean b) { public void setPresenceMessagesPublic(boolean b) {
this.presenceMessagesPublic = b; this.presenceMessagesPublic = b;
} }
} }
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment