use EventBase.getBaseURL() in SailingNotificationServiceImpl

Change-Id: I5d2afbc26f5ddb35c877fcc0dc5126f47d795db8
This commit is contained in:
Axel Uhl committed 2016-07-15 14:27:58 +02:00
1 parent e9a3cbbbce
commit 721808aa77
2 files changed
+24 -2

No files matched your search

@@ -1,11 +1,13 @@
package com.sap.sailing.server.notification.impl;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.osgi.framework.BundleContext;
@@ -183,9 +185,23 @@ public class SailingNotificationServiceImpl implements Stoppable, SailingNotific
return createHomeRegattaLink("races", leaderboard, event);
}
/**
* The base URL for notifications as extracted from the {@link Event#getBaseURL() event}; defaults
* to {@code https://www.sapsailing.com} if no base URL has been provided for the event.
*/
private URL getBaseURL(final Event event) {
// TODO where to get the base URL?
return event.getBaseURL();
URL result;
if (event.getBaseURL() == null) {
try {
result = new URL("https://www.sapsailing.com");
} catch (MalformedURLException e) {
logger.log(Level.WARNING, "Strange... why isn't https://www.sapsailing.com a valid URL?", e);
result = null;
}
} else {
result = event.getBaseURL();
}
return result;
}
private String createHomeLeaderboardLink(Leaderboard leaderboard, Event event) {
@@ -46,6 +46,12 @@
now possible to enter a time stamp for the fix. This way it is also possible to adjust
a mark's position to a fixed lat/lng for some time point in the past.
</li>
<li>An event now has a "Base URL" which should be used to enable useful e-mail notifications with
links embedded in them that lead to the correct server. If a notification is to contain
a link to a dedicated event server, the event cannot be reached through www.sapsailing.com,
and so if this generic link is used as a default, users will end up not finding the page
linked to by the notification.
</li>
</ul>
<h2 class="articleSubheadline">June 2016</h2>