From 3377af130559c0c20364f706adf232d0287bf8dc Mon Sep 17 00:00:00 2001 From: Anthony Stirling <77850077+Frooodle@users.noreply.github.com> Date: Sun, 25 Jun 2023 09:16:32 +0100 Subject: [PATCH] api tag --- .../software/SPDF/SPdfApplication.java | 7 +-- .../SPDF/controller/api/MergeController.java | 2 + .../api/MultiPageLayoutController.java | 2 + .../api/RearrangePagesPDFController.java | 2 + .../controller/api/RotationController.java | 2 + .../controller/api/ScalePagesController.java | 2 + .../controller/api/SplitPDFController.java | 5 +- .../converters/ConvertImgPDFController.java | 2 + .../converters/ConvertOfficeController.java | 2 + .../api/converters/ConvertPDFToOffice.java | 2 + .../api/converters/ConvertPDFToPDFA.java | 2 + .../api/other/BlankPageController.java | 3 +- .../api/other/CompressController.java | 2 + .../other/ExtractImageScansController.java | 2 + .../api/other/ExtractImagesController.java | 2 + .../api/other/FakeScanControllerWIP.java | 62 ++++++++----------- .../api/other/MetadataController.java | 2 + .../controller/api/other/OCRController.java | 2 + .../api/other/OverlayImageController.java | 2 + .../api/other/RepairController.java | 2 + .../controller/api/pipeline/Controller.java | 50 ++++++++------- .../api/security/CertSignController.java | 2 + .../api/security/PasswordController.java | 2 + .../api/security/WatermarkController.java | 14 ++--- .../web/ConverterWebController.java | 2 + .../controller/web/GeneralWebController.java | 39 ++---------- .../controller/web/HomeWebController.java | 52 ++++++++++++++++ .../controller/web/MetricsController.java | 2 + .../controller/web/OtherWebController.java | 2 + .../controller/web/SecurityWebController.java | 2 + .../software/SPDF/model/PipelineConfig.java | 5 +- src/main/resources/application.properties | 14 ++--- src/main/resources/static/js/pipeline.js | 10 ++- src/main/resources/templates/pipeline.html | 33 +++++----- 34 files changed, 199 insertions(+), 139 deletions(-) create mode 100644 src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java diff --git a/src/main/java/stirling/software/SPDF/SPdfApplication.java b/src/main/java/stirling/software/SPDF/SPdfApplication.java index de43b72c..e89413bd 100644 --- a/src/main/java/stirling/software/SPDF/SPdfApplication.java +++ b/src/main/java/stirling/software/SPDF/SPdfApplication.java @@ -1,15 +1,12 @@ package stirling.software.SPDF; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import java.awt.*; -import java.net.URI; +import org.springframework.core.env.Environment; import jakarta.annotation.PostConstruct; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; - @SpringBootApplication public class SPdfApplication { diff --git a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java index de6d255e..7639d154 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MergeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MergeController.java @@ -17,9 +17,11 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "General", description = "General APIs") public class MergeController { private static final Logger logger = LoggerFactory.getLogger(MergeController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java index cdbf4079..9bf0a3d7 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/MultiPageLayoutController.java @@ -24,9 +24,11 @@ import com.itextpdf.kernel.pdf.xobject.PdfFormXObject; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "General", description = "General APIs") public class MultiPageLayoutController { private static final Logger logger = LoggerFactory.getLogger(MultiPageLayoutController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java index e87a88e3..d9cb2686 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RearrangePagesPDFController.java @@ -18,10 +18,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "General", description = "General APIs") public class RearrangePagesPDFController { private static final Logger logger = LoggerFactory.getLogger(RearrangePagesPDFController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java index acc40484..916d2afb 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/RotationController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/RotationController.java @@ -16,9 +16,11 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "General", description = "General APIs") public class RotationController { private static final Logger logger = LoggerFactory.getLogger(RotationController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java index fafe83e6..420902cf 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/ScalePagesController.java @@ -39,9 +39,11 @@ import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "General", description = "General APIs") public class ScalePagesController { private static final Logger logger = LoggerFactory.getLogger(ScalePagesController.class); 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 4f69afb8..abc201ab 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/SplitPDFController.java @@ -15,9 +15,6 @@ import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.core.io.ByteArrayResource; -import org.springframework.core.io.Resource; -import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; @@ -28,10 +25,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "General", description = "General APIs") public class SplitPDFController { private static final Logger logger = LoggerFactory.getLogger(SplitPDFController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java index 6526dd90..5a74e1a5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertImgPDFController.java @@ -20,9 +20,11 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Convert", description = "Convert APIs") public class ConvertImgPDFController { private static final Logger logger = LoggerFactory.getLogger(ConvertImgPDFController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java index 8c3f72ad..79be9e2e 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertOfficeController.java @@ -17,10 +17,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Convert", description = "Convert APIs") public class ConvertOfficeController { public byte[] convertToPdf(MultipartFile inputFile) throws IOException, InterruptedException { diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java index 7f4a8e3b..7c99ee4d 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToOffice.java @@ -12,9 +12,11 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.PDFToFile; @RestController +@Tag(name = "Convert", description = "Convert APIs") public class ConvertPDFToOffice { @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-html") diff --git a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java index 5d563f98..4ff2b4f2 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java +++ b/src/main/java/stirling/software/SPDF/controller/api/converters/ConvertPDFToPDFA.java @@ -14,10 +14,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Convert", description = "Convert APIs") public class ConvertPDFToPDFA { @PostMapping(consumes = "multipart/form-data", value = "/pdf-to-pdfa") diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/BlankPageController.java b/src/main/java/stirling/software/SPDF/controller/api/other/BlankPageController.java index cc89451a..6ed76edb 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/BlankPageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/BlankPageController.java @@ -28,12 +28,13 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import stirling.software.SPDF.pdf.ImageFinder; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Other", description = "Other APIs") public class BlankPageController { @PostMapping(consumes = "multipart/form-data", value = "/remove-blanks") diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/CompressController.java b/src/main/java/stirling/software/SPDF/controller/api/other/CompressController.java index a20643f3..0002b808 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/CompressController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/CompressController.java @@ -31,11 +31,13 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.GeneralUtils; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Other", description = "Other APIs") public class CompressController { private static final Logger logger = LoggerFactory.getLogger(CompressController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java b/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java index 147195d3..f9ac6761 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImageScansController.java @@ -31,10 +31,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Other", description = "Other APIs") public class ExtractImageScansController { private static final Logger logger = LoggerFactory.getLogger(ExtractImageScansController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImagesController.java b/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImagesController.java index eb7d1c62..c10dd7b4 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImagesController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/ExtractImagesController.java @@ -29,8 +29,10 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Other", description = "Other APIs") public class ExtractImagesController { private static final Logger logger = LoggerFactory.getLogger(ExtractImagesController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/FakeScanControllerWIP.java b/src/main/java/stirling/software/SPDF/controller/api/other/FakeScanControllerWIP.java index 26541bb7..7a25d28c 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/FakeScanControllerWIP.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/FakeScanControllerWIP.java @@ -1,12 +1,31 @@ package stirling.software.SPDF.controller.api.other; +import java.awt.Color; +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +//Required for image manipulation +import java.awt.image.BufferedImage; +import java.awt.image.BufferedImageOp; +import java.awt.image.ConvolveOp; +import java.awt.image.Kernel; +import java.awt.image.RescaleOp; +//Required for file input/output +import java.io.File; import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; +//Other required classes +import java.util.Random; + +//Required for image input/output +import javax.imageio.ImageIO; import org.apache.pdfbox.pdmodel.PDDocument; +import org.apache.pdfbox.pdmodel.PDPage; +import org.apache.pdfbox.pdmodel.PDPageContentStream; +import org.apache.pdfbox.pdmodel.common.PDRectangle; +import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; +import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; +import org.apache.pdfbox.rendering.ImageType; +import org.apache.pdfbox.rendering.PDFRenderer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.ResponseEntity; @@ -17,43 +36,14 @@ import org.springframework.web.multipart.MultipartFile; import com.itextpdf.io.source.ByteArrayOutputStream; +import io.swagger.v3.oas.annotations.Hidden; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; -import stirling.software.SPDF.utils.ProcessExecutor; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; -//Required for PDF manipulation -import org.apache.pdfbox.pdmodel.PDDocument; -import org.apache.pdfbox.pdmodel.PDPage; -import org.apache.pdfbox.pdmodel.PDPageContentStream; -import org.apache.pdfbox.pdmodel.common.PDRectangle; -import org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject; -import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; -import org.apache.pdfbox.rendering.ImageType; -import org.apache.pdfbox.rendering.PDFRenderer; - - -//Required for image manipulation -import java.awt.image.BufferedImage; -import java.awt.image.BufferedImageOp; -import java.awt.image.RescaleOp; -import java.awt.image.AffineTransformOp; -import java.awt.image.ConvolveOp; -import java.awt.image.Kernel; -import java.awt.Color; -import java.awt.geom.AffineTransform; - -//Required for image input/output -import javax.imageio.ImageIO; - -//Required for file input/output -import java.io.File; - -//Other required classes -import java.util.Random; - -import io.swagger.v3.oas.annotations.Hidden; @RestController +@Tag(name = "Other", description = "Other APIs") public class FakeScanControllerWIP { private static final Logger logger = LoggerFactory.getLogger(FakeScanControllerWIP.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/MetadataController.java b/src/main/java/stirling/software/SPDF/controller/api/other/MetadataController.java index ca9c522d..e3979d10 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/MetadataController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/MetadataController.java @@ -19,9 +19,11 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Other", description = "Other APIs") public class MetadataController { diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/OCRController.java b/src/main/java/stirling/software/SPDF/controller/api/other/OCRController.java index 61534aee..c3c323f5 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/OCRController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/OCRController.java @@ -27,10 +27,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Other", description = "Other APIs") public class OCRController { private static final Logger logger = LoggerFactory.getLogger(OCRController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/OverlayImageController.java b/src/main/java/stirling/software/SPDF/controller/api/other/OverlayImageController.java index 949466d9..61768f6a 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/OverlayImageController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/OverlayImageController.java @@ -14,10 +14,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.PdfUtils; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Other", description = "Other APIs") public class OverlayImageController { private static final Logger logger = LoggerFactory.getLogger(OverlayImageController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/other/RepairController.java b/src/main/java/stirling/software/SPDF/controller/api/other/RepairController.java index e076d34b..536f8c89 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/other/RepairController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/other/RepairController.java @@ -16,10 +16,12 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.ProcessExecutor; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Other", description = "Other APIs") public class RepairController { private static final Logger logger = LoggerFactory.getLogger(RepairController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/pipeline/Controller.java b/src/main/java/stirling/software/SPDF/controller/api/pipeline/Controller.java index a8424b67..a8cad084 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/pipeline/Controller.java +++ b/src/main/java/stirling/software/SPDF/controller/api/pipeline/Controller.java @@ -1,9 +1,35 @@ package stirling.software.SPDF.controller.api.pipeline; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.stream.Stream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; +import java.util.zip.ZipOutputStream; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ByteArrayResource; import org.springframework.core.io.Resource; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; @@ -14,35 +40,17 @@ import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import org.springframework.web.multipart.MultipartFile; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.model.PipelineConfig; import stirling.software.SPDF.model.PipelineOperation; import stirling.software.SPDF.utils.WebResponseUtils; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.time.LocalDate; -import java.time.LocalTime; -import java.time.format.DateTimeFormatter; -import java.util.*; -import java.util.stream.Stream; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.io.*; -import java.util.*; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - @RestController +@Tag(name = "Pipeline", description = "Pipeline APIs") public class Controller { @Autowired diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java b/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java index 6e95d175..55000dc7 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/CertSignController.java @@ -51,8 +51,10 @@ import com.itextpdf.signatures.SignatureUtil; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Security", description = "Security APIs") public class CertSignController { private static final Logger logger = LoggerFactory.getLogger(CertSignController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java index 3555cb9c..fa6df6ef 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/PasswordController.java @@ -17,8 +17,10 @@ import org.springframework.web.multipart.MultipartFile; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; @RestController +@Tag(name = "Security", description = "Security APIs") public class PasswordController { private static final Logger logger = LoggerFactory.getLogger(PasswordController.class); diff --git a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java index 037e8445..63bf6476 100644 --- a/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java +++ b/src/main/java/stirling/software/SPDF/controller/api/security/WatermarkController.java @@ -1,8 +1,12 @@ package stirling.software.SPDF.controller.api.security; import java.awt.Color; +import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; +import org.apache.commons.io.IOUtils; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.pdmodel.PDPage; import org.apache.pdfbox.pdmodel.PDPageContentStream; @@ -11,6 +15,7 @@ import org.apache.pdfbox.pdmodel.font.PDType0Font; import org.apache.pdfbox.pdmodel.font.PDType1Font; import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState; import org.apache.pdfbox.util.Matrix; +import org.springframework.core.io.ClassPathResource; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -20,19 +25,14 @@ import org.springframework.web.multipart.MultipartFile; import com.cybozu.labs.langdetect.Detector; import com.cybozu.labs.langdetect.DetectorFactory; -import com.cybozu.labs.langdetect.LangDetectException; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import stirling.software.SPDF.utils.WebResponseUtils; -import org.springframework.core.io.ClassPathResource; -import org.apache.commons.io.IOUtils; - -import java.io.InputStream; -import java.io.FileOutputStream; -import java.io.File; @RestController +@Tag(name = "Security", description = "Security APIs") public class WatermarkController { @PostMapping(consumes = "multipart/form-data", value = "/add-watermark") diff --git a/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java b/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java index f110cdc8..e8c1fa76 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/ConverterWebController.java @@ -6,8 +6,10 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.servlet.ModelAndView; import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.tags.Tag; @Controller +@Tag(name = "Convert", description = "Convert APIs") public class ConverterWebController { @GetMapping("/img-to-pdf") diff --git a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java index f911429b..11a7c9bf 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/GeneralWebController.java @@ -1,14 +1,14 @@ package stirling.software.SPDF.controller.web; -import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.ResponseBody; import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.tags.Tag; @Controller +@Tag(name = "General", description = "General APIs") public class GeneralWebController { @GetMapping("/pipeline") @Hidden @@ -23,12 +23,7 @@ public class GeneralWebController { model.addAttribute("currentPage", "merge-pdfs"); return "merge-pdfs"; } - @GetMapping("/about") - @Hidden - public String gameForm(Model model) { - model.addAttribute("currentPage", "about"); - return "about"; - } + @GetMapping("/multi-tool") @Hidden @@ -36,17 +31,7 @@ public class GeneralWebController { model.addAttribute("currentPage", "multi-tool"); return "multi-tool"; } - - @GetMapping("/") - public String home(Model model) { - model.addAttribute("currentPage", "home"); - return "home"; - } - - @GetMapping("/home") - public String root(Model model) { - return "redirect:/"; - } + @GetMapping("/remove-pages") @Hidden @@ -83,20 +68,4 @@ public class GeneralWebController { return "sign"; } - @GetMapping(value = "/robots.txt", produces = MediaType.TEXT_PLAIN_VALUE) - @ResponseBody - @Hidden - public String getRobotsTxt() { - String allowGoogleVisibility = System.getProperty("ALLOW_GOOGLE_VISIBILITY"); - if (allowGoogleVisibility == null) - allowGoogleVisibility = System.getenv("ALLOW_GOOGLE_VISIBILITY"); - if (allowGoogleVisibility == null) - allowGoogleVisibility = "false"; - if (Boolean.parseBoolean(allowGoogleVisibility)) { - return "User-agent: Googlebot\nAllow: /\n\nUser-agent: *\nAllow: /"; - } else { - return "User-agent: Googlebot\nDisallow: /\n\nUser-agent: *\nDisallow: /"; - } - } - } diff --git a/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java b/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java new file mode 100644 index 00000000..ba857afd --- /dev/null +++ b/src/main/java/stirling/software/SPDF/controller/web/HomeWebController.java @@ -0,0 +1,52 @@ +package stirling.software.SPDF.controller.web; + +import org.springframework.http.MediaType; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +import io.swagger.v3.oas.annotations.Hidden; + +@Controller +public class HomeWebController { + + @GetMapping("/about") + @Hidden + public String gameForm(Model model) { + model.addAttribute("currentPage", "about"); + return "about"; + } + + + + @GetMapping("/") + public String home(Model model) { + model.addAttribute("currentPage", "home"); + return "home"; + } + + @GetMapping("/home") + public String root(Model model) { + return "redirect:/"; + } + + + + @GetMapping(value = "/robots.txt", produces = MediaType.TEXT_PLAIN_VALUE) + @ResponseBody + @Hidden + public String getRobotsTxt() { + String allowGoogleVisibility = System.getProperty("ALLOW_GOOGLE_VISIBILITY"); + if (allowGoogleVisibility == null) + allowGoogleVisibility = System.getenv("ALLOW_GOOGLE_VISIBILITY"); + if (allowGoogleVisibility == null) + allowGoogleVisibility = "false"; + if (Boolean.parseBoolean(allowGoogleVisibility)) { + return "User-agent: Googlebot\nAllow: /\n\nUser-agent: *\nAllow: /"; + } else { + return "User-agent: Googlebot\nDisallow: /\n\nUser-agent: *\nDisallow: /"; + } + } + +} diff --git a/src/main/java/stirling/software/SPDF/controller/web/MetricsController.java b/src/main/java/stirling/software/SPDF/controller/web/MetricsController.java index de73f9e2..1bea8821 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/MetricsController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/MetricsController.java @@ -12,9 +12,11 @@ import io.micrometer.core.instrument.Counter; import io.micrometer.core.instrument.Meter; import io.micrometer.core.instrument.MeterRegistry; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; @RestController @RequestMapping("/api/v1") +@Tag(name = "API", description = "Info APIs") public class MetricsController { private final MeterRegistry meterRegistry; diff --git a/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java b/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java index 90a18de9..2c11decc 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/OtherWebController.java @@ -12,8 +12,10 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.servlet.ModelAndView; import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.tags.Tag; @Controller +@Tag(name = "Other", description = "Other APIs") public class OtherWebController { @GetMapping("/compress-pdf") @Hidden diff --git a/src/main/java/stirling/software/SPDF/controller/web/SecurityWebController.java b/src/main/java/stirling/software/SPDF/controller/web/SecurityWebController.java index 98821c85..0dbb226b 100644 --- a/src/main/java/stirling/software/SPDF/controller/web/SecurityWebController.java +++ b/src/main/java/stirling/software/SPDF/controller/web/SecurityWebController.java @@ -5,8 +5,10 @@ import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.tags.Tag; @Controller +@Tag(name = "Security", description = "Security APIs") public class SecurityWebController { @GetMapping("/add-password") @Hidden diff --git a/src/main/java/stirling/software/SPDF/model/PipelineConfig.java b/src/main/java/stirling/software/SPDF/model/PipelineConfig.java index 8fb7d32a..77ef7a05 100644 --- a/src/main/java/stirling/software/SPDF/model/PipelineConfig.java +++ b/src/main/java/stirling/software/SPDF/model/PipelineConfig.java @@ -1,8 +1,7 @@ package stirling.software.SPDF.model; -import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.List; -import java.util.Map; + +import com.fasterxml.jackson.annotation.JsonProperty; public class PipelineConfig { private String name; diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index be16c7ec..6d5dfe95 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,12 +1,12 @@ -spring.http.multipart.max-file-size=2GB -spring.http.multipart.max-request-size=2GB +spring.http.multipart.max-file-size=${MAX_FILE_SIZE:2000MB} +spring.http.multipart.max-request-size=${MAX_FILE_SIZE:2000MB} multipart.enabled=true -multipart.max-file-size=2000MB -multipart.max-request-size=2000MB +multipart.max-file-size=${MAX_FILE_SIZE:2000MB} +multipart.max-request-size=${MAX_FILE_SIZE:2000MB} -spring.servlet.multipart.max-file-size=2000MB -spring.servlet.multipart.max-request-size=2000MB +spring.servlet.multipart.max-file-size=${MAX_FILE_SIZE:2000MB} +spring.servlet.multipart.max-request-size=${MAX_FILE_SIZE:2000MB} server.forward-headers-strategy=NATIVE @@ -22,7 +22,7 @@ server.servlet.context-path=${APP_ROOT_PATH:/} spring.devtools.restart.enabled=true spring.devtools.livereload.enabled=true -spring.thymeleaf.encoding=UTF-8 +spring.thymeleaf.encoding=UTF-8 server.connection-timeout=${CONNECTION_TIMEOUT:5m} spring.mvc.async.request-timeout=${ASYNC_CONNECTION_TIMEOUT:300000} diff --git a/src/main/resources/static/js/pipeline.js b/src/main/resources/static/js/pipeline.js index 2d8d2638..a96c3f97 100644 --- a/src/main/resources/static/js/pipeline.js +++ b/src/main/resources/static/js/pipeline.js @@ -122,13 +122,17 @@ fetch('v3/api-docs') .then(data => { apiDocs = data.paths; let operationsDropdown = document.getElementById('operationsDropdown'); - + const ignoreOperations = ["operationToIgnore", "operationToIgnore"]; // Add the operations you want to ignore here + operationsDropdown.innerHTML = ''; Object.keys(apiDocs).forEach(operation => { - if (apiDocs[operation].hasOwnProperty('post')) { + if (apiDocs[operation].hasOwnProperty('post')&& !ignoreOperations.includes(operation)) { + let option = document.createElement('option'); - option.textContent = operation; + let operationWithoutSlash = operation.replace(/\//g, ''); // Remove slashes + option.textContent = operationWithoutSlash; + option.value = operation; // Keep the value with slashes for querying operationsDropdown.appendChild(option); } }); diff --git a/src/main/resources/templates/pipeline.html b/src/main/resources/templates/pipeline.html index 66880d7c..53428fa8 100644 --- a/src/main/resources/templates/pipeline.html +++ b/src/main/resources/templates/pipeline.html @@ -14,13 +14,11 @@