|
|
@ -42,13 +42,18 @@ public class Main |
|
|
|
private static JSONParser parser = new JSONParser(); |
|
|
|
private static String testRequest; |
|
|
|
private static File errorFile; |
|
|
|
//TODO: enduco needs to insert the correct request limits here |
|
|
|
// TODO: enduco needs to insert the correct request limits here |
|
|
|
private static final int requestLimit15Minutes = 100; |
|
|
|
private static final int requestLimitDay = 1000 / 3; |
|
|
|
|
|
|
|
private static int dailyRequestCount =0; |
|
|
|
private static int waitTimeMil = 60000*3*15/requestLimit15Minutes; |
|
|
|
private static long lastRequestTimeInMillis=0; |
|
|
|
private static int dailyRequestCount = 0; |
|
|
|
private static int waitTimeMil = 60000 * 3 * 15 / requestLimit15Minutes; |
|
|
|
private static long lastRequestTimeInMillis = 0; |
|
|
|
private static String accessToken = ""; |
|
|
|
/** |
|
|
|
* a is client_id, b is client_secret, c is refresh_token |
|
|
|
*/ |
|
|
|
private static Triplet refreshInfo; |
|
|
|
|
|
|
|
private static void writeError(String text) |
|
|
|
{ |
|
|
@ -80,32 +85,50 @@ public class Main |
|
|
|
/** |
|
|
|
* Saves the data of one athlete into a temp file and returns it. |
|
|
|
* |
|
|
|
* @param token Identifier / authorization token of the athlete |
|
|
|
* @return created temp file |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
static File oneAthlete(String token) |
|
|
|
static File oneAthlete() |
|
|
|
{ |
|
|
|
// get Activities |
|
|
|
Map<String, JSONObject> activities = getActivities(token); |
|
|
|
// get Activities and general information |
|
|
|
Map<String, JSONObject> activities; |
|
|
|
JSONObject athleteInfo; |
|
|
|
try |
|
|
|
{ |
|
|
|
activities = getActivities(); |
|
|
|
athleteInfo = saveGeneralInformation(); |
|
|
|
} |
|
|
|
catch (NoAccessException e1) |
|
|
|
{ |
|
|
|
writeError("Athlete " + athleteId + ": Access expired and no new token possible"); |
|
|
|
return null; // no data at all. Stop right away |
|
|
|
} |
|
|
|
if (athleteInfo == null) // error getting General Information |
|
|
|
{ |
|
|
|
athleteInfo = new JSONObject(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// for each activity: save streams |
|
|
|
JSONArray allActivities = new JSONArray(); |
|
|
|
int simpleActivityId = 0; |
|
|
|
for (String id : activities.keySet()) |
|
|
|
{ |
|
|
|
JSONObject data = addStreams(id, activities.get(id), token); |
|
|
|
JSONObject data; |
|
|
|
try |
|
|
|
{ |
|
|
|
data = addStreams(id, activities.get(id)); |
|
|
|
} |
|
|
|
catch (NoAccessException e) |
|
|
|
{ |
|
|
|
writeError("Athlete " + athleteId + ": Access expired and no new token possible"); |
|
|
|
break; //stop the loop and save what you got up to there |
|
|
|
} |
|
|
|
data.put("activity_id", simpleActivityId); |
|
|
|
allActivities.add(data); |
|
|
|
simpleActivityId++; |
|
|
|
} |
|
|
|
|
|
|
|
// get general information |
|
|
|
JSONObject athleteInfo = saveGeneralInformation(token); |
|
|
|
if(athleteInfo==null) //error getting General Information |
|
|
|
{ |
|
|
|
athleteInfo = new JSONObject(); |
|
|
|
} |
|
|
|
athleteInfo.put("activities", allActivities); |
|
|
|
|
|
|
|
try |
|
|
@ -129,19 +152,19 @@ public class Main |
|
|
|
* |
|
|
|
* @param id Strava id of the activity |
|
|
|
* @param data general information of the activity |
|
|
|
* @param token Identifier / authorization token of the athlete |
|
|
|
* @return The data with the added streams |
|
|
|
* @throws NoAccessException If the access token expired and no new one could be acquired. |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
static JSONObject addStreams(String id, JSONObject data, String token) |
|
|
|
static JSONObject addStreams(String id, JSONObject data) throws NoAccessException |
|
|
|
{ |
|
|
|
String requestUrlExtension = "activities/" + id + "/streams?" |
|
|
|
+ "keys=[time,distance,latlng,altitude,velocity_smooth,heartrate," |
|
|
|
+ "cadence,watts,temp,moving,grade_smooth]&key_by_type=true"; |
|
|
|
|
|
|
|
String json = makeGetRequestWithRetry(requestUrlExtension, token);; |
|
|
|
String json = makeGetRequestWithRetry(requestUrlExtension); |
|
|
|
|
|
|
|
if (json==null ||json.isEmpty()||json.isBlank()||json.equals("")) |
|
|
|
if (json == null || json.isEmpty() || json.isBlank() || json.equals("")) |
|
|
|
{ |
|
|
|
return data; |
|
|
|
} |
|
|
@ -167,12 +190,12 @@ public class Main |
|
|
|
* Gathers all activities of a user, extracts the general information and the |
|
|
|
* ids. |
|
|
|
* |
|
|
|
* @param token Identifier / authorization token of the athlete |
|
|
|
* @return A Map with key = Strava Id of an activity and value = JSONObject with |
|
|
|
* the general information of the activity |
|
|
|
* @throws NoAccessException If the access token expired and no new one could be acquired. |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
static Map<String, JSONObject> getActivities(String token) |
|
|
|
static Map<String, JSONObject> getActivities() throws NoAccessException |
|
|
|
{ |
|
|
|
Map<String, JSONObject> result = new HashMap<>(); |
|
|
|
/* |
|
|
@ -191,10 +214,12 @@ public class Main |
|
|
|
int pageIndex = 1; |
|
|
|
while (true) |
|
|
|
{ |
|
|
|
//TODO: this 'per_page' value could perhaps be the root of all evil |
|
|
|
String requestExtension = "athlete/activities?per_page=100&page=" + pageIndex; |
|
|
|
String json = makeGetRequestWithRetry(requestExtension, token); |
|
|
|
if (json==null || json.isEmpty() || json.isBlank() || json.equals("") || json.equals("[]")) // don't know where the last page is... |
|
|
|
String json = makeGetRequestWithRetry(requestExtension); |
|
|
|
if (json == null || json.isEmpty() || json.isBlank() || json.equals("") || json.equals("[]")) // don't know |
|
|
|
// where the |
|
|
|
// last page |
|
|
|
// is... |
|
|
|
{ |
|
|
|
break; |
|
|
|
} |
|
|
@ -231,16 +256,17 @@ public class Main |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* In the case that the daily request limit has been reached, this method waits for the next day |
|
|
|
* In the case that the daily request limit has been reached, this method waits |
|
|
|
* for the next day |
|
|
|
*/ |
|
|
|
static void checkRequestLimit() |
|
|
|
{ |
|
|
|
if(dailyRequestCount>requestLimitDay) //daily request limit reached, wait until the next day |
|
|
|
if (dailyRequestCount > requestLimitDay) // daily request limit reached, wait until the next day |
|
|
|
{ |
|
|
|
Calendar tomorrow = new GregorianCalendar(); |
|
|
|
tomorrow.setTimeInMillis(System.currentTimeMillis()); |
|
|
|
tomorrow.set(Calendar.DAY_OF_YEAR, tomorrow.get(Calendar.DAY_OF_YEAR)+1); |
|
|
|
if(tomorrow.get(Calendar.DAY_OF_YEAR)==1) //reached a new year ... |
|
|
|
tomorrow.set(Calendar.DAY_OF_YEAR, tomorrow.get(Calendar.DAY_OF_YEAR) + 1); |
|
|
|
if (tomorrow.get(Calendar.DAY_OF_YEAR) == 1) // reached a new year ... |
|
|
|
{ |
|
|
|
tomorrow.set(Calendar.YEAR, 2022); |
|
|
|
} |
|
|
@ -248,7 +274,7 @@ public class Main |
|
|
|
tomorrow.set(Calendar.MINUTE, 0); |
|
|
|
try |
|
|
|
{ |
|
|
|
TimeUnit.MILLISECONDS.sleep(tomorrow.getTimeInMillis()-System.currentTimeMillis()); |
|
|
|
TimeUnit.MILLISECONDS.sleep(tomorrow.getTimeInMillis() - System.currentTimeMillis()); |
|
|
|
} |
|
|
|
catch (InterruptedException e1) |
|
|
|
{ |
|
|
@ -257,42 +283,51 @@ public class Main |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Method is used to find the next request window: It tries the same request again after 5 minutes. |
|
|
|
* After a set number of times (retryTimes) it stops if it still wasn't successful. |
|
|
|
* Method is used to find the next request window: It tries the same request |
|
|
|
* again after 5 minutes. After a set number of times (retryTimes) it stops if |
|
|
|
* it still wasn't successful. |
|
|
|
* |
|
|
|
* @param urlExtension UrlExtension for the request |
|
|
|
* @param token Token for the request |
|
|
|
* @return Data as a String or {@code null} if there is no data |
|
|
|
* @throws NoAccessException If the access token expired and no new one could be acquired. |
|
|
|
*/ |
|
|
|
static String makeGetRequestWithRetry(String urlExtension, String token) |
|
|
|
static String makeGetRequestWithRetry(String urlExtension) throws NoAccessException |
|
|
|
{ |
|
|
|
checkRequestLimit(); |
|
|
|
String json=null; |
|
|
|
int count=0; |
|
|
|
String json = null; |
|
|
|
int count = 0; |
|
|
|
do |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
json = makeOneGetRequest(urlExtension, token); |
|
|
|
json = makeOneGetRequest(urlExtension); |
|
|
|
dailyRequestCount++; |
|
|
|
} |
|
|
|
catch (ResponseCodeWrongException e) |
|
|
|
{ |
|
|
|
//tried enough times, so stop now |
|
|
|
if(count >= retryTimes) |
|
|
|
// tried enough times, so stop now |
|
|
|
if (count >= retryTimes) |
|
|
|
{ |
|
|
|
writeError("Athlete: "+athleteId+" Retry limit reached. Last error code: "+e.getResponseCode()); |
|
|
|
writeError( |
|
|
|
"Athlete: " + athleteId + " Retry limit reached. Last error code: " + e.getResponseCode()); |
|
|
|
return null; |
|
|
|
} |
|
|
|
//request limit is reached, try again later |
|
|
|
if (e.getResponseCode()==httpCodeLimitReached) |
|
|
|
if (e.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED) |
|
|
|
{ //token might have expired |
|
|
|
if(!getAccessToken()) //token doesn't work anymore and we can't get a new one |
|
|
|
{ |
|
|
|
throw new NoAccessException(); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (e.getResponseCode() == httpCodeLimitReached) |
|
|
|
{// request limit is reached, try again later |
|
|
|
count++; |
|
|
|
} |
|
|
|
else //some other error: try only one other time! |
|
|
|
else // some other error: try only one other time! |
|
|
|
{ |
|
|
|
count=retryTimes; |
|
|
|
count = retryTimes; |
|
|
|
} |
|
|
|
//Sleep for 5 minutes and try to get the next 15 min request window |
|
|
|
// Sleep for 5 minutes and try to get the next 15 min request window |
|
|
|
try |
|
|
|
{ |
|
|
|
TimeUnit.MINUTES.sleep(5); |
|
|
@ -302,18 +337,18 @@ public class Main |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}while(json==null); |
|
|
|
} while (json == null); |
|
|
|
return json; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Extracts an athletes general information. |
|
|
|
* |
|
|
|
* @param token Identifier / authorization token of the athlete |
|
|
|
* @return extracted data or null if there was an error |
|
|
|
* @throws NoAccessException If the access token expired and no new one could be acquired. |
|
|
|
*/ |
|
|
|
@SuppressWarnings("unchecked") |
|
|
|
static JSONObject saveGeneralInformation(String token) |
|
|
|
static JSONObject saveGeneralInformation() throws NoAccessException |
|
|
|
{ |
|
|
|
String sex = "sex"; // Possible values = M, F |
|
|
|
String country = "country"; |
|
|
@ -321,8 +356,7 @@ public class Main |
|
|
|
String meas_pref = "measurement_preference"; // Possible values = feet, meters |
|
|
|
String weight = "weight"; |
|
|
|
|
|
|
|
|
|
|
|
String json = makeGetRequestWithRetry("athlete", token); |
|
|
|
String json = makeGetRequestWithRetry("athlete"); |
|
|
|
|
|
|
|
JSONObject toSave = new JSONObject(); |
|
|
|
try |
|
|
@ -359,7 +393,7 @@ public class Main |
|
|
|
*/ |
|
|
|
static void zipFiles(Map<String, File> files, int count) throws IOException |
|
|
|
{ |
|
|
|
FileOutputStream fos = new FileOutputStream("data("+count+").zip"); |
|
|
|
FileOutputStream fos = new FileOutputStream("data(" + count + ").zip"); |
|
|
|
ZipOutputStream zipOut = new ZipOutputStream(fos); |
|
|
|
for (String key : files.keySet()) |
|
|
|
{ |
|
|
@ -384,12 +418,10 @@ public class Main |
|
|
|
* Handles one GET request to the API |
|
|
|
* |
|
|
|
* @param requestUrlExtension Extension for the baseUrl (without '/') |
|
|
|
* @param token Identification / authorization token of the |
|
|
|
* athlete |
|
|
|
* @return The response as a String, an empty String in case of error. |
|
|
|
* @throws ResponseCodeWrongException If there was an http error |
|
|
|
*/ |
|
|
|
static String makeOneGetRequest(String requestUrlExtension, String token) throws ResponseCodeWrongException |
|
|
|
static String makeOneGetRequest(String requestUrlExtension) throws ResponseCodeWrongException |
|
|
|
{ |
|
|
|
if (testRequest != null) |
|
|
|
{ |
|
|
@ -400,29 +432,30 @@ public class Main |
|
|
|
HttpsURLConnection connection = null; |
|
|
|
try |
|
|
|
{ |
|
|
|
long timeSinceLastRequest =System.currentTimeMillis()-lastRequestTimeInMillis; |
|
|
|
if( timeSinceLastRequest<waitTimeMil) |
|
|
|
long timeSinceLastRequest = System.currentTimeMillis() - lastRequestTimeInMillis; |
|
|
|
if (timeSinceLastRequest < waitTimeMil) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
TimeUnit.MILLISECONDS.sleep(waitTimeMil-timeSinceLastRequest); |
|
|
|
TimeUnit.MILLISECONDS.sleep(waitTimeMil - timeSinceLastRequest); |
|
|
|
} |
|
|
|
catch (InterruptedException e) |
|
|
|
{ |
|
|
|
} |
|
|
|
}; |
|
|
|
lastRequestTimeInMillis=System.currentTimeMillis(); |
|
|
|
} |
|
|
|
; |
|
|
|
lastRequestTimeInMillis = System.currentTimeMillis(); |
|
|
|
// Create connection |
|
|
|
URL url = new URL(baseUrl + requestUrlExtension); |
|
|
|
connection = (HttpsURLConnection) url.openConnection(); |
|
|
|
connection.setRequestMethod("GET"); |
|
|
|
connection.setRequestProperty("Authorization", "Bearer " + token); |
|
|
|
connection.setRequestProperty("Authorization", "Bearer " + accessToken); |
|
|
|
|
|
|
|
return getResponse(connection); |
|
|
|
} |
|
|
|
catch (IOException e) |
|
|
|
{ |
|
|
|
writeError("Athlete: "+athleteId+" Error while handling GET request: " + e.toString()); |
|
|
|
writeError("Athlete: " + athleteId + " Error while handling GET request: " + e.toString()); |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
@ -433,7 +466,8 @@ public class Main |
|
|
|
* @param connection Connection to the site |
|
|
|
* @return Response as a String |
|
|
|
* @throws IOException in case of error with the stream |
|
|
|
* @throws ResponseCodeWrongException if no data was read because of http problems |
|
|
|
* @throws ResponseCodeWrongException if no data was read because of http |
|
|
|
* problems |
|
|
|
*/ |
|
|
|
static String getResponse(HttpsURLConnection connection) throws IOException, ResponseCodeWrongException |
|
|
|
{ |
|
|
@ -441,10 +475,10 @@ public class Main |
|
|
|
int responseCode = connection.getResponseCode(); |
|
|
|
if (responseCode != HttpURLConnection.HTTP_OK) |
|
|
|
{ |
|
|
|
//excluded error messages appearing on missing streams and reached rate limit |
|
|
|
if(responseCode != HttpURLConnection.HTTP_NOT_FOUND && responseCode!= httpCodeLimitReached) |
|
|
|
// excluded error messages appearing on missing streams and reached rate limit |
|
|
|
if (responseCode != HttpURLConnection.HTTP_NOT_FOUND && responseCode != httpCodeLimitReached) |
|
|
|
{ |
|
|
|
writeError("Athlete: "+athleteId+" Wrong response code: " + responseCode); |
|
|
|
writeError("Athlete: " + athleteId + " Wrong response code: " + responseCode); |
|
|
|
} |
|
|
|
throw new ResponseCodeWrongException(responseCode); |
|
|
|
} |
|
|
@ -467,12 +501,10 @@ public class Main |
|
|
|
/** |
|
|
|
* Used for generating the accessToken |
|
|
|
* |
|
|
|
* @param data Triplet containing: a the client_id, b the client_secret, c the |
|
|
|
* refresh_token |
|
|
|
* @return The response as a String, an empty String in case of error. |
|
|
|
* @throws ResponseCodeWrongException If there was an http error |
|
|
|
*/ |
|
|
|
static String makeOnePostRequest(Triplet data) throws ResponseCodeWrongException |
|
|
|
static String makeOnePostRequest() throws ResponseCodeWrongException |
|
|
|
{ |
|
|
|
HttpsURLConnection connection = null; |
|
|
|
try |
|
|
@ -484,10 +516,10 @@ public class Main |
|
|
|
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); |
|
|
|
|
|
|
|
Map<String, String> params = new LinkedHashMap<>(); |
|
|
|
params.put("client_id", data.getA()); |
|
|
|
params.put("client_secret", data.getB()); |
|
|
|
params.put("client_id", refreshInfo.getA()); |
|
|
|
params.put("client_secret", refreshInfo.getB()); |
|
|
|
params.put("grant_type", "refresh_token"); |
|
|
|
params.put("refresh_token", data.getC()); |
|
|
|
params.put("refresh_token", refreshInfo.getC()); |
|
|
|
|
|
|
|
StringBuilder postData = new StringBuilder(); |
|
|
|
for (String key : params.keySet()) |
|
|
@ -510,45 +542,57 @@ public class Main |
|
|
|
} |
|
|
|
catch (IOException e) |
|
|
|
{ |
|
|
|
writeError("Athlete: "+athleteId+"Error while handling POST request: " + e.toString()); |
|
|
|
writeError("Athlete: " + athleteId + "Error while handling POST request: " + e.toString()); |
|
|
|
} |
|
|
|
return ""; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* Sends the old refresh token to strava and retrieves a new one and an access token |
|
|
|
* @param refreshInfo Refresh data with a the cliend_id, b the client_secret and c the refresh_token |
|
|
|
* @return A tuple with a the access_token and b the new refresh_token or {@code null} if there was an error |
|
|
|
* Sends the old refresh token to strava and retrieves a new one and an access |
|
|
|
* token |
|
|
|
* |
|
|
|
* @param refreshInfo Refresh data with a the cliend_id, b the client_secret and |
|
|
|
* c the refresh_token |
|
|
|
* @return {@code true} if everything went right or {@code false} if there was |
|
|
|
* an error |
|
|
|
*/ |
|
|
|
static Tuple getAccessToken(Triplet refreshInfo) |
|
|
|
static boolean getAccessToken() |
|
|
|
{ |
|
|
|
checkRequestLimit(); |
|
|
|
String json=null; |
|
|
|
int count =0; |
|
|
|
String json = null; |
|
|
|
int count = 0; |
|
|
|
do |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
json = makeOnePostRequest(refreshInfo); |
|
|
|
json = makeOnePostRequest(); |
|
|
|
dailyRequestCount++; |
|
|
|
} |
|
|
|
catch (ResponseCodeWrongException e) |
|
|
|
{ |
|
|
|
//tried enough times, so stop now |
|
|
|
if(count >= retryTimes) |
|
|
|
// tried enough times, so stop now |
|
|
|
if (count >= retryTimes) |
|
|
|
{ |
|
|
|
return null; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
if (e.getResponseCode()==HttpURLConnection.HTTP_UNAUTHORIZED) |
|
|
|
{ //token might have expired |
|
|
|
if(!getAccessToken()) //token doesn't work anymore and we can't get a new one |
|
|
|
{ |
|
|
|
return false; |
|
|
|
} |
|
|
|
//request limit is reached, try again later |
|
|
|
if (e.getResponseCode()==httpCodeLimitReached) |
|
|
|
} |
|
|
|
else if (e.getResponseCode() == httpCodeLimitReached) |
|
|
|
{ |
|
|
|
// request limit is reached, try again later |
|
|
|
count++; |
|
|
|
} |
|
|
|
else //some other error: try only one other time! |
|
|
|
else // some other error: try only one other time! |
|
|
|
{ |
|
|
|
count=retryTimes; |
|
|
|
count = retryTimes; |
|
|
|
} |
|
|
|
//Sleep for 5 minutes and try to get the next 15 min request window |
|
|
|
// Sleep for 5 minutes and try to get the next 15 min request window |
|
|
|
try |
|
|
|
{ |
|
|
|
TimeUnit.MINUTES.sleep(5); |
|
|
@ -558,18 +602,20 @@ public class Main |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}while(json==null); |
|
|
|
} while (json == null); |
|
|
|
try |
|
|
|
{ |
|
|
|
Object obj = parser.parse(json); |
|
|
|
JSONObject data = (JSONObject) obj; |
|
|
|
return new Tuple(data.get("access_token").toString(), data.get("refresh_token").toString()); |
|
|
|
accessToken = data.get("access_token").toString(); |
|
|
|
refreshInfo.setC(data.get("refresh_token").toString()); |
|
|
|
return true; |
|
|
|
} |
|
|
|
catch (ParseException e) |
|
|
|
{ |
|
|
|
writeError("Athlete " + athleteId + ": Error parsing general information."); |
|
|
|
writeError("Athlete " + athleteId + ": Error parsing refresh info."); |
|
|
|
} |
|
|
|
return null; |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
public static void main(String[] args) |
|
|
@ -583,32 +629,32 @@ public class Main |
|
|
|
List<Triplet> newRefreshTokens = new ArrayList<>(); |
|
|
|
|
|
|
|
Map<String, File> allFiles = new HashMap<>(); |
|
|
|
int zipcount =1; |
|
|
|
int zipcount = 1; |
|
|
|
for (Triplet oneUser : refreshTokens) |
|
|
|
{ |
|
|
|
refreshInfo = oneUser; |
|
|
|
athleteId++; |
|
|
|
// a is access_token and b is new refresh_token |
|
|
|
Tuple withAccessToken = getAccessToken(oneUser); |
|
|
|
if (withAccessToken == null) |
|
|
|
if (!getAccessToken()) |
|
|
|
{ |
|
|
|
writeError("Couldn't get new access token for client "+athleteId); |
|
|
|
writeError("Couldn't get new access token for client " + athleteId); |
|
|
|
continue; |
|
|
|
} |
|
|
|
newRefreshTokens.add(new Triplet(oneUser.getA(), oneUser.getB(), withAccessToken.getB())); |
|
|
|
|
|
|
|
File athlete = oneAthlete(withAccessToken.getA()); |
|
|
|
File athlete = oneAthlete(); |
|
|
|
if (athlete != null) |
|
|
|
{ |
|
|
|
allFiles.put("Athlete_" + athleteId + ".json", athlete); |
|
|
|
} |
|
|
|
//pack zip-files of 10 athletes |
|
|
|
if(allFiles.size()>=10) |
|
|
|
newRefreshTokens.add(refreshInfo); |
|
|
|
|
|
|
|
// pack zip-files of 10 athletes |
|
|
|
if (allFiles.size() >= 10) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
zipFiles(allFiles, zipcount); |
|
|
|
zipcount++; |
|
|
|
allFiles=new HashMap<>(); |
|
|
|
allFiles = new HashMap<>(); |
|
|
|
} |
|
|
|
catch (IOException e) |
|
|
|
{ |
|
|
@ -616,7 +662,7 @@ public class Main |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//zip the rest |
|
|
|
// zip the rest |
|
|
|
try |
|
|
|
{ |
|
|
|
zipFiles(allFiles, zipcount); |
|
|
|