diff --git a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java index 1820af65..e4c2d97c 100644 --- a/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java +++ b/src/main/java/cokr/xit/fims/cmmn/CmmnUtil.java @@ -217,26 +217,28 @@ public class CmmnUtil { /** * 리소스 파일을 파일 공통 저장 경로로 복사한다. - * @param staticResourcePath 리소스 파일 경로 + * @param staticResourcePath 리소스 파일 경로, replace 기존 생성 파일 덮어쓰기 여부 * @return */ - public static String copyStaticResource(String staticResourcePath) { + public static String copyStaticResource(String staticResourcePath, boolean replace) { try { String folderPath = FilenameUtils.getFullPathNoEndSeparator(staticResourcePath); String storageRoot = "files"; + ClassPathResource cps = new ClassPathResource(staticResourcePath); + String fileName = cps.getFilename(); + + File newFile = new File(storageRoot + "/" + folderPath + "/" + fileName); + if(replace && newFile.exists()) { + return storageRoot + "/" + folderPath + "/" + fileName; + } File folder = new File(storageRoot + "/" + folderPath); if(!folder.exists()) { folder.mkdirs(); } - - ClassPathResource cps = new ClassPathResource(staticResourcePath); - - String fileName = cps.getFilename(); InputStream is = cps.getInputStream(); - File newFile = new File(storageRoot + "/" + folderPath + "/" + fileName); Files.copy(is, newFile.toPath(), StandardCopyOption.REPLACE_EXISTING); return storageRoot + "/" + folderPath + "/" + fileName; diff --git a/src/main/java/cokr/xit/fims/sprt/service/bean/IntegrationSearchServiceBean.java b/src/main/java/cokr/xit/fims/sprt/service/bean/IntegrationSearchServiceBean.java index d958a6af..773015ca 100644 --- a/src/main/java/cokr/xit/fims/sprt/service/bean/IntegrationSearchServiceBean.java +++ b/src/main/java/cokr/xit/fims/sprt/service/bean/IntegrationSearchServiceBean.java @@ -473,7 +473,7 @@ public class IntegrationSearchServiceBean extends AbstractServiceBean implements } if(!imagePath.startsWith("files")) { - imagePath = CmmnUtil.copyStaticResource(imagePath); + imagePath = CmmnUtil.copyStaticResource(imagePath, false); } File imageFile = new File(imagePath); @@ -537,7 +537,7 @@ public class IntegrationSearchServiceBean extends AbstractServiceBean implements } if(!imagePaths.get(i).startsWith("files")) { - imagePaths.set(i, CmmnUtil.copyStaticResource(imagePaths.get(i))); + imagePaths.set(i, CmmnUtil.copyStaticResource(imagePaths.get(i), false)); } String imagePath = imagePaths.get(i); @@ -661,7 +661,7 @@ public class IntegrationSearchServiceBean extends AbstractServiceBean implements } if(!orgnFilePath.startsWith("files")) { - orgnFilePath = CmmnUtil.copyStaticResource(orgnFilePath);; + orgnFilePath = CmmnUtil.copyStaticResource(orgnFilePath, false); } File orgnFile = new File(orgnFilePath);