Define a constant for a literal string that is duplicated n times (Sonar) (#978)
Co-authored-by: pixeebot[bot] <104101892+pixeebot[bot]@users.noreply.github.com>
This commit is contained in:
parent
c16db14cd9
commit
1035a3be31
3 changed files with 16 additions and 10 deletions
|
@ -129,7 +129,7 @@ public class EndpointConfiguration {
|
||||||
addEndpointToGroup("Other", "sign");
|
addEndpointToGroup("Other", "sign");
|
||||||
addEndpointToGroup("Other", "flatten");
|
addEndpointToGroup("Other", "flatten");
|
||||||
addEndpointToGroup("Other", "repair");
|
addEndpointToGroup("Other", "repair");
|
||||||
addEndpointToGroup("Other", "remove-blanks");
|
addEndpointToGroup("Other", REMOVE_BLANKS);
|
||||||
addEndpointToGroup("Other", "remove-annotations");
|
addEndpointToGroup("Other", "remove-annotations");
|
||||||
addEndpointToGroup("Other", "compare");
|
addEndpointToGroup("Other", "compare");
|
||||||
addEndpointToGroup("Other", "add-page-numbers");
|
addEndpointToGroup("Other", "add-page-numbers");
|
||||||
|
@ -161,13 +161,13 @@ public class EndpointConfiguration {
|
||||||
|
|
||||||
// python
|
// python
|
||||||
addEndpointToGroup("Python", "extract-image-scans");
|
addEndpointToGroup("Python", "extract-image-scans");
|
||||||
addEndpointToGroup("Python", "remove-blanks");
|
addEndpointToGroup("Python", REMOVE_BLANKS);
|
||||||
addEndpointToGroup("Python", "html-to-pdf");
|
addEndpointToGroup("Python", "html-to-pdf");
|
||||||
addEndpointToGroup("Python", "url-to-pdf");
|
addEndpointToGroup("Python", "url-to-pdf");
|
||||||
|
|
||||||
// openCV
|
// openCV
|
||||||
addEndpointToGroup("OpenCV", "extract-image-scans");
|
addEndpointToGroup("OpenCV", "extract-image-scans");
|
||||||
addEndpointToGroup("OpenCV", "remove-blanks");
|
addEndpointToGroup("OpenCV", REMOVE_BLANKS);
|
||||||
|
|
||||||
// LibreOffice
|
// LibreOffice
|
||||||
addEndpointToGroup("LibreOffice", "repair");
|
addEndpointToGroup("LibreOffice", "repair");
|
||||||
|
@ -217,7 +217,7 @@ public class EndpointConfiguration {
|
||||||
addEndpointToGroup("Java", "split-by-size-or-count");
|
addEndpointToGroup("Java", "split-by-size-or-count");
|
||||||
addEndpointToGroup("Java", "overlay-pdf");
|
addEndpointToGroup("Java", "overlay-pdf");
|
||||||
addEndpointToGroup("Java", "split-pdf-by-sections");
|
addEndpointToGroup("Java", "split-pdf-by-sections");
|
||||||
addEndpointToGroup("Java", "remove-blanks");
|
addEndpointToGroup("Java", REMOVE_BLANKS);
|
||||||
|
|
||||||
// Javascript
|
// Javascript
|
||||||
addEndpointToGroup("Javascript", "pdf-organizer");
|
addEndpointToGroup("Javascript", "pdf-organizer");
|
||||||
|
@ -244,4 +244,6 @@ public class EndpointConfiguration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String REMOVE_BLANKS = "remove-blanks";
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class UserController {
|
||||||
// Logout using Spring's utility
|
// Logout using Spring's utility
|
||||||
new SecurityContextLogoutHandler().logout(request, response, null);
|
new SecurityContextLogoutHandler().logout(request, response, null);
|
||||||
|
|
||||||
return new RedirectView("/login?messageType=credsUpdated");
|
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
||||||
|
@ -130,7 +130,7 @@ public class UserController {
|
||||||
// Logout using Spring's utility
|
// Logout using Spring's utility
|
||||||
new SecurityContextLogoutHandler().logout(request, response, null);
|
new SecurityContextLogoutHandler().logout(request, response, null);
|
||||||
|
|
||||||
return new RedirectView("/login?messageType=credsUpdated");
|
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
||||||
|
@ -163,7 +163,7 @@ public class UserController {
|
||||||
// Logout using Spring's utility
|
// Logout using Spring's utility
|
||||||
new SecurityContextLogoutHandler().logout(request, response, null);
|
new SecurityContextLogoutHandler().logout(request, response, null);
|
||||||
|
|
||||||
return new RedirectView("/login?messageType=credsUpdated");
|
return new RedirectView(LOGIN_MESSAGETYPE_CREDSUPDATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
@PreAuthorize("!hasAuthority('ROLE_DEMO_USER')")
|
||||||
|
@ -291,4 +291,6 @@ public class UserController {
|
||||||
}
|
}
|
||||||
return ResponseEntity.ok(apiKey);
|
return ResponseEntity.ok(apiKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String LOGIN_MESSAGETYPE_CREDSUPDATED = "/login?messageType=credsUpdated";
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ public class ExtractImageScansController {
|
||||||
// Create zip file if multiple images
|
// Create zip file if multiple images
|
||||||
if (processedImageBytes.size() > 1) {
|
if (processedImageBytes.size() > 1) {
|
||||||
String outputZipFilename =
|
String outputZipFilename =
|
||||||
fileName.replaceFirst("[.][^.]+$", "") + "_processed.zip";
|
fileName.replaceFirst(REPLACEFIRST, "") + "_processed.zip";
|
||||||
tempZipFile = Files.createTempFile("output_", ".zip");
|
tempZipFile = Files.createTempFile("output_", ".zip");
|
||||||
|
|
||||||
try (ZipOutputStream zipOut =
|
try (ZipOutputStream zipOut =
|
||||||
|
@ -165,7 +165,7 @@ public class ExtractImageScansController {
|
||||||
for (int i = 0; i < processedImageBytes.size(); i++) {
|
for (int i = 0; i < processedImageBytes.size(); i++) {
|
||||||
ZipEntry entry =
|
ZipEntry entry =
|
||||||
new ZipEntry(
|
new ZipEntry(
|
||||||
fileName.replaceFirst("[.][^.]+$", "")
|
fileName.replaceFirst(REPLACEFIRST, "")
|
||||||
+ "_"
|
+ "_"
|
||||||
+ (i + 1)
|
+ (i + 1)
|
||||||
+ ".png");
|
+ ".png");
|
||||||
|
@ -187,7 +187,7 @@ public class ExtractImageScansController {
|
||||||
byte[] imageBytes = processedImageBytes.get(0);
|
byte[] imageBytes = processedImageBytes.get(0);
|
||||||
return WebResponseUtils.bytesToWebResponse(
|
return WebResponseUtils.bytesToWebResponse(
|
||||||
imageBytes,
|
imageBytes,
|
||||||
fileName.replaceFirst("[.][^.]+$", "") + ".png",
|
fileName.replaceFirst(REPLACEFIRST, "") + ".png",
|
||||||
MediaType.IMAGE_PNG);
|
MediaType.IMAGE_PNG);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -219,4 +219,6 @@ public class ExtractImageScansController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String REPLACEFIRST = "[.][^.]+$";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue