Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public String getLinkString(String id) {
}
switch (id.charAt(0)) {
case ('1'):
// if (s.charAt(1) == '0') return s+','+"MSSante"+','+'1';
//
return id + ',' + "ADELI" + ',' + '1';
case ('3'):
return id + ',' + "FINESS" + ',' + '1';
Expand Down Expand Up @@ -341,23 +341,9 @@ public File extractToCsv(ExtractionController extractionController) throws IOExc
log.trace("Ps " + ps.getId() + " transformed and written");
}
page++;
try {
response = extractionController.getPsApi().getPsByPage(BigDecimal.valueOf(page), size);
log.debug("Page " + page + " of size " + size + " received, writing to file...");
} catch (HttpStatusCodeException e) {
log.warn("Out of pages: " + e.getMessage());
if (e.getStatusCode() != HttpStatus.GONE) {
log.info("Extraction failed, exiting without replacing the extract file");
if (tempExtractFile.delete()) {
log.info("Temp file at " + tempExtractFile.getAbsolutePath() + " deleted");
} else {
log.warn("Temp file at " + tempExtractFile.getAbsolutePath() + " not deleted");
}
return null;
}
response = fetchNextPage(extractionController, page, size);
if (response == null) {
outOfPages = true;
} catch (Exception e) {
log.error("exception raised : ", e);
}
} while (!outOfPages);
} catch (HttpStatusCodeException e) {
Expand Down Expand Up @@ -397,7 +383,7 @@ public File extractToCsv(ExtractionController extractionController) throws IOExc
zos.finish();

} catch (NoSuchAlgorithmException ex) {
throw new RuntimeException("No SHA256 digest support in the current java runtime - please fix this."+ex.getMessage(),ex);
throw new IllegalStateException("No SHA256 digest support in the current java runtime - please fix this."+ex.getMessage(),ex);
}

if (tempExtractFile.delete()) {
Expand All @@ -423,6 +409,23 @@ public File extractToCsv(ExtractionController extractionController) throws IOExc
getFileNameWithExtension(extractionController.getZIP_EXTENSION()));
}

private List<Ps> fetchNextPage(ExtractionController extractionController, int page, BigDecimal size) {
try {
List<Ps> response = extractionController.getPsApi().getPsByPage(BigDecimal.valueOf(page), size);
log.debug("Page " + page + " of size " + size + " received, writing to file...");
return response;
} catch (HttpStatusCodeException e) {
log.warn("Out of pages: " + e.getMessage());
if (e.getStatusCode() != HttpStatus.GONE) {
throw e;
}
return null;
} catch (Exception e) {
log.error("exception raised : ", e);
return Collections.emptyList();
}
}

private void writeDigestEntry(final ZipOutputStream zos, MessageDigest extractEntryDigester) throws IOException {
ZipEntry digestEntry = new ZipEntry(getFileNameWithExtension(DIGEST_FILE_EXTENSION));
zos.putNextEntry(digestEntry);
Expand Down
Loading