mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-04 10:09:42 +00:00
pass through bearer token to polar data extraction
This commit is contained in:
1 parent
c6e08c120b
commit
9053dd3500
2 files changed
+8
-7
No files matched your search
+7
-6
@@ -27,9 +27,9 @@ public class PolarDataImporter {
|
|||||||
public PolarDataImporter() {
|
public PolarDataImporter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public InputStream retrievePolarDataRegressionAsBytes() throws IOException, ParseException {
|
public InputStream retrievePolarDataRegressionAsBytes(String bearerToken) throws IOException, ParseException {
|
||||||
LoggingUtil.logInfo("Loading polar regression data from remote server " + polarDataSourceUrl);
|
LoggingUtil.logInfo("Loading polar regression data from remote server " + polarDataSourceUrl);
|
||||||
final InputStream inputStream = getContentFromResponse();
|
final InputStream inputStream = getContentFromResponse(bearerToken);
|
||||||
LoggingUtil.logInfo("Loading polar regression data succeeded");
|
LoggingUtil.logInfo("Loading polar regression data succeeded");
|
||||||
return inputStream;
|
return inputStream;
|
||||||
}
|
}
|
||||||
@@ -44,20 +44,21 @@ public class PolarDataImporter {
|
|||||||
return polarDataSourceUrl + (polarDataSourceUrl.endsWith("/") ? "" : "/") + RESOURCE;
|
return polarDataSourceUrl + (polarDataSourceUrl.endsWith("/") ? "" : "/") + RESOURCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InputStream getContentFromResponse() throws IOException, ParseException {
|
protected InputStream getContentFromResponse(String bearerToken) throws IOException, ParseException {
|
||||||
HttpClient client = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategyForAllRedirectResponseCodes()).build();
|
HttpClient client = HttpClientBuilder.create().setRedirectStrategy(new LaxRedirectStrategyForAllRedirectResponseCodes()).build();
|
||||||
HttpGet getProcessor = new HttpGet(getAPIString());
|
HttpGet getProcessor = new HttpGet(getAPIString());
|
||||||
|
getProcessor.setHeader("Authorization", "Bearer "+bearerToken);
|
||||||
HttpResponse processorResponse = client.execute(getProcessor);
|
HttpResponse processorResponse = client.execute(getProcessor);
|
||||||
return processorResponse.getEntity().getContent();
|
return processorResponse.getEntity().getContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
PolarDataImporter polarDataImporter = new PolarDataImporter();
|
PolarDataImporter polarDataImporter = new PolarDataImporter();
|
||||||
polarDataImporter.importPolarData();
|
polarDataImporter.importPolarData(args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void importPolarData() throws IOException, ParseException {
|
public void importPolarData(String bearerToken) throws IOException, ParseException {
|
||||||
InputStream inputStream = retrievePolarDataRegressionAsBytes();
|
InputStream inputStream = retrievePolarDataRegressionAsBytes(bearerToken);
|
||||||
persistPolarDataRegressionAsBytes(new File(polarDataFilePath), inputStream);
|
persistPolarDataRegressionAsBytes(new File(polarDataFilePath), inputStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -89,7 +89,7 @@ public class SimpleModelsTrainingPart1 {
|
|||||||
maneuverForEstimationPersistenceManager.dropCollection();
|
maneuverForEstimationPersistenceManager.dropCollection();
|
||||||
new RegularManeuversForEstimationPersistenceManager().dropCollection();
|
new RegularManeuversForEstimationPersistenceManager().dropCollection();
|
||||||
logger.info("Scheduling import of polar data");
|
logger.info("Scheduling import of polar data");
|
||||||
executeInThreadPool(() -> new PolarDataImporter().importPolarData());
|
executeInThreadPool(() -> new PolarDataImporter().importPolarData(bearerToken));
|
||||||
logger.info("Scheduling import of regattas with a bearer token of length "+bearerToken.length());
|
logger.info("Scheduling import of regattas with a bearer token of length "+bearerToken.length());
|
||||||
executeInThreadPool(() -> new ManeuverAndWindImporter().importAllRegattas(bearerToken));
|
executeInThreadPool(() -> new ManeuverAndWindImporter().importAllRegattas(bearerToken));
|
||||||
awaitThreadPoolCompletion();
|
awaitThreadPoolCompletion();
|
||||||
|
|||||||
Reference in new issue
Block a user