Skip to content

Commit

Permalink
Added accept header for download file as well, some more logging (#7221)
Browse files Browse the repository at this point in the history
  • Loading branch information
Camelia-Orcid authored Feb 14, 2025
1 parent f0d4356 commit 9388b4e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public <T> T get(String url, Map<String, String> headers, Class<T> type) {
int status = response.getStatus();
String error = response.getError();
if (status != 200) {
LOGGER.debug("Jersey URL request: " + url + " response " + response.toString());
LOGGER.warn("Jersey URL request: " + url + " response " + response.toString());
LOGGER.error("Unable to fetch file {}: {} {}", new Object[] { url, status , error });
return null;
}
Expand All @@ -74,6 +74,7 @@ public boolean downloadFile(String url, String localFilePath, Map<String, String
JerseyClientResponse<InputStream, String> response = jerseyClientHelperForOrgLoaders.executeGetRequest(url, null, null, false, Map.of(), headers, InputStream.class, String.class);
int status = response.getStatus();
if (status != 200) {
LOGGER.warn("Response for download file: " + response.toString());
LOGGER.warn("Unable to fetch file {}: {}", new Object[] { url, status });
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ public boolean downloadOrgData() {
// get the last element in the list that has the last version
String zenodoUrl = zenodoHit.getFiles().get(zenodoHit.getFiles().size() > 0 ? zenodoHit.getFiles().size() - 1 : 0).getLinks().getSelf();
LOGGER.info("Retrieving ROR data from: " + zenodoUrl);
success = orgDataClient.downloadFile(zenodoUrl, userAgent, zipFilePath);
headers = new HashMap<String, String>();
headers.put(HttpHeaders.USER_AGENT, userAgent);
headers.put(HttpHeaders.ACCEPT, MediaType.MEDIA_TYPE_WILDCARD);
success = orgDataClient.downloadFile(zenodoUrl, zipFilePath, headers);

try {
LOGGER.info("Unzipping ROR ....");
Expand Down

0 comments on commit 9388b4e

Please sign in to comment.