java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/Activator.java
... ...
@@ -1,27 +1,31 @@
1 1
package com.sap.sailing.gwt.ui.server;
2 2
3
-import java.util.logging.Logger;
4
-
5 3
import org.osgi.framework.BundleActivator;
6 4
import org.osgi.framework.BundleContext;
7 5
8 6
import com.sap.sailing.gwt.ui.shared.racemap.GoogleMapsLoader;
9 7
10 8
public class Activator implements BundleActivator {
11
- private static final Logger logger = Logger.getLogger(Activator.class.getName());
12
-
13 9
private static BundleContext context;
14 10
private SailingServiceImpl sailingServiceToStopWhenStopping;
15 11
private static Activator INSTANCE;
16 12
17 13
private final static String GOOGLE_MAPS_LOADER_AUTHENTICATION_PARAMS_PROPERTY_NAME = "google.maps.authenticationparams";
18 14
15
+ private final static String YOUTUBE_V3_API_KEY_PROPERTY_NAME = "youtube.api.key";
16
+
19 17
/**
20 18
* Required by {@link GoogleMapsLoader#load(Runnable, String)} and to be provided through a system property named
21 19
* after {@link GOOGLE_MAPS_LOADER_AUTHENTICATION_PARAMS_PROPERTY_NAME}. The value would be something like
22 20
* {@code client=abcde&channel=fghij}.
23 21
*/
24 22
private String googleMapsLoaderAuthenticationParams;
23
+
24
+ /**
25
+ * A secret for accessing the YouTube V3 API; provided through the system property named as specified by
26
+ * {@link #YOUTUBE_V3_API_KEY_PROPERTY_NAME}.
27
+ */
28
+ private String youtubeApiKey;
25 29
26 30
public Activator() {
27 31
INSTANCE = this;
... ...
@@ -31,11 +35,7 @@ public class Activator implements BundleActivator {
31 35
public void start(BundleContext context) throws Exception {
32 36
Activator.context = context;
33 37
googleMapsLoaderAuthenticationParams = context.getProperty(GOOGLE_MAPS_LOADER_AUTHENTICATION_PARAMS_PROPERTY_NAME);
34
- if (googleMapsLoaderAuthenticationParams == null) {
35
- googleMapsLoaderAuthenticationParams = "key=AIzaSyD1Se4tIkt-wglccbco3S7twaHiG20hR9E";
36
- logger.warning("Did not find a value for the "+GOOGLE_MAPS_LOADER_AUTHENTICATION_PARAMS_PROPERTY_NAME+
37
- " system property. Using a test key for the Google Maps API instead. Your mileage may vary.");
38
- }
38
+ youtubeApiKey = context.getProperty(YOUTUBE_V3_API_KEY_PROPERTY_NAME);
39 39
}
40 40
41 41
@Override
... ...
@@ -64,6 +64,10 @@ public class Activator implements BundleActivator {
64 64
public String getGoogleMapsLoaderAuthenticationParams() {
65 65
return googleMapsLoaderAuthenticationParams;
66 66
}
67
+
68
+ public String getYoutubeApiKey() {
69
+ return youtubeApiKey;
70
+ }
67 71
68 72
public void setSailingService(SailingServiceImpl sailingServiceImpl) {
69 73
sailingServiceToStopWhenStopping = sailingServiceImpl;
java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/MediaServiceImpl.java
... ...
@@ -49,8 +49,6 @@ import com.sap.sse.common.impl.MillisecondsDurationImpl;
49 49
import com.sap.sse.security.ui.server.SecurityDTOUtil;
50 50
51 51
public class MediaServiceImpl extends RemoteServiceServlet implements MediaService {
52
- private String YOUTUBE_V3_API_KEY = "AIzaSyBPJQx0nIjYJmIaOBu0m28pEau8WKENMxs";
53
-
54 52
private static final Logger logger = Logger.getLogger(MediaServiceImpl.class.getName());
55 53
56 54
private static final int METADATA_CONNECTION_TIMEOUT = 10000;
... ...
@@ -245,7 +243,7 @@ public class MediaServiceImpl extends RemoteServiceServlet implements MediaServi
245 243
videoId = URLEncoder.encode(videoId, StandardCharsets.UTF_8.name());
246 244
try {
247 245
URL apiURL = new URL(
248
- "https://www.googleapis.com/youtube/v3/videos?id=" + videoId + "&key=" + YOUTUBE_V3_API_KEY
246
+ "https://www.googleapis.com/youtube/v3/videos?id=" + videoId + "&key=" + Activator.getInstance().getYoutubeApiKey()
249 247
+ "&part=snippet,contentDetails&fields=items(snippet/title,contentDetails/duration)");
250 248
URLConnection connection = apiURL.openConnection();
251 249
connection.setRequestProperty("Referer", "http://mediaservice.sapsailing.com/");
java/com.sap.sailing.server/SailingServer (No Proxy, Axel).launch
... ...
@@ -24,7 +24,7 @@
24 24
<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
25 25
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console 12001 -clean"/>
26 26
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/>
27
- <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dfile.encoding=cp1252 -Dexpedition.udp.port=5010 -Xmx6000m -XX:ThreadPriorityPolicy=2 -XX:+UseG1GC -Djetty.home=${project_loc:com.sap.sailing.server}/../target/configuration/jetty -Djava.util.logging.config.file=${project_loc:com.sap.sailing.server}/../target/configuration/logging_debug.properties -Dkiwo.results=${project_loc:com.sap.sailing.kiworesultimport.test}/resources -Dpersistentcompetitors.clear=false -Dpolardata.source.url=https://www.sapsailing.com -Dwindestimation.source.url=https://www.sapsailing.com -Drestore.tracked.races=true -Dorg.eclipse.jetty.server.Request.maxFormContentSize=50000000 -Dmongo.uri=&quot;mongodb://silent,klo,homemp3/winddb?replicaSet=rs0&amp;retryWrites=true&quot; -DAnniversaryRaceDeterminator.enabled=true -Djava.naming.factory.url.pkgs=org.eclipse.jetty.jndi -Djava.naming.factory.initial=org.eclipse.jetty.jndi.InitialContextFactory -Dorg.eclipse.jetty.annotations.maxWait=120 -Dchargebee.site=${CHARGEBEE_SITE} -Dchargebee.apikey=${CHARGEBEE_API_KEY} -Dmanage2sail.accesstoken=${MANAGE2SAIL_ACCESS_TOKEN} -Dsubscriptions.disableMailVerificationRequirement=true -Dgoogle.maps.authenticationparams=${GOOGLE_MAPS_AUTHENTICATION_PARAMS} -Dgwt.rpc.version=9 -Digtimi.riot.port=6000 -Digtimi.base.url=http://127.0.0.1:8888"/>
27
+ <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-ea -Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dfile.encoding=cp1252 -Dexpedition.udp.port=5010 -Xmx6000m -XX:ThreadPriorityPolicy=2 -XX:+UseG1GC -Djetty.home=${project_loc:com.sap.sailing.server}/../target/configuration/jetty -Djava.util.logging.config.file=${project_loc:com.sap.sailing.server}/../target/configuration/logging_debug.properties -Dkiwo.results=${project_loc:com.sap.sailing.kiworesultimport.test}/resources -Dpersistentcompetitors.clear=false -Dpolardata.source.url=https://www.sapsailing.com -Dwindestimation.source.url=https://www.sapsailing.com -Drestore.tracked.races=true -Dorg.eclipse.jetty.server.Request.maxFormContentSize=50000000 -Dmongo.uri=&quot;mongodb://silent,klo,homemp3/winddb?replicaSet=rs0&amp;retryWrites=true&quot; -DAnniversaryRaceDeterminator.enabled=true -Djava.naming.factory.url.pkgs=org.eclipse.jetty.jndi -Djava.naming.factory.initial=org.eclipse.jetty.jndi.InitialContextFactory -Dorg.eclipse.jetty.annotations.maxWait=120 -Dchargebee.site=${CHARGEBEE_SITE} -Dchargebee.apikey=${CHARGEBEE_API_KEY} -Dmanage2sail.accesstoken=${MANAGE2SAIL_ACCESS_TOKEN} -Dsubscriptions.disableMailVerificationRequirement=true -Dgoogle.maps.authenticationparams=${GOOGLE_MAPS_AUTHENTICATION_PARAMS} -Dyoutube.api.key=${YOUTUBE_API_KEY} -Dgwt.rpc.version=9 -Digtimi.riot.port=6000 -Digtimi.base.url=http://127.0.0.1:8888"/>
28 28
<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc}"/>
29 29
<stringAttribute key="pde.version" value="3.3"/>
30 30
<stringAttribute key="profilingTraceType-ALLOCATION_TRACE" value="KEY_APPLICATION_FILTER%CTX_KEY%*%CTX_ENTRY%INCREASE_COUNT%CTX_KEY%8192%CTX_ENTRY%KEY_MIN_SIZE%CTX_KEY%32%CTX_ENTRY%KEY_MAX_SIZE%CTX_KEY%65536%CTX_ENTRY%KEY_INC_LINE_NRS%CTX_KEY%true%CTX_ENTRY%KEY_SESSION_FILTER%CTX_KEY%*%CTX_ENTRY%KEY_ENABLEMENT%CTX_KEY%false%CTX_ENTRY%CLASS_FILTER%CTX_KEY%*%CTX_ENTRY%KEY_USER_FILTER%CTX_KEY%*%CTX_ENTRY%KEY_REQUEST_FILTER%CTX_KEY%*%CTX_ENTRY%KEY_TENANT_FILTER%CTX_KEY%*%CTX_ENTRY%KEY_ADAPTIVE%CTX_KEY%false%CTX_ENTRY%"/>
java/target/env-default-rules.sh
... ...
@@ -128,6 +128,9 @@ fi
128 128
if [ -n "${GOOGLE_MAPS_AUTHENTICATION_PARAMS}" ]; then
129 129
ADDITIONAL_JAVA_ARGS="${ADDITIONAL_JAVA_ARGS} -Dgoogle.maps.authenticationparams=${GOOGLE_MAPS_AUTHENTICATION_PARAMS}"
130 130
fi
131
+if [ -n "${YOUTUBE_API_KEY}" ]; then
132
+ ADDITIONAL_JAVA_ARGS="${ADDITIONAL_JAVA_ARGS} -Dyoutube.api.key=${YOUTUBE_API_KEY}"
133
+fi
131 134
if [ -n "${WINDESTIMATION_BEARER_TOKEN}" ]; then
132 135
ADDITIONAL_JAVA_ARGS="${ADDITIONAL_JAVA_ARGS} -Dwindestimation.source.bearertoken=${WINDESTIMATION_BEARER_TOKEN}"
133 136
fi
wiki/howto/onboarding.md
... ...
@@ -116,6 +116,7 @@ Out of the box, multiple settings in Eclipse need to be changed. Go to Window
116 116
- In "General ⇒ Editors ⇒ Text Editors ⇒ Quick Diff" change the reference source from 'Version on Disk' to 'A Git Revision'. If you like other colours for marking diffs change them here. (Example: Changes = Yellow, Additions = Green, Deletions = Red)
117 117
- If you'd like to be able to import official results from the Manage2Sail regatta management system: In Run/Debug ⇒ String Substitution add a variable ``MANAGE2SAIL_ACCESS_TOKEN``. Ask your team lead for the value of such an access token you can uses for testing. The variable is used by the "Sailing Server (No Proxy)" launch configuration. and maybe others.
118 118
- For Google Maps API access, the server needs to know authentication parameters. These are provided through an Eclipse variable used by various launch configurations named ``GOOGLE_MAPS_AUTHENTICATION_PARAMS``. Ask for the official SAP Google Maps API credentials, or use ``key=AIzaSyD1Se4tIkt-wglccbco3S7twaHiG20hR9E`` for a test key that works for your localhost-based tests.
119
+- For YouTube API access, provide an Eclipse variable ``YOUTUBE_API_KEY``. You can use your own Google developer account to create such a key; see [here](https://console.cloud.google.com).
119 120
- In case you need to test with the payment provider (ChargeBee) active, you need to provide Eclipse variables (Run/Rebug ⇒ String Substitution) ``CHARGEBEE_SITE`` and ``CHARGEBEE_API_KEY`` where the recommendation is to use ``sailytics-test`` for the site and a corresponding test API key; there is one launch configuration running against the live ChargeBee site, but its use is not recommended for obvious reasons. For it, define the variables ``CHARGEBEE_SITE_LIVE`` and ``CHARGEBEE_API_KEY_LIVE``, respectively.
120 121
- To successfully obtain polar and wind estimation data from ``sapsailing.com``, you need to define the Eclipse variables (Run/Debug ⇒ String Substitution) ``POLAR_DATA_BEARER_TOKEN`` and ``WIND_ESTIMATION_MODEL_BEARER_TOKEN`` that need to authenticate a user with permissions to read the respective models.
121 122
- To work with the wind estimation model training launch configuration (e.g., SimpleModelsTrainingPart1.launch), define an Eclipse variable (Run/Debug ⇒ String Substitution) ``SAPSAILING_BEARER_TOKEN`` which needs to authenticate a user eligible to read all maneuver data from sapsailing.com