From 6fa0c785fe557fe1ca394a8d09d55da12b1bcd8f Mon Sep 17 00:00:00 2001 From: jinno Yun Date: Mon, 23 Sep 2024 23:06:44 +0900 Subject: [PATCH] =?UTF-8?q?#21=20Refactor:=20checkPageExist=20=EB=A9=94?= =?UTF-8?q?=EC=84=9C=EB=93=9C=20=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../compileJava/previous-compilation-data.bin | Bin 2183005 -> 2183005 bytes .../s3Storage/service/S3StorageService.java | 12 ++++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/web3-credential-server/build/tmp/compileJava/previous-compilation-data.bin b/web3-credential-server/build/tmp/compileJava/previous-compilation-data.bin index f4ee95368cb239610d0557eae795b57cfe3c85fd..3db4634b81dee137d4abe74ff55ac2136d4fae9b 100644 GIT binary patch delta 165 zcmWl~u?>Pi06@`jAnJ(-2r3GSJ2(ZgWDVmCgb;cXTW8S9#0i{1bBPu8jlidPdFoyp z3Xi|=I{E&5pFedgPHmZAWu--= totalPages) { - throw new IllegalArgumentException("Page number out of range: " + pageNumberToRemove); - } + checkPageExist(pageIndexToRemove < 0, pageIndexToRemove >= totalPages, "Page number out of range: " + pageNumberToRemove); byte[] frontPart = createPdfBytesPart(originalDocument, 0, pageIndexToRemove); byte[] backPart = createPdfBytesPart(originalDocument, pageIndexToRemove + 1, originalDocument.getNumberOfPages()); @@ -352,7 +350,7 @@ public void deletePdfForPage(Wallet wallet, int pageNumberToRemove) throws IOExc // PDF 합치기 byte[] finalPdfBytes = mergePdfs(frontPart,backPart); HashMap metadata = getPdfMetadata(fileName); - + log.info("metadata = {}",metadata); metadata.remove("page-" + pageNumberToRemove); // 최종 PDF를 S3에 업로드 @@ -366,6 +364,12 @@ public void deletePdfForPage(Wallet wallet, int pageNumberToRemove) throws IOExc } + private static void checkPageExist(boolean pageIndexToRemove, boolean pageIndexToRemove1, String pageNumberToRemove) { + if (pageIndexToRemove || pageIndexToRemove1) { + throw new IllegalArgumentException(pageNumberToRemove); + } + } + public ResponseInputStream getPdf(String pdfUrl) { String key = extractKeyFromUrl(pdfUrl); GetObjectRequest getObjectRequest = GetObjectRequest.builder()