From 81af48e7449aa34c29b53b05d62ed1d7823381ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominique=20Eifl=C3=A4nder?= Date: Mon, 16 Aug 2021 09:46:44 +0200 Subject: [PATCH] Fixed NPE if image placeholder image value is null --- .../ExcelTemplateReportGenerationService.java | 15 +++++++++------ .../service/WordReportGenerationService.java | 14 ++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelTemplateReportGenerationService.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelTemplateReportGenerationService.java index 624c35f..f09b63d 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelTemplateReportGenerationService.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/ExcelTemplateReportGenerationService.java @@ -78,12 +78,15 @@ public class ExcelTemplateReportGenerationService { for (DossierAttributeConfig attribute : dossierAttributesConfig.getDossierAttributeConfigs()) { if (dossierAttribute.getDossierAttributeId().equals(attribute.getId())) { if (attribute.getType().equals(DossierAttributeConfig.DossierAttributeType.IMAGE)) { - if (dossierAttribute.getValue().startsWith("data:")) { - imagePlaceholders.add(new ImagePlaceholder(attribute.getPlaceholder(), Base64.getDecoder() - .decode(dossierAttribute.getValue().split(",")[1]))); - } else { - imagePlaceholders.add(new ImagePlaceholder(attribute.getPlaceholder(), Base64.getDecoder() - .decode(dossierAttribute.getValue()))); + + if(dossierAttribute.getValue() != null) { + if (dossierAttribute.getValue().startsWith("data:")) { + imagePlaceholders.add(new ImagePlaceholder(attribute.getPlaceholder(), Base64.getDecoder() + .decode(dossierAttribute.getValue().split(",")[1]))); + } else { + imagePlaceholders.add(new ImagePlaceholder(attribute.getPlaceholder(), Base64.getDecoder() + .decode(dossierAttribute.getValue()))); + } } } else { dossierAttributesPlaceholder.put(attribute.getPlaceholder(), dossierAttribute.getValue()); diff --git a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/WordReportGenerationService.java b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/WordReportGenerationService.java index ad6f7e3..835bf9e 100644 --- a/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/WordReportGenerationService.java +++ b/redaction-report-service-v1/redaction-report-service-server-v1/src/main/java/com/iqser/red/service/redaction/report/v1/server/service/WordReportGenerationService.java @@ -98,12 +98,14 @@ public class WordReportGenerationService { if (dossierAttribute.getDossierAttributeId().equals(attributeConfig.getId())) { if (attributeConfig.getType().equals(DossierAttributeConfig.DossierAttributeType.IMAGE)) { - if (dossierAttribute.getValue().startsWith("data:")) { - imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder() - .decode(dossierAttribute.getValue().split(",")[1]))); - } else { - imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder() - .decode(dossierAttribute.getValue()))); + if(dossierAttribute.getValue() != null) { + if (dossierAttribute.getValue().startsWith("data:")) { + imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder() + .decode(dossierAttribute.getValue().split(",")[1]))); + } else { + imagePlaceholders.add(new ImagePlaceholder(attributeConfig.getPlaceholder(), Base64.getDecoder() + .decode(dossierAttribute.getValue()))); + } } } else { dossierAttributesPlaceholder.put(attributeConfig.getPlaceholder(), dossierAttribute.getValue());