diff --git a/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java b/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java index 2b25b7fb..76875ac7 100644 --- a/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java +++ b/src/main/java/stirling/software/SPDF/config/EndpointConfiguration.java @@ -129,7 +129,7 @@ public class EndpointConfiguration { addEndpointToGroup("Other", "sign"); addEndpointToGroup("Other", "flatten"); addEndpointToGroup("Other", "repair"); - addEndpointToGroup("Other", "remove-blanks"); + addEndpointToGroup("Other", REMOVE_BLANKS); addEndpointToGroup("Other", "remove-annotations"); addEndpointToGroup("Other", "compare"); addEndpointToGroup("Other", "add-page-numbers"); @@ -161,13 +161,13 @@ public class EndpointConfiguration { // python addEndpointToGroup("Python", "extract-image-scans"); - addEndpointToGroup("Python", "remove-blanks"); + addEndpointToGroup("Python", REMOVE_BLANKS); addEndpointToGroup("Python", "html-to-pdf"); addEndpointToGroup("Python", "url-to-pdf"); // openCV addEndpointToGroup("OpenCV", "extract-image-scans"); - addEndpointToGroup("OpenCV", "remove-blanks"); + addEndpointToGroup("OpenCV", REMOVE_BLANKS); // LibreOffice addEndpointToGroup("LibreOffice", "repair"); @@ -217,7 +217,7 @@ public class EndpointConfiguration { addEndpointToGroup("Java", "split-by-size-or-count"); addEndpointToGroup("Java", "overlay-pdf"); addEndpointToGroup("Java", "split-pdf-by-sections"); - addEndpointToGroup("Java", "remove-blanks"); + addEndpointToGroup("Java", REMOVE_BLANKS); // Javascript addEndpointToGroup("Javascript", "pdf-organizer"); @@ -244,4 +244,6 @@ public class EndpointConfiguration { } } } + + private static final String REMOVE_BLANKS = "remove-blanks"; } diff --git a/src/main/java/stirling/software/SPDF/controller/api/UserController.java b/src/main/java/stirling/software/SPDF/controller/api/UserController.java index e5c0b114..8e7adf94 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/UserController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/UserController.java @@ -97,7 +97,7 @@ public class UserController { // Logout using Spring's utility new SecurityContextLogoutHandler().logout(request, response, null); - return new RedirectView("/login?messageType=credsUpdated"); + return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED); } @PreAuthorize("!hasAuthority('ROLE_DEMO_USER')") @@ -130,7 +130,7 @@ public class UserController { // Logout using Spring's utility new SecurityContextLogoutHandler().logout(request, response, null); - return new RedirectView("/login?messageType=credsUpdated"); + return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED); } @PreAuthorize("!hasAuthority('ROLE_DEMO_USER')") @@ -163,7 +163,7 @@ public class UserController { // Logout using Spring's utility new SecurityContextLogoutHandler().logout(request, response, null); - return new RedirectView("/login?messageType=credsUpdated"); + return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED); } @PreAuthorize("!hasAuthority('ROLE_DEMO_USER')") @@ -291,4 +291,6 @@ public class UserController { } return ResponseEntity.ok(apiKey); } + + private static final String LOGIN_MESSAGETYPE_CREDSUPDATED = "/login?messageType=credsUpdated"; } diff --git a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java index be82364f..af8bbea6 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/misc/ExtractImageScansController.java @@ -156,7 +156,7 @@ public class ExtractImageScansController { // Create zip file if multiple images if (processedImageBytes.size() > 1) { String outputZipFilename = - fileName.replaceFirst("[.][^.]+$", "") + "_processed.zip"; + fileName.replaceFirst(REPLACEFIRST, "") + "_processed.zip"; tempZipFile = Files.createTempFile("output_", ".zip"); try (ZipOutputStream zipOut = @@ -165,7 +165,7 @@ public class ExtractImageScansController { for (int i = 0; i < processedImageBytes.size(); i++) { ZipEntry entry = new ZipEntry( - fileName.replaceFirst("[.][^.]+$", "") + fileName.replaceFirst(REPLACEFIRST, "") + "_" + (i + 1) + ".png"); @@ -187,7 +187,7 @@ public class ExtractImageScansController { byte[] imageBytes = processedImageBytes.get(0); return WebResponseUtils.bytesToWebResponse( imageBytes, - fileName.replaceFirst("[.][^.]+$", "") + ".png", + fileName.replaceFirst(REPLACEFIRST, "") + ".png", MediaType.IMAGE_PNG); } } finally { @@ -219,4 +219,6 @@ public class ExtractImageScansController { }); } } + + private static final String REPLACEFIRST = "[.][^.]+$"; }