diff --git a/src/main/java/nlib/sch/util/NlibCmmUtil.java b/src/main/java/nlib/sch/util/NlibCmmUtil.java index 4501cc9f..b1e4d586 100644 --- a/src/main/java/nlib/sch/util/NlibCmmUtil.java +++ b/src/main/java/nlib/sch/util/NlibCmmUtil.java @@ -431,318 +431,6 @@ public class NlibCmmUtil { } return false; } - public static String getContextPath(final HttpServletRequest req, final String path) { - //if (isApp(req)) { - return Constant.PREFIX_M + (path.startsWith("/") ? path : "/" + path); - //} - // return path; - } - public static String unscript(String data) { - if (data == null || data.trim().equals("")) { - return ""; - } - - String ret = data; - - ret = ret.replaceAll("<(S|s)(C|c)(R|r)(I|i)(P|p)(T|t)", "<script"); - ret = ret.replaceAll(" getListMapFromJsonArray( JSONArray jsonArray ) { - List list = new ArrayList(); - if( jsonArray != null ){ - int jsonSize = jsonArray.length(); - for( int i = 0; i < jsonSize; i++ ){ - DataMap map = NlibCmmUtil.getMapFromJsonObject( ( JSONObject ) jsonArray.get(i) ); - list.add( map ); - } - } - return list; - } - public static String getAisSidoName(String sido) { - String rtnStr = ""; - for(int i=0;i 0){ - for(Cookie cookie : cookies){ - if(Name.equals(cookie.getName())){ - cookieValue = cookie.getValue(); - break; - } - } - } - return cookieValue; - } - public static String getDecoderCookie(final HttpServletRequest req, String Name){ - String cookieValue = ""; - Cookie[] cookies = req.getCookies(); - if(cookies != null && cookies.length > 0){ - for(Cookie cookie : cookies){ - if(Name.equals(cookie.getName())){ - try { - cookieValue = java.net.URLDecoder.decode(cookie.getValue(),Constant.ENCODING_UTF8); - } catch (UnsupportedEncodingException e) { - LOGGER.error("fail in getDecoderCookie()" , e); - } catch (Exception e) { - LOGGER.error("fail in getDecoderCookie()", e); - } - break; - } - } - } - return cookieValue; - } - public static String getCookieIdKey(){ - return propertyService.getString("kccf.cookie.id.key"); - } - - public static String getCookieId(final HttpServletRequest req){ - String cookieId = ""; - String key = getCookieIdKey(); - Cookie[] cookies = req.getCookies(); - if(cookies != null && cookies.length > 0){ - for(Cookie cookie : cookies){ - if(key.equals(cookie.getName())){ - try { - cookieId = java.net.URLDecoder.decode( cookie.getValue(),Constant.ENCODING_UTF8); - } catch (UnsupportedEncodingException e) { - LOGGER.error("fail in getCookieId()" , e); - } catch (Exception e) { - LOGGER.error("fail in getCookieId()", e); - } - break; - } - } - } - return cookieId; - } - public static String getNewCookieId(final HttpServletRequest req){ - String key = getCookieIdKey(); - String value = ""; - try { - value = java.net.URLEncoder.encode( encryptPassword(getPassStr(50), key) , Constant.ENCODING_UTF8 ); - } catch (UnsupportedEncodingException e) { - LOGGER.error("Error in getNewCookieId()", e); - } catch (Exception e) { - LOGGER.error("Error in getNewCookieId()", e); - } - return value; - } - public static void setCookieId(final HttpServletRequest req, final HttpServletResponse res){ - String key = getCookieIdKey(); - String value = ""; - - try { - value = java.net.URLEncoder.encode( encryptPassword(getPassStr(50), key) , Constant.ENCODING_UTF8 ); - } catch (UnsupportedEncodingException e) { - LOGGER.error("Error in setCookieId()", e); - } catch (Exception e) { - LOGGER.error("Error in setCookieId()", e); - } - - /* 2019.02.26 웹취약점 수정사항 => 1시간마다 쿠키 만료되고 있음 - String maxAge = String.valueOf((60*60*24*365)*10); - if (maxAge.matches("[0-9]+")) { - Cookie cookie = new Cookie(key,value); - // 수정 : 외부입력값 검증 후 쿠키 유효시한 설정에 사용 - int t = Integer.parseInt(maxAge); - if ( t > 3600 ) { - t = 3600; - } - cookie.setMaxAge(t); - cookie.setPath("/"); - res.addCookie(cookie); - } - */ - - // 쿠키 유효기간 1년으로 변경 (2019.08.08) - int maxAge = 60*60*24*365; // 1년 - Cookie cookie = new Cookie(key,value); - cookie.setMaxAge(maxAge); - cookie.setPath("/"); - res.addCookie(cookie); - } - - public static void setCookie(final HttpServletResponse res, String key, String value){ - /* 2019.02.26 웹취약점 수정사항 => 1시간마다 쿠키 만료되고 있음 - String maxAge = String.valueOf((60*60*24*365)*10); - if (maxAge.matches("[0-9]+")) { - Cookie cookie = new Cookie(key,value); - // 수정 : 외부입력값 검증 후 쿠키 유효시한 설정에 사용 - int t = Integer.parseInt(maxAge); - if ( t > 3600 ) { - t = 3600; - } - cookie.setMaxAge(t); - cookie.setPath("/"); - res.addCookie(cookie); - } - */ - - // 쿠키 유효기간 1년으로 변경 (2019.08.08) - int maxAge = 60*60*24*365; // 1년 - Cookie cookie = new Cookie(key,value); - cookie.setMaxAge(maxAge); - cookie.setPath("/"); - res.addCookie(cookie); - } - - public static void setEncoderCookie(final HttpServletResponse res, String key, String value){ - - try { - value = java.net.URLEncoder.encode(value,Constant.ENCODING_UTF8); - } catch (UnsupportedEncodingException e) { - LOGGER.error("Error in setEncoderCookie()", e); - } catch (Exception e) { - LOGGER.error("Error in setEncoderCookie()", e); - } - - /* 2019.02.26 웹취약점 수정사항 => 1시간마다 쿠키 만료되고 있음 - String maxAge = String.valueOf((60*60*24*365)*10); - if (maxAge.matches("[0-9]+")) { - Cookie cookie = new Cookie(key,value); - // 수정 : 외부입력값 검증 후 쿠키 유효시한 설정에 사용 - int t = Integer.parseInt(maxAge); - if ( t > 3600 ) { - t = 3600; - } - cookie.setMaxAge(t); - cookie.setPath("/"); - res.addCookie(cookie); - } - */ - - // 쿠키 유효기간 1년으로 변경 (2019.08.08) - int maxAge = 60*60*24*365; // 1년 - Cookie cookie = new Cookie(key,value); - cookie.setMaxAge(maxAge); - cookie.setPath("/"); - res.addCookie(cookie); - } - - public static void removeCookie(final HttpServletRequest req, final HttpServletResponse res, String key){ - Cookie[] cookies = req.getCookies(); - if(cookies != null && cookies.length > 0){ - for(Cookie cookie : cookies){ - if(key.equals(cookie.getName())){ - cookie.setMaxAge(0); - cookie.setPath("/"); - cookie.setSecure(true); //중요정보 평문전송 (HTTP): 취약점 수정 - String val = cookie.getValue(); - String filtered_val = val.replaceAll("\r","").replaceAll("\n",""); - Cookie cookie2 = new Cookie(key, filtered_val); - res.addCookie(cookie2); - break; - } - } - } - } - private static String encryptPassword(String key, String val) throws NoSuchAlgorithmException { - if (key == null) { - return ""; - } - byte[] hashValue = null; // 해쉬값 - MessageDigest md = MessageDigest.getInstance("SHA-512"); - md.reset(); - md.update(val.getBytes()); - hashValue = md.digest(key.getBytes()); - - return new String(Base64.encodeBase64(hashValue)).replaceAll("\\+", "").replaceAll("=", ""); - } - public static boolean isSido(String str){ - boolean isSido = false; - for(int i=0; i -1 ){ - isSido = true; - break; - } - if(str.indexOf( Constant.AIS_SIDO_PARAM_NAME_ARRAY[i] ) > -1 ){ - isSido = true; - break; - } - } - return isSido; - } - public static String changeSido(String str){ - if(str == null || "".equals(str)) return ""; - String rtnSido = ""; - for(int i=0; i -1 ){ - rtnSido = Constant.AIS_SIDO_PARAM_NAME_ARRAY[i]; - break; - } - if(str.indexOf( Constant.AIS_SIDO_PARAM_NAME_ARRAY[i] ) > -1 ){ - rtnSido = Constant.AIS_SIDO_PARAM_NAME_ARRAY[i]; - break; - } - } - return rtnSido; - } - public static void setAmsPathModelMap(HttpServletRequest req, ModelMap modelMap){ - // ams 경로 - String amsAssetsPath = getPropertyStr(Constant.AMS_SERVER_KEY) + getPropertyStr(Constant.AMS_ASSETS_PATH_KEY); - String amsThumbnailPath = getPropertyStr(Constant.AMS_THUMBNAIL_PATH_KEY); - String amsImagePath = getPropertyStr(Constant.AMS_FILE_PATH_KEY); - modelMap.addAttribute("amsAssetsPath", amsAssetsPath); - modelMap.addAttribute("amsThumbnailPath", amsThumbnailPath); - modelMap.addAttribute("amsImagePath", amsImagePath); - } - public static void setNfsPathModelMap(HttpServletRequest req, ModelMap modelMap){ // ams 경로 String nfsNasPath = getPropertyStr(Constant.NFS_NAS_KEY); @@ -751,286 +439,6 @@ public class NlibCmmUtil { modelMap.addAttribute("nfsDocPath", nfsDocPath); } - public static String getAssetImageUrl(String imagePath) { - String imageUrl = ""; - if (StringUtils.isEmpty(imagePath)) return imageUrl; - - String amsAssetsPath = getPropertyStr(Constant.AMS_SERVER_KEY) + getPropertyStr(Constant.AMS_ASSETS_PATH_KEY); - String amsThumbnailPath = getPropertyStr(Constant.AMS_THUMBNAIL_PATH_KEY); - if (imagePath.startsWith("http")) { // http 포함한 전체 경로일 경우 ex) object storage 이미지 - imageUrl = imagePath; - - } else if (imagePath.indexOf("/") >= 0) { // ex) 2/2/7292_thumbnail.jpg - imageUrl = amsAssetsPath + "/" + imagePath; - - } else { - imageUrl = amsAssetsPath + "/" + amsThumbnailPath + "/" + imagePath; // ex) ac6be22ee9db4414aeb4dab6078d27feb723f1c0.jpg - } - - imageUrl = imageUrl.replaceAll("//", "/"); - imageUrl = imageUrl.replaceAll(":/", "://"); // ex) https:/ => https:// - - return imageUrl; - } - - - public static String getContentsImageUrl(String imagePath) { - String imageUrl = ""; - if (StringUtils.isEmpty(imagePath)) return imageUrl; - - String amsAssetsPath = getPropertyStr(Constant.KCCF_HOME_KEY); - if (imagePath.startsWith("http")) { // http 포함한 전체 경로일 경우 ex) object storage 이미지 - imageUrl = imagePath; - - } else if (imagePath.indexOf("/") >= 0) { // ex) 2/2/7292_thumbnail.jpg - imageUrl = amsAssetsPath + "/" + imagePath; - - } else { - imageUrl = amsAssetsPath + "/" + imagePath; // ex) ac6be22ee9db4414aeb4dab6078d27feb723f1c0.jpg - } - - imageUrl = imageUrl.replaceAll("//", "/"); - imageUrl = imageUrl.replaceAll(":/", "://"); // ex) https:/ => https:// - - return imageUrl; - } - - - public static void setUploadPathModelMap(HttpServletRequest req, ModelMap modelMap){ - // 서버경로 (upload폴더 상위경로) : 로컬 개발시 upload 파일이 로컬에 존재하지 않을 경우 사용 - String uploadHomePath = getPropertyStr(Constant.UPLOAD_HOME_KEY); - modelMap.addAttribute("uploadHomePath", uploadHomePath); - } - - /** - * 자산미디어 - 문서 목차 문자열 파싱 - * -테스트 목차 -----1 -제1장 6.25전쟁 전투수기 -----100 - -발간사 ---2 ***1 -축간사(창녕군수) ---4 -축간사(창녕군의회의장)---5 -제1장 6.25전쟁 전투수기 ***2 - 끊어진 한강 철교 빈 보트로 건너다.(성경상) ---12 - 포탄이 날아들어 전우 3명이 즉사하다.(김윤규) ---16 - * - * @param str - * @return - * @throws Exception - */ - public static List parseTableOfContents(String str) { - List list = new ArrayList(); - if (StringUtils.isEmpty(str)) return list; - - - String[] lineArr = str.split("\n"); - int listIdx = 1; - for (int i=0; i errorList = new ArrayList(); - - if (idx1 >= 0 && idx2 >= 0) { // ex) 발간사 ---2 ***1 - String[] arr = line.split(pattern1); - title = arr[0]; - String[] arr2 = arr[1].split(pattern2); - - try { - if (arr2.length == 2) { - pageNum = parseTableOfContentsPageNum(arr2[0]); - ocrFileNum = new Integer(StringUtils.trim(arr2[1]).replaceAll(" ", "")); - - } else if (arr2.length == 1) { // ex) 1. 옹기의 지역적인 특성 ---7 *** - pageNum = parseTableOfContentsPageNum(arr2[0]); - ocrFileNum = new Integer(""); // 강제로 에러발생시킴 - } - } catch (Exception e) { - errorList.add(listIdx+"\t"+e.getMessage()); - } - } else if (idx1 >= 0 && idx2 < 0) { // ex) 축간사(창녕군수) ---4 - String[] arr = line.split(pattern1); - title = arr[0]; - try { - pageNum = parseTableOfContentsPageNum(arr[1]); - } catch (Exception e) { - errorList.add(listIdx+"\t"+e.getMessage()); - } - - } else if (idx1 < 0 && idx2 >= 0) { // ex) 제1장 6.25전쟁 전투수기 ***2 - String[] arr = line.split(pattern2); - title = arr[0]; - try { - if (arr.length == 2) { - ocrFileNum = new Integer(StringUtils.trim(arr[1]).replaceAll(" ", "")); - - } else if (arr.length == 1) { // ex) -참고문헌 *** - ocrFileNum = new Integer(""); // 강제로 에러발생시킴 - } - } catch (Exception e) { - errorList.add(listIdx+"\t"+e.getMessage()); - } - - } else { - title = line; - } - - list.add(new CmmAmsDocTableOfContentsVO(title, pageNum, ocrFileNum, errorList)); - listIdx++; - } - - return list; - } - - /** - * PDF 목차 페이지번호 파싱 - * @param pageNumStr - * @return - * @throws Exception - */ - public static String parseTableOfContentsPageNum(String pageNumStr) throws Exception { - if (StringUtils.isEmpty(pageNumStr)) { - pageNumStr = new Integer(pageNumStr).toString(); // 강제로 Exception 발생시킴 - } - - pageNumStr = StringUtils.trim(pageNumStr).replaceAll(" ", ""); - - boolean isPageNum = true; - for (int i=0; i list, String delimiter) throws Exception { - StringBuffer sb = new StringBuffer();; - - String title = ""; - int titleDepth = 1; - int prevTitleDepth = 100; - String pageNum = null; - Integer ocrFileNum = null; - boolean hasOcrFileNum = false; - - for (int i=0; list!=null && i= 0) { - title = title.replaceAll("\"", " "); // 따옴표 치환 - } - pageNum = vo.getPageNum(); - - ocrFileNum = vo.getOcrFileNum(); - - if (ocrFileNum != null) { - hasOcrFileNum = true; - } else { - hasOcrFileNum = false; - } - - if (title.startsWith(" ") || title.startsWith("\t")) { - if (title.startsWith(" ")) { // 공백6칸 - titleDepth = 4; - } else if (title.startsWith(" ")) { // 공백5칸 - titleDepth = 4; - } else if (title.startsWith(" ")) { // 공백4칸 - titleDepth = 3; - } else if (title.startsWith(" ")) { // 공백3칸 - titleDepth = 3; - } else if (title.startsWith(" ")) { // 공백2칸 - titleDepth = 2; - } else if (title.startsWith(" ")) { // 공백1칸 - titleDepth = 2; - } else if (title.startsWith(" •")) { // 공백1칸 +원문자 ex) K163832.pdf - titleDepth = 2; - } - } else { - titleDepth = 1; - } - - String cssDepth = ""; - if (titleDepth == 1) cssDepth = "d1"; - else if (titleDepth == 2) cssDepth = "d2"; - else if (titleDepth == 3) cssDepth = "d3"; - else if (titleDepth == 4) cssDepth = "d4"; - - if (hasOcrFileNum) { - if (i > 0 && ocrFileNum != null) sb.append(delimiter); - title = title.replaceAll("(\r\n|\r|\n|\n\r)", ""); - sb.append("

"+title); - if (pageNum != null) sb.append(" - "+pageNum); - sb.append("

"); - - } else { - title = title.replaceAll("(\r\n|\r|\n|\n\r)", ""); - sb.append("

"+title); - if (pageNum != null) sb.append(" - "+pageNum); - sb.append("

"); - } - - // ocrFileNum 위치 검증 - if (titleDepth == 1 && prevTitleDepth > 1 && !hasOcrFileNum) { - List errorList = vo.getErrorList(); - errorList.add((i+1)+"\t"+"missing divided file number? : "+title+(pageNum!=null ? " - "+pageNum : "")); - } - - - prevTitleDepth = titleDepth; - } - - return sb.toString(); - } - - /** - * URL scheme HTTPS로 변경 - * @param url - * @return - */ - public static String changeSchemeToHttps(String url) { - String result = ""; - if (StringUtils.isEmpty(url)) return result; - - Pattern p = Pattern.compile("^(http:\\/\\/|https:\\/\\/)?(www\\.)?(.*)$"); // URL 앞부분 패턴 - Matcher m = p.matcher(url); - if (m.find()) { - LOGGER.info("changeSchemeToHttps() m.groupCount()={}, m.group(1)={}, m.group(2)={}, m.group(3)={}, m.group(0)={}", m.groupCount(), m.group(1), m.group(2), m.group(3), m.group(0)); - result = "https://"; - if (m.group(2) != null) result += m.group(2); - result += m.group(3); - } - - return result; - } - public static String getLinkUrl(String aId, String mId )throws EgovBizException { DataMap param = new DataMap(); diff --git a/src/main/webapp/WEB-INF/jsp/nlib/collection/searchItemDetail.jsp b/src/main/webapp/WEB-INF/jsp/nlib/collection/searchItemDetail.jsp index 8ddfaa0a..545135ff 100644 --- a/src/main/webapp/WEB-INF/jsp/nlib/collection/searchItemDetail.jsp +++ b/src/main/webapp/WEB-INF/jsp/nlib/collection/searchItemDetail.jsp @@ -248,12 +248,12 @@ function goList(){
반납예정일
-
+
-
대출
-
+
신청가능 예약가능 신청/예약불가