params) throws Exception {
+
+ if (!UserInfo.isValidSession(request, response, "admin")) {
+ throw new Exception("로그인이 필요한 서비스입니다.");
+ }
+
+ String userId = (String)request.getSession().getAttribute("admin.userID");
+ params.put("userId", userId);
+
+ try {
+ homeTrainingMapper.callSpDelHomeTrainingReg(params);
+ return params;
+ } catch (SQLException e) {
+ throw new Exception( e.getMessage() );
+ }
+
+ }
+
+}
diff --git a/src/main/java/geoinfo/util/Box.java b/src/main/java/geoinfo/util/Box.java
new file mode 100644
index 0000000..3fe5211
--- /dev/null
+++ b/src/main/java/geoinfo/util/Box.java
@@ -0,0 +1,831 @@
+/*******************************************************************/
+/* Class Name : Box */
+/* Description : HttpRequest 값을 다루기 위한 Class */
+/*******************************************************************/
+/* Modification Log */
+/* No DATE Company Author Description */
+/*******************************************************************/
+package geoinfo.util;
+
+import java.util.Hashtable;
+import java.util.Enumeration;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.jfree.util.Log;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.net.MalformedURLException;
+import java.text.ParseException;
+
+/**
+ *
+ * HttpRequest 값과 Entity class와의 간편한 mapping을 도와준다.
+ * Usage :
+ * Box box = HttpUtility.getBox(req);
+ * 또는
+ * Box box = HttpUtility.getBoxFromCookie(req);
+ * box.copyToEntity(c); // c class field 에 해당하는 값을 넣어준다.
+ *
+ * checkbox 와 같이 여러개의 값이 한 key 에 있을 경우 다음 처럼 받을 수 있다.
+ * Vector list = box.getVector("id_list")
+ *
+ * @(#)
+ * Copyright 1999-2000 by LG-EDS Systems, Inc.,
+ * Information Technology Group, Application Architecture Team,
+ * Application Intrastructure Part.
+ * 236-1, Hyosung-2dong, Kyeyang-gu, Inchun, 407-042, KOREA.
+ * All rights reserved.
+ *
+ * NOTICE ! You can copy or redistribute this code freely,
+ * but you should not remove the information about the copyright notice
+ * and the author.
+ *
+ *
+ *
+ *
+ * @author WonYoung Lee, wyounglee@lgeds.lg.co.kr.
+ */
+
+public class Box extends java.util.Hashtable {
+
+ private static final Logger logger = LoggerFactory.getLogger(Box.class);
+
+ /**
+ * MultipartParser 파일이 스프링을 통해 넘어왔을 경우 mReq를 셋팅한다.
+ */
+ private org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest springMPas;
+
+ private String mType = ""; // NORMAL(mPas), SPRING(mReq)
+
+ /**
+ * String format
+ */
+ public static final int DEF_DATE_FMT = 1; // 년월일
+ public static final int DEF_DATETIME_FMT = 2; // 년월일 시분초
+ public static final int THOUSAND_COMMA = 3; // 천단위 콤마 ( 정수형 )
+ public static final int THOUSAND_COMMA_FLOAT = 4; // 천단위 콤마 ( 소수점 포함 )
+ public static final int ZIP_CODE = 5; // 우편번호
+ public static final int JUMIN_NO = 6; // 주민등록번호
+ public static final int MULTILINE_TEXT = 7; // 여러줄 문자열
+ public static final int DEF_DATETIME_FMT_APM = 8; // 년월일 시분초 (오전 오후)
+ public static final int HTML = 9; // HTML 형태
+ public static final int YES_NO = 10; // 예, 아니오
+ public static final int POSSIBLE_OR_NOT = 11; // 가능, 불가능
+ public static final int JAVASCRIPT = 12; // 자바스크립트 사용
+ public static final int SPECIAL_CHAR = 23; // 특수문자 치환
+
+ private Hashtable colIndex = new Hashtable();
+
+ protected String name = null;
+
+ public Box() {
+ super();
+ this.name = "";
+ }
+
+ /**
+ *
+ * Constructor
+ *
+ *
+ * @param name
+ * Box의 이름
+ */
+ public Box(String name) {
+ super();
+ this.name = name;
+ }
+
+
+ public void setParser(org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest springMPas) {
+ this.springMPas = springMPas;
+ mType = "SPRING";
+ }
+
+ // upload file의 클라이언트가 보낸 파일 이름
+ public String getSourceFileNm(String key) {
+ try {
+ return springMPas.getFile(key).getOriginalFilename();
+ } catch (NumberFormatException e) {
+ return "";
+ } catch (Exception e) {
+ return "";
+ }
+
+ }
+
+ // upload되어 서버에 저장된 파일의 이름
+ public String getStoredFileNm(String key) {
+ try {
+ return springMPas.getFile(key).getName();
+ } catch (NumberFormatException e) {
+ return "";
+ } catch (Exception e) {
+ return "";
+ }
+ }
+
+ // 저장된 파일의 사이즈
+ public String getStoredFileSize(String key) throws Exception {
+ try {
+ return (new Long(springMPas.getFile(key).getSize())).toString();
+ } catch (NumberFormatException e) {
+ return "0";
+ } catch (Exception e) {
+ return "0";
+ }
+
+ }
+
+ // 파일이 업로드 되었는지 체크
+ public boolean isUploaded(String key) {
+ return springMPas.getFileMap().get(key) != null ? true : false;
+ }
+
+ // 업로드된 파일이 최대크기를 초과하였는지 체크
+ public boolean isOverLimitSize(String key, int limitSize) throws Exception {
+ return Long.parseLong(getStoredFileSize(key)) / 1000 / 1000 >= limitSize ? true : false;
+ }
+
+ /**
+ *
+ * Box를 복사해 새로운 Box instance를 반환한다.
+ *
+ *
+ * @return Object 복사된 Box Object
+ */
+ public Object clone() {
+
+ Box newbox = new Box(name);
+
+ Hashtable src = (Hashtable) this;
+ Hashtable target = (Hashtable) newbox;
+
+ Enumeration e = src.keys();
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement();
+ Object value = src.get(key);
+ target.put(key, value);
+ }
+ return newbox;
+ }
+
+ /**
+ *
+ * Box에 있는 값 중 entity class의 field 에 해당하는 값이 있으면 entity object의 filed 값을 셋팅.
+ * Usage :
+ * Box box = HttpUtility.getBox(req);
+ * box.copyToEntity(c); // c class field 에 해당하는 값을 넣어준다.
+ *
+ *
+ * @param entity
+ * java.lang.Object
+ */
+ public Object copyToEntity(Object entity) {
+ if (entity == null)
+ throw new NullPointerException("trying to copy from box to null entity class");
+
+ Class c = entity.getClass();
+ java.lang.reflect.Field[] field = c.getFields();
+ for (int i = 0; i < field.length; i++) {
+ try {
+ String fieldtype = field[i].getType().getName();
+ String fieldname = field[i].getName();
+
+ if (containsKey(fieldname)) {
+ if (fieldtype.equals("java.lang.String")) {
+ field[i].set(entity, getString(fieldname));
+ } else if (fieldtype.equals("int")) {
+ field[i].setInt(entity, getInt(fieldname));
+ } else if (fieldtype.equals("double")) {
+ field[i].setDouble(entity, getDouble(fieldname));
+ } else if (fieldtype.equals("long")) {
+ field[i].setLong(entity, getLong(fieldname));
+ } else if (fieldtype.equals("float")) {
+ field[i].set(entity, new Float(getDouble(fieldname)));
+ } else if (fieldtype.equals("boolean")) {
+ field[i].setBoolean(entity, getBoolean(fieldname));
+ }
+ }
+ } catch (NumberFormatException e) {
+ logger.debug("error", e);
+ } catch (Exception e) {
+ logger.debug("error", e);
+ }
+ }
+ return entity;
+ }
+
+ public Properties getProperty() {
+ Properties pt = new Properties();
+
+ Enumeration e = this.keys();
+ while (e.hasMoreElements()) {
+ String key = (String) e.nextElement();
+ pt.setProperty(key, this.get(key));
+ }
+ return pt;
+ }
+
+ // index에 의해 데이터를 가져올때 사용
+ public String get(int idx) {
+ String key = (String) colIndex.get((new Integer(idx).toString()));
+ return get(key);
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 String 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return String 찾은 값
+ */
+ public String get(String key) {
+ return getString(key);
+ }
+
+ /**
+ * key에 해당하는 값이 없을 경우 target의 값을 리턴한다.
+ *
+ * @param key
+ * @param target
+ * @return
+ */
+ public String getNvl(String key, String target) {
+ String str = getString(key);
+ if (str == null || str.equals(""))
+ str = target;
+ return str;
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 금액 표시에 맞게 천단위 , 를 붙여 가져온다. 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return String 찾은 값
+ */
+ public String getThdComma(String key) {
+ return FormatUtil.insertComma(get(key));
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 boolean 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return boolean 찾은 값
+ */
+ public boolean getBoolean(String key) {
+ String value = getString(key);
+ boolean isTrue = false;
+ try {
+ isTrue = (new Boolean(value)).booleanValue();
+ } catch (NumberFormatException e) {
+ logger.debug("error", e);
+ } catch (Exception e) {
+ logger.debug("error", e);
+ }
+ return isTrue;
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 double 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return double 찾은 값
+ */
+ public double getDouble(String key) {
+ String value = removeComma(getString(key));
+ if (value.equals(""))
+ return 0;
+ double num = 0;
+ try {
+ num = Double.valueOf(value).doubleValue();
+ } catch (NumberFormatException e) {
+ num = 0;
+ } catch (Exception e) {
+ num = 0;
+ }
+ return num;
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 double 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return double 찾은 값
+ */
+ public float getFloat(String key) {
+ return (float) getDouble(key);
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 int 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return int 찾은 값
+ */
+ public int getInt(String key) {
+ double value = getDouble(key);
+ return (int) value;
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 long 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return long 찾은 값
+ */
+ public long getLong(String key) {
+ String value = removeComma(getString(key));
+ if (value.equals(""))
+ return 0L;
+
+ long lvalue = 0L;
+ try {
+ lvalue = Long.valueOf(value).longValue();
+ } catch (NumberFormatException e) {
+ lvalue = 0L;
+ } catch (Exception e) {
+ lvalue = 0L;
+ }
+ return lvalue;
+ }
+
+ /**
+ *
+ * Box에서 날짜에 해당하는 값을 가져온다.
+ * usage)
+ * box.getDateParams("due_date");
+ * 는 다음과 같다.
+ * box.get("due_date1") + box.get("due_date2") + box.get("due_date3");
+ * request.getParameter("due_date1") + request.getParameter("due_date2") + request.getParameter("due_date3");
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return String 찾은 값
+ */
+ public String getDateParams(String key) {
+
+ return getString(key + "1") + getString(key + "2") + getString(key + "3");
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 String 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return String 찾은 값
+ */
+ public String getString(String key) {
+ String value = "";
+ try {
+ Object o = (Object) super.get(key);
+ Class c = o.getClass();
+ if (o == null)
+ value = "";
+ else if (c.isArray()) {
+ int length = Array.getLength(o);
+ if (length == 0)
+ value = "";
+ else {
+ for (int i = 0; i < Array.getLength(o); i++) {
+ Object item = Array.get(o, i);
+ if (item != null) {
+ value += item.toString();
+ }
+ }
+ }
+ } else
+ value = o.toString();
+ } catch (NumberFormatException e) {
+ value = "";
+ } catch (Exception e) {
+ value = "";
+ }
+ return value;
+ }
+
+ /**
+ *
+ * check box 와 같이 같은 name에 대해 여러 value들이 String의 Vector로 넘겨준다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return Vector
+ */
+ public Vector getVector(String key) {
+ Vector vector = new Vector();
+ try {
+ Object o = (Object) super.get(key);
+ Class c = o.getClass();
+ if (o != null) {
+ if (c.isArray()) {
+ int length = Array.getLength(o);
+ if (length != 0) {
+ for (int i = 0; i < length; i++) {
+ Object tiem = Array.get(o, i);
+ if (tiem == null)
+ vector.addElement("");
+ else
+ vector.addElement(tiem.toString());
+ }
+ }
+ } else
+ vector.addElement(o.toString());
+ }
+ } catch (NumberFormatException e) {
+ logger.debug("error", e);
+ } catch (Exception e) {
+ logger.debug("error", e);
+ }
+ return vector;
+ }
+
+ public String getVectorValueAt(String key, int i) {
+ Object o = (Object) super.get(key);
+ Class c = o.getClass();
+ if (c.isArray()) {
+ Object tiem = Array.get(o, i);
+ return tiem.toString();
+ } else {
+ return get(key);
+ }
+ }
+
+ public int getVectorSize(String key) {
+ return getVector(key).size();
+ }
+
+ /**
+ *
+ * check box 와 같이 같은 name에 대해 여러 value들이 String의 Vector에서 값을 빼내 스트링으로
+ * 붙여서 넘겨준다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @param concat_str
+ * string과 string을 붙일때 사용될 문자열
+ * @param trim_tail
+ * 스트링의 맨뒤의 concat_str을 없앨것인지 여부
+ * @return Vector
+ */
+ public String getVectorToStr(String key, String concat_str, boolean trim_tail) {
+ Vector vt = getVector(key);
+ String rtn = "";
+ for (int i = 0; i < vt.size(); i++) {
+ rtn += (String) vt.get(i) + concat_str;
+ }
+ if (rtn.length() > 0 && trim_tail) {
+ return rtn.substring(0, rtn.length() - concat_str.length());
+ } else {
+ return rtn;
+ }
+ }
+
+ /**
+ *
+ * Box에 새로운 값을 저장한다.
+ *
+ *
+ * @param key
+ * 찾을때 쓸 key
+ * @param value
+ * 저장할 값
+ */
+ public void put(String key, String value) {
+ super.put(key, value);
+ }
+
+ /**
+ *
+ * 문자열에서 ","를 제거한다.
+ *
+ *
+ * @param s
+ * source문자열
+ * @return ","를 제거한 문자열
+ */
+ private static String removeComma(String s) {
+ if (s == null)
+ return null;
+ if (s.indexOf(",") != -1) {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (c != ',')
+ buf.append(c);
+ }
+ return buf.toString();
+ }
+ return s;
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 Object 형식으로 가져온다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @return Object 찾은 값
+ */
+ public Object getObject(String key) {
+ try {
+ return (Object) super.get(key);
+ } catch (NumberFormatException e) {
+ return null;
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ *
+ * Box의 모든 값을 스트링으로 반환
+ *
+ *
+ * @return java.lang.String
+ */
+ public synchronized String toString() {
+ int max = size() - 1;
+ StringBuffer buf = new StringBuffer();
+ Enumeration keys = keys();
+ Enumeration objects = elements();
+ buf.append("{");
+
+ for (int i = 0; i <= max; i++) {
+ String key = keys.nextElement().toString();
+ String value = null;
+ Object o = objects.nextElement();
+ if (o == null)
+ value = "";
+ else {
+ Class c = o.getClass();
+ if (c.isArray()) {
+ int length = Array.getLength(o);
+ if (length == 0)
+ value = "";
+ else if (length == 1) {
+ Object item = Array.get(o, 0);
+ if (item == null)
+ value = "";
+ else
+ value = item.toString();
+ } else {
+ StringBuffer valueBuf = new StringBuffer();
+ valueBuf.append("[");
+ for (int j = 0; j < length; j++) {
+ Object item = Array.get(o, j);
+ if (item != null)
+ valueBuf.append(item.toString());
+ if (j < length - 1)
+ valueBuf.append(",");
+ }
+ valueBuf.append("]");
+ value = valueBuf.toString();
+ }
+ } else
+ value = o.toString();
+ }
+ buf.append(key + "=" + value);
+ if (i < max)
+ buf.append(", ");
+ }
+ buf.append("}");
+
+ return "Box[" + name + "]=" + buf.toString();
+
+ }
+
+ public synchronized String toStringNl() {
+ int max = size() - 1;
+ StringBuffer buf = new StringBuffer();
+ Enumeration keys = keys();
+ Enumeration objects = elements();
+
+ for (int i = 0; i <= max; i++) {
+ String key = keys.nextElement().toString();
+ String value = null;
+ Object o = objects.nextElement();
+ if (o == null)
+ value = "";
+ else {
+ Class c = o.getClass();
+ if (c.isArray()) {
+ int length = Array.getLength(o);
+ if (length == 0)
+ value = "";
+ else if (length == 1) {
+ Object item = Array.get(o, 0);
+ if (item == null)
+ value = "";
+ else
+ value = item.toString();
+ } else {
+ StringBuffer valueBuf = new StringBuffer();
+ valueBuf.append("[");
+ for (int j = 0; j < length; j++) {
+ Object item = Array.get(o, j);
+ if (item != null)
+ valueBuf.append(item.toString());
+ if (j < length - 1)
+ valueBuf.append(",");
+ }
+ valueBuf.append("]");
+ value = valueBuf.toString();
+ }
+ } else
+ value = o.toString();
+ }
+ buf.append(key + "=" + value);
+ if (i < max)
+ buf.append("\n ");
+ }
+
+ return "Box[" + name + "]=" + buf.toString();
+ }
+
+ public Box[] multiJsonBoxArray(String headKey) {
+
+ Enumeration keys = keys();
+
+ int arrSize = 0;
+ while (keys.hasMoreElements()) {
+ String key = keys.nextElement().toString();
+ if (key.startsWith(headKey)) {
+ int idx = Integer.parseInt(key.substring(0, key.indexOf("[")).replaceAll(headKey, ""));
+ if (idx > arrSize) {
+ arrSize = idx;
+ }
+ }
+ }
+
+ keys = keys();
+ Box[] boxArr = new Box[arrSize];
+ while (keys.hasMoreElements()) {
+ String key = keys.nextElement().toString();
+ if (key.startsWith(headKey)) {
+ int idx = Integer.parseInt(key.substring(0, key.indexOf("[")).replaceAll(headKey, "")) - 1;
+ String nKey = key.substring(key.indexOf("[") + 1);
+ if (nKey.indexOf("[") >= 0) {
+ nKey = nKey.substring(0, nKey.indexOf("]")) + nKey.substring(nKey.indexOf("["));
+ } else if (nKey.indexOf("]") >= 0) {
+ nKey = nKey.substring(0, nKey.indexOf("]"));
+ }
+
+ //웹 취약점 때문에 수정 시작
+ if (boxArr[idx] == null) {
+ boxArr[idx] = new Box("");
+ }
+ //웹 취약점 때문에 수정 끝
+
+ // System.out.println(String.format("idx : %s nKey : %s value : %s", idx, nKey,
+ // this.get(key)));
+ boxArr[idx].put(nKey, this.get(key));
+ }
+ }
+
+ return boxArr;
+ }
+
+ public String get(String key, String fmt) {
+ return get(key, Integer.parseInt(fmt));
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 가져와 fmt에 맞게 포맷하여 반환한다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @param fmt
+ * 포맷형태 상수
+ * @return String 찾은 값
+ */
+ public String get(String key, int fmt) {
+ String tmp = "";
+ switch (fmt) {
+ case DEF_DATE_FMT:
+ tmp = DateUtil.defFmtDate(get(key));
+ break;
+ case DEF_DATETIME_FMT:
+ tmp = DateUtil.defFmtDateTime(get(key));
+ break;
+ case THOUSAND_COMMA:
+ tmp = StringUtil.getComma(get(key));
+ break;
+ case THOUSAND_COMMA_FLOAT:
+ tmp = StringUtil.getComma(get(key), false);
+ break;
+ case ZIP_CODE:
+ tmp = StringUtil.getZip(get(key));
+ break;
+ case JUMIN_NO:
+ tmp = StringUtil.getJumin(get(key));
+ break;
+ case MULTILINE_TEXT:
+ tmp = get(key).replaceAll("\n", " ");
+ break;
+ case DEF_DATETIME_FMT_APM:
+ tmp = DateUtil.defFmtDateTimeAPM(get(key));
+ break;
+ case HTML:
+ tmp = get(key);
+ break;
+ case YES_NO:
+ tmp = (get(key).equals("Y") ? "예" : "아니오");
+ break;
+ case POSSIBLE_OR_NOT:
+ tmp = (get(key).equals("Y") ? "가능" : "불가능");
+ break;
+ case JAVASCRIPT:
+ tmp = get(key).replaceAll("\n", "@NEWLINE@").replaceAll("\r", "").replaceAll("'", "@SQUOT@");
+ break;
+ case SPECIAL_CHAR:
+ tmp = get(key).replaceAll("\"", """).replaceAll("'", "'").replaceAll("<", "<").replaceAll(">",
+ ">");
+ break;
+ }
+ return tmp;
+ }
+
+ /**
+ *
+ * Box에서 key에 해당하는 값을 가져와 fmt에 맞게 포맷하여 반환한다.
+ * 만약 값이 공백일 경우 target을 넘겨준다.
+ *
+ *
+ * @param key
+ * Box에서 찾을 key
+ * @param fmt
+ * 포맷형태 상수
+ * @return String 찾은 값
+ */
+ public String get(String key, int fmt, String target) {
+ String tmp = get(key, fmt);
+ return tmp.equals("") ? target : tmp;
+ }
+
+ public int getDEF_DATE_FMT() {
+ return DEF_DATE_FMT;
+ }
+
+ public int getDEF_DATETIME_FMT() {
+ return DEF_DATETIME_FMT;
+ }
+
+ public int getTHOUSAND_COMMA() {
+ return THOUSAND_COMMA;
+ }
+
+ public int getTHOUSAND_COMMA_FLOAT() {
+ return THOUSAND_COMMA_FLOAT;
+ }
+
+ public int getZIP_CODE() {
+ return ZIP_CODE;
+ }
+
+ public int getJUMIN_NO() {
+ return JUMIN_NO;
+ }
+
+ public int getMULTILINE_TEXT() {
+ return MULTILINE_TEXT;
+ }
+
+ public int getSPECIAL_CHAR() {
+ return SPECIAL_CHAR;
+ }
+}
diff --git a/src/main/java/geoinfo/util/CrossScriptingFilter.java b/src/main/java/geoinfo/util/CrossScriptingFilter.java
new file mode 100644
index 0000000..aef0b61
--- /dev/null
+++ b/src/main/java/geoinfo/util/CrossScriptingFilter.java
@@ -0,0 +1,33 @@
+package geoinfo.util;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+
+
+public class CrossScriptingFilter implements Filter {
+
+ private FilterConfig filterConfig;
+
+ public void init(FilterConfig filterConfig) throws ServletException {
+ this.filterConfig = filterConfig;
+ }
+
+ public void destroy() {
+ this.filterConfig = null;
+ }
+
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
+ throws IOException, ServletException {
+ System.out.println("CrossScriptingFilter");
+ chain.doFilter(new RequestWrapper((HttpServletRequest) request), response);
+
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/geoinfo/util/CustomErrorReportValve.java b/src/main/java/geoinfo/util/CustomErrorReportValve.java
new file mode 100644
index 0000000..e65c424
--- /dev/null
+++ b/src/main/java/geoinfo/util/CustomErrorReportValve.java
@@ -0,0 +1,45 @@
+package geoinfo.util;
+
+import java.io.BufferedWriter;
+import java.io.OutputStreamWriter;
+import java.net.MalformedURLException;
+
+import org.apache.catalina.connector.Request;
+import org.apache.catalina.connector.Response;
+import org.apache.catalina.valves.ErrorReportValve;
+import org.jfree.util.Log;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CustomErrorReportValve extends ErrorReportValve{
+
+ private static final Logger logger = LoggerFactory.getLogger(CustomErrorReportValve.class);
+
+ @Override
+ protected void report(Request request, Response response, Throwable t) {
+ try {
+ BufferedWriter out = new BufferedWriter(new OutputStreamWriter(response.getOutputStream(), "UTF8"));
+ out.write("");
+ out.write("");
+ out.write("");
+ out.write(" ");
+ out.write(" ");
+ out.write(" ");
+ out.write("");
+ out.write(" ");
+ out.write(" ");
+ out.write("");
+ out.write("");
+ out.close();
+ } catch (NumberFormatException e) {
+ logger.debug("error", e);
+ } catch (MalformedURLException e) {
+ logger.debug("error", e);
+ } catch (Exception e) {
+ logger.debug("error", e);
+ }
+ }
+}
diff --git a/src/main/java/geoinfo/util/DateUtil.java b/src/main/java/geoinfo/util/DateUtil.java
new file mode 100644
index 0000000..37df853
--- /dev/null
+++ b/src/main/java/geoinfo/util/DateUtil.java
@@ -0,0 +1,844 @@
+/*******************************************************************/
+/* Class Name : DateUtil */
+/* Description : 날짜 시간 관련 utility class */
+/*******************************************************************/
+/* Modification Log */
+/* No DATE Company Author Description */
+/* 01 2002/06/01 IRAM Initial Release */
+/*******************************************************************/
+
+package geoinfo.util;
+
+import java.util.*;
+import java.text.*;
+
+/**
+ *
+ * 날짜 시간 관련 utility class
+ *
+ *
+ * @author IRAM
+ * @version 1.0
+ * @since 2002.01.
+ *
+ */
+
+public class DateUtil
+{
+ /**
+ * 양력 쉬는 날
+ */
+ private static final String sunOffDays = "0101,0301,0405,0505,0606,0717,0815,1003,1225";
+
+ /**
+ *
+ * Constructor
+ *
+ */
+ public DateUtil() {}
+
+ /**
+ *
+ * 현재 시스템의 날짜/시간을 xFormat에 맞도록 리턴한다.
+ *
+ *
+ * @param xFormat 날짜 format
+ * @return format된 날짜
+ */
+ private static String fmDate(String xFormat) {
+ Date currentTime = new Date();
+ SimpleDateFormat fmt = new SimpleDateFormat(xFormat);
+ return fmt.format(currentTime);
+ }
+
+ /**
+ *
+ * 현재 시스템의 날짜/시간을 "yyyy/MM/dd HH:mm:ss S" 형태로 리턴한다
+ *
+ *
+ * @return format된 Date 문자열
+ */
+ public String toString()
+ {
+ return fmDate("yyyy/MM/dd HH:mm:ss S");
+ }
+
+ /**
+ *
+ * 현재 시스템의 날짜/시간을 xFormat에 맞도록 리턴한다.
+ * ex)
+ * String dt = DateUtil.toString("yyyy/MM/dd");
+ *
+ *
+ * @param xFormat 포맷 문자열
+ * @return format된 Date 문자열
+ */
+ public static String toString(String xFormat)
+ {
+ return fmDate(xFormat);
+ }
+
+
+ /**
+ *
+ * 현재 시스템의 년도(year)를 yyyy형태로 리턴
+ *
+ *
+ * @return String 년도
+ */
+ public static String getYear() {
+ return fmDate("yyyy");
+ }
+
+ public static String nextYear() {
+ return nextYear(1);
+ }
+
+ public static String nextYear(int year) {
+ return String.valueOf(Integer.parseInt(getYear()) + year);
+ }
+
+/**
+ *
+ * 현재 시스템의 월(month)을 MM형태로 리턴
+ *
+ *
+ * @return String 월
+ */
+ public static String getMonth() {
+ return fmDate("MM");
+ }
+
+ /**
+ *
+ * 현재 시스템의 일(day)을 dd형태로 리턴
+ *
+ *
+ * @return String 날짜
+ */
+ public static String getDay() {
+ return fmDate("dd");
+ }
+
+ /**
+ *
+ * 현재 시스템의 시간(hour)를 hh형태로 리턴
+ *
+ *
+ * @return String 현재시간
+ */
+ public static String getHour() {
+ return fmDate("hh");
+ }
+
+ /**
+ *
+ * 현재 시스템의 분(minute)을 mm형태로 리턴
+ *
+ *
+ * @return String 현재 분
+ */
+ public static String getMinute() {
+ return fmDate("mm");
+ }
+
+ /**
+ *
+ * 현재 시스템의 초(second)를 ss형태로 리턴
+ *
+ *
+ * @return String 현재 초
+ */
+ public static String getSecond() {
+ return fmDate("ss");
+ }
+
+ /**
+ *
+ * 시스템 날짜를 리턴한다.
+ * 20000621182030형태로 리턴 (2000년6월21일 오후 6시 20분 30초)
+ *
+ *
+ * @return String
+ */
+ public static String getSysDate()
+ {
+ String second, minute, hour;
+ Calendar cal = Calendar.getInstance();
+
+ String year = String.valueOf(cal.get(Calendar.YEAR));
+ String month = String.valueOf(cal.get(Calendar.MONTH)+1);
+ String day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
+
+ if((cal.get(Calendar.MONTH)+1) < 10) month = "0" + String.valueOf((cal.get(Calendar.MONTH)+1));
+ else month = String.valueOf((cal.get(Calendar.MONTH)+1));
+
+ if(cal.get(Calendar.DAY_OF_MONTH) < 10) day = "0" + String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
+ else day = String.valueOf(cal.get(Calendar.DAY_OF_MONTH));
+
+ if(cal.get(Calendar.HOUR_OF_DAY) < 10) hour = "0" + String.valueOf(cal.get(Calendar.HOUR_OF_DAY));
+ else hour = String.valueOf(cal.get(Calendar.HOUR_OF_DAY));
+
+ if(cal.get(Calendar.MINUTE) < 10) minute = "0" + String.valueOf(cal.get(Calendar.MINUTE));
+ else minute = String.valueOf(cal.get(Calendar.MINUTE));
+
+ if(cal.get(Calendar.SECOND) < 10) second = "0" + String.valueOf(cal.get(Calendar.SECOND));
+ else second = String.valueOf(cal.get(Calendar.SECOND));
+
+ return year + month + day + hour+ minute + second;
+ }
+
+ /**
+ *
+ * from , to 날짜 사이의 날짜
+ *
+ *
+ * @param from 기간 부터
+ * @param to 기간 까지
+ * @param format 날짜 포맷
+ * @return int 날짜 형식이 맞고, 존재하는 날짜일 때 2개 일자 사이의 일자 리턴
+ * -999: 형식이 잘못 되었거나 존재하지 않는 날짜 또는 기간의 역전
+ */
+ public static int getDaysBetween(String from, String to, String format)
+ {
+ java.text.SimpleDateFormat formatter =
+ new java.text.SimpleDateFormat (format, java.util.Locale.KOREA);
+ java.util.Date d1 = null;
+ java.util.Date d2 = null;
+ try {
+ d1 = formatter.parse(from);
+ d2 = formatter.parse(to);
+ } catch(java.text.ParseException e) {
+ return -999;
+ }
+ if ( !formatter.format(d1).equals(from) ) return -999;
+ if ( !formatter.format(d2).equals(to) ) return -999;
+
+ long duration = d2.getTime() - d1.getTime();
+
+ if ( duration < 0 ) return -999;
+ return (int)( duration/(1000 * 60 * 60 * 24) );
+ // seconds in 1 day
+ }
+
+ /**
+ *
+ * 해당월의 일자수를 리턴한다.
+ *
+ *
+ * @param year 년
+ * @param month 월
+ * @return int 일자수
+ */
+ public static int getDayCount(int year, int month)
+ {
+ int day[] = {31,28,31,30,31,30,31,31,30,31,30,31};
+
+ if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
+ day[1] = 29;
+ }
+ return day[month-1];
+ }
+
+ /**
+ *
+ * 윤년인지 판단한다.
+ *
+ *
+ * @param year 년도
+ * @return 윤년 true 아니면 false
+ */
+ public static boolean isLeafYear(int year)
+ {
+ if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * 날짜가 유효한 날짜인지를 검사한다.
+ * "02/30/2000" 형태로 검사
+ *
+ *
+ * @param date 검사할 날짜
+ * @return boolean 유효하면 true 아니면 false
+ */
+ public static boolean isDate(String date)
+ {
+ SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy");
+
+ format.setLenient(false);
+ return format.parse(date,new ParsePosition(0)) == null ? false : true;
+ }
+
+ /**
+ *
+ * 날짜문자열이 주어진 포맷으로 변환될 수 있는지 검사한다.
+ *
+ *
+ * @param date 검사할 문자열
+ * @param xfmt 날짜 포맷
+ * @return 변환가능 true 불가능 false
+ */
+ public static boolean isDate(String date,String xfmt)
+ {
+ SimpleDateFormat format = new SimpleDateFormat(xfmt);
+
+ format.setLenient(false);
+ return format.parse(date,new ParsePosition(0)) == null ? false : true;
+ }
+
+ /**
+ *
+ * 요일에 대한 int를 리턴한다.
+ * 0=일요일,1=월요일,2=화요일,3=수요일,4=목요일,5=금요일,6=토요일
+ *
+ *
+ * @param year 년
+ * @param month 월
+ * @param day 일
+ *
+ * @return String 요일에 대한 int
+ */
+ public static int getWeekDay(int year,int month,int day)
+ {
+ Calendar cal = Calendar.getInstance();
+ cal.set(year,month-1,day);
+
+ return cal.get(Calendar.DAY_OF_WEEK) - 1;
+ }
+
+ /**
+ *
+ * 요일에 대한 이름을 리턴한다.
+ * 일,월,화,수,목,금,토
+ *
+ *
+ * @param year 년
+ * @param month 월
+ * @param day 일
+ *
+ * @return String 요일
+ */
+ public static String getWeekDayNm(int year,int month,int day)
+ {
+ String weekNm="";
+ switch (getWeekDay(year, month, day)) {
+ case 0: weekNm = "일";break;
+ case 1: weekNm = "월";break;
+ case 2: weekNm = "화";break;
+ case 3: weekNm = "수";break;
+ case 4: weekNm = "목";break;
+ case 5: weekNm = "금";break;
+ case 6: weekNm = "토";break;
+ }
+ return weekNm;
+ }
+
+ public static String getWeekDayNm(String ymd)
+ {
+ return getWeekDayNm(Integer.parseInt(ymd.substring(0,4)), Integer.parseInt(ymd.substring(4,6)), Integer.parseInt(ymd.substring(6,8)));
+ }
+
+ /**
+ *
+ * 년도,월,날짜에 주어진 날짜를 더한 날짜를 만들어준다.
+ *
+ *
+ * @param year 년
+ * @param month 월
+ * @param day 일
+ * @param add 더할 날짜(년도,월,일)
+ * @param fmt 리턴 포맷
+ * @param ymd 더할 필드('Y' : 년도, 'M' : 월, 'D' : 일 )
+ * @return String 날짜
+ */
+ public static String addDate(int year, int month, int day, int add, String fmt, String ymd) {
+
+ Calendar calendar = Calendar.getInstance();
+ Date _date = null;
+ calendar.set(year,month-1,day);
+
+ if (ymd.equals("Y")) {
+ // 년도 더하기
+ calendar.add(Calendar.YEAR, add);
+ } else if (ymd.equals("M")) {
+ // 월 더하기
+ calendar.add(Calendar.MONTH, add);
+ } else {
+ // 일 더하기
+ calendar.add(Calendar.DATE, add);
+ }
+
+ _date = calendar.getTime();
+ SimpleDateFormat sfmt = new SimpleDateFormat(fmt);
+ return sfmt.format(_date);
+ }
+
+ /**
+ *
+ * 년도,월,날짜에 주어진 날짜를 더한 날짜를 만들어준다.
+ *
+ *
+ * @param date 년월일
+ * @param add 더할 날짜(년도,월,일)
+ * @param fmt 리턴 포맷
+ * @param ymd 더할 필드('Y' : 년도, 'M' : 월, 'D' : 일 )
+ * @return String 날짜
+ */
+ public static String addDate(String date, int add, String fmt, String ymd) {
+ int year = Integer.parseInt(date.substring(0,4));
+ int month = Integer.parseInt(date.substring(4,6));
+ int day = Integer.parseInt(date.substring(6,8));
+
+ return addDate(year, month, day, add, fmt, ymd);
+ }
+
+ /**
+ *
+ * yyyyMMdd 형태의 스트링을 주어진 포맷 형태로 만든다.
+ *
+ *
+ * @param date 날짜문자열
+ * @param fmt 리턴 포맷
+ * @return String
+ */
+ public static String strToDateStr(String date, String fmt) {
+
+ int year = Integer.parseInt(date.substring(0,4));
+ int month = Integer.parseInt(date.substring(4,6));
+ int day = Integer.parseInt(date.substring(6,8));
+
+ Calendar calendar = Calendar.getInstance();
+ Date _date = null;
+ calendar.set(year,month-1,day);
+
+ _date = calendar.getTime();
+ SimpleDateFormat sfmt = new SimpleDateFormat(fmt);
+ return sfmt.format(_date);
+ }
+
+ /**
+ *
+ * yyyyMMdd 또는 yyyyMMddHHmmss 형태로 주어진 스트링을 주어진 Date 형식으로 만든다.
+ *
+ *
+ * @param date 날짜문자열
+ * @return Date
+ */
+ public static Date strToDate(String date) {
+ int year=0, month=0, day=0, hour=0, min=0, sec=0;
+ if ( date.length() > 14) {
+ year = Integer.parseInt(date.substring(0,4));
+ month = Integer.parseInt(date.substring(4,6));
+ day = Integer.parseInt(date.substring(6,8));
+ hour = Integer.parseInt(date.substring(8,10));
+ min = Integer.parseInt(date.substring(10,12));
+ sec = Integer.parseInt(date.substring(12,14));
+ } else if (date.length() == 8) {
+ year = Integer.parseInt(date.substring(0,4));
+ month = Integer.parseInt(date.substring(4,6));
+ day = Integer.parseInt(date.substring(6,8));
+ }
+ Calendar calendar = Calendar.getInstance();
+ Date _date = null;
+ calendar.set(year,month-1,day,hour,min,sec);
+
+ _date = calendar.getTime();
+ return _date;
+ }
+
+ /**
+ *
+ * sqlDate 를 문자열로 변환한다.
+ *
+ *
+ * @param _date java.sql.Date형태의 날짜
+ * @return String 변환된 문자열
+ */
+ public static String sqlDateToStr(java.sql.Date _date) {
+ // _date.toString();
+ return _date.toString();
+ }
+
+ /**
+ *
+ * 인자로 넘어온 년월이 양력에서 쉬?z 날인지 확인한다.
+ *
+ *
+ * @param month 월
+ * @param day 일
+ * @return boolean true : 쉬는날 , false : 쉬지 않는 날
+ */
+ public static boolean isSunOffDay(String month, String day) {
+ String month_day = month + day;
+ if (sunOffDays.indexOf(month_day) >= 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * 인자로 넘어온 년월이 양력에서 쉬?z 날인지 확인한다.
+ *
+ *
+ * @param month 월
+ * @param day 일
+ * @return boolean true : 쉬는날 , false : 쉬지 않는 날
+ */
+ public static boolean isSunOffDay(int month, int day) {
+ String sMonth = StringUtil.getZeroBaseString(month,2);
+ String sDay = StringUtil.getZeroBaseString(day,2);
+ return isSunOffDay(sMonth, sDay);
+ }
+
+ /**
+ *
+ * 인자로 넘어온 년월이 쉬는 날인지 확인한다.
+ * 음력 쉬는 날 확인 구현 안되어 있음
+ *
+ *
+ * @param month 월
+ * @param day 일
+ *
+ * @return boolean true : 쉬는날 , false : 쉬지 않는 날
+ */
+ public static boolean isOffDay(int month, int day) {
+ String sMonth = StringUtil.getZeroBaseString(month,2);
+ String sDay = StringUtil.getZeroBaseString(day,2);
+ return isSunOffDay(sMonth, sDay);
+ }
+
+ /**
+ *
+ * 인자로 넘어온 년월이 쉬는 날인지 확인한다.
+ * 음력 쉬는 날 확인 구현 안되어 있음
+ *
+ *
+ * @param month 월
+ * @param day 일
+ * @return boolean true : 쉬는날 , false : 쉬지 않는 날
+ */
+ public static boolean isOffDay(String month, String day) {
+ if (month.length() == 1) month = "0" + month;
+ if (day.length() == 1) day = "0" + day;
+ return isSunOffDay(month, day);
+ }
+
+ /**
+ *
+ * 날짜 차이를 int로 반환(검증 필요)
+ *
+ *
+ * @param from 날짜 부터
+ * @param to 날짜 까지
+ * @return int 차이
+ */
+ public static int dayDiff(String from, String to) throws Exception {
+ try {
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
+ Date beginDate = formatter.parse(from.substring(0,8));
+ Date endDate = formatter.parse(to.substring(0,8));
+ long diff = endDate.getTime() - beginDate.getTime();
+ long diffDays = diff / (24 * 60 * 60 * 1000);
+ return new Long(diffDays).intValue();
+ } catch (NumberFormatException e) {
+ return -9999;
+ } catch (Exception e) {
+ return -9999;
+ }
+
+ } // dayDiff
+
+ /**
+ *
+ * 날짜 차이를 int로 반환(년도만 구현)
+ *
+ *
+ * @param from 날짜 부터
+ * @param to 날짜 까지
+ * @param ymd 차이를 리턴할 구분자 "Y" 년 "M"월 "D" 일
+ * @return int 차이
+ */
+ public static int dateDiff(String from, String to, String ymd) {
+ if (ymd.equals("Y") && from.length() == 8 && to.length() == 8) {
+ int f_year = Integer.parseInt(from.substring(0,4));
+ int t_year = Integer.parseInt(to.substring(0,4));
+ int f_md = Integer.parseInt(from.substring(4));
+ int t_md = Integer.parseInt(to.substring(4));
+ int diff = 0;
+
+ if (t_year > 0 && f_year > 0) {
+ diff = t_year - f_year;
+ }
+
+ if ( f_md > t_md) {
+ --diff;
+ }
+ return diff;
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ *
+ * sql날짜로 바꾸어서 리턴
+ *
+ *
+ * @param inDate 변환할 date
+ * @return java.sql.Date
+ */
+ public static final java.sql.Date toSQLDate(java.util.Date inDate) {
+ // This method returns a sql.Date version of the util.Date arg.
+ // new java.sql.Date(java.util.Calendar.getInstance().getTime().getTime())
+ return new java.sql.Date(inDate.getTime());
+ }
+
+ /**
+ *
+ * 날짜 문자열을 받아들여 기본 날짜 형태(yyyy-MM-dd)로 만든다.
+ *
+ *
+ * @param xFormat 날짜 format
+ * @return format된 날짜
+ */
+ public static String defFmtDate(String inDate) {
+ return defFmtDate(inDate,"-");
+ }
+
+ public static String defFmtDate(String inDate, String dmt) {
+ if (inDate.length() >= 8) {
+ return inDate.substring(0,4) + dmt
+ + inDate.substring(4,6) + dmt
+ + inDate.substring(6,8);
+ } else if (inDate.length() >= 6) {
+ return inDate.substring(0,4) + dmt
+ + inDate.substring(4,6);
+ } else if (inDate.length() >= 4) {
+ return inDate.substring(0,4);
+ } else {
+ return inDate;
+ }
+ }
+
+ /**
+ *
+ * 날짜 문자열을 받아들여 기본 날짜 형태(yyyy-MM-dd HH:mm:ss)로 만든다.
+ *
+ *
+ * @param xFormat 날짜 format
+ * @return format된 날짜
+ */
+ public static String defFmtDateTime(String inDate) {
+ if (inDate.length() >= 14) {
+ return inDate.substring(0,4) + "-"
+ + inDate.substring(4,6) + "-"
+ + inDate.substring(6,8) + " "
+ + inDate.substring(8,10) + ":"
+ + inDate.substring(10,12) + ":"
+ + inDate.substring(12,14);
+ } else if (inDate.length() >= 12) {
+ return inDate.substring(0,4) + "-"
+ + inDate.substring(4,6) + "-"
+ + inDate.substring(6,8) + " "
+ + inDate.substring(8,10) + ":"
+ + inDate.substring(10,12);
+ } else if (inDate.length() >= 8) {
+ return inDate.substring(0,4) + "-"
+ + inDate.substring(4,6) + "-"
+ + inDate.substring(6,8);
+ } else {
+ return inDate;
+ }
+ }
+
+ /**
+ *
+ * 날짜 문자열을 받아들여 시설안전기술 공단의 기본 날짜 형태로 만든다.
+ *
+ *
+ * @param xFormat 날짜 format
+ * @return format된 날짜
+ */
+ public static String defFmtDate2(String inDate) {
+ if (inDate.length() >= 8) {
+ return inDate.substring(0,4) + "년 "
+ + inDate.substring(4,6) + "월 "
+ + inDate.substring(6,8) + "일";
+ } else if (inDate.length() == 6) {
+ return inDate.substring(0,4) + "년 "
+ + inDate.substring(4,6) + "월";
+ } else if (inDate.length() == 4) {
+ return inDate.substring(0,4) + "년";
+ } else {
+ return inDate;
+ }
+ }
+
+ /**
+ *
+ * 날짜 문자열을 받아들여 시설안전기술 공단의 기본 날짜 형태로 만든다.
+ *
+ *
+ * @param xFormat 날짜 format
+ * @return format된 날짜
+ */
+ public static String defFmtDateTime2(String inDate) {
+ if (inDate.length() >= 14) {
+ return inDate.substring(0,4) + "년 "
+ + inDate.substring(4,6) + "월 "
+ + inDate.substring(6,8) + "일 "
+ + inDate.substring(8,10) + "시 "
+ + inDate.substring(10,12) + "분 "
+ + inDate.substring(12,14) + "초";
+ } else if (inDate.length() >= 12) {
+ return inDate.substring(0,4) + "년 "
+ + inDate.substring(4,6) + "월 "
+ + inDate.substring(6,8) + "일 "
+ + inDate.substring(8,10) + "시 "
+ + inDate.substring(10,12) + "분 ";
+ } else {
+ return inDate;
+ }
+ }
+
+ /**
+ *
+ * 날짜 문자열을 받아들여 기본 날짜 형태(yyyy-MM-dd 오전오후 HH:mm)로 만든다.
+ *
+ *
+ * @param inDate 포맷할 날짜
+ * @return String format된 날짜
+ */
+ public static String defFmtDateTimeAPM(String inDate) {
+ if (inDate.length() >= 14) {
+ return inDate.substring(0,4) + "-"
+ + inDate.substring(4,6) + "-"
+ + inDate.substring(6,8) + " "
+ + getAmPm(inDate.substring(8,10)) + ":"
+ + inDate.substring(10,12);
+ } else if (inDate.length() >= 12) {
+ return inDate.substring(0,4) + "-"
+ + inDate.substring(4,6) + "-"
+ + inDate.substring(6,8) + " "
+ + getAmPm(inDate.substring(8,10)) + ":"
+ + inDate.substring(10,12);
+ } else if (inDate.length() >= 8) {
+ return inDate.substring(0,4) + "-"
+ + inDate.substring(4,6) + "-"
+ + inDate.substring(6,8);
+ } else {
+ return inDate;
+ }
+ }
+
+ /**
+ * 해당 시간이 오전인지 오후인지 조회
+ * @param hour 시간
+ * @return String 오전, 오후
+ */
+ public static String getAmPm(String hour) {
+ if (hour == null ) {
+ return "";
+ } else if (hour == "") {
+ return "";
+ } else {
+ if (Integer.parseInt(hour) <= 12 ) {
+ return "오전 " + hour;
+ } else { return "오후 " + StringUtil.lpad(String.valueOf((Integer.parseInt(hour) - 12)),"0",2) ;}
+ }
+ }
+
+ public static String getYearOptionTag(String defYear, String from, String to, String order, String postFix) {
+ String optionStr = "";
+ String selected = "";
+ int ifrom = Integer.parseInt(from);
+ int ito = Integer.parseInt(to);
+ int idefYear = Integer.parseInt(FormatUtil.nvl2(defYear,"0"));
+ if (order.equals("asc")) {
+ for (int i= ifrom; i <= ito; i++) {
+ selected = i == idefYear ? "selected" : "";
+ optionStr += "\n "+i+postFix+" ";
+ }
+ } else {
+ for (int i= ito; i >= ifrom; i--) {
+ selected = i == idefYear ? "selected" : "";
+ optionStr += "\n "+i+postFix+" ";
+ }
+ }
+ return optionStr;
+
+ }
+
+ public static String getYearOptionTag(String defYear, String from, String to, String order) {
+ return getYearOptionTag(defYear, from, to, order, "");
+ }
+
+ public static String getYearOptionTag(String defYear, String from, String to) {
+ return getYearOptionTag(defYear, from, to, "desc");
+ }
+
+ public static String getMonthOptionTag(String defMon, String postFix) {
+ String optionStr = "";
+ String selected = "";
+ int idefMon = Integer.parseInt(FormatUtil.nvl2(defMon,"0"));
+ for (int i= 1; i < 13; i++) {
+ selected = i == idefMon ? "selected" : "";
+ String mon = StringUtil.lpad(String.valueOf(i), "0", 2);
+ optionStr += "\n "+mon+postFix+" ";
+ }
+ return optionStr;
+ }
+
+ public static String getMonthOptionTag(String defMon) {
+ return getMonthOptionTag(defMon, "");
+ }
+
+ public static String getDayOptionTag(String defDay, String postFix) {
+ String optionStr = "";
+ String selected = "";
+ int idefDay = Integer.parseInt(FormatUtil.nvl2(defDay,"0"));
+ for (int i= 1; i < 32; i++) {
+ selected = i == idefDay ? "selected" : "";
+ String day = StringUtil.lpad(String.valueOf(i), "0", 2);
+ optionStr += "\n "+day+postFix+" ";
+ }
+ return optionStr;
+ }
+
+ public static String getDayOptionTag(String defDay) {
+ return getDayOptionTag(defDay, "");
+ }
+
+ public static String getHourOptionTag(String defHour) {
+ String optionStr = "";
+ String selected = "";
+ int idefHour = Integer.parseInt(FormatUtil.nvl2(defHour,"0"));
+ for (int i= 0; i < 24; i++) {
+ selected = i == idefHour ? "selected" : "";
+ String hour = StringUtil.lpad(String.valueOf(i), "0", 2);
+ optionStr += "\n "+hour+" ";
+ }
+ return optionStr;
+ }
+
+ public static String getMinOptionTag(String defMin) {
+ String optionStr = "";
+ String selected = "";
+ int idefMin = Integer.parseInt(FormatUtil.nvl2(defMin,"0"));
+ for (int i= 0; i < 61; i++) {
+ selected = i == idefMin ? "selected" : "";
+ String min = StringUtil.lpad(String.valueOf(i), "0", 2);
+ optionStr += "\n "+min+" ";
+ }
+ return optionStr;
+ }
+
+}
+
diff --git a/src/main/java/geoinfo/util/ExcelUtil.java b/src/main/java/geoinfo/util/ExcelUtil.java
new file mode 100644
index 0000000..49774cc
--- /dev/null
+++ b/src/main/java/geoinfo/util/ExcelUtil.java
@@ -0,0 +1,222 @@
+package geoinfo.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+
+import org.jfree.util.Log;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import jxl.Cell;
+import jxl.Sheet;
+import jxl.Workbook;
+
+import geoinfo.util.RsWrapper;
+public class ExcelUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(ExcelUtil.class);
+
+ public static RsWrapper getExcelSheetName(String excelPath) throws Exception {
+ RsWrapper rsWp = new RsWrapper();
+ FileInputStream fis = null;
+ try {
+ Workbook wb = Workbook.getWorkbook(new File(excelPath));
+
+ int sheetCnt = wb.getNumberOfSheets();
+
+ for(short i=0; i < sheetCnt; i++) {
+ String sheetName = wb.getSheet(i).getName();
+ Box obox = new Box();
+ obox.put("sheetNo", i);
+ obox.put("sheetNm", sheetName);
+ //System.out.println("sheetName:"+sheetName + ", i:"+i);
+ rsWp.appendRs(obox);
+ }
+
+ return rsWp;
+ } catch(IndexOutOfBoundsException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(IOException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(NumberFormatException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(Exception ex) {
+ logger.debug("error", ex);
+ throw ex;
+ } finally {
+ if (fis != null) { fis.close(); }
+ }
+ }
+
+ public static String[] getExcelSheetNameArray(String excelPath) throws Exception {
+ RsWrapper rsWp = new RsWrapper();
+ FileInputStream fis = null;
+ try {
+ Workbook wb = Workbook.getWorkbook(new File(excelPath));
+
+ int sheetCnt = wb.getNumberOfSheets();
+
+ return wb.getSheetNames();
+ } catch(IndexOutOfBoundsException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(IOException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(NumberFormatException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(Exception ex) {
+ logger.debug("error", ex);
+ throw ex;
+ } finally {
+ if (fis != null) { fis.close(); }
+ }
+ }
+
+ public static Sheet getExcelWorkSheet(String excelPath, int sheetNo) throws Exception {
+ FileInputStream fis = null;
+ try {
+ excelPath.replaceAll("\\.", "").replaceAll("/", "").replaceAll("\\\\", "").replaceAll ("&","");
+ Workbook wb = Workbook.getWorkbook(new File(excelPath));
+ return wb.getSheet(sheetNo);
+ } catch(IndexOutOfBoundsException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(IOException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(NumberFormatException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(Exception ex) {
+ logger.debug("error", ex);
+ throw ex;
+ } finally {
+ if (fis != null) { fis.close(); }
+ }
+ }
+
+ public static Sheet getExcelWorkSheet(String excelPath, String sheetName) throws Exception {
+ FileInputStream fis = null;
+ try {
+ excelPath.replaceAll("\\.", "").replaceAll("/", "").replaceAll("\\\\", "").replaceAll ("&","");
+ Workbook wb = Workbook.getWorkbook(new File(excelPath));
+ return wb.getSheet(sheetName);
+ } catch(IndexOutOfBoundsException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(IOException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(NumberFormatException ex) {
+ logger.debug("error", ex);
+ return null;
+ } catch(Exception ex) {
+ logger.debug("error", ex);
+ throw ex;
+ } finally {
+ if (fis != null) { fis.close(); }
+ }
+ }
+//1
+ public static RsWrapper getRsWp(String excelPath, int sheetNo, int colNmRow, int startRow, int maxCol) throws Exception {
+ RsWrapper rsWp = new RsWrapper();
+ Sheet exlSheet = getExcelWorkSheet(excelPath, sheetNo);
+ if(exlSheet == null) { return rsWp; }
+
+ Box hbox = new Box();
+ for(short i=0; i < exlSheet.getColumns() && i < maxCol; i++) {
+ Cell cell = exlSheet.getCell(i,colNmRow);
+ if(cell == null) { break; }
+ hbox.put(i+"", cell.getContents());
+ }
+
+ //System.out.println("exlSheet.getRows():" + exlSheet.getRows());
+ for(int i=startRow; i < exlSheet.getRows(); i++) {
+ Cell[] cells = exlSheet.getRow(i);
+ if(cells == null) { break; }
+ boolean isOk = false;
+ for(short j=0; j < maxCol && j < cells.length; j++) {
+ if(cells[j] != null && cells[j].getContents() != null && !cells[j].getContents().trim().equals("")) { isOk = true; break; }
+ }
+ if(!isOk) { break; }
+
+ Box obox = new Box();
+ for(short j=0; j < hbox.size() && j < cells.length; j++) {
+ if(cells[j] == null || cells[j].getContents().trim().equals("")) { continue; }
+ if(cells[j].getType().toString().equals("Date")) {
+ String val = getDateVal(cells[j]);
+ obox.put("col"+j, val);
+ }else {
+ obox.put("col"+j, cells[j].getContents().trim());
+ }
+ }
+ rsWp.appendRs(obox);
+ }
+ return rsWp;
+ }
+//2
+ public static RsWrapper getRsWp(String excelPath, String sheetName, int colNmRow, int startRow, int maxCol) throws Exception {
+ RsWrapper rsWp = new RsWrapper();
+ Sheet exlSheet = getExcelWorkSheet(excelPath, sheetName);
+ if(exlSheet == null) { return rsWp; }
+
+ Box hbox = new Box();
+ for(short i=0; i < exlSheet.getColumns() && i < maxCol; i++) {
+ Cell cell = exlSheet.getCell(i,colNmRow);
+ if(cell == null) { break; }
+ hbox.put(i+"", cell.getContents());
+ }
+
+ System.out.println("exlSheet.getRows(): " + exlSheet.getRows());
+ for(int i=startRow; i < exlSheet.getRows(); i++) {
+ Cell[] cells = exlSheet.getRow(i);
+ if(cells == null) { break; }
+ boolean isOk = false;
+ for(short j=0; j < maxCol && j < cells.length; j++) {
+ if(cells[j] != null && cells[j].getContents() != null && !cells[j].getContents().trim().equals("")) { isOk = true; break; }
+ }
+ if(!isOk) { break; }
+
+ Box obox = new Box();
+ for(short j=0; j < hbox.size() && j < cells.length; j++) {
+ if(cells[j] == null || cells[j].getContents().trim().equals("")) { continue; }
+ if(cells[j].getType().toString().equals("Date")) {
+ String val = getDateVal(cells[j]);
+ obox.put("col"+j, val);
+ }else {
+ obox.put("col"+j, cells[j].getContents().trim());
+ }
+ }
+ rsWp.appendRs(obox);
+ }
+ return rsWp;
+ }
+
+ public static RsWrapper getRsWp(String excelPath, int sheetNo, int colNmRow, int startRow) throws Exception {
+ return getRsWp(excelPath, sheetNo, colNmRow, startRow, 10);
+ }
+ public static RsWrapper getRsWp(String excelPath, String sheetName, int colNmRow, int startRow) throws Exception {
+ return getRsWp(excelPath, sheetName, colNmRow, startRow, 10);
+ }
+
+ public static String getDateVal(Cell cell) {
+ String rtn = "";
+ String val = cell.getContents();
+ val = val.replaceAll("/", "");
+ val = val.replaceAll("-", "");
+ if (val.length() == 8) {
+ return val.substring(4, 8) + val.substring(2, 4) + val.substring(0, 2);
+ } else {
+ return val;
+ }
+ }
+
+}
diff --git a/src/main/java/geoinfo/util/FileUtil.java b/src/main/java/geoinfo/util/FileUtil.java
new file mode 100644
index 0000000..3b795df
--- /dev/null
+++ b/src/main/java/geoinfo/util/FileUtil.java
@@ -0,0 +1,87 @@
+package geoinfo.util;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.jfree.util.Log;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.multipart.MultipartFile;
+
+public class FileUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(FileUtil.class);
+
+ private static final int BUFF_SIZE = 2048;
+
+ /**
+ * 파일 업로드
+ * @param file 업로드 파일
+ * @param newName 파일명
+ * @param stordFilePath 파일경로
+ */
+ public static void writeUploadedFile(MultipartFile file, String newName, String savePath) throws Exception{
+ InputStream stream = null;
+ OutputStream bos = null;
+
+ stream = file.getInputStream();
+ File cFile = new File(savePath);
+
+ if (!cFile.isDirectory()) {
+ boolean _flag = cFile.mkdir();
+ if(_flag) throw new IOException("Directory creation Failed ");
+ }
+
+ bos = new FileOutputStream(savePath + newName);
+
+ int bytesRead = 0;
+ byte[] buffer = new byte[BUFF_SIZE];
+
+ while ((bytesRead = stream.read(buffer, 0, BUFF_SIZE)) != -1) {
+ bos.write(buffer, 0, bytesRead);
+ }
+
+ if (bos != null) {
+ try {
+ bos.close();
+ } catch (IOException ignore) {
+ logger.debug("error", ignore);
+ } catch (NumberFormatException ignore) {
+ logger.debug("error", ignore);
+ } catch (IndexOutOfBoundsException ignore) {
+ logger.debug("error", ignore);
+ } catch (Exception ignore) {
+ logger.debug("error", ignore);
+ }
+ }
+ if (stream != null) {
+ try {
+ stream.close();
+ } catch (IOException ignore) {
+ logger.debug("error", ignore);
+ } catch (NumberFormatException ignore) {
+ logger.debug("error", ignore);
+ } catch (IndexOutOfBoundsException ignore) {
+ logger.debug("error", ignore);
+ } catch (Exception ignore) {
+ logger.debug("error", ignore);
+ }
+ }
+
+ bos.close();
+ }
+
+ /**
+ * 파일 삭제
+ * @param savePath 파일저장경로
+ * @param fileName 파일명
+ */
+ public static void deleteFile(String savePath, String fileName) throws Exception{
+ File file = new File(savePath + fileName);
+ if(file.exists()) file.delete();
+ }
+
+}
diff --git a/src/main/java/geoinfo/util/FormatUtil.java b/src/main/java/geoinfo/util/FormatUtil.java
new file mode 100644
index 0000000..d81a43f
--- /dev/null
+++ b/src/main/java/geoinfo/util/FormatUtil.java
@@ -0,0 +1,415 @@
+/*******************************************************************/
+/* Class Name : FormatUtil */
+/* Description : 출력형태 포맷 관련 Class */
+/*******************************************************************/
+/* Modification Log */
+/* No DATE Company Author Description */
+/* 01 2002/06/01 IRAM Initial Release */
+/*******************************************************************/
+
+package geoinfo.util;
+
+import java.io.IOException;
+
+import org.jfree.util.Log;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * 출력형태 포맷 관련 Class
+ *
+ *
+ * @author IRAM
+ * @version 1.0
+ * @since 2002.01.
+ */
+
+public class FormatUtil
+{
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(FormatUtil.class);
+ /**
+ *
+ * 10글자로 넘어온 사업자 등록 번호에 "-"를 붙여준다
+ * 예) "1234567890" -> "123-45-67890"
+ *
+ *
+ * @param bizRegiNo 사업자등록번호
+ * @return java.lang.String
+ */
+ public static String bizRegiNoFormat(String bizRegiNo)
+ {
+ String b = bizRegiNo;
+
+ if (b.length() != 10)
+ return b;
+ else
+ return b.substring(0,3) + "-" + b.substring(3,5) + "-" + b.substring(5,10);
+ }
+
+ /**
+ *
+ * source의 값이 null일경우 target값을 리턴하고 아닐경우 source값을 리턴한다.
+ *
+ *
+ * @param source null인지 판단할 문자열
+ * @param target null일경우 반환할 문자열
+ * @return java.lang.String
+ */
+ public static String nvl(String source, String target)
+ {
+ return source == null ? target: source;
+ }
+
+ /**
+ *
+ * source의 값이 null 또는 "" 일경우 target값을 리턴하고 아닐경우 source값을 리턴한다.
+ *
+ *
+ * @param source null 또는 "" 인지 판단할 문자열
+ * @param target null 또는 "" 일경우 반환할 문자열
+ * @return java.lang.String
+ */
+ public static String nvl2(String source, String target)
+ {
+ return ( source == null || source.equals("") )? target: source;
+ }
+
+ /**
+ *
+ * source의 값이 null 또는 trim하여 "" 일경우 target값을 리턴하고 아닐경우 source값을 리턴한다.
+ *
+ *
+ * @param source null 또는 "" 인지 판단할 문자열
+ * @param target null 또는 "" 일경우 반환할 문자열
+ * @return java.lang.String
+ */
+ public static String nvl3(String source, String target)
+ {
+ return ( source == null || source.trim().equals("") )? target: source;
+ }
+
+ /**
+ *
+ * substring을 할 수 있을 경우 substring 한 결과
+ * substring을 할 수 없을 경우 target 리턴
+ *
+ *
+ * @param source 원문자열
+ * @param from substring 시작
+ * @param to substring 끝
+ * @param target substring 할 수 없을 경우 target 리턴
+ * @return java.lang.String
+ */
+ public static String nvlSubstr(String source, int from, int to, String target)
+ {
+ try {
+ return source.substring(from,to);
+ } catch(IndexOutOfBoundsException e) {
+ LOGGER.debug("error", e);
+ return target;
+ } catch(NumberFormatException e) {
+ LOGGER.debug("error", e);
+ return target;
+ } catch(Exception e) {
+ LOGGER.debug("error", e);
+ return target;
+ }
+ }
+
+
+ /**
+ *
+ * source의 양쪽 끝에 '를 붙여준다
+ * 예) abcdef -> 'abcdef'
+ *
+ *
+ * @param source 양쪽에 ''를 붙일 문자열
+ * @return java.lang.String
+ */
+ public static String makeQuot(String source)
+ {
+ return "'" + nvl2(source,"") + "'";
+ }
+
+ /**
+ *
+ * 주민등록 번호를 포맷에 맞추어 리턴한다.
+ * 예) '1234561234567' -> '123456-1234567'
+ * 13자리가 아닐경우 그냥 반환
+ *
+ *
+ * @param juminno 주민등록번호
+ * @return java.lang.String
+ */
+ public static String juminNo(String juminno) {
+ int juminno_len = juminno.length();
+ String retValue = "";
+
+ if (juminno_len == 13) {
+ retValue = juminno.substring(0, 6) + "-" + juminno.substring(6, 13);
+ } else {
+ retValue = juminno;
+ }
+
+ return retValue;
+ }
+
+ public static String juminNo(String juminno, String x) {
+ int juminno_len = juminno.length();
+ String retValue = "";
+
+ if (juminno_len == 13) {
+ retValue = juminno.substring(0, 6) + "-" + juminno.substring(6, 7) + "xxxxxx";
+ } else {
+ retValue = juminno;
+ }
+
+ return retValue;
+ }
+
+ public static String[] dateArr(String datestr) {
+ String[] tmp = {"","",""};
+ if ( datestr != null && datestr.length() == 8) {
+ tmp[0] = datestr.substring(0,4);
+ tmp[1] = datestr.substring(4,6);
+ tmp[2] = datestr.substring(6,8);
+ }
+ return tmp;
+ }
+
+ public static String[] zipArr(String zipstr) {
+ String[] tmp = {"",""};
+ if ( zipstr != null && zipstr.length() == 6) {
+ tmp[0] = zipstr.substring(0,3);
+ tmp[1] = zipstr.substring(3,6);
+ }
+ return tmp;
+ }
+
+ /**
+ *
+ * 입렫된 숫자를 휴대전화 포맷에 맞게 리턴한다.
+ *
+ *
+ * @param pNumber 휴대전화번호
+ * @return java.lang.String
+ */
+ public static Object pcsFormat(String pNumber) {
+ String pcsNumber = StringUtil.replace(pNumber.trim(), "-", "");
+ String retValue = "";
+ int len = pcsNumber.length();
+
+ if (len >= 10) {
+ retValue = pcsNumber.substring(0, 3) + "-" + pcsNumber.substring(3, len-4) + "-" + pcsNumber.substring(len-4);
+ } else {
+ retValue = pcsNumber;
+ }
+
+ return retValue;
+ }
+
+
+ /**
+ *
+ * 입력된 스트링에 1000 단위 컴마를 삽입하여 리턴한다.
+ * 예) 10000000 -> 10,000,000
+ *
+ *
+ * @param inputStr 숫자 문자열
+ * @return java.lang.String
+ */
+ public static String insertComma(String inputStr) {
+ String tmpStr = inputStr;
+ String underComma = "";
+
+ if (inputStr.indexOf(".") >=0) {
+ // 소숫점 아래는 자른다.
+ tmpStr = inputStr.substring(0,tmpStr.indexOf("."));
+ underComma = "."+inputStr.substring(inputStr.indexOf(".")+1);
+ }
+
+
+ int len = tmpStr.length();
+ String resultValue = "";
+ String sign = "";
+ if (inputStr.startsWith("-")) {
+ sign = "-";
+ len = len -1;
+ tmpStr = tmpStr.substring(1);
+ }
+
+ for (int i=0 ; i 0 && (i % 3) == 0 )
+ resultValue = "," + resultValue;
+
+ resultValue = tmpStr.charAt(len - 1 - i) + resultValue;
+ }
+ return sign+resultValue+underComma;
+ }
+
+ /**
+ *
+ *
+ *
+ *
+ * @param inputStr 숫자 문자열
+ * @return java.lang.String
+ */
+ public static String dotPadding(String inputStr, int size) {
+ if (inputStr.indexOf(".") >=0) {
+ String beforeComma = inputStr.substring(0,inputStr.indexOf("."));
+ String underComma = inputStr.substring(inputStr.indexOf(".")+1);
+ return beforeComma + "." + StringUtil.rpad(underComma,"0",size);
+ } else {
+ return inputStr + ".00";
+ }
+ }
+
+ /**
+ *
+ * 입력된 스트링에 1000 단위 컴마를 삽입하여 리턴한다.
+ * 만약 resultValue가 0일경우 resultValue는 공백으로 처리
+ * 예) 10000000 -> 10,000,000
+ *
+ *
+ * @param inputStr 숫자 문자열
+ * @return java.lang.String
+ */
+ public static String insertComma2(String inputStr) {
+ String resultValue = insertComma(inputStr);
+ resultValue = resultValue.equals("0") ? "":resultValue;
+ return resultValue;
+ }
+
+ /**
+ *
+ * source의 길이가 length만큼 될 때 까지 source 앞에 0을 붙여 리턴한다.
+ * 예) fillZero('123',5) ==> '00123'
+ *
+ *
+ * @param source 앞에 0을 붙일 문자열
+ * @param length 0을 붙여 만들 문자열의 전체 길이
+ * @return java.lang.String
+ */
+ public static String fillZero(String source, int length){
+ if(source == null) return "";
+
+ if(source.length() >= length) return source;
+
+ while(source.length() < length)
+ source = "0" + source;
+
+ return source;
+ }
+
+ /**
+ *
+ * 0을 빈공간으로
+ * 예) zeroToEmpty("0") = ""
+ *
+ *
+ * @param value 문자열
+ * @return java.lang.String
+ */
+ public static String zeroToEmpty(String value) {
+ return value.equals("0") ? "":value;
+ }
+
+ /**
+ *
+ * 빈공간을 0으로
+ * 예) emptyToZero("") = 0
+ *
+ *
+ * @param value 문자열
+ * @return java.lang.String
+ */
+ public static String emptyToZero(String value) {
+ return value.equals("") ? "0":value;
+ }
+
+ /**
+ *
+ * src1과 src2가 같으면target1을 반환하고 틀리면 target2를 반환
+ *
+ *
+ * @param src1 비교문자열1
+ * @param src2 비교문자열2
+ * @param target1 반환값1
+ * @param target2 반환값2
+ * @return java.lang.String
+ */
+ public static String iifEQ(String src1, String src2, String target1, String target2) {
+ try {
+ return src1.equals(src2) ? target1 : target2;
+ } catch(IndexOutOfBoundsException e) {
+ LOGGER.debug("error", e);
+ return target2;
+ } catch(NumberFormatException e) {
+ LOGGER.debug("error", e);
+ return target2;
+ } catch (Exception e) {
+ LOGGER.debug("error", e);
+ return target2;
+ }
+ }
+
+ public static String makeFileSizeStr(String size, String color_yn) {
+ String tmp = "";
+ long lsize = Long.parseLong(size);
+ if (color_yn.equals("N")) {
+ if (lsize > 1024*1024*1024) { tmp = insertComma(String.valueOf((lsize/1024/1024/10) / 100.0)) + "GB"; }
+ else if (lsize > 1024*1024) { tmp = insertComma(String.valueOf((lsize/1024/10) / 100.0)) + "MB"; }
+ else if (lsize > 1024) { tmp = insertComma(String.valueOf((lsize/10) / 100.0)) + "KB"; }
+ else { tmp = size + "B";}
+ } else {
+ if (lsize > 1024*1024*1024) { tmp = insertComma(String.valueOf((lsize/1024/1024/10) / 100.0)) + "GB "; }
+ else if (lsize > 1024*1024) { tmp = insertComma(String.valueOf((lsize/1024/10) / 100.0)) + "MB "; }
+ else if (lsize > 1024) { tmp = insertComma(String.valueOf((lsize/10) / 100.0)) + "KB "; }
+ else { tmp = size + "B";}
+ }
+ return tmp;
+ }
+
+ public static String getPercent(int value1, int value2, int cutPoint) {
+ String rtn = "";
+ if(value1 == 0 && value2 == 0) {
+ rtn = "";
+ }else if(value1 == 0) {
+ rtn = cutPoint > 0 ? "0." : "0";
+ for(int i=0; i < cutPoint; i++) { rtn += "0"; }
+ }else if(value1 == value2) {
+ rtn = cutPoint > 0 ? "100." : "100";
+ for(int i=0; i < cutPoint; i++) { rtn += "0"; }
+ }else {
+ rtn = String.valueOf(value1 * 100.0 / value2);
+ if(rtn.indexOf(".") > 0) { rtn += "00000"; }
+ else { rtn += ".00000"; }
+ rtn = rtn.substring(0,rtn.indexOf(".") + cutPoint + 1);
+ }
+ return rtn;
+ }
+
+ public static String getPercent(long value1, long value2, int cutPoint) {
+ String rtn = "";
+ if(value1 == 0 && value2 == 0) {
+ rtn = "";
+ }else if(value2 == 0) {
+ rtn = "N/A";
+ }else if(value1 == 0) {
+ rtn = cutPoint > 0 ? "0." : "0";
+ for(int i=0; i < cutPoint; i++) { rtn += "0"; }
+ }else if(value1 == value2) {
+ rtn = cutPoint > 0 ? "100." : "100";
+ for(int i=0; i < cutPoint; i++) { rtn += "0"; }
+ }else {
+ rtn = String.valueOf(value1 * 100.0 / value2);
+ if(rtn.indexOf(".") > 0) { rtn += "00000"; }
+ else { rtn += ".00000"; }
+ rtn = rtn.substring(0,rtn.indexOf(".") + cutPoint + 1);
+ }
+ return rtn;
+ }
+}
diff --git a/src/main/java/geoinfo/util/MobileCertificationUtil.java b/src/main/java/geoinfo/util/MobileCertificationUtil.java
new file mode 100644
index 0000000..1934830
--- /dev/null
+++ b/src/main/java/geoinfo/util/MobileCertificationUtil.java
@@ -0,0 +1,236 @@
+package geoinfo.util;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class MobileCertificationUtil {
+ /**
+ * 모바일 인증 사용자 정보 암호화
+ * @param cpId 회원사ID
+ * @param urlCode URL코드
+ * @param certNum 요청번호
+ * @param date 요청일시
+ * @param certMet 본인인증방법
+ * @param name 성명
+ * @param phoneNo 휴대폰번호
+ * @param phoneCorp 이동통신사
+ * @param birthDay 생년월일
+ * @param gender 성별
+ * @param nation 내외국인 구분
+ * @param plusInfo 추가DATA정보
+ * @return
+ * @throws Exception
+ */
+ public static String encryptCertData(String cpId, String urlCode, String certNum,
+ String date, String certMet, String name, String phoneNo, String phoneCorp,
+ String birthDay, String gender, String nation, String plusInfo) throws Exception {
+
+ String tr_cert = "";
+ String extendVar = "0000000000000000"; // 확장변수
+ String regex = "";
+ String regex1 = "";
+
+ regex = "[A-Z]*";
+ regex1 = "[0-9]*";
+ if( cpId.length() == 8 ){
+ String engcpId = cpId.substring(0,4);
+ String numcpId = cpId.substring(4,8);
+ if( !paramChk(regex, engcpId) || !paramChk(regex1, numcpId) ){
+ throw new Exception("회원사ID 비정상");
+ }
+ } else {
+ throw new Exception("회원사ID 비정상");
+ }
+
+ regex = "[0-9]*";
+ if( urlCode.length() != 6 || !paramChk(regex, urlCode) ){
+ throw new Exception("URL코드 비정상");
+ }
+
+ if( certNum.length() == 0 || certNum.length() > 40){
+ throw new Exception("요청번호 비정상");
+ }
+
+ regex = "[0-9]*";
+ if( date.length() != 14 || !paramChk(regex, date) ){
+ throw new Exception("요청일시 비정상");
+ }
+
+ regex = "[A-Z]*";
+ if( certMet.length() != 1 || !paramChk(regex, certMet) ){
+ throw new Exception("본인인증방법 비정상");
+ }
+
+ regex = "[0-9]*";
+ if( phoneNo.length() != 0 ){
+ if( (phoneNo.length() != 10 && phoneNo.length() != 11) || !paramChk(regex, phoneNo) ){
+ throw new Exception("휴대폰번호 비정상");
+ }
+ }
+
+ regex = "[A-Z]*";
+ if( phoneCorp.length() != 0 ){
+ if( phoneCorp.length() != 3 || !paramChk(regex, phoneCorp) ){
+ throw new Exception("이동통신사 비정상");
+ }
+ }
+
+ regex = "[0-9]*";
+ if( birthDay.length() != 0 ){
+ if( birthDay.length() != 8 || !paramChk(regex, birthDay) ){
+ throw new Exception("생년월일 비정상");
+ }
+ }
+
+ regex = "[0-9]*";
+ if( gender.length() != 0 ){
+ if( gender.length() != 1 || !paramChk(regex, gender) ){
+ throw new Exception("성별 비정상");
+ }
+ }
+
+ regex = "[0-9]*";
+ if( nation.length() != 0 ){
+ if( nation.length() != 1 || !paramChk(regex, nation) ){
+ throw new Exception("내/외국인 비정상");
+ }
+ }
+
+ regex = "[\\sA-Za-z가-?.,-]*";
+ if( name.length() != 0 ){
+ if( name.length() > 60 || !paramChk(regex, name) ){
+ throw new Exception("성명 비정상");
+ }
+ }
+
+ //01. 한국모바일인증(주) 암호화 모듈 선언
+ com.icert.comm.secu.IcertSecuManager seed = new com.icert.comm.secu.IcertSecuManager();
+
+ //02. 1차 암호화 (tr_cert 데이터변수 조합 후 암호화)
+ String enc_tr_cert = "";
+ tr_cert = cpId +"/"+ urlCode +"/"+ certNum +"/"+ date +"/"+ certMet +"/"+ birthDay +"/"+ gender +"/"+ name +"/"+ phoneNo +"/"+ phoneCorp +"/"+ nation +"/"+ plusInfo +"/"+ extendVar;
+ enc_tr_cert = seed.getEnc(tr_cert, "");
+
+ //03. 1차 암호화 데이터에 대한 위변조 검증값 생성 (HMAC)
+ String hmacMsg = "";
+ hmacMsg = seed.getMsg(enc_tr_cert);
+
+ //04. 2차 암호화 (1차 암호화 데이터, HMAC 데이터, extendVar 조합 후 암호화)
+ tr_cert = seed.getEnc(enc_tr_cert + "/" + hmacMsg + "/" + extendVar, "");
+
+ return tr_cert;
+ }
+
+ /**
+ * 파라미터 유효성 검사
+ * @param patn 정규식 패턴
+ * @param param 검사 대상 데이터
+ * @return
+ */
+ public static Boolean paramChk(String patn, String param){
+ Pattern pattern = Pattern.compile(patn);
+ Matcher matcher = pattern.matcher(param);
+ return matcher.matches();
+ }
+
+ /**
+ * 모바일 인증 결과 복호화
+ * @param in_recCert
+ * @param in_certNum
+ * @return Map(certNum:요청번호,date:요청일시,phoneNo:휴대폰번호,phoneCorp:이동통신사,birthDay:생년월일,gender:성별,nation:내외국인,name:성명,result:결과값,certMet:인증방법,ip:ip주소,M_name:미성년자성명,M_birthDay:미성년자생년월일,M_Gender:미성년자성별,M_nation:미성년자내외국인,plusInfo:추가DATA정보,CI:연계정보,DI:중복가입확인정보)
+ * @throws Exception
+ */
+ public static Map decryptCertData(String in_recCert, String in_certNum) throws Exception{
+ Map resultMap = new HashMap<>();
+
+ //01. 한국모바일인증(주) 암호화 모듈 선언
+ com.icert.comm.secu.IcertSecuManager seed = new com.icert.comm.secu.IcertSecuManager();
+
+ //02. 1차 복호화
+ String rec_cert = seed.getDec(in_recCert, in_certNum);
+
+ //03. 1차 파싱
+ int inf1 = rec_cert.indexOf("/",0);
+ int inf2 = rec_cert.indexOf("/",inf1+1);
+
+ String encPara = rec_cert.substring(0,inf1); //암호화된 통합 파라미터
+ String encMsg1 = rec_cert.substring(inf1+1,inf2); //암호화된 통합 파라미터의 Hash값
+
+ //04. 위변조 검증
+ String encMsg2 = seed.getMsg(encPara);
+
+ String msgChk = "N";
+ if(encMsg2.equals(encMsg1)){
+ msgChk="Y";
+ }
+
+ if(msgChk.equals("N")){
+ throw new Exception("비정상적인 접근입니다.");
+ }
+
+ //05. 2차 복호화
+ rec_cert = seed.getDec(encPara, in_certNum);
+
+ //06. 2차 파싱
+ int info1 = rec_cert.indexOf("/",0);
+ int info2 = rec_cert.indexOf("/",info1+1);
+ int info3 = rec_cert.indexOf("/",info2+1);
+ int info4 = rec_cert.indexOf("/",info3+1);
+ int info5 = rec_cert.indexOf("/",info4+1);
+ int info6 = rec_cert.indexOf("/",info5+1);
+ int info7 = rec_cert.indexOf("/",info6+1);
+ int info8 = rec_cert.indexOf("/",info7+1);
+ int info9 = rec_cert.indexOf("/",info8+1);
+ int info10 = rec_cert.indexOf("/",info9+1);
+ int info11 = rec_cert.indexOf("/",info10+1);
+ int info12 = rec_cert.indexOf("/",info11+1);
+ int info13 = rec_cert.indexOf("/",info12+1);
+ int info14 = rec_cert.indexOf("/",info13+1);
+ int info15 = rec_cert.indexOf("/",info14+1);
+ int info16 = rec_cert.indexOf("/",info15+1);
+ int info17 = rec_cert.indexOf("/",info16+1);
+ int info18 = rec_cert.indexOf("/",info17+1);
+
+ String certNum = rec_cert.substring(0,info1);
+ String date = rec_cert.substring(info1+1,info2);
+ String CI = rec_cert.substring(info2+1,info3);
+ String phoneNo = rec_cert.substring(info3+1,info4);
+ String phoneCorp = rec_cert.substring(info4+1,info5);
+ String birthDay = rec_cert.substring(info5+1,info6);
+ String gender = rec_cert.substring(info6+1,info7);
+ String nation = rec_cert.substring(info7+1,info8);
+ String name = rec_cert.substring(info8+1,info9);
+ String result = rec_cert.substring(info9+1,info10);
+ String certMet = rec_cert.substring(info10+1,info11);
+ String ip = rec_cert.substring(info11+1,info12);
+ String reserve1 = rec_cert.substring(info12+1,info13);
+ String reserve2 = rec_cert.substring(info13+1,info14);
+ String reserve3 = rec_cert.substring(info14+1,info15);
+ String reserve4 = rec_cert.substring(info15+1,info16);
+ String plusInfo = rec_cert.substring(info16+1,info17);
+ String DI = rec_cert.substring(info17+1,info18);
+
+ //07. CI, DI 복호화
+ CI = seed.getDec(CI, in_certNum);
+ DI = seed.getDec(DI, in_certNum);
+
+ resultMap.put("certNum", certNum);
+ resultMap.put("date", date);
+ resultMap.put("CI", CI);
+ resultMap.put("phoneNo", phoneNo);
+ resultMap.put("phoneCorp", phoneCorp);
+ resultMap.put("birthDay", birthDay);
+ resultMap.put("gender", gender);
+ resultMap.put("nation", nation);
+ resultMap.put("name", name);
+ resultMap.put("result", result);
+ resultMap.put("certMet", certMet);
+ resultMap.put("ip", ip);
+ resultMap.put("plusInfo", plusInfo);
+ resultMap.put("DI", DI);
+
+ return resultMap;
+ }
+}
diff --git a/src/main/java/geoinfo/util/MyUtil.java b/src/main/java/geoinfo/util/MyUtil.java
new file mode 100644
index 0000000..2e07fbf
--- /dev/null
+++ b/src/main/java/geoinfo/util/MyUtil.java
@@ -0,0 +1,804 @@
+package geoinfo.util;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigDecimal;
+import java.net.URLDecoder;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.sql.Timestamp;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.httpclient.NameValuePair;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+import org.json.simple.parser.ParseException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
+
+
+public final class MyUtil {
+
+ private static final Logger logger = LoggerFactory.getLogger(MyUtil.class);
+
+ public static final String VERSION = "20240816_1430";
+
+ private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss");
+
+ // 주석 다는 기준: https://www.oracle.com/technetwork/java/javase/tech/index-137868.html
+
+ /**
+ * 특정 자리수의 랜덤 숫자를 생성한다.
+ * @param nLength 랜덤문자의 길이
+ * @return 생성된 랜덤 문자
+ */
+ public static String getRandomNumber(int nLength) {
+ Random generator = new Random();
+ String strRandValue = "";
+
+ for (int i = 0; i < nLength; i++) {
+ strRandValue += Integer.toString( generator.nextInt(10) );
+ }
+
+ return strRandValue;
+ }
+
+ /**
+ * 현재 Timestamp를 반환한다
+ * @return 현재 Timestamp yyyy-MM-dd hh:mm:ss
+ */
+ public static String getCurrentDateTime() {
+ Timestamp timestamp = new Timestamp(System.currentTimeMillis());
+ System.out.println(timestamp);
+
+ return new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(timestamp);
+ }
+
+
+ /**
+ * 현재 date를 반환한다
+ * @return 현재 Timestamp yyyy-MM-dd
+ */
+ public static String getCurrentDate() {
+ Timestamp timestamp = new Timestamp(System.currentTimeMillis());
+ System.out.println(timestamp);
+
+ return new SimpleDateFormat("yyyy-MM-dd").format(timestamp);
+ }
+
+
+ /**
+ * 현재 시각 구하기
+ * @return 현재 Timestamp hh:mm:ss
+ */
+ public static String getCurrentTime() {
+ Timestamp timestamp = new Timestamp(System.currentTimeMillis());
+ System.out.println(timestamp);
+
+ return new SimpleDateFormat("hh:mm:ss").format(timestamp);
+ }
+
+ /**
+ * 년 월 일 날짜 더하기
+ *
+ * @param dt(날짜) , y(년) , m(월), d(일)
+ * @Exam addDate("2018-09-10",1,12,1) -->20200911 addDate("2018-09-10",1,-2,1) -->20200711
+ * @return String
+ */
+ public static String addDate(String dt, int y, int m, int d) throws Exception {
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+
+ Calendar cal = Calendar.getInstance();
+ Date date = format.parse(dt);
+ cal.setTime(date);
+ cal.add(Calendar.YEAR, y); //년 더하기
+ cal.add(Calendar.MONTH, m); //월 더하기
+ cal.add(Calendar.DATE, d); //일 더하기
+
+ return format.format(cal.getTime());
+ }
+
+ /**
+ * 일 구하기
+ *
+ * @param dt(날짜)
+ * @Exam addDate("2018-09-10",1,12,1) -->20200911 addDate("2018-09-10",1,-2,1) -->20200711
+ * @return int
+ */
+ public static int getDate(String dt) throws Exception {
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+
+ Calendar cal = Calendar.getInstance();
+ Date date = format.parse(dt);
+ cal.setTime(date);
+ logger.info("getDate:" + cal.get(cal.DATE));
+ return cal.get(cal.DATE);
+ }
+
+
+
+ /**
+ * UPDATE 문에서 문자열 타입의 필드를 추가한다.
+ *
+ * @param strQuery 쿼리, strColumnName 컬럼명, strTarget
+ * @Exam addUpdateString("UPDATE SET ", "name", "홍길동") --> UPDATE SET name='홍길동',
+ * @return String
+ */
+ public static String addUpdateString(String strQuery, String strColumnName, String strValue ) {
+
+ if( strValue != null && strValue.isEmpty() == false && strValue.equals("undefined") == false && strValue.equals("null") == false ) {
+ strQuery += strColumnName + "='" + strValue + "',";
+ }
+ return strQuery;
+ }
+
+ /**
+ * UPDATE 문에서 Long 타입의 필드를 추가한다.
+ *
+ * @param strQuery 쿼리, strColumnName 컬럼명, longTarget
+ * @Exam addUpdateString("UPDATE SET ", "age", 2l) --> UPDATE SET age=2,
+ * @return String
+ */
+ public static String addUpdateLong(String strQuery, String strColumnName, Long longTarget ) {
+
+ if( longTarget != null ) {
+ strQuery += strColumnName + "=" + longTarget + ",";
+ }
+ return strQuery;
+ }
+
+ /*
+ public static boolean isJSONValid(String test) {
+ try {
+ new JSONObject(test);
+ } catch (JSONException ex) {
+ // edited, to include @Arthur's comment
+ // e.g. in case JSONArray is valid as well...
+ try {
+ new JSONArray(test);
+ } catch (JSONException ex1) {
+ return false;
+ }
+ }
+ return true;
+ }
+ */
+
+ public static String getQuery(List params) throws UnsupportedEncodingException
+ {
+ StringBuilder result = new StringBuilder();
+ boolean first = true;
+
+ for (NameValuePair pair : params)
+ {
+ if (first)
+ first = false;
+ else
+ result.append("&");
+
+ //result.append(URLEncoder.encode(pair.getName(), "UTF-8"));
+ result.append(pair.getName());
+ result.append("=");
+ result.append(pair.getValue());
+ //result.append(URLEncoder.encode(pair.getValue(), "UTF-8"));
+ }
+
+ return result.toString();
+ }
+
+ /**
+ * SHA-256으로 해싱하는 메소드
+ * @param msg
+ * @return
+ * @throws NoSuchAlgorithmException
+ */
+ public static String sha256(String msg) throws NoSuchAlgorithmException {
+ MessageDigest md = MessageDigest.getInstance("SHA-256");
+ md.update(msg.getBytes());
+
+ return bytesToHex(md.digest());
+ }
+
+
+ /**
+ * 바이트를 헥스값으로 변환한다
+ *
+ * @param bytes
+ * @return
+ */
+ public static String bytesToHex(byte[] bytes) {
+ StringBuilder builder = new StringBuilder();
+ for (byte b: bytes) {
+ builder.append(String.format("%02x", b));
+ }
+ return builder.toString();
+ }
+
+ /**
+ * 세틀뱅크 수취인 조회 서비스 HTML문서에서 특정 값 추출하기
+ * @param html_line
+ * @param inputName
+ * @return
+ */
+ public static String parseInpuValueForSettleBankResponse(String html_line, String inputName) {
+
+ String[] strArrValue = html_line.split("name=\"" + inputName + "\" value=");
+ String strValue = "";
+
+ if( strArrValue.length == 2 ) {
+ strValue = strArrValue[1].replaceAll("[\"|>|\\r\\n|\\n\\r|\\r|\\n|\\s|\\+)]","");
+ try {
+ //logger.info("Encoding EUC-KR:" + URLDecoder.decode(strValue, "EUC-KR"));
+ //logger.info("Encoding UTF-8:" + URLDecoder.decode(strValue, "UTF-8"));
+ strValue = URLDecoder.decode(strValue, "UTF-8");
+ } catch (UnsupportedEncodingException e2) {
+ // TODO Auto-generated catch block
+ e2.printStackTrace();
+ }
+ }
+ return strValue;
+ }
+
+ /**
+ * 숫자 외 소수점을 포함한 모든 특수문자를 제거해준다.
+ *
+ */
+ public static String removeSpecialChractersNumber( String decimalNumber ) {
+ decimalNumber = decimalNumber.replaceAll("[^0-9]", ""); //숫자 외 모두 제거한다.
+ return decimalNumber;
+ }
+
+ /**
+ * 수수점을 제외한 나머지 특수문자를 제거해준다. 그리고 소수점은 1개만 들어가도록 해준다.
+ *
+ */
+ public static String removeSpecialChractersDecimalNumber( String decimalNumber ) {
+ decimalNumber = decimalNumber.replaceAll("[^0-9.\\-]", ""); //숫자와 쩜.-말고는 제거한다.
+ // 소수점 1개만 넣도록 하기
+ int nDotIdx = decimalNumber.indexOf(".");
+ if( nDotIdx > -1 ) {
+ String[] arrSplit = decimalNumber.split("\\.");
+ if( arrSplit.length != 0) {
+ decimalNumber = "";
+ }
+ for( int i = 0; i < arrSplit.length ; i++ ) {
+ decimalNumber += arrSplit[i];
+ if( i == 0 ) {
+ decimalNumber += ".";
+ }
+ }
+ }
+ logger.info("removeSpecialChractersDecimalNumber() decimalNumber:" + decimalNumber);
+ return decimalNumber;
+ }
+
+
+ /**
+ * 소수점자리수가 3자리 이상이면 2자리까지만 남기고 나머지는 지운다.
+ * @param decimalNumber 소수점 자리 n개 이상 인 경우, 지울 숫자가 들어있는 문자열
+ * @param nLimitDecimalNumber 허용할 소수점 자
+ * @return
+ */
+ public static String removeOverDecimalNumber( String decimalNumber, int nLimitDecimalNumber ) {
+ logger.error("decimalNumber:" + decimalNumber);
+ int nDotIdx = decimalNumber.indexOf(".");
+ if( nDotIdx > -1 ) {
+ String[] arrSplit = decimalNumber.split("\\.");
+ if( arrSplit[1].length() > nLimitDecimalNumber ) {
+ return arrSplit[0] + "." + arrSplit[1].substring(0,2);
+ }
+ }
+ logger.error("decimalNumber:" + decimalNumber);
+ return decimalNumber;
+ }
+
+ /**
+ * 1,000 단위마다 콤마를 찍는다.
+ * @param bdAmount
+ * @return
+ */
+ public static String addComma(BigDecimal bdAmount) {
+ return addComma(bdAmount.toPlainString());
+ }
+
+ /**
+ * 1,000 단위마다 콤마를 찍는다.
+ * @param doubleAmount
+ * @return
+ */
+ public static String addComma(Double doubleAmount) {
+ return addComma(BigDecimal.valueOf(doubleAmount));
+ }
+
+ /**
+ * 1,000 단위마다 콤마를 찍는다.
+ * @param longAmount
+ * @return
+ */
+ public static String addComma(Long longAmount) {
+ return addComma(BigDecimal.valueOf(longAmount));
+ }
+
+ /**
+ * 1,000 단위마다 콤마를 찍는다.
+ * @param strAmount
+ * @return
+ */
+ public static String addComma(String strAmount) {
+ DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
+ DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
+
+ if( isNumeric(strAmount) == false ) {
+ return strAmount;
+ }
+
+ int nDotIndex = strAmount.indexOf(".");
+
+
+ symbols.setGroupingSeparator(',');
+ formatter.setDecimalFormatSymbols(symbols);
+ if( nDotIndex > -1 ) {
+ return formatter.format(Double.parseDouble( strAmount ));
+ } else {
+ return formatter.format(Long.parseLong( strAmount ));
+ }
+
+ }
+
+ /**
+ * 숫자에서 끝에 0000을 제거한다.
+ *
+ */
+ public static String trimTrailingZero( String decimalNumber ) {
+ decimalNumber = decimalNumber.replaceAll("[^0-9.\\-]", ""); //숫자와 쩜.-말고는 제거한다.
+ decimalNumber = decimalNumber.indexOf(".") < 0 ? decimalNumber : decimalNumber.replaceAll("0*$", "").replaceAll("\\.$", "");
+ logger.info("trimTrailingZero() decimalNumber:" + decimalNumber);
+ return decimalNumber;
+ }
+
+ /**
+ * SQL 인젝션 방어를 위해 특수문자를 제거한다.
+ * @param myString
+ * @return
+ */
+ public static String removeSQLInjectionSpecialCharacter(String myString) {
+ if( myString == null ) {
+ return myString;
+ }
+ myString = myString.replaceAll( "<|>|\\(|\\)|'|\"|\\|;|=|\\+|\\||&|#|\\.\\.", " ");
+
+ return myString;
+ }
+
+
+ /**
+ * UUID(GUID)를 얻는다.
+ * @return 구한 UUID(GUID) 값.
+ */
+ public static String getUuid() {
+ String uuid = UUID.randomUUID().toString();
+ return uuid;
+ }
+
+ /** 숫자인지 아닌지 확인한다. */
+ public static boolean isNumeric(String strNum) {
+ if (strNum == null) {
+ return false;
+ }
+ try {
+ double d = Double.parseDouble(strNum);
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ return true;
+ }
+
+ public static boolean isNumeric(Double num) {
+ if (num == null) {
+ return false;
+ }
+ return isNumeric(num.toString());
+ }
+
+ public static boolean isNumeric(Integer num) {
+ if (num == null) {
+ return false;
+ }
+ return isNumeric(num.toString());
+ }
+
+ public static boolean isNumeric(Long num) {
+ if (num == null) {
+ return false;
+ }
+ return isNumeric(num.toString());
+ }
+
+ /** Long형태의 숫자인지 아닌지 확인한다. */
+ public static boolean isNumericForLong(String strNum) {
+ if (strNum == null) {
+ return false;
+ }
+ try {
+ Long lValue = Long.parseLong(strNum);
+ } catch (NumberFormatException nfe) {
+ return false;
+ }
+ return true;
+ }
+
+
+ public static Integer getIntegerFromObject(Object obj) {
+ if (obj instanceof Integer ) {
+ return (Integer) obj;
+ } else if (obj instanceof String ) {
+ return Integer.parseInt((String) obj);
+ } else if (obj instanceof Long) {
+ return ((Long) obj).intValue();
+ } else if (obj instanceof Double) {
+ return ((Long)Math.round((Double)obj)).intValue();
+ }
+
+ return null;
+ }
+
+ public static Long getLongFromObject(Object obj) {
+ if (obj instanceof String ) {
+ String strObj = (String) obj;
+ if( isNumeric(strObj) ) {
+ return Long.parseLong((String) obj);
+ }
+ } else if (obj instanceof Integer) {
+ return ((Integer) obj).longValue();
+ } else if (obj instanceof Long) {
+ return (Long) obj;
+ } else if (obj instanceof BigDecimal) {
+ return ((BigDecimal) obj).longValue();
+ } else if (obj instanceof Double) {
+ return ((Long)Math.round((Double)obj));
+ }
+
+ return null;
+ }
+
+ public static Double getDoubleFromObject(Object obj) throws Exception {
+ String str = getStringFromObject(obj);
+ str = removeSpecialChractersDecimalNumber(str);
+ return Double.parseDouble((String) str);
+ }
+
+ public static BigDecimal getBigDecimalFromObject(Object obj) throws Exception {
+ return BigDecimal.valueOf(getDoubleFromObject(obj));
+ }
+
+
+
+ public static String getStringFromObject(Object obj) throws Exception {
+ if (obj == null) {
+ return null;
+ } else if (obj instanceof String ) {
+ return (String) obj;
+ } else if (obj instanceof Integer) {
+ return ((Integer)obj).toString();
+ } else if (obj instanceof Long) {
+ return ((Long) obj).toString();
+ } else if (obj instanceof Float) {
+ return ((Float)obj).toString();
+ } else if (obj instanceof Double) {
+ return ((Double)obj).toString();
+ } else if (obj instanceof BigDecimal) {
+ return ((BigDecimal)obj).toPlainString();
+ } else if (obj instanceof Date) {
+ return ((Date)obj).toString();
+ }
+
+ return null;
+ }
+
+ public static org.json.simple.JSONObject getJSONObjectFromObject(Object obj) {
+ if (obj instanceof org.json.simple.JSONObject ) {
+ return (org.json.simple.JSONObject) obj;
+ } else if (obj instanceof String ) {
+ JSONParser parser = new JSONParser();
+ try {
+ obj = parser.parse( (String) obj );
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return (org.json.simple.JSONObject) obj;
+ }
+ return null;
+ }
+
+ public static org.json.simple.JSONArray getJSONArrayFromObject(Object obj) {
+ if (obj instanceof org.json.simple.JSONArray ) {
+ return (org.json.simple.JSONArray) obj;
+ } else if (obj instanceof String ) {
+ JSONParser parser = new JSONParser();
+ try {
+ obj = parser.parse( (String) obj );
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ return (org.json.simple.JSONArray) obj;
+ }
+ return null;
+ }
+
+ public static Boolean getBooleanFromObject(Object obj) {
+
+ if (obj instanceof String ) {
+ return Boolean.parseBoolean( ((String)obj).trim() );
+ } else if (obj instanceof Boolean) {
+ return (Boolean)obj;
+ }
+
+ return null;
+ }
+
+ /**
+ * Parse a URI String into Name-Value Collection
+ * 쿼리스트링을 분석해서 Map형태로 return해준다.
+ * @param query
+ * @return query string name-value Map.
+ * @throws UnsupportedEncodingException
+ */
+ public static Map splitQuery(String query, String token) throws UnsupportedEncodingException {
+ Map query_pairs = new LinkedHashMap();
+ String[] pairs = query.split(token);
+ for (String pair : pairs) {
+ int idx = pair.indexOf("=");
+ query_pairs.put(URLDecoder.decode(pair.substring(0, idx), "UTF-8"), URLDecoder.decode(pair.substring(idx + 1), "UTF-8"));
+ }
+ return query_pairs;
+ }
+
+
+
+ public static SortedMap getParameterMap(HttpServletRequest request) {
+
+ SortedMap sMap = Collections.synchronizedSortedMap
+ ( new TreeMap(request.getParameterMap()));
+
+ String params = "\n--------------------------------------------------------------\n" +
+ MyUtil.getBASEURL(request) + request.getRequestURI() + " IN:" +
+ "\n--------------------------------------------------------------\n";
+ synchronized(sMap) {
+ for(String key : sMap.keySet()) {
+ String[] value = sMap.get(key);
+ for(int i=0; i sMap = Collections.synchronizedSortedMap
+ ( new TreeMap(request.getParameterMap()));
+
+ String params = "\n--------------------------------------------------------------\n" +
+ MyUtil.getBASEURL(request) + request.getRequestURI() + " IN:" +
+ "\n--------------------------------------------------------------\n";
+ synchronized(sMap) {
+ for(String key : sMap.keySet()) {
+ String[] value = sMap.get(key);
+ for(int i=0; i 1.23
+ * @return
+ * @throws Exception
+ */
+ public static Double floor(String strAmount, int decimalPlace) throws Exception {
+
+ Double dPoint = Double.parseDouble(strAmount);
+
+ String[] arrSplitedDot = strAmount.split("\\.");
+ int nLength = arrSplitedDot.length;
+ if (arrSplitedDot.length == 2) {
+ if (MyUtil.isNumeric(arrSplitedDot[1])) {
+
+ //소수부 끝에 0을 제거해준다.
+ arrSplitedDot[1] = arrSplitedDot[1].replaceAll("0+$", "");
+
+ int nDecimalLength = arrSplitedDot[1].length();
+ if( nDecimalLength >= decimalPlace ) {
+ String strDecimal = "1";
+ for (int i = 0; i < decimalPlace; i++) {
+ strDecimal += "0";
+ }
+ dPoint = Math.floor(dPoint*Long.valueOf(strDecimal)) / Long.valueOf(strDecimal);
+ }
+ }
+ }
+
+ return dPoint;
+ }
+
+
+ /**
+ * days안에는 "월" 또는 "월,수,금" 이런 요일에 대한 한글문자가 들어가고 오늘이 주어진 요일 안에 포함되는지 여부를 알아낸다.
+ *
+ * @param days "월" 또는 "월,수,금'과 같이 요일이 한글로 들어있다.
+ * @return 만약 days에 "월"이 들어가 있고 오늘이 월요일이라면 true를 return한다.
+ */
+ public static Boolean isContainDayOfWeekToday( String days ) {
+
+ // 1. Date 생성 / 현재 날짜
+ Date currentDate = new Date();
+ System.out.println(currentDate);
+
+ // 2. Calendar 생성
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(currentDate);
+
+ // 3. 텍스트 요일 구하기 (숫자)
+ int dayOfWeekNumber = calendar.get(Calendar.DAY_OF_WEEK);
+
+ if( dayOfWeekNumber == 1 ) {
+ if( days.indexOf("일") > -1 ) {
+ return true;
+ }
+ } else if( dayOfWeekNumber == 2 ) {
+ if( days.indexOf("월") > -1 ) {
+ return true;
+ }
+ } else if( dayOfWeekNumber == 3 ) {
+ if( days.indexOf("화") > -1 ) {
+ return true;
+ }
+ } else if( dayOfWeekNumber == 4 ) {
+ if( days.indexOf("수") > -1 ) {
+ return true;
+ }
+ } else if( dayOfWeekNumber == 5 ) {
+ if( days.indexOf("목") > -1 ) {
+ return true;
+ }
+ } else if( dayOfWeekNumber == 6 ) {
+ if( days.indexOf("금") > -1 ) {
+ return true;
+ }
+ } else if( dayOfWeekNumber == 7 ) {
+ if( days.indexOf("토") > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * 현재 시각이 timeRange에 명시한 시간대 안에 포함되는지 여부를 return 한다.
+ * @param timeRange 01~14 -> 오전 1시부터 오후 2시를 의미하며 ~ 구분자를 사용한다.
+ * @return 현재 시각이 해당 시간대 내에 포함되면 true를 return 한다.
+ * @throws Exception timeRange이 형식에 맞지 않으면 Exception이 발생한다.
+ */
+ public static Boolean isInTimeRange( String timeRange ) throws Exception {
+
+ String[] arrTimeRange = timeRange.split("~");
+ if( arrTimeRange.length != 2 ) {
+ throw new Exception("timeRange이 형식에 맞지 않습니다.");
+ }
+
+ if( MyUtil.isNumeric(arrTimeRange[0]) == false ) {
+ throw new Exception("timeRange이 형식에 맞지 않습니다 - 1");
+ }
+
+ if( MyUtil.isNumeric(arrTimeRange[1]) == false ) {
+ throw new Exception("timeRange이 형식에 맞지 않습니다 - 1");
+ }
+
+
+ Date currentDate = new Date();
+ // 포맷팅 정의
+ SimpleDateFormat formatter = new SimpleDateFormat("HH");
+ // 포맷팅 적용
+ String formatedNow = formatter.format(currentDate);
+
+ Integer currentHour = MyUtil.getIntegerFromObject( formatedNow );
+ Integer rangeStart = MyUtil.getIntegerFromObject( arrTimeRange[0] );
+ Integer rangeEnd = MyUtil.getIntegerFromObject( arrTimeRange[0] );
+
+ if( rangeStart <= rangeEnd && rangeEnd <= rangeEnd ) {
+ return true;
+ }
+
+ return false;
+ }
+
+}
diff --git a/src/main/java/geoinfo/util/RequestWrapper.java b/src/main/java/geoinfo/util/RequestWrapper.java
new file mode 100644
index 0000000..9f28037
--- /dev/null
+++ b/src/main/java/geoinfo/util/RequestWrapper.java
@@ -0,0 +1,58 @@
+package geoinfo.util;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+public final class RequestWrapper extends HttpServletRequestWrapper {
+
+ public RequestWrapper(HttpServletRequest servletRequest) {
+ super(servletRequest);
+ }
+
+ public String[] getParameterValues(String parameter) {
+
+ String[] values = super.getParameterValues(parameter);
+
+ System.out.println("getParameterValues" + values);
+
+ if (values==null) {
+ return null;
+ }
+ int count = values.length;
+ String[] encodedValues = new String[count];
+ for (int i = 0; i < count; i++) {
+ encodedValues[i] = cleanXSS(values[i]);
+ }
+ return encodedValues;
+ }
+
+ public String getParameter(String parameter) {
+ String value = super.getParameter(parameter);
+ if (value == null) {
+ return null;
+ }
+ return cleanXSS(value);
+ }
+
+ public String getHeader(String name) {
+ String value = super.getHeader(name);
+ if (value == null)
+ return null;
+ return cleanXSS(value);
+
+ }
+
+ public static String cleanXSS(String value) {
+ System.out.println("cleanXSS : " + value);
+ //You'll need to remove the spaces from the html entities below
+ value = value.replaceAll("<", "& lt;").replaceAll(">", "& gt;");
+ value = value.replaceAll("\\(", "& #40;").replaceAll("\\)", "& #41;");
+ value = value.replaceAll("'", "& #39;");
+ value = value.replaceAll("eval\\((.*)\\)", "");
+ value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\"");
+ value = value.replaceAll("script", "");
+ return value;
+ }
+}
+
+
diff --git a/src/main/java/geoinfo/util/RsWrapper.java b/src/main/java/geoinfo/util/RsWrapper.java
new file mode 100644
index 0000000..ba5fc61
--- /dev/null
+++ b/src/main/java/geoinfo/util/RsWrapper.java
@@ -0,0 +1,275 @@
+/*********************************************************************************
+* 파 일 명 : RsWrapper.java
+* 작 성 일 : 2005.02
+* 작 성 자 : 최군길
+*---------------------------------------------------------------------------------
+* 프로그램명 : RsWrapper
+* 기능 및 설명 : JDBC Result Set Wrapper
+*---------------------------------------------------------------------------------
+* 기 타 :
+*********************************************************************************/
+package geoinfo.util;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.text.ParseException;
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.jfree.util.Log;
+import org.slf4j.LoggerFactory;
+
+import com.extentech.toolkit.Logger;
+
+
+public class RsWrapper implements java.io.Serializable {
+
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(RsWrapper.class);
+
+ /**
+ * RsBox 를 담기위한 Vector
+ */
+ private Vector vtRsBox;
+
+ /**
+ * 레코드 갯수
+ */
+ private int rowCount;
+
+ /**
+ * 레코드의 인덱스 필드에서 가장 큰 것을 갖는다
+ */
+ private String firstRowID;
+
+ /**
+ * 레코드의 인덱스 필드에서 가장 작은 것을 갖는다
+ */
+ private String lastRowID;
+
+ private String pageCount = "1"; // 페이징의 페이지 번호
+ private String unitCount = "10"; // 페이징의 페이지 당 아이템 갯수
+
+ /**
+ * Constructor
+ */
+ public RsWrapper() {
+ vtRsBox = new Vector(10, 10);
+ firstRowID = "";
+ lastRowID = "";
+ }
+
+ /**
+ *
+ * RsBox 를 RsWrapper 에 추가한다.
+ *
+ *
+ * @param rsBox
+ * RsBox
+ */
+ public void appendRs(Box rb) {
+ vtRsBox.addElement(rb);
+ }
+
+ /**
+ *
+ * RsWrapper에 저장된 RsBox의 갯수를 리턴한다.
+ *
+ *
+ * @return int RsBox의 갯수
+ */
+ public int getLength() {
+ return vtRsBox.size();
+ }
+
+ /**
+ *
+ * index 위치에 있는 RsBox를 가져와 반환한다.
+ *
+ *
+ * @param index
+ * RsBox를 찾을 위치
+ * @return RsBox
+ */
+ public Box getRsBoxAt(int index) {
+ return (Box) vtRsBox.get(index);
+ }
+
+ /**
+ *
+ * RsWrapper 를 Iterator 를 이용하여 사용할 수 있도록 RsWrapperIterator 를 반환한다.
+ *
+ *
+ * @return RsWrapperIterator (Iterator 를 implements 하였음)
+ */
+ public RsWrapperIterator iterator() {
+ return new RsWrapperIterator(this);
+ }
+
+ public void setRowCount(int cnt) {
+ this.rowCount = cnt;
+ }
+
+ public void setFirstRowID(String firstRowID) {
+ this.firstRowID = firstRowID;
+ }
+
+ public void setLastRowID(String lastRowID) {
+ this.lastRowID = lastRowID;
+ }
+
+ public int getRowCount() {
+ return this.rowCount;
+ }
+
+ public String getPageCount() {
+ return this.pageCount;
+ }
+
+ public String getUnitCount() {
+ return this.unitCount;
+ }
+
+ public void setPageCount(String pageCount) {
+ this.pageCount = pageCount;
+ }
+
+ public void setUnitCount(String unitCount) {
+ this.unitCount = unitCount;
+ }
+
+ public String getSno(int i, int unit, HttpServletRequest request) {
+ int page = Integer.parseInt(FormatUtil.nvl2(request.getParameter("page_count"), "1"));
+
+ return (getRowCount() - (((page - 1) * unit) + i)) + "";
+ }
+
+ public String getSnoAsc(int i, int unit, HttpServletRequest request) {
+ int page = Integer.parseInt(FormatUtil.nvl2(request.getParameter("page_count"), "1"));
+
+ return (((page - 1) * unit) + i + 1) + "";
+ }
+
+ public String getSno(int i) {
+ int page = 10;
+ int unit = 10;
+
+ if (!pageCount.equals("")) {
+ page = Integer.parseInt(pageCount);
+ }
+ if (!unitCount.equals("")) {
+ unit = Integer.parseInt(unitCount);
+ }
+
+ return (((page - 1) * unit) + getLength() - i) + "";
+ }
+
+ public String getMaxRowID() {
+ // bug 수정
+ // firstRowID와 lastRowID의 길이가 다를 경우 compareTo로만 비교하면 안됨
+ if (CheckNumber(firstRowID) && CheckNumber(lastRowID)) {
+ if ((new Double(firstRowID)).compareTo(new Double(lastRowID)) >= 0)
+ return this.firstRowID;
+ else
+ return this.lastRowID;
+ } else {
+ if (firstRowID.compareTo(lastRowID) >= 0)
+ return this.firstRowID;
+ else
+ return this.lastRowID;
+ }
+ }
+
+ public String getMinRowID() {
+ if (CheckNumber(firstRowID) && CheckNumber(lastRowID)) {
+ if ((new Double(firstRowID)).compareTo(new Double(lastRowID)) >= 0)
+ return this.lastRowID;
+ else
+ return this.firstRowID;
+ } else {
+ if (firstRowID.compareTo(lastRowID) >= 0)
+ return this.lastRowID;
+ else
+ return this.firstRowID;
+ }
+ }
+
+ /**
+ *
+ * 문자열이 숫자로만 이루어져 있는지 판단한다.
+ *
+ *
+ * @param Value
+ * 검사할 문자열
+ * @return boolean 숫자만 있을 경우 true 아니면 false
+ */
+ public static boolean CheckNumber(String Value) {
+ if ((Value == null) || Value.equals("")) {
+ return false;
+ } else {
+ int ilen = Value.length();
+ for (int i = 0; i < ilen; i++) {
+ if (!Character.isDigit(Value.charAt(i)))
+ return false;
+ }
+ return true;
+ }
+ }
+
+ public String get(String key, int i) {
+ return getRsBoxAt(i).get(key);
+ }
+
+ public String get(String key, int i, int fmt) {
+ return getRsBoxAt(i).get(key, fmt);
+ }
+
+ public String getCutStr(String key, int i, int len) {
+ return StringUtil.fixLength(getRsBoxAt(i).get(key), len);
+ }
+
+ public int getInt(String key, int i) {
+ return getRsBoxAt(i).getInt(key);
+ }
+
+ public double getDouble(String key, int i) {
+ return getRsBoxAt(i).getDouble(key);
+ }
+
+ public boolean getBoolean(String key, int i) {
+ return getRsBoxAt(i).getBoolean(key);
+ }
+
+ public float getFloat(String key, int i) {
+ return getRsBoxAt(i).getFloat(key);
+ }
+
+ public long getLong(String key, int i) {
+ return getRsBoxAt(i).getLong(key);
+ }
+
+ public int dayCnt(String key, int i) {
+ try {
+ String day = getRsBoxAt(i).get(key);
+ return DateUtil.dayDiff(day.substring(0, 8), DateUtil.toString("yyyyMMdd"));
+ } catch (MalformedURLException ex) {
+ LOGGER.debug("error", ex);
+ return -1;
+ } catch (ParseException ex) {
+ LOGGER.debug("error", ex);
+ return -1;
+ } catch (IndexOutOfBoundsException ex) {
+ LOGGER.debug("error", ex);
+ return -1;
+ } catch (IOException ex) {
+ LOGGER.debug("error", ex);
+ return -1;
+ } catch (NumberFormatException ex) {
+ LOGGER.debug("error", ex);
+ return -1;
+ } catch (Exception ex) {
+ LOGGER.debug("error", ex);
+ return -1;
+ }
+ }
+}
diff --git a/src/main/java/geoinfo/util/RsWrapperIterator.java b/src/main/java/geoinfo/util/RsWrapperIterator.java
new file mode 100644
index 0000000..a2e4cde
--- /dev/null
+++ b/src/main/java/geoinfo/util/RsWrapperIterator.java
@@ -0,0 +1,70 @@
+/*********************************************************************************
+* 파 일 명 : RsBox.java
+* 작 성 일 : 2005.02
+* 작 성 자 : 최군길
+*---------------------------------------------------------------------------------
+* 프로그램명 : RsBox
+* 기능 및 설명 : JDBC Result Set Box Util
+*---------------------------------------------------------------------------------
+* 기 타 :
+*********************************************************************************/
+package geoinfo.util;
+
+import java.util.*;
+
+public class RsWrapperIterator implements Iterator, java.io.Serializable {
+ private RsWrapper rsWrapper;
+ private int index;
+
+ /**
+ *
+ * Constructor.
+ * rsWrapper를 인자로 받아 RsWrapper에 대한 Iterator를 사용할 수 있도록 RsWrapperIterator를 생성
+ *
+ * @param rsWrapper
+ */
+ public RsWrapperIterator(RsWrapper rsWrapper) {
+ this.rsWrapper = rsWrapper;
+ this.index = 0;
+ }
+
+ /**
+ *
+ * Iterator 의 hasNext 구현.
+ * 다음 RsBox가 있는지 판단한다.
+ *
+ *
+ * @return 다음 RsBox가 있을 경우 true 아닐경우 false
+ */
+ public boolean hasNext() {
+ if (index < rsWrapper.getLength()) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * Iterator 의 next 구현.
+ * 다음 RsBox를 가져온다.
+ *
+ *
+ * @return 다음 RsBox
+ */
+ public Object next() {
+ Box rb = rsWrapper.getRsBoxAt(index);
+ index++;
+ return rb;
+ }
+
+ /**
+ *
+ * 현재 구현하지 않음.
+ * 필요시 구현
+ *
+ */
+ public void remove() {
+ // 구현하지 않음 ^^
+ }
+}
diff --git a/src/main/java/geoinfo/util/ScriptUtil.java b/src/main/java/geoinfo/util/ScriptUtil.java
new file mode 100644
index 0000000..6be0860
--- /dev/null
+++ b/src/main/java/geoinfo/util/ScriptUtil.java
@@ -0,0 +1,121 @@
+package geoinfo.util;
+
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.xml.serializer.utils.Utils;
+import org.jfree.util.Log;
+import org.slf4j.LoggerFactory;
+
+public class ScriptUtil {
+
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ScriptUtil.class);
+
+ private static final String _jsStartTag = "";
+ private static final String _contentType = "text/html;charset=utf-8";
+
+ /**
+ * 메시지 창 출력 후 지정한 경로로 이동
+ * @param message 메시지
+ * @param locationHref 이동경로
+ */
+ public static void doAlertToLocation(HttpServletResponse response , String message , String locationHref) throws Exception{
+ StringBuffer sb = new StringBuffer(1024);
+ sb.append("alert('"+strToAlert(message)+"');");
+ sb.append("location.href = '"+locationHref+"';");
+ pDoPrintWriteFlush(response, sb.toString());
+ }
+
+ /**
+ * 메시지 창 출력 후 팝업 창 종료, 부모창 지정한 경로로 이동
+ * @param message 메시지
+ * @param locationHref 이동경로
+ */
+ public static void doAlertToOpenerLocation(HttpServletResponse response , String message , String locationHref) throws Exception{
+ StringBuffer sb = new StringBuffer(1024);
+ sb.append("alert('"+strToAlert(message)+"');");
+ sb.append("opener.location.href = '"+locationHref+"';");
+ sb.append("window.close();");
+ pDoPrintWriteFlush(response, sb.toString());
+ }
+
+ /**
+ * 메시지 창 출력 후 팝업 창 종료
+ * @param message 메시지
+ */
+ public static void doAlertWindowClose(HttpServletResponse response, String message) throws Exception{
+ StringBuffer sb = new StringBuffer(1024);
+ sb.append("alert('"+strToAlert(message)+"');");
+ sb.append("window.close();");
+ pDoPrintWriteFlush(response, sb.toString());
+ }
+
+ /**
+ * 메시지 창 출력 후 전화면으로 이동
+ * @param message 메시지
+ */
+ public static void doAlertHistoryBack(HttpServletResponse response, String message) throws Exception{
+ StringBuffer sb = new StringBuffer(1024);
+ sb.append("alert('"+strToAlert(message)+"');");
+ sb.append("history.back();");
+ pDoPrintWriteFlush(response, sb.toString());
+ }
+
+ private static void pDoPrintWriteFlush(HttpServletResponse response , String jsMessage) throws Exception{
+ response.setContentType(_contentType);
+ PrintWriter out = response.getWriter();
+ out.println(_jsStartTag);
+ out.println(jsMessage);
+ out.println(_jsEndTag);
+ out.flush();
+ out.close();
+ }
+
+ private static String strToAlert(String alertMessage){
+ alertMessage = alertMessage.replaceAll("'", "\\\\'");
+ alertMessage = alertMessage.replaceAll("\n", "\\\\n");
+ return alertMessage;
+ }
+
+ public static String getSha256(String text, String encoding){
+ String sha = "";
+ try {
+
+ MessageDigest digest = MessageDigest.getInstance("SHA-256");
+ byte[] hash = digest.digest(text.getBytes(encoding));
+ //웹 취약점 때문에 수정
+ digest.reset();
+ digest.update(hash);
+ StringBuffer hexString = new StringBuffer();
+
+ for (int i = 0; i < hash.length; i++) {
+ String hex = Integer.toHexString(0xff & hash[i]);
+ if(hex.length() == 1) hexString.append('0');
+ hexString.append(hex);
+ }
+
+ sha = hexString.toString();
+
+ } catch (IndexOutOfBoundsException ex) {
+ LOGGER.debug("error", ex);
+ System.out.println("getSha256");
+ } catch (NumberFormatException ex) {
+ LOGGER.debug("error", ex);
+ System.out.println("getSha256");
+ } catch (NoSuchAlgorithmException | UnsupportedEncodingException ex) {
+ LOGGER.debug("error", ex);
+ System.out.println("getSha256");
+ } catch (Exception ex) {
+ LOGGER.debug("error", ex);
+ System.out.println("getSha256");
+ }
+ return sha;
+ }
+}
diff --git a/src/main/java/geoinfo/util/StringUtil.java b/src/main/java/geoinfo/util/StringUtil.java
new file mode 100644
index 0000000..3db4658
--- /dev/null
+++ b/src/main/java/geoinfo/util/StringUtil.java
@@ -0,0 +1,1533 @@
+/*******************************************************************/
+/* Class Name : StringUtil */
+/* Description : 문자열 처리 관련 Class */
+/*******************************************************************/
+/* Modification Log */
+/* No DATE Company Author Description */
+/* 01 2002/06/01 IRAM Initial Release */
+/*******************************************************************/
+
+package geoinfo.util;
+
+import java.io.*;
+import java.text.*;
+
+import org.jfree.util.Log;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * 문자열 처리 관련 Class
+ *
+ *
+ * @author IRAM
+ * @version 1.0
+ * @since 2002.01.
+ */
+
+public class StringUtil {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(StringUtil.class);
+
+ public static String urlEncode(String str) {
+ return replace(java.net.URLEncoder.encode(str), "+", "%20");
+ }
+
+ /**
+ *
+ * 입력된 문자열에서 source형태의 문자열을 target문자열로 변환하여 리턴한다.
+ * 예) replace('엔터프라이즈 자바빈즈','즈','빈') -> 엔터프라이빈 자바빈빈
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param pattern
+ * 바꿀 문자열
+ * @param replace
+ * 바뀔 문자열
+ * @return java.lang.String
+ */
+ public static String replace(String str, String pattern, String replace) {
+ int s = 0; // 시작위치
+ int e = 0; // append하는 위치
+ if (pattern.equals(""))
+ return str;
+
+ StringBuffer result = new StringBuffer();
+ while ((e = str.indexOf(pattern, s)) >= 0) {
+ result.append(str.substring(s, e));
+ result.append(replace);
+ s = e + pattern.length();
+ } // while 종료
+ result.append(str.substring(s));
+ return result.toString();
+ }
+
+ /**
+ *
+ * 입력된 문자열에서 source형태의 문자열을 target문자열로 변환하여 리턴한다.
+ * 예) 1번째로 나오는 하나만 변환한다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param pattern
+ * 바꿀 문자열
+ * @param replace
+ * 바뀔 문자열
+ * @return java.lang.String
+ */
+ public static String replaceFirst1(String str, String pattern, String replace) {
+ int s = 0; // 시작위치
+ int e = 0; // append하는 위치
+ if (pattern.equals(""))
+ return str;
+
+ StringBuffer result = new StringBuffer();
+ while ((e = str.indexOf(pattern, s)) >= 0) {
+ result.append(str.substring(s, e));
+ result.append(replace);
+ s = e + pattern.length();
+ break; // 한번만 실행한 후 종료
+ } // while 종료
+ result.append(str.substring(s));
+ return result.toString();
+ }
+
+ /**
+ *
+ * 특정 부분의 문자열을 지정한 문장열로 바꾼다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param sPos
+ * 원래문자열을 자를 시작위치
+ * @param ePos
+ * 원래문자열을 자를 끝 위치
+ * @param replace
+ * 자른 문자열 사이에 넣을 문자열
+ * @return String 변환된 문자열
+ */
+ public static String replace(String str, int sPos, int ePos, String replace) {
+ StringBuffer result = new StringBuffer(str.substring(0, sPos));
+ result.append(replace);
+ result.append(str.substring(ePos));
+ return result.toString();
+ }
+
+ /**
+ *
+ * 스트링을 토큰하여 array로 넘긴다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param delim
+ * 자를 delim 문자
+ * @return String[] delim 문자로 토큰된 array
+ */
+ public static String[] getArrToken(String str, String delim) {
+ java.util.StringTokenizer tk = new java.util.StringTokenizer(str, delim);
+ String[] arr = new String[tk.countTokens()];
+ for (int i = 0; i < arr.length; i++) {
+ arr[i] = tk.nextToken();
+ }
+ return arr;
+ }
+
+ /**
+ *
+ * 스트링을 토큰하여 array로 넘긴다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param delim
+ * 자를 delim 문자
+ * @return String[] delim 문자로 토큰된 array
+ */
+ public static String[] getArrToken2(String str, String delim) {
+ return split(str, delim, true);
+ }
+
+ /**
+ *
+ * str의 문자열을 " " 으로 구분하여 length마다의 길이에 enter문자를 삽입시켜준다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param length
+ * Enter문자를 넣을 위치
+ * @return String 원래 문자열에 Enter를 넣은 문자열
+ */
+ public static String HrInsEnterX(String str, int length) {
+
+ String[] tmp = getArrToken(str, " ");
+ String rtnStr = "";
+ int line_num = 1;
+ for (int i = 0; i < tmp.length; i++) {
+ if ((rtnStr + tmp[i]).length() > length * line_num) {
+ rtnStr += "\n";
+ line_num++;
+ }
+ rtnStr += " " + tmp[i];
+ }
+ return rtnStr;
+ }
+
+ /**
+ *
+ * str의 문자열을 " " 으로 구분하여 length마다의 길이에 enter문자를 삽입시켜준다.
+ * enter(\n)다음에 pad 문자를 넣어준다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param length
+ * Enter문자를 넣을 위치
+ * @param pad
+ * Enter를 넣은 후 다음 줄 시작에 넣을 문자열
+ * @return String 원래 문자열에 Enter를 넣은 문자열
+ */
+ public static String HrInsEnterX(String str, int length, String pad) {
+ return replace(HrInsEnterX(str, length), "\n", "\n" + pad);
+ }
+
+ /**
+ *
+ * str의 문자열을 length마다의 길이에 enter문자를 삽입시켜준다.
+ * " " 로 토큰한 후 토큰 한 string 이 length보다 클경우 /n 을 넣어준다.
+ * HrInsEnterX와 틀린 점은 length 안에 enter가 있을 경우 그 다음부터 다시 length를 체크한다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param length
+ * Enter문자를 넣을 위치
+ * @return String 원래 문자열에 Enter를 넣은 문자열
+ */
+ public static String HrInsEnterX2(String str, int length) {
+
+ String[] tmp = getArrToken(str, " ");
+ String rtnStr = "";
+ String this_line = "";
+ for (int i = 0; i < tmp.length; i++) {
+ this_line += tmp[i];
+ if (this_line.length() > length) {
+ rtnStr += this_line + "\n";
+ this_line = "";
+ } else if (this_line.indexOf("\n") != -1) {
+ // 엔터가 있을 경우
+ rtnStr += this_line;
+ this_line = "";
+ }
+ }
+ rtnStr += this_line;
+ return rtnStr;
+ }
+
+ /**
+ *
+ * string에서 integer에 해당하는 값을 찾아온다.
+ *
+ *
+ * @param str
+ * 숫자가 들어있는 문자열
+ * @return 숫자로 만들어지는 문자열일 경우 integer에 해당하는 문자열이 넘어오고 아닐경우 공백("")이 넘어온다.
+ */
+ public static String getIntString(String str) {
+ String rtn = "";
+ try {
+ rtn = String.valueOf(Integer.parseInt(str));
+ } catch (NumberFormatException e) {
+ LOGGER.debug("error", e);
+ rtn = "";
+ } catch (Exception e) {
+ LOGGER.debug("error", e);
+ rtn = "";
+ }
+ return rtn;
+ }
+
+ /**
+ *
+ * str string에서 숫자인 것만 찾아온다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @return String 원래 문자열에서 숫자만 리턴
+ */
+ public static String getNumber(String str) {
+ if (str == null) {
+ return str;
+ }
+
+ StringBuffer sb = new StringBuffer(str);
+ StringBuffer newSb = new StringBuffer();
+
+ int sbLen = sb.length();
+ char number;
+ for (int i = 0; i < sbLen; i++) {
+ number = sb.charAt(i);
+ if (number >= 48 && number <= 57)
+ newSb.append(sb.charAt(i));
+ }
+
+ return newSb.toString();
+ }
+
+ /**
+ *
+ * 문자열을 15자 만큼만 보여주고
+ * 그 길이에 초과되는 문자열일 경우 "..."를 덧붙여 보여준다.
+ *
+ *
+ * @param input
+ * 변환할 문자열
+ * @return String 제한된 길이만큼 자르고 ... 을 붙인 문자열
+ */
+ public static String fixLength(String input) {
+ return fixLength(input, 15, "...");
+ }
+
+ /**
+ *
+ * 문자열을 일정길이 만큼만 보여주고
+ * 그 길이에 초과되는 문자열일 경우 "..."를 덧붙여 보여준다.
+ *
+ *
+ * @param input
+ * 변환할 문자열
+ * @param limit
+ * 문자열의 제한 길이
+ * @return String 제한된 길이만큼 자르고 ... 을 붙인 문자열
+ */
+ public static String fixLength(String input, int limit) {
+ return fixLength(input, limit, "...");
+ }
+
+ /**
+ *
+ * 문자열을 일정길이 만큼만 보여주고
+ * 그 길이에 초과되는 문자열일 경우 특정문자를 덧붙여 보여준다.
+ *
+ *
+ * @param input
+ * 변환할 문자열
+ * @param limit
+ * 문자열의 제한 길이
+ * @param postfix
+ * 덧붙일 문자열
+ * @return String 제한된 길이만큼 자르고 postfix문자열을 붙인 문자열
+ */
+ public static String fixLength(String input, int limit, String postfix) {
+ char[] charArray = input.toCharArray();
+ if (limit >= charArray.length)
+ return input;
+ return new String(charArray, 0, limit).concat(postfix);
+ }
+
+ /**
+ *
+ * 문자열을 일정길이 만큼만 보여주고
+ * 그 길이(Unicode)에 초과되는 문자열일 경우 "..." 문자를 덧붙여 보여준다.
+ *
+ * 단 fixLength와의 차이는 제한길이의 기준이 char가 아니라 byte로
+ * 처리함으로해서 한글문제를 해결할수 있다.
+ *
+ *
+ * @param input
+ * 변환할 문자열
+ * @param limitByte
+ * 문자열의 제한 길이(byte)
+ * @return 제한된 길이만큼 자르고 ... 을 붙인 문자열
+ */
+ public static String fixUnicodeLength(String input, int limitByte) {
+ return fixLength(input, limitByte, "...");
+ }
+
+ /**
+ *
+ * 문자열을 일정길이 만큼만 보여주고
+ * 그 길이에 초과되는 문자열일 경우 특정문자를 덧붙여 보여준다.
+ *
+ * 단 fixLength와의 차이는 제한길이의 기준이 char가 아니라 byte로
+ * 처리함으로해서 한글문제를 해결할수 있다.
+ *
+ *
+ * @param input
+ * 변환할 문자열
+ * @param limitByte
+ * 문자열의 제한 길이(byte)
+ * @param postfix
+ * 덧붙일 문자열
+ * @return String 제한된 길이만큼 자르고 postfix문자열을 붙인 문자열
+ */
+ public static String fixUnicodeLength(String input, int limitByte, String postfix) {
+ /*
+ * 중간에 -1을 해주는 것은. 21바이트짜리 한글 스트링을. 20으로 짤라서 String을 생성하면, 끝글자만 짤리는것이 아니라.
+ * 스트링자체가 완전 생성이 되지 않기 때문. 그러므로 길이가 0이면 -1한만큼 스트링을 생성하는 것이다.
+ */
+ byte[] outputBytes = input.getBytes();
+
+ String output = outputBytes.length <= limitByte ? input
+ : (new String(outputBytes, 0, limitByte).length() == 0
+ ? new String(outputBytes, 0, limitByte - 1).concat(postfix)
+ : new String(outputBytes, 0, limitByte)).concat(postfix);
+
+ return output;
+ }
+
+ /**
+ *
+ * String EUC_KR로 encoding한다.
+ *
+ *
+ * @param text
+ * 한글로 encoding할 문자열
+ * @return String 한글로 encoding된 문자열
+ */
+ public static String getEUC_KR(String text) {
+ String rtn;
+
+ rtn = "";
+
+ if (text == null)
+ return rtn;
+ else {
+ try {
+ return new String(text.getBytes("8859_1"), "EUC-KR");
+ } catch (UnsupportedEncodingException UEE) {
+ return rtn;
+ }
+ }
+ // return text;
+ }
+
+ /**
+ *
+ * String EUC_KR로 encoding한다.
+ *
+ *
+ * @param text
+ * 한글로 encoding할 문자열
+ * @return String 한글로 encoding된 문자열
+ */
+ public static String getUTF8(String text) {
+ String rtn;
+
+ rtn = "";
+
+ if (text == null)
+ return rtn;
+ else {
+ try {
+ return new String(text.getBytes("8859_1"), "UTF-8");
+ } catch (UnsupportedEncodingException UEE) {
+ return rtn;
+ }
+ }
+ // return text;
+ }
+
+ /**
+ *
+ * String EUC_KR로 encoding한다.
+ *
+ *
+ * @param text
+ * 한글로 encoding할 문자열
+ * @return String 한글로 encoding된 문자열
+ */
+ public static String[] getUTF8(String[] arrText) {
+ String[] arrRtn = new String[arrText.length];
+
+ for (int i = 0; i < arrText.length; i++) {
+ arrRtn[i] = getUTF8(arrText[i]);
+ }
+ return arrRtn;
+ }
+
+ /**
+ *
+ * String EUC_KR로 encoding한다.
+ *
+ *
+ * @param text
+ * 한글로 encoding할 문자열
+ * @return String 한글로 encoding된 문자열
+ */
+ public static String[] getEUC_KR(String[] arrText) {
+ String[] arrRtn = new String[arrText.length];
+
+ for (int i = 0; i < arrText.length; i++) {
+ arrRtn[i] = getEUC_KR(arrText[i]);
+ }
+ return arrRtn;
+ }
+
+ /**
+ *
+ * String 8859_1(Unicode)로 encoding한다.
+ *
+ *
+ * @param text
+ * 8859_1로 encoding할 문자열
+ * @return String 8859_1로 encoding한 문자열
+ */
+ public static String get8859_1(String text) {
+ String rtn;
+
+ rtn = "";
+
+ if (text == null)
+ return rtn;
+ else {
+ try {
+ return new String(text.getBytes("euc-kr"), "8859_1");
+ } catch (UnsupportedEncodingException UEE) {
+ return rtn;
+ }
+ }
+ }
+
+ /**
+ *
+ * String 을 from enc 에서 to enc 형태로 변환한다.
+ *
+ *
+ * @param text
+ * @param fromenc
+ * @param toenc
+ * @return
+ */
+ public static String[] getEncodeStr(String[] arrText, String fromenc, String toenc) {
+ String[] arrRtn = new String[arrText.length];
+
+ for (int i = 0; i < arrText.length; i++) {
+ arrRtn[i] = getEncodeStr(arrText[i], fromenc, toenc);
+ }
+ return arrRtn;
+ }
+
+ /**
+ *
+ * String 을 from enc 에서 to enc 형태로 변환한다.
+ *
+ *
+ * @param text
+ * @param fromenc
+ * @param toenc
+ * @return
+ */
+ public static String getEncodeStr(String text, String fromenc, String toenc) {
+ String rtn;
+
+ rtn = "";
+
+ if (text == null)
+ return rtn;
+ else {
+ try {
+ return new String(text.getBytes(fromenc), toenc);
+ } catch (UnsupportedEncodingException UEE) {
+ return rtn;
+ }
+ }
+ }
+
+ /**
+ *
+ * String을 encoding한다.
+ *
+ *
+ * @param text
+ * encoding할 문자열
+ * @param fromEncode
+ * text의 원래 encoding
+ * @param toEncode
+ * 변환할 encoding
+ * @return String 변환된 문자열
+ */
+ public static String getConvertCharset(String text, String fromEncode, String toEncode) {
+ String rtn;
+
+ rtn = "";
+
+ if (text == null)
+ return rtn;
+ else {
+ try {
+ return new String(text.getBytes(fromEncode), toEncode);
+ } catch (UnsupportedEncodingException UEE) {
+ return rtn;
+ }
+ }
+ }
+
+ /**
+ *
+ * HTML과 관련하여 일부 특수문자를 반환한다.
+ * & --->> &
+ * < --->> <
+ * > --->> >
+ * ' --->> ´
+ * " --->> "
+ * | --->> ¦
+ *
+ *
+ * @param str
+ * 일부 html 특수문자가 포함된 문자열
+ * @return String 일부 html 특수문자를 변환한 문자열
+ */
+ public static String getSpecialCharacters(String str) {
+ str = replace(str, "&", "&");
+ str = replace(str, "<", "<");
+ str = replace(str, ">", ">");
+ // str = replace(str, "'", "´");
+ str = replace(str, "\"", """);
+ // str = replace(str, "|", "¦");
+ //
+ // str = replace(str, "\n", " ");
+ // str = replace(str, "\r", "");
+
+ return str;
+ }
+
+ /**
+ *
+ * HTML과 관련하여 일부 특수문자를 변환한다.
+ * & --->> &
+ * < --->> <
+ * > --->> >
+ * ´ --->> '
+ * " --->> "
+ * ¦ --->> |
+ *
+ *
+ * @param str
+ * html로 변환될 문자를 포함하는 문자열
+ * @return String 일부가 html문자로 변환된 문자열
+ */
+ public static String getRreplaceSpecialCharacters(String str) {
+ str = replace(str, " ", "\n");
+
+ str = replace(str, "&", "&");
+ str = replace(str, "<", "<");
+ str = replace(str, ">", ">");
+ str = replace(str, "´", "'");
+ str = replace(str, """, "\"");
+ str = replace(str, "¦", "|");
+
+ return str;
+ }
+
+ /**
+ *
+ * String에 comma를 삽입한다.
+ *
+ *
+ * @param str
+ * 숫자로 이루어진 문자열
+ * @return String 천단위 comma를 삽입한 문자열
+ */
+ public static String getComma(String str) {
+ return getComma(str, true);
+ }
+
+ /**
+ *
+ * String에 comma를 삽입한다.
+ * isTruncated가 false이면 소수점 이하를 자르지 않는다.
+ *
+ *
+ * @param str
+ * 숫자로 이루어진 문자열
+ * @param isTruncated
+ * true이면 소숫점이하를 자른다.
+ * @return String 천단위 comma를 삽입한 문자열
+ */
+ public static String getComma(String str, boolean isTruncated) {
+ DecimalFormat commaFormat; // comma 삽입을 위한 변수
+
+ if (str == null)
+ return "";
+ else if (str.trim().equals(""))
+ return "";
+ else if (str.trim().equals(" "))
+ return " ";
+ else {
+ // str에 .이 있으면 Float으로 처리한다.
+ int pos = str.indexOf(".");
+ if (pos != -1) {
+ if (!isTruncated) {
+ commaFormat = new DecimalFormat("#,##0.00");
+ return commaFormat.format(Float.parseFloat(str.trim()));
+ } else {
+ commaFormat = new DecimalFormat("#,##0");
+ return commaFormat.format(Long.parseLong(str.trim().substring(0, pos)));
+ }
+ } else {
+ commaFormat = new DecimalFormat("#,##0");
+ return commaFormat.format(Long.parseLong(str.trim()));
+ }
+ }
+ }
+
+ /**
+ * val 문자열을 우편번호 형식으로 변환하여 반환한다. ex)000-000
+ *
+ * @param val
+ * @return
+ */
+ public static String getZip(String val) {
+ String tmp = val.replaceAll("-", "");
+ if (tmp.length() > 5) {
+ tmp = tmp.substring(0, 3) + "-" + tmp.substring(3);
+ }
+ return tmp;
+ }
+
+ /**
+ * val 문자열을 주민등록번호 형식으로 변환하여 반환한다. ex)000000-0000000
+ *
+ * @param val
+ * @return
+ */
+ public static String getJumin(String val) {
+ String tmp = val.replaceAll("-", "");
+ if (tmp.length() > 6) {
+ tmp = tmp.substring(0, 6) + "-" + tmp.substring(6);
+ }
+ return tmp;
+ }
+
+ public static String getJumin(String val, String fmt) {
+ String tmp = val.replaceAll("-", "");
+ if (tmp.length() > 6) {
+ tmp = tmp.substring(0, 6) + "-" + tmp.substring(6, 7);
+ for (int i = 0; i < 6; i++) {
+ tmp += fmt;
+ }
+ }
+ return tmp;
+ }
+
+ /**
+ *
+ * Long값에 comma를 삽입한 String을 리턴한다.
+ *
+ *
+ * @param lstr
+ * long형 데이터
+ * @return String long값에 천단위 comma를 삽입한 문자열
+ */
+ public static String getComma(Long lstr) {
+ DecimalFormat commaFormat; // comma 삽입을 위한 변수
+ commaFormat = new DecimalFormat("#,##0");
+
+ if (lstr == null)
+ return "";
+ else
+ return commaFormat.format(lstr);
+ }
+
+ /**
+ *
+ * text를 format에 맞추어 출력한다.
+ * getFormatedText("0193372412","???-???-????") --->> 019-337-2412로 출력
+ *
+ *
+ * @param text
+ * 원래 문자열
+ * @param format
+ * 포맷 문자열
+ * @return String 포맷에 맞게 변환된 문자열
+ */
+ public static String getFormatedText(String text, String format) {
+ String rtn;
+ int start, i, j, len;
+ int tCount, fCount;
+
+ tCount = text.length();
+ fCount = format.length();
+
+ rtn = "";
+
+ if (text.equals(""))
+ return rtn;
+ if (text.equals(" "))
+ return " ";
+ // text가 01252412 이고 format 이 ????-???? 이면 0125-2412로 출력
+ // text에서 -를 제거한다.
+ for (i = 0; i < tCount; ++i) {
+ if (!text.substring(i, i + 1).equals("-"))
+ rtn = rtn + text.substring(i, i + 1);
+ }
+
+ text = rtn;
+ tCount = text.length();
+
+ // 포멧에서 ?의 count
+ len = 0;
+ for (j = 0; j < fCount; ++j) {
+ if (format.substring(j, j + 1).equals("?"))
+ ++len;
+ }
+ // text의 길이가 len보다 작으면 앞에 0를 붙인다.
+ if (tCount < len) {
+ for (i = 0; i < (len - tCount); ++i) {
+ text = '0' + text;
+ }
+ tCount = len;
+ }
+
+ rtn = "";
+ start = 0;
+ for (i = 0; i < tCount; ++i) {
+ for (j = start; j < fCount; ++j) {
+ if (format.substring(j, j + 1).equals("?")) {
+ rtn = rtn + text.substring(i, i + 1);
+ start = start + 1;
+ break;
+ } else {
+ rtn = rtn + format.substring(j, j + 1);
+ start = start + 1;
+ }
+ }
+ }
+ return rtn + format.substring(start);
+ }
+
+ /**
+ *
+ * format형태의 String에서 문자만을 추출하여 리턴한다.
+ * getFormatedText("019-337-2412","???-???-????") --->> 0193372412로 출력
+ *
+ *
+ * @param text
+ * 원래 문자열
+ * @param format
+ * 포맷 문자열
+ * @return String 원래 문자열에서 포맷에 해당하는 문자만을 추출한 문자열
+ */
+ public static String getRawText(String text, String format) {
+ int start, i, j, tCount, fCount;
+ String rtn;
+
+ tCount = text.length();
+ fCount = format.length();
+
+ rtn = "";
+ if (text.equals(""))
+ return rtn;
+ if (text.equals(" "))
+ return " ";
+ // test가 0125-2412 이고 format 이 ????-???? 이면 01252412로 출력
+
+ start = 0;
+ for (i = 0; i < tCount; ++i) {
+ for (j = start; j < fCount; ++j) {
+ if (format.substring(j, j + 1).equals("?")) {
+ rtn = rtn + text.substring(i, i + 1);
+ start = start + 1;
+ break;
+ } else {
+ start = start + 1;
+ break;
+ }
+ }
+ }
+ return rtn;
+ }
+
+ /**
+ *
+ * 주어진 size내에서 0으로 채워진 String을 리턴한다.
+ *
+ *
+ * @param num
+ * 원래 숫자
+ * @param size
+ * 0을 넣어 만들 문자열의 길이
+ * @return String 주어진 size 앞부분에 0을 채운 문자열
+ */
+ public static String getZeroBaseString(int num, int size) {
+ return getZeroBaseString(String.valueOf(num), size);
+ }
+
+ /**
+ *
+ * 주어진 size내에서 0으로 채워진 String을 리턴한다.
+ *
+ *
+ * @param num
+ * 원래 숫자 문자열
+ * @param size
+ * 0을 넣어 만들 문자열의 길이
+ * @return String 주어진 size 앞부분에 0을 채운 문자열
+ */
+ public static String getZeroBaseString(String num, int size) {
+ String zeroBase = "";
+
+ if (num.length() >= size)
+ return num;
+
+ for (int index = 0; index < (size - num.length()); ++index) {
+ zeroBase += "0";
+ }
+
+ return zeroBase + num;
+ }
+
+ /**
+ *
+ * 문자열을 getMethod에 맞는 형태로 변환한다.
+ * 엔터를 공백으로 하고 공백은 "%20"으로 변환한다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @return String 변환된 문자열
+ */
+ public static String getGetMethodFormat(String str) {
+ String rtn = "";
+ rtn = replace(str, "\n", " ");
+ rtn = replace(rtn, " ", "%20");
+ return rtn;
+ }
+
+ /**
+ * val 문자열을 사건번호 형식으로 변환하여 반환한다.
+ *
+ * @param val
+ * @return
+ */
+ public static String getCaseNo(String case_no, String merge_no) {
+ String case_nm = "";
+ if (!merge_no.equals("")) {
+ case_nm = merge_no;
+ } else if (case_no.length() >= 10) {
+ case_nm = "제" + case_no.substring(0, 4) + "-";
+ if (case_no.substring(4, 5).equals("A")) {
+ case_nm += "심사";
+ } else if (case_no.substring(4, 5).equals("B")) {
+ case_nm += "조정";
+ } else if (case_no.substring(4, 5).equals("C")) {
+ case_nm += "재심";
+ } else if (case_no.substring(4, 5).equals("D")) {
+ case_nm += "조";
+ } else if (case_no.substring(4, 5).equals("X")) {
+ case_nm += "";
+ }
+
+ if (case_no.substring(10).equals("M")) {
+ case_nm += "(병합)";
+ }
+ try {
+ case_nm += String.valueOf(Integer.parseInt(case_no.substring(5, 10))) + "호";
+ } catch(NumberFormatException e) {
+ LOGGER.debug("error", e);
+ case_nm += String.valueOf(case_no.substring(5, 10)) + "호";
+ } catch(IndexOutOfBoundsException e) {
+ LOGGER.debug("error", e);
+ case_nm += String.valueOf(case_no.substring(5, 10)) + "호";
+ } catch(Exception e) {
+ LOGGER.debug("error", e);
+ case_nm += String.valueOf(case_no.substring(5, 10)) + "호";
+ }
+ }
+ return case_nm;
+ }
+
+ /**
+ *
+ * 서버 도메인.
+ *
+ *
+ * @return String
+ */
+ public static String svrDomain(String pageUrl, String protocol) {
+ String svr_domain = "";
+ int startPos = pageUrl.indexOf("http://");
+ int endPos = -1;
+ if (startPos >= 0) {
+ endPos = pageUrl.indexOf("/", startPos + 7);
+ } else {
+ startPos = pageUrl.indexOf("https://");
+ endPos = pageUrl.indexOf("/", startPos + 8);
+ }
+ svr_domain = pageUrl.substring(startPos, endPos);
+ return replace(svr_domain, "https://", protocol + "://");
+ }
+
+ public static String svrDomain(String pageUrl) {
+ return svrDomain(pageUrl, "http");
+ }
+
+ /**
+ *
+ * str을 size길이에 맞도록 왼쪽에 f_char로 채운다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param f_char
+ * 원래 문자열 뒤에 붙일 문자열
+ * @param size
+ * f_char를 붙여 만들 문자열의 길이
+ * @return String 원래 문자열에 f_char를 붙여 만든 문자열
+ */
+ public static String lpad(String str, String f_char, int size) {
+ if (str.length() >= size)
+ return str;
+ else
+ return getFillChar("", f_char, size - str.length()) + str;
+ }
+
+ /**
+ *
+ * str을 size길이에 맞도록 오른쪽에 f_char로 채운다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param f_char
+ * 원래 문자열 뒤에 붙일 문자열
+ * @param size
+ * f_char를 붙여 만들 문자열의 길이
+ * @return String 원래 문자열에 f_char를 붙여 만든 문자열
+ */
+ public static String rpad(String str, String f_char, int size) {
+ if (str.length() >= size)
+ return str;
+ else
+ return str + getFillChar("", f_char, size - str.length());
+ }
+
+ /**
+ *
+ * str을 size길이에 맞도록 뒤에 f_char로 채운다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param f_char
+ * 원래 문자열 뒤에 붙일 문자열
+ * @param size
+ * f_char를 붙여 만들 문자열의 길이
+ * @return String 원래 문자열에 f_char를 붙여 만든 문자열
+ */
+ public static String getFillChar(String str, String f_char, int size) {
+ String fillChar = "";
+
+ if (str.length() >= size)
+ return str;
+
+ for (int index = 0; index < (size - str.length()); ++index) {
+ fillChar += f_char;
+ }
+
+ return str + fillChar;
+ }
+
+ /**
+ *
+ * str을 size(Byte)길이에 맞도록 뒤에 f_char로 채운다.
+ * str의 길이를 byte로 계산한다.
+ *
+ *
+ * @param str
+ * 원래 문자열
+ * @param f_char
+ * 원래 문자열 뒤에 붙일 문자열
+ * @param size
+ * f_char를 붙여 만들 문자열의 길이
+ * @return String 원래 문자열에 f_char를 붙여 만든 문자열
+ */
+ public static String getFillCharByte(String str, String f_char, int size) {
+ String fillChar = "";
+
+ if (str.getBytes().length >= size)
+ return str;
+
+ for (int index = 0; index < (size - str.getBytes().length); ++index) {
+ fillChar += f_char;
+ }
+
+ return str + fillChar;
+ }
+
+ /**
+ *
+ * 대상문자열(strTarget)에서 구분문자열(strDelim)을 기준으로 문자열을 분리하여
+ * 각 분리된 문자열을 배열에 할당하여 반환한다.
+ *
+ *
+ * @param strTarget
+ * 분리 대상 문자열
+ * @param strDelim
+ * 구분시킬 문자열로서 결과 문자열에는 포함되지 않는다.
+ * @param bContainNull
+ * 구분되어진 문자열중 공백문자열의 포함여부. true : 포함, false : 포함하지 않음.
+ * @return 분리된 문자열을 순서대로 배열에 격납하여 반환한다.
+ */
+ public static String[] split(String strTarget, String strDelim, boolean bContainNull) {
+ // StringTokenizer는 구분자가 연속으로 중첩되어 있을 경우 공백 문자열을 반환하지 않음.
+ // 따라서 아래와 같이 작성함.
+ int index = 0;
+ String[] resultStrArray = new String[getStrCnt(strTarget, strDelim) + 1];
+ String strCheck = new String(strTarget);
+ while (strCheck.length() != 0) {
+ int begin = strCheck.indexOf(strDelim);
+ if (begin == -1) {
+ resultStrArray[index] = strCheck;
+ break;
+ } else {
+ int end = begin + strDelim.length();
+ if (bContainNull) {
+ resultStrArray[index++] = strCheck.substring(0, begin);
+ }
+ strCheck = strCheck.substring(end);
+ if (strCheck.length() == 0 && bContainNull) {
+ resultStrArray[index] = strCheck;
+ break;
+ }
+ }
+ }
+ return resultStrArray;
+ }
+
+ /**
+ *
+ * strTarget 문자열에서 strSearch문자열이 몇개가 나오는지 찾아 리턴
+ *
+ *
+ * @param strTarget
+ * 찾을 소스 문자열
+ * @param strSearch
+ * 찾을 문자열
+ * @return int 발생한 갯수
+ */
+ public static int getStrCnt(String strTarget, String strSearch) {
+ int result = 0;
+ String strCheck = new String(strTarget);
+ for (int i = 0; i < strTarget.length();) {
+ int loc = strCheck.indexOf(strSearch);
+ if (loc == -1) {
+ break;
+ } else {
+ result++;
+ i = loc + strSearch.length();
+ strCheck = strCheck.substring(i);
+ }
+ }
+ return result;
+ }
+
+ // URL 변환
+ public static String encodeURL(String theURL) {
+ return replace(replace(theURL, "?", "@QUES@"), "&", "@AMP@");
+ }
+
+ public static String decodeURL(String theURL) {
+ return replace(replace(theURL, "@QUES@", "?"), "@AMP@", "&");
+ }
+
+ /**
+ *
+ * src문자열에서 맨 첫 글자를 대문자로 만들어 반환한다.
+ *
+ *
+ * @param src
+ * 바꿀문자열
+ * @return Strin 바뀐 문자열
+ */
+ public static String makeFUpper(String src) {
+ if (src != null && src.length() > 0) {
+ return src.substring(0, 1).toUpperCase() + src.substring(1).toLowerCase();
+ } else {
+ return "";
+ }
+ }
+
+ /**
+ *
+ * 1차원배열에서 특정 String객체의 존재여부를 확인한다.
+ *
+ *
+ * @param array
+ * 1차원배열
+ * @param str
+ * 찾을 문자열
+ * @param ignorecase
+ * true 일경우 대소문자 구별
+ * @return boolean 존재하면 true 없으면 false
+ */
+ public static boolean isExistInArray(String[] array, String str, boolean ignorecase) {
+ if (array == null)
+ return false;
+
+ for (int i = 0; i < array.length; ++i) {
+ if (ignorecase) {
+ if (array[i].toUpperCase().equals(str.toUpperCase()))
+ return true;
+ } else {
+ if (array[i].equals(str))
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * 구분자로 분리된 스트링에서 특정 인덱스의 값을 리턴.
+ *
+ *
+ * @param arrayStr
+ * 구분자로 분리된 스트링
+ * @param pos
+ * 특정 인덱스
+ * @param dmt
+ * 구분자
+ * @return String
+ */
+ public static String arrayCol(String arrayStr, int pos) {
+ return arrayCol(arrayStr, pos, "|");
+ }
+
+ public static String arrayCol(String arrayStr, int pos, String dmt) {
+ if (arrayStr.equals("")) {
+ return "";
+ }
+ String array[] = split(arrayStr, dmt, true);
+ return array.length < pos - 1 ? "" : array[pos - 1];
+ }
+
+ /**
+ *
+ * 구분자로 분리된 스트링에서 특정 값 존재여부 리턴.
+ *
+ *
+ * @param arrayStr
+ * 구분자로 분리된 스트링
+ * @param key
+ * 특정 값
+ * @param dmt
+ * 구분자
+ * @return String
+ */
+ public static boolean arrayFind(String arrayStr, String key, String dmt) {
+ if (arrayStr.equals("")) {
+ return false;
+ }
+ String array[] = split(arrayStr, dmt, true);
+ for (int i = 0; i < array.length; i++) {
+ if (array[i].equals(key)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ *
+ * String 객체의 substring 메쏘드의 에러방지
+ *
+ *
+ * @return String
+ */
+ public static String substr(String str, int sPos, int ePos) {
+ if (sPos > ePos)
+ return "";
+ return str.length() < ePos ? "" : str.substring(sPos, ePos);
+ }
+
+ public static String substr(String str, int sPos) {
+ return substr(str, sPos, str.length());
+ }
+
+ // HTML내의 RGB값을 16진수로 변황
+ public static String rgbToHexInHtml(String cHtml) throws Exception {
+ while (true) {
+ int sPos = cHtml.toLowerCase().indexOf("rgb(");
+ if (sPos < 0) {
+ break;
+ }
+
+ int ePos = cHtml.toLowerCase().indexOf(")", sPos);
+ String rgb_text = cHtml.substring(sPos + 4, ePos);
+ String rgb[] = StringUtil.split(StringUtil.replace(rgb_text, " ", "") + ",,", ",", true);
+ String rgb16 = "";
+ for (int i = 0; i < 3; i++) {
+ rgb16 += Integer.toHexString(Integer.parseInt(rgb[i]));
+ }
+ cHtml = StringUtil.replace(cHtml, "rgb(" + rgb_text + ")", rgb16);
+ cHtml = StringUtil.replace(cHtml, "RGB(" + rgb_text + ")", rgb16);
+ }
+ return cHtml;
+ }
+
+ /**
+ *
+ * 스트링의 왼쪽공백을 없애준다.
+ *
+ *
+ * @return String
+ */
+ public static String ltrim(String str) {
+ int len = str.length();
+ int st = 0;
+ int off = 0;
+ char[] val = str.toCharArray();
+
+ while ((st < len) && (val[off + st] <= ' ')) {
+ st++;
+ }
+
+ return st > 0 ? str.substring(st) : str;
+ }
+
+ /**
+ *
+ * 스트링의 오른쪽공백을 없애준다.
+ *
+ *
+ * @return String
+ */
+ public static String rtrim(String str) {
+ int len = str.length();
+ int st = 0;
+ int off = 0;
+ char[] val = str.toCharArray();
+
+ while ((st < len) && (val[off + len - 1] <= ' ')) {
+ len--;
+ }
+ return len < str.length() ? str.substring(0, len) : str;
+ }
+
+ /**
+ *
+ * 스트링에 BackSlash 를 추가해준다.
+ *
+ *
+ * @return String
+ * @changed 2002.09.14 이광렬
+ */
+ public static String addBackSlash(String pm_sString) {
+ String lm_sRetString = "";
+
+ for (int i = 0; i < pm_sString.length(); i++) {
+ if (pm_sString.charAt(i) == '\\') {
+ lm_sRetString += "\\\\";
+ } else if (pm_sString.charAt(i) == '\'') {
+ lm_sRetString += "\\\'";
+ } else {
+ lm_sRetString += pm_sString.charAt(i);
+ }
+ }
+ return lm_sRetString;
+ }
+
+
+ /**
+ *
+ * 문자열 합하기
+ *
+ *
+ * @return String
+ * @changed 2017.09.14 정진수
+ */
+ public static String concatStr(String[] strArr, String delimeter) {
+ String rtnStr = "";
+ for(int i=0; i < strArr.length; i++) {
+ if(!strArr[i].trim().equals("")) {
+ if(!rtnStr.equals("")) { rtnStr += delimeter; }
+ rtnStr += strArr[i].trim();
+ }
+ }
+ return rtnStr;
+ }
+ /**
+ *
+ * 스트링 암호화.
+ *
+ *
+ * @return String
+ * @changed 2002.09.23 정진수
+ */
+ public static String strEncode(String inputStr) {
+ String result = "";
+ inputStr = inputStr.trim();
+
+ for (int i = 0; i < inputStr.length(); i++) {
+ int val = (int) inputStr.charAt(i) + i * 29;
+ result = result + lpad(String.valueOf(val), "0", 3);
+ }
+ return result;
+ }
+
+ /**
+ *
+ * 암호화된 스트링 복호화.
+ *
+ *
+ * @return String
+ * @changed 2002.09.23 정진수
+ */
+ public static String strDecode(String inputStr) {
+ String result = "";
+ inputStr = inputStr.trim();
+
+ //웹 취약점 때문에 수정
+ if (inputStr.length() > 0) {
+ for (int i = 0; i < inputStr.length() / 3; i++) {
+ int num = Integer.parseInt(inputStr.substring(i * 3, i * 3 + 3)) - (i * 29);
+ //웹 취약점 때문에 수정
+ if (num > 0) {
+ result = result + (char) num;
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ *
+ * 주어진 갯수만큼 출력
+ *
+ *
+ * @return String
+ * @changed 2002.09.23 정진수
+ */
+ public static String nbsp(int count) {
+ String result = "";
+
+ for (int i = 0; i < count; i++) {
+ result = result + " ";
+ }
+ return result;
+ }
+
+ public static boolean containsCharOnly(String input, String chars) {
+ for (int i = 0; i < input.length(); i++) {
+ boolean isOk = false;
+ for (int j = 0; j < chars.length(); j++) {
+ if (input.charAt(i) == chars.charAt(j)) {
+ isOk = true;
+ break;
+ }
+ }
+
+ if (!isOk) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ public static boolean containsBadChar(String input, String chars) {
+ for (int i = 0; i < input.length(); i++) {
+ boolean isOk = false;
+ for (int j = 0; j < chars.length(); j++) {
+ if (input.charAt(i) == chars.charAt(j)) {
+ isOk = true;
+ break;
+ }
+ }
+ if (isOk) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static String streamToStr(InputStream in) throws Exception {
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ int bcount = 0;
+ byte[] buf = new byte[2048];
+ int read_retry_count = 0;
+ try {
+ while (true) {
+ int n = in.read(buf);
+ if (n > 0) {
+ bcount += n;
+ bout.write(buf, 0, n);
+ } else if (n == -1)
+ break;
+ }
+ bout.flush();
+ bout.close();
+ return new String(bout.toByteArray());
+ } catch (NumberFormatException e) {
+ LOGGER.debug("error", e);
+ return "";
+ } catch (IndexOutOfBoundsException e) {
+ LOGGER.debug("error", e);
+ return "";
+ } catch (IOException e) {
+ LOGGER.debug("error", e);
+ return "";
+ } catch (Exception e) {
+ LOGGER.debug("error", e);
+ return "";
+ }
+ }
+
+ /**
+ *
+ * GET 방식의 파라메터를 제한
+ *
+ *
+ * @return boolean
+ * @changed 2015.10.13 정진수
+ */
+ public static boolean blockParam(String queryStr, String okParam) {
+ if (queryStr != null && !queryStr.equals("")) {
+ String[] params = split(queryStr, "&", true);
+ for (int i = 0; i < params.length; i++) {
+ String[] arr = split(params[i], "=", true);
+ if (arr[0].equals("method")) {
+ continue;
+ }
+ if (okParam.indexOf(arr[0] + ",") < 0) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public static String nvl(String src, String target) {
+ if (src == null) {
+ return target;
+ } else {
+ return src;
+ }
+ }
+
+ public static void main(String[] args) {
+ try {
+ java.io.InputStream in = new FileInputStream(
+ "D:/iram/iramlib/src/iram/lib/db/helper/JDBCStatementHelper.java");
+ System.out.println(StringUtil.streamToStr(in));
+ in.close();
+ } catch (NumberFormatException e) {
+ LOGGER.debug("error", e);
+ } catch (IndexOutOfBoundsException e) {
+ LOGGER.debug("error", e);
+ } catch (IOException e) {
+ LOGGER.debug("error", e);
+ } catch (Exception e) {
+ LOGGER.debug("error", e);
+ }
+
+ }
+
+}
diff --git a/src/main/java/geoinfo/util/WebCoorUtil.java b/src/main/java/geoinfo/util/WebCoorUtil.java
new file mode 100644
index 0000000..0540cd4
--- /dev/null
+++ b/src/main/java/geoinfo/util/WebCoorUtil.java
@@ -0,0 +1,184 @@
+package geoinfo.util;
+
+/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
+/* */
+import java.io.PrintStream;
+/* */
+import java.util.HashMap;
+/* */
+import java.util.Map;
+
+/* */
+/* */public class WebCoorUtil
+/* */{
+ /* */public Map getRealCoordinate(double xPointNorth,
+ double yPointEast, double realStartPointNorth,
+ double realStartPointEast, double realEndPointNorth,
+ double realEndPointEast)
+ /* */{
+ /* 13 */Map result = new HashMap();
+ /* */
+ /* 16 */double bearing = bearingP1toP2(realStartPointNorth,
+ realStartPointEast, realEndPointNorth, realEndPointEast);
+ /* */
+ /* 18 */double distance = getDistance(xPointNorth, yPointEast);
+ /* */
+ /* 20 */System.out.println("_______________bearing: " + bearing);
+ /* 21 */System.out.println("_______________distance:" + distance);
+ /* */
+ /* 24 */double lx = getLx(distance, bearing * 3.141592D / 180.0D);
+ /* */
+ /* 26 */double ly = getLy(distance, bearing * 3.141592D / 180.0D);
+ /* */
+ /* 29 */double resultX = realStartPointNorth + lx;
+ /* 30 */double resultY = realStartPointEast + ly;
+ /* */
+ /* 32 */result.put("bearing", Double.valueOf(bearing));
+ /* 33 */result.put("distance", Double.valueOf(distance));
+ /* 34 */result.put("resultX", Double.valueOf(resultX));
+ /* 35 */result.put("resultY", Double.valueOf(resultY));
+ /* */
+ /* 39 */return result;
+ /* */}
+
+ /* */
+ /* */private double getLx(double distance, double bearing)
+ /* */{
+ /* 45 */double resultLx = 0.0D;
+ /* */
+ /* 47 */resultLx = distance * Math.cos(bearing);
+ /* 48 */return resultLx;
+ /* */}
+
+ /* */
+ /* */private double getLy(double distance, double bearing) {
+ /* 52 */double resultLy = 0.0D;
+ /* 53 */resultLy = distance * Math.sin(bearing);
+ /* */
+ /* 55 */return resultLy;
+ /* */}
+
+ /* */
+ /* */private double getDistance(double latitude, double longitude)
+ /* */{
+ /* 67 */double resultDistance = 0.0D;
+ /* */
+ /* 69 */resultDistance = Math.sqrt(latitude * latitude + longitude
+ * longitude);
+ /* */
+ /* 71 */return resultDistance;
+ /* */}
+
+ /* */
+ /* */private double bearingP1toP2(double P1_latitude,
+ double P1_longitude, double P2_latitude, double P2_longitude)
+ /* */{
+ /* 85 */System.out.println("P1_latitude: " + P1_latitude);
+ /* 86 */System.out.println("P1_longitude: " + P1_longitude);
+ /* 87 */System.out.println("P2_latitude: " + P2_latitude);
+ /* 88 */System.out.println("P2_longitude: " + P2_longitude);
+ /* */
+ /* 91 */double Cur_Lat_radian = P1_latitude * 0.0174532888888889D;
+ /* 92 */double Cur_Lon_radian = P1_longitude * 0.0174532888888889D;
+ /* */
+ /* 96 */double Dest_Lat_radian = P2_latitude * 0.0174532888888889D;
+ /* 97 */double Dest_Lon_radian = P2_longitude * 0.0174532888888889D;
+ /* */
+ /* 101 */double radian_bearing = Math
+ .atan((P2_longitude - P1_longitude)
+ / (P2_latitude - P1_latitude));
+ /* 102 */double true_bearing = 0.0D;
+ /* */
+ /* 104 */System.out.println("____________radian_bearing : "
+ + radian_bearing);
+ /* */
+ /* 107 */true_bearing = radian_bearing * 57.29579143313326D;
+ /* 108 */if ((Dest_Lat_radian - Cur_Lat_radian <= 0.0D)
+ || (Dest_Lon_radian - Cur_Lon_radian <= 0.0D))
+ /* */{
+ /* 111 */if ((Dest_Lat_radian - Cur_Lat_radian < 0.0D)
+ && (Dest_Lon_radian - Cur_Lon_radian > 0.0D))
+ /* */{
+ /* 113 */true_bearing = 180.0D + true_bearing;
+ /* */}
+ /* 115 */else if ((Dest_Lat_radian - Cur_Lat_radian < 0.0D)
+ && (Dest_Lon_radian - Cur_Lon_radian < 0.0D))
+ /* */{
+ /* 117 */true_bearing = 180.0D + true_bearing;
+ /* 118 */} else if ((Dest_Lat_radian - Cur_Lat_radian > 0.0D)
+ && (Dest_Lon_radian - Cur_Lon_radian < 0.0D))
+ /* */{
+ /* 120 */true_bearing = 360.0D + true_bearing;
+ /* */}
+ /* */}
+ /* 123 */return true_bearing;
+ /* */}
+
+ /* */
+ /* */private short __bearingP1toP2(double P1_latitude,
+ double P1_longitude, double P2_latitude, double P2_longitude)
+ /* */{
+ /* 136 */System.out.println("P1_latitude: " + P1_latitude);
+ /* 137 */System.out.println("P1_longitude: " + P1_longitude);
+ /* 138 */System.out.println("P2_latitude: " + P2_latitude);
+ /* 139 */System.out.println("P2_longitude: " + P2_longitude);
+ /* */
+ /* 141 */double Cur_Lat_radian = P1_latitude * 0.0174532888888889D;
+ /* 142 */double Cur_Lon_radian = P1_longitude * 0.0174532888888889D;
+ /* */
+ /* 146 */double Dest_Lat_radian = P2_latitude * 0.0174532888888889D;
+ /* 147 */double Dest_Lon_radian = P2_longitude * 0.0174532888888889D;
+ /* */
+ /* 150 */double radian_distance = 0.0D;
+ /* 151 */radian_distance = Math.acos(Math.sin(Cur_Lat_radian)
+ * Math.sin(Dest_Lat_radian) + Math.cos(Cur_Lat_radian)
+ * Math.cos(Dest_Lat_radian)
+ * Math.cos(Cur_Lon_radian - Dest_Lon_radian));
+ /* */
+ /* 154 */double radian_bearing = Math
+ .acos((Math.sin(Dest_Lat_radian) - (Math.sin(Cur_Lat_radian) * Math
+ .cos(radian_distance)))
+ / Math.cos(Cur_Lat_radian)
+ * Math.sin(radian_distance));
+ /* */
+ /* 156 */double true_bearing = 0.0D;
+ /* 157 */System.out.println("________________1: "
+ + (Dest_Lon_radian - Cur_Lon_radian));
+ /* 158 */System.out.println("________________"
+ + Math.sin(Dest_Lon_radian - Cur_Lon_radian));
+ /* 159 */if (Math.sin(Dest_Lon_radian - Cur_Lon_radian) < 0.0D)
+ /* */{
+ /* 161 */true_bearing = radian_bearing * 57.29579143313326D;
+ /* 162 */true_bearing = 360.0D - true_bearing;
+ /* */}
+ /* */else
+ /* */{
+ /* 166 */true_bearing = radian_bearing * 57.29579143313326D;
+ /* */}
+ /* */
+ /* 169 */return (short) (int) true_bearing;
+ /* */}
+
+ /* */
+ /* */public static void main(String[] args) {
+ /* 173 */System.out.println("______________aaaa");
+ /* 174 */System.out.println("______________bbbb: "
+ + (Math.acos(0.7072135785007072D) * 57.299999999999997D));
+ /* */
+ /* 176 */WebCoorUtil util = new WebCoorUtil();
+ /* 177 */double P1_latitude = 392837.5638D;
+ /* 178 */double P1_longitude = 330572.78100000002D;
+ /* 179 */double P2_latitude = 393275.59940000001D;
+ /* 180 */double P2_longitude = 330320.05200000003D;
+ /* 181 */double result = util.bearingP1toP2(P1_latitude, P1_longitude,
+ P2_latitude, P2_longitude);
+ /* */
+ /* 183 */System.out.println("_________________result: " + result);
+ /* */
+ /* 185 */double distance = 7.07D;
+ /* 186 */double lx = util.getLx(distance, 0.785398D);
+ /* */
+ /* 188 */System.out.println("_______________lx: " + lx);
+ /* */}
+ /* */
+}
\ No newline at end of file
diff --git a/src/main/resources/geoinfo/sqlmap/mappers/admins/user/HomeTrainingMapper.xml b/src/main/resources/geoinfo/sqlmap/mappers/admins/user/HomeTrainingMapper.xml
new file mode 100644
index 0000000..44aa3c6
--- /dev/null
+++ b/src/main/resources/geoinfo/sqlmap/mappers/admins/user/HomeTrainingMapper.xml
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ { CALL SP_ADD_HOME_TRAINING_REG(
+ #{trainingName},
+ #{trainingDatetime},
+ #{trainingLocation},
+ #{trainingAdmin},
+ #{trainingTel},
+ #{regStartDate},
+ #{regEndDate},
+ #{userId},
+ #{p_wvt_reg_id, mode=OUT, jdbcType=INTEGER},
+ #{p_result_code, mode=OUT, jdbcType=INTEGER},
+ #{p_err_msg, mode=OUT, jdbcType=VARCHAR}
+ ) }
+
+
+
+
+
+
+
+
+ select SP_CNT_HOME_TRAINING_REG(#{wvtRegId},#{trainingName},#{startDate},#{endDate},#{stateCode}) from DUAL
+
+
+
+
+
+
+
+
+
+
+ select SP_CNT_HOME_TRAINING_REQ(
+ #{wvtId},
+ #{wvtRegId},
+ #{companyName},
+ #{reqName},
+ #{reqTel},
+ #{stateCode}
+ ) from DUAL
+
+
+
+
+ CALL SP_DEL_HOME_TRAINING_REG(
+ #{whtRegId},
+ #{userId},
+ #{p_result_code, mode=OUT, jdbcType=INTEGER},
+ #{p_err_msg, mode=OUT, jdbcType=VARCHAR}
+ )
+
+
+
\ No newline at end of file
diff --git a/src/main/webapp/WEB-INF/config/springmvc/action-servlet.xml b/src/main/webapp/WEB-INF/config/springmvc/action-servlet.xml
index c595579..9fe211d 100644
--- a/src/main/webapp/WEB-INF/config/springmvc/action-servlet.xml
+++ b/src/main/webapp/WEB-INF/config/springmvc/action-servlet.xml
@@ -14,6 +14,8 @@
+
+
diff --git a/src/main/webapp/WEB-INF/lib/json-simple-1.1.1.jar b/src/main/webapp/WEB-INF/lib/json-simple-1.1.1.jar
new file mode 100644
index 0000000..dfd5856
Binary files /dev/null and b/src/main/webapp/WEB-INF/lib/json-simple-1.1.1.jar differ
diff --git a/src/main/webapp/WEB-INF/views/admins/user/home-training-index.jsp b/src/main/webapp/WEB-INF/views/admins/user/home-training-index.jsp
index dbf9275..fb1c594 100644
--- a/src/main/webapp/WEB-INF/views/admins/user/home-training-index.jsp
+++ b/src/main/webapp/WEB-INF/views/admins/user/home-training-index.jsp
@@ -12,6 +12,276 @@
집합교육
-
+
- 수정
- 삭제
+ 수정
+ 삭제
-
+
추가
-
+
- 교육 대상자 명단
- ⁕ 신청 집합교육명 : `24 제2차 국토지반정보 집합교육
- 내보내기
-
-
-
-
-
-
-
-
-
-
-
-
-
- 신청자
- 소속기관
- 부서
- 직급
- 연락처
- 이메일
- 비고
-
-
-
-
- 홍길동
- 디비엔텍
- 개발
- 대리
- 010-1234-5678
- abcdw@naver.com
-
-
-
- 홍길동
- 디비엔텍
- 개발
- 대리
- 010-1234-5678
- abcdw@naver.com
-
-
-
- 홍길동
- 디비엔텍
- 개발
- 대리
- 010-1234-5678
- abcdw@naver.com
-
-
-
-
+
+
교육 대상자 명단
+
⁕ 신청 집합교육명 :
+ 교육 대상자 명단 내보내기
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 신청자
+ 소속기관
+ 부서
+ 직급
+ 연락처
+ 이메일
+ 비고
+
+
+
+
+
+