java/com.sap.sailing.server/SailingServer (No Proxy).launch
... ...
@@ -14,6 +14,9 @@
14 14
<setAttribute key="deselected_workspace_bundles"/>
15 15
<booleanAttribute key="includeOptional" value="false"/>
16 16
<booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
17
+ <mapAttribute key="org.eclipse.debug.core.environmentVariables">
18
+ <mapEntry key="GITHUB_TOKEN" value="${GITHUB_TOKEN}"/>
19
+ </mapAttribute>
17 20
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.pde.ui.launcher.PDESourceLookupDirector"/>
18 21
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;sourceLookupDirector&gt;&#13;&#10; &lt;sourceContainers duplicates=&quot;false&quot;&gt;&#13;&#10; &lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;directory nest=&amp;quot;false&amp;quot; path=&amp;quot;C:\Users\georg\Documents\Business\Kunden\OIO\SAPsailing\jetty.project\apache-jsp\src\main\java&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.directory&quot;/&gt;&#13;&#10; &lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;classpathContainer path=&amp;quot;com.google.gwt.eclipse.core.GWT_CONTAINER&amp;quot;/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.jdt.launching.sourceContainer.classpathContainer&quot;/&gt;&#13;&#10; &lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#13;&amp;#10;&amp;lt;default/&amp;gt;&amp;#13;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#13;&#10; &lt;/sourceContainers&gt;&#13;&#10;&lt;/sourceLookupDirector&gt;&#13;&#10;"/>
19 22
<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
java/com.sap.sse.landscape/src/com/sap/sse/landscape/impl/GithubReleasesRepository.java
... ...
@@ -3,6 +3,7 @@ package com.sap.sse.landscape.impl;
3 3
import java.io.IOException;
4 4
import java.io.InputStream;
5 5
import java.io.InputStreamReader;
6
+import java.net.HttpURLConnection;
6 7
import java.net.MalformedURLException;
7 8
import java.net.URL;
8 9
import java.net.URLConnection;
... ...
@@ -24,6 +25,7 @@ import org.json.simple.parser.ParseException;
24 25
25 26
import com.sap.sse.common.Duration;
26 27
import com.sap.sse.common.TimePoint;
28
+import com.sap.sse.common.Util;
27 29
import com.sap.sse.common.Util.Pair;
28 30
import com.sap.sse.landscape.Release;
29 31
import com.sap.sse.landscape.ReleaseRepository;
... ...
@@ -153,8 +155,8 @@ public class GithubReleasesRepository extends AbstractReleaseRepository implemen
153 155
} else {
154 156
logger.fine(()->"Need to fetch page with newest releases because last request was at "+
155 157
(lastFetchOfNewestReleases==null?"<never>":lastFetchOfNewestReleases));
156
- lastFetchOfNewestReleases = now;
157 158
fillCacheWithNewestReleases();
159
+ lastFetchOfNewestReleases = now;
158 160
}
159 161
cachedReleasesIterator = releasesByPublishingTimePoint.descendingMap().values().iterator();
160 162
}
... ...
@@ -215,6 +217,11 @@ public class GithubReleasesRepository extends AbstractReleaseRepository implemen
215 217
* cache when this method is invoked.
216 218
* <p>
217 219
*
220
+ * If the {@code GITHUB_TOKEN} environment variable is set, it is used as a bearer token forthe Github requests,
221
+ * resulting in a higher rate limit. If no token is set, or if using the token results in a 401 response code
222
+ * (authentication failed), an unauthenticated request is tried instead.
223
+ * <p>
224
+ *
218 225
* The method makes no changes to the cache or any other state of this instance.
219 226
*
220 227
* @return the link to the next page in the returned pair's {@link Pair#getA() A component}, and the sequence of
... ...
@@ -222,7 +229,24 @@ public class GithubReleasesRepository extends AbstractReleaseRepository implemen
222 229
*/
223 230
private synchronized Pair<String, Iterable<Pair<TimePoint, GithubRelease>>> getReleasesFromPage(String pageURL) throws IOException, ParseException {
224 231
logger.info("Requesting releases page "+pageURL);
225
- final URLConnection connection = HttpUrlConnectionHelper.redirectConnection(new URL(pageURL));
232
+ final URLConnection connection;
233
+ final String githubToken = System.getenv("GITHUB_TOKEN");
234
+ if (Util.hasLength(githubToken)) {
235
+ final HttpURLConnection authenticatedConnectionAttempt = (HttpURLConnection) HttpUrlConnectionHelper
236
+ .redirectConnectionWithBearerToken(new URL(pageURL), githubToken);
237
+ if (authenticatedConnectionAttempt.getResponseCode() == 401) {
238
+ try {
239
+ authenticatedConnectionAttempt.disconnect();
240
+ } catch (Exception e) {
241
+ logger.warning("Couldn't disconnect from Github: "+e.getMessage());
242
+ }
243
+ connection = HttpUrlConnectionHelper.redirectConnection(new URL(pageURL));
244
+ } else {
245
+ connection = authenticatedConnectionAttempt;
246
+ }
247
+ } else {
248
+ connection = HttpUrlConnectionHelper.redirectConnection(new URL(pageURL));
249
+ }
226 250
final InputStream index = (InputStream) connection.getContent();
227 251
final String xRatelimitRemaining = connection.getHeaderField("x-ratelimit-remaining");
228 252
logger.fine(()->""+xRatelimitRemaining+" requests left in this hour");
wiki/howto/onboarding.md
... ...
@@ -115,6 +115,7 @@ Go to Window ⇒ Preferences and change the following two settings:
115 115
- 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).
116 116
- 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.
117 117
- 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.
118
+- Define a ``GITHUB_TOKEN`` variable; it may be empty (but has to be generally present), or you can use it to set a personal access token (PAT) which will then be used, in particular, for requesting application releases from GitHub.
118 119
- 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
119 120
- In "GWT ⇒ Errors/Warnings" set "Missing SDK" to "Ignore"
120 121
- In "GWT ⇒ GWT Settings ⇒ Add..." add the GWT SDK you downloaded and unpacked earlier