From 2f703796e96723e5b6f35cb39f01c72507675522 Mon Sep 17 00:00:00 2001 From: Eric <71648843+sbplat@users.noreply.github.com> Date: Thu, 7 Mar 2024 12:05:26 -0500 Subject: [PATCH] fix(SplitPDF): create immutable list for dynamic additions (#877) --- .../software/SPDF/controller/api/SplitPDFController.java | 6 +++++- .../SPDF/controller/api/SplitPdfBySectionsController.java | 1 - .../stirling/software/SPDF/model/ApplicationProperties.java | 1 - src/main/java/stirling/software/SPDF/model/Role.java | 6 +++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java index a69dea34..6979b40b 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java @@ -51,8 +51,12 @@ public class SplitPDFController { PDDocument document = Loader.loadPDF(file.getBytes()); List pageNumbers = request.getPageNumbersList(document, true); - if (!pageNumbers.contains(document.getNumberOfPages() - 1)) + if (!pageNumbers.contains(document.getNumberOfPages() - 1)) { + // Create a mutable ArrayList so we can add to it + pageNumbers = new ArrayList<>(pageNumbers); pageNumbers.add(document.getNumberOfPages() - 1); + } + logger.info( "Splitting PDF into pages: {}", pageNumbers.stream().map(String::valueOf).collect(Collectors.joining(","))); diff --git a/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java b/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java index c3f858ed..3682aaf7 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPdfBySectionsController.java @@ -155,5 +155,4 @@ public class SplitPdfBySectionsController { return splitDocuments; } - } diff --git a/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java b/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java index 30ec1245..a41d641c 100644 --- a/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java +++ b/src/main/java/stirling/software/SPDF/model/ApplicationProperties.java @@ -277,7 +277,6 @@ public class ApplicationProperties { + enableAlphaFunctionality + "]"; } - } public static class Ui { diff --git a/src/main/java/stirling/software/SPDF/model/Role.java b/src/main/java/stirling/software/SPDF/model/Role.java index d2650aee..02e7dd5f 100644 --- a/src/main/java/stirling/software/SPDF/model/Role.java +++ b/src/main/java/stirling/software/SPDF/model/Role.java @@ -20,7 +20,11 @@ public enum Role { // 0 API calls per day and 20 web calls WEB_ONLY_USER("ROLE_WEB_ONLY_USER", 0, 20, "adminUserSettings.webOnlyUser"), - INTERNAL_API_USER("STIRLING-PDF-BACKEND-API-USER", Integer.MAX_VALUE, Integer.MAX_VALUE, "adminUserSettings.internalApiUser"), + INTERNAL_API_USER( + "STIRLING-PDF-BACKEND-API-USER", + Integer.MAX_VALUE, + Integer.MAX_VALUE, + "adminUserSettings.internalApiUser"), DEMO_USER("ROLE_DEMO_USER", 100, 100, "adminUserSettings.demoUser");