shjung пре 2 година
родитељ
комит
54a015259b

+ 2 - 1
src/main/java/com/its/op/entity/its/scrs/TbScIxrCmraMngm.java

@@ -261,7 +261,8 @@ public class TbScIxrCmraMngm implements Serializable {
         dto.setMissSttsYn(ItsUtils.getMissSttsYn(dto.getUpdtDt()));
         if (("Y").equals(dto.getMissSttsYn())) {
             // 기준시각 보다 크기 때문에 상태정보를 통신두절로 설정
-            dto.setCmncSttsCd(CmmnCdManager.CMNC_STTS_ERROR);
+            //TODO: 주기적으로 상태를 업데이트 하지 않고 있음.
+            // dto.setCmncSttsCd(CmmnCdManager.CMNC_STTS_ERROR);
         }
         dto.setCmncSttsDesc(CmmnCdManager.getCodeDescShort(CmmnCdManager.CMNC_STTS_CD, dto.getCmncSttsCd()));
         return dto;

+ 8 - 0
src/main/java/com/its/utils/FileType.java

@@ -0,0 +1,8 @@
+package com.its.utils;
+
+public enum FileType {
+    Word,
+    Cell,
+    Slide,
+    Hwp
+}

+ 119 - 0
src/main/java/com/its/utils/FileUtils.java

@@ -0,0 +1,119 @@
+package com.its.utils;
+
+import java.net.URL;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class FileUtils {
+
+    private FileUtils() { }
+
+    // document extensions
+    private static List<String> extsDocument = Arrays.asList(
+            ".doc", ".docx", ".docm",
+            ".dot", ".dotx", ".dotm",
+            ".odt", ".fodt", ".ott", ".rtf", ".txt",
+            ".html", ".htm", ".mht", ".xml",
+            ".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oxps", ".oform"
+    );
+
+    // spreadsheet extensions
+    private static List<String> extsSpreadsheet = Arrays.asList(
+            ".xls", ".xlsx", ".xlsm", ".xlsb",
+            ".xlt", ".xltx", ".xltm",
+            ".ods", ".fods", ".ots", ".csv"
+    );
+
+    // presentation extensions
+    private static List<String> extsPresentation = Arrays.asList(
+            ".pps", ".ppsx", ".ppsm",
+            ".ppt", ".pptx", ".pptm",
+            ".pot", ".potx", ".potm",
+            ".odp", ".fodp", ".otp"
+    );
+    // hangul extensions
+    private static List<String> extsHangul = Arrays.asList(
+            ".hwp"
+    );
+
+    // get file type
+    public static FileType getFileType(final String fileName) {
+        String ext = getFileExtension(fileName).toLowerCase();
+
+        // word type for document extensions
+        if (extsDocument.contains(ext)) {
+            return FileType.Word;
+        }
+
+        // cell type for spreadsheet extensions
+        if (extsSpreadsheet.contains(ext)) {
+            return FileType.Cell;
+        }
+
+        // slide type for presentation extensions
+        if (extsPresentation.contains(ext)) {
+            return FileType.Slide;
+        }
+
+        // hwp type for presentation extensions
+        if (extsHangul.contains(ext)) {
+            return FileType.Hwp;
+        }
+
+        // default file type is word
+        return FileType.Word;
+    }
+
+
+    // get file name from the url
+    public static String getFileName(final String url) {
+        if (url == null) {
+            return "";
+        }
+
+        // get file name from the last part of url
+        String fileName = url.substring(url.lastIndexOf('/') + 1, url.length());
+        fileName = fileName.split("\\?")[0];
+        return fileName;
+    }
+
+    // get file name without extension
+    public static String getFileNameWithoutExtension(final String url) {
+        String fileName = getFileName(url);
+        if (fileName == null) {
+            return null;
+        }
+        String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf('.'));
+        return fileNameWithoutExt;
+    }
+
+    // get file extension from url
+    public static String getFileExtension(final String url) {
+        String fileName = getFileName(url);
+        if (fileName == null) {
+            return null;
+        }
+        String fileExt = fileName.substring(fileName.lastIndexOf("."));
+        return fileExt.toLowerCase();
+    }
+
+    // get url parameters
+    public static Map<String, String> getUrlParams(final String url) {
+        try {
+            // take all the parameters which are placed after ? sign in the file url
+            String query = new URL(url).getQuery();
+            String[] params = query.split("&");  // parameters are separated by & sign
+            Map<String, String> map = new HashMap<>();
+            for (String param : params) {  // write parameters and their values to the map dictionary
+                String name = param.split("=")[0];
+                String value = param.split("=")[1];
+                map.put(name, value);
+            }
+            return map;
+        } catch (Exception ex) {
+            return null;
+        }
+    }
+}

+ 0 - 1
src/test/java/com/its/op/ItsOpServerApplicationTests.java

@@ -30,7 +30,6 @@ import java.util.Optional;
 import java.util.concurrent.TimeUnit;
 
 import static org.assertj.core.api.Assertions.assertThat;
-
 @Slf4j
 //@SpringBootTest
 @ActiveProfiles(profiles = "dev")