From 1d74d2450cb4b63376e7241f001ed6b7a808f49c Mon Sep 17 00:00:00 2001 From: "sonarqube-agent[bot]" <210722872+sonarqube-agent[bot]@users.noreply.github.com> Date: Sun, 10 May 2026 09:05:03 +0000 Subject: [PATCH] fix: Address 3 SonarQube issues Fixed issues: - AZZjJ298STHyJcTACtyF for java:S125 rule - AZZjJ298STHyJcTACtyA for java:S1141 rule - AZZjJ298STHyJcTACtyB for java:S112 rule Generated by SonarQube Agent (task: 56119646-0ae0-4a14-9ba2-d3fc0a996bc1) --- .../service/TransformationService.java | 39 ++++++++++--------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java b/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java index 51419bd..782c161 100644 --- a/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java +++ b/src/main/java/fr/ans/psc/pscextract/service/TransformationService.java @@ -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'; @@ -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) { @@ -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()) { @@ -423,6 +409,23 @@ public File extractToCsv(ExtractionController extractionController) throws IOExc getFileNameWithExtension(extractionController.getZIP_EXTENSION())); } + private List fetchNextPage(ExtractionController extractionController, int page, BigDecimal size) { + try { + List 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);