diff --git a/data/dataxml/uac.service.board.qna.list_GET.xml b/data/dataxml/uac.service.board.qna.list_GET.xml index e2289653..1ab66ff9 100644 --- a/data/dataxml/uac.service.board.qna.list_GET.xml +++ b/data/dataxml/uac.service.board.qna.list_GET.xml @@ -1,94 +1,95 @@ - - - - S - 성공적으로 조회되었습니다. - 10 - 1 - 15 - - 1 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 2 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 3 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 4 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 5 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 6 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 7 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 8 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 9 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 10 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 11 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - 12 - 101 - 공지사항 테스트 - 55 - 2021-07-19 - - - + + + + S + 성공적으로 조회되었습니다. + 10 + 1 + 15 + + 1 + 101 + 공지사항 테스트 + 15 + 2021-07-19 + + + 2 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 3 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 4 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 5 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 6 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 7 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 8 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 9 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 10 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 11 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + + 12 + 101 + 공지사항 테스트 + 55 + 2021-07-19 + + 3333 + + diff --git a/pom.xml b/pom.xml index c1eace59..c149ed97 100644 --- a/pom.xml +++ b/pom.xml @@ -1,398 +1,391 @@ - - - 4.0.0 - nlib - nlib - war - 1.0.0 - nlib - http://www.egovframe.go.kr - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - - - - - 4.3.16.RELEASE - 3.8.0 - 4.2.5.RELEASE - - - - - mvn2 - http://repo1.maven.org/maven2/ - - true - - - true - - - - egovframe - http://www.egovframe.go.kr/maven/ - - true - - - false - - - - egovframe2 - http://maven.egovframe.kr:8080/maven/ - - true - - - false - - - - - - - - egovframework.rte - egovframework.rte.ptl.mvc - ${egovframework.rte.version} - - - commons-logging - commons-logging - - - - - egovframework.rte - egovframework.rte.psl.dataaccess - ${egovframework.rte.version} - - - egovframework.rte - egovframework.rte.fdl.idgnr - ${egovframework.rte.version} - - - egovframework.rte - egovframework.rte.fdl.property - ${egovframework.rte.version} - - - - javax.servlet - servlet-api - provided - 2.5 - - - - javax.servlet - jstl - 1.2 - - - - taglibs - standard - 1.1.2 - - - - org.antlr - antlr - 3.5 - - - - commons-codec - commons-codec - 1.9 - - - - egovframework.rte - egovframework.rte.fdl.crypto - ${egovframework.rte.version} - - - - - commons-fileupload - commons-fileupload - 1.3.1 - - - - - - - org.springframework.security - spring-security-web - ${spring-security.version} - - - org.springframework.security - spring-security-core - ${spring-security.version} - - - org.springframework.security - spring-security-config - ${spring-security.version} - - - org.springframework.security - spring-security-taglibs - ${spring-security.version} - - - - - com.ibm.icu - icu4j - 53.1 - - - - - com.thoughtworks.xstream - xstream - 1.4.4 - - - - - com.fasterxml.jackson.dataformat - jackson-dataformat-xml - 2.9.0 - - - - - com.google.zxing - core - 3.3.0 - - - com.google.zxing - javase - 3.3.0 - - - - - com.fasterxml.jackson.core - jackson-core - 2.7.3 - - - com.fasterxml.jackson.core - jackson-databind - 2.7.3 - - - - - org.apache.tiles - tiles-extras - 3.0.8 - - - org.apache.tiles - tiles-servlet - 3.0.8 - - - org.apache.tiles - tiles-jsp - 3.0.8 - - - - - com.fasterxml.jackson.core - jackson-core - 2.11.4 - - - com.fasterxml.jackson.core - jackson-annotations - 2.11.4 - - - com.fasterxml.jackson.core - jackson-databind - 2.11.4 - - - - - - install - ${basedir}/target - ${artifactId}-${version} - - - - org.apache.tomcat.maven - tomcat7-maven-plugin - 2.2 - - 80 - / - - -Xms256m -Xmx768m -XX:MaxPermSize=256m - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - UTF-8 - - - - org.codehaus.mojo - hibernate3-maven-plugin - 2.1 - - - - hbm2ddl - annotationconfiguration - - - - - - org.hsqldb - hsqldb - 2.3.2 - - - - - - org.codehaus.mojo - emma-maven-plugin - 1.0-alpha-3 - - - - org.apache.maven.plugins - maven-pmd-plugin - 3.1 - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - once - xml - - **/Abstract*.java - **/*Suite.java - - - **/*Test.java - - - - - org.codehaus.mojo - emma-maven-plugin - true - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9.1 - - - - - ${basedir}/target/site - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.7 - - - sunlink - - javadoc - - true - - - http://docs.oracle.com/javase/6/docs/api/ - - - - - - - - org.codehaus.mojo - emma-maven-plugin - true - - - org.codehaus.mojo - surefire-report-maven-plugin - true - - - - report-only - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - 128m - 512m - ${encoding} - ${encoding} - ${encoding} - - - - - org.apache.maven.plugins - maven-jxr-plugin - - ${encoding} - ${encoding} - true - apidocs - - - - - + + + 4.0.0 + nlib + nlib + war + 1.0.0 + nlib + http://www.egovframe.go.kr + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + 4.3.16.RELEASE + 3.8.0 + 4.2.5.RELEASE + + + + + mvn2 + http://repo1.maven.org/maven2/ + + true + + + true + + + + egovframe + http://www.egovframe.go.kr/maven/ + + true + + + false + + + + egovframe2 + http://maven.egovframe.kr:8080/maven/ + + true + + + false + + + + + + + + egovframework.rte + egovframework.rte.ptl.mvc + ${egovframework.rte.version} + + + commons-logging + commons-logging + + + + + egovframework.rte + egovframework.rte.psl.dataaccess + ${egovframework.rte.version} + + + egovframework.rte + egovframework.rte.fdl.idgnr + ${egovframework.rte.version} + + + egovframework.rte + egovframework.rte.fdl.property + ${egovframework.rte.version} + + + + javax.servlet + servlet-api + provided + 2.5 + + + + javax.servlet + jstl + 1.2 + + + + taglibs + standard + 1.1.2 + + + + org.antlr + antlr + 3.5 + + + + commons-codec + commons-codec + 1.9 + + + + egovframework.rte + egovframework.rte.fdl.crypto + ${egovframework.rte.version} + + + + + commons-fileupload + commons-fileupload + 1.3.1 + + + + + + + org.springframework.security + spring-security-web + ${spring-security.version} + + + org.springframework.security + spring-security-core + ${spring-security.version} + + + org.springframework.security + spring-security-config + ${spring-security.version} + + + org.springframework.security + spring-security-taglibs + ${spring-security.version} + + + + + com.ibm.icu + icu4j + 53.1 + + + + + com.fasterxml.jackson.dataformat + jackson-dataformat-xml + 2.9.0 + + + + + com.google.zxing + core + 3.3.0 + + + com.google.zxing + javase + 3.3.0 + + + + + com.fasterxml.jackson.core + jackson-core + 2.7.3 + + + com.fasterxml.jackson.core + jackson-databind + 2.7.3 + + + + + org.apache.tiles + tiles-extras + 3.0.8 + + + org.apache.tiles + tiles-servlet + 3.0.8 + + + org.apache.tiles + tiles-jsp + 3.0.8 + + + + + com.fasterxml.jackson.core + jackson-core + 2.11.4 + + + com.fasterxml.jackson.core + jackson-annotations + 2.11.4 + + + com.fasterxml.jackson.core + jackson-databind + 2.11.4 + + + + + + install + ${basedir}/target + ${artifactId}-${version} + + + + org.apache.tomcat.maven + tomcat7-maven-plugin + 2.2 + + 80 + / + + -Xms256m -Xmx768m -XX:MaxPermSize=256m + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + UTF-8 + + + + org.codehaus.mojo + hibernate3-maven-plugin + 2.1 + + + + hbm2ddl + annotationconfiguration + + + + + + org.hsqldb + hsqldb + 2.3.2 + + + + + + org.codehaus.mojo + emma-maven-plugin + 1.0-alpha-3 + + + + org.apache.maven.plugins + maven-pmd-plugin + 3.1 + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + once + xml + + **/Abstract*.java + **/*Suite.java + + + **/*Test.java + + + + + org.codehaus.mojo + emma-maven-plugin + true + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + + + ${basedir}/target/site + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.7 + + + sunlink + + javadoc + + true + + + http://docs.oracle.com/javase/6/docs/api/ + + + + + + + + org.codehaus.mojo + emma-maven-plugin + true + + + org.codehaus.mojo + surefire-report-maven-plugin + true + + + + report-only + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + 128m + 512m + ${encoding} + ${encoding} + ${encoding} + + + + + org.apache.maven.plugins + maven-jxr-plugin + + ${encoding} + ${encoding} + true + apidocs + + + + + diff --git a/src/main/java/nlib/cmm/util/MapEntryConverter.java b/src/main/java/nlib/cmm/util/MapEntryConverter.java deleted file mode 100644 index c898a8cb..00000000 --- a/src/main/java/nlib/cmm/util/MapEntryConverter.java +++ /dev/null @@ -1,95 +0,0 @@ -package nlib.cmm.util; - -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.Map; -import java.util.Map.Entry; - -import com.thoughtworks.xstream.converters.Converter; -import com.thoughtworks.xstream.converters.MarshallingContext; -import com.thoughtworks.xstream.converters.UnmarshallingContext; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; - -/** - *
- * @Class Name : MapEntryConverter.java
- * 
- * @Description : XML 문자열을 Map 객체로 변환 처리 
- * 
- * 
- * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
- *
- * 
- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 6. 22. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 6. 22. - * @version 1.0 - * - */ -public class MapEntryConverter implements Converter { - - public boolean canConvert(Class clazz) { - return AbstractMap.class.isAssignableFrom(clazz); - } - - public void marshal(Object value, HierarchicalStreamWriter writer, MarshallingContext context) { - AbstractMap map = (AbstractMap) value; - for (Object obj : map.entrySet()) { - Entry entry = (Entry) obj; - Object entryValue = entry.getValue(); - - if (entryValue instanceof Map) { - writer.startNode(entry.getKey().toString()); - marshal(entry.getValue(), writer, context); - writer.endNode(); - continue; - } - - writer.startNode(entry.getKey().toString()); - writer.setValue(entryValue.toString()); - writer.endNode(); - } - } - - public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) { - Map map = new HashMap(); - - while (reader.hasMoreChildren()) { - reader.moveDown(); - if (reader.hasMoreChildren()) { - Map childMap = new HashMap(); - map.put(reader.getNodeName(), childMap); - unmarshalHierarchical(reader, context, childMap); - reader.moveUp(); - continue; - } - map.put(reader.getNodeName(), reader.getValue()); - reader.moveUp(); - } - return map; - } - - private void unmarshalHierarchical(HierarchicalStreamReader reader, UnmarshallingContext context, - Map map) { - while (reader.hasMoreChildren()) { - reader.moveDown(); - if (reader.hasMoreChildren()) { - Map childMap = new HashMap(); - map.put(reader.getNodeName(), childMap); - unmarshalHierarchical(reader, context, childMap); - reader.moveUp(); - continue; - } - map.put(reader.getNodeName(), reader.getValue()); - reader.moveUp(); - } - } -} - diff --git a/src/main/java/nlib/restful/service/DataApiInterface.java b/src/main/java/nlib/restful/service/DataApiInterface.java index 5fc95db0..42d8dff7 100644 --- a/src/main/java/nlib/restful/service/DataApiInterface.java +++ b/src/main/java/nlib/restful/service/DataApiInterface.java @@ -1,242 +1,235 @@ -package nlib.restful.service; - -import java.util.HashMap; -import java.util.Map; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpMethod; -import org.springframework.util.LinkedMultiValueMap; -import org.springframework.util.MultiValueMap; - -import com.thoughtworks.xstream.XStream; - -import nlib.cmm.util.MapEntryConverter; -import nlib.util.StringUtil; - -/** - *
- * @Class Name : DataApiInterface.java
- * 
- * @Description : DAO에서 상속할 DataApi의 부모 클래스들을 위한 인터페이스 
- * 
- * 
- * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
- *
- * 
- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 7. 9. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 7. 9. - * @version 1.0 - * - */ -public interface DataApiInterface { - - static final Logger log = LoggerFactory.getLogger(DataApiInterface.class); - - /** - * 조회 - * - * @param reqVO - * @return - */ - public DataApiResVO get(DataApiReqVO reqVO); - - /** - * 등록 - * - * @param reqVO - * @return - */ - public DataApiResVO put(DataApiReqVO reqVO); - - /** - * 수정 - * - * @param reqVO - * @return - */ - public DataApiResVO post(DataApiReqVO reqVO); - - /** - * 삭제 - * - * @param reqVO - * @return - */ - public DataApiResVO delete (DataApiReqVO reqVO); - - /** - * 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다. - * - * @param reqVO - * @param method - * @return - */ - public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method); - - - /** - * 요청 VO를 Map 형태로 변환한다. - * - * @param reqVO - * @return - */ - public static MultiValueMap makeParamMap(DataApiReqVO reqVO) { - - MultiValueMap map = new LinkedMultiValueMap<>(); - - // 공통 - map.add("authKey", reqVO.getAuthKey()); - map.add("rows", "" + reqVO.getPageRows()); - map.add("page", "" + reqVO.getPageNo()); - - // 추가 정보 - if(reqVO.hasInfo()) { - HashMap info = reqVO.getInfo(); - for(String key : info.keySet()) { - Object val = info.get(key); - if(val instanceof HashMap) { - HashMap subInfo = (HashMap)val; - for(String subKey : subInfo.keySet()) { - String subVal = subInfo.get(subKey); - map.add(subKey, subVal); - } - } else { - map.add(key, (String)val); - } - } - } - - // 요청 파라메타 확인 - for(String key : map.keySet()) { - log.debug("MultiValueMap > " + key + "=" + map.get(key)); - } - - return map; - } - - - /** - * 요청전 공통 입력 파라메터를 확인한다. - * - * @param reqVO - * @return - * @throws Exception - */ - public static DataApiResVO checkReqCommonParams(DataApiReqVO reqVO) throws Exception { - - if(reqVO == null) { - return new DataApiResVO("ERR_NO_REQ", "데이터송수신 요청객체가 존재하지 않습니다."); - } - - if(StringUtil.isEmpty(reqVO.getReqUrl())) { - return new DataApiResVO("ERR_NO_RURL", "데이터 요청 업무ID에 대한 URL/RUI 정보가 존재하지 않습니다."); - } - if(StringUtil.isEmpty(reqVO.getAuthKey())) { - return new DataApiResVO("ERR_NO_AUTHKEY", "데이터 요청에 대한 권한키 정보가 존재하지 않습니다."); - } - - return null; - } - - /** - * 처리결과 정보를 입력받아 DataApiResVO를 생성한다. - * - * @param resultCode - * @param resultMessage - * @return - */ - public static DataApiResVO makeErrorRes(String resultCode, String resultMessage) { - return new DataApiResVO(resultCode, resultMessage); - } - - /** - * 응답받은 XML 문자열을 DataApiResVO (내부 Map객체 포함) 객체로 변환하여 리턴한다. - * - * @param xmlStr - * @return - */ - public static DataApiResVO convertXmlToResVO(String xmlStr) { - - DataApiResVO resVO = new DataApiResVO(); - - XStream magicApi = new XStream(); - magicApi.registerConverter(new MapEntryConverter()); - magicApi.alias("result", Map.class); - - Map map = null; - try { - map = (Map) magicApi.fromXML(xmlStr); - } catch(Exception e) { - e.printStackTrace(); - - resVO.setResultCode("ERR_RES_XML_FORMAT"); - resVO.setResultMessage(String.format("올바르지 않은 XML 형식의 응답입니다. : [%s]", xmlStr)); - - return resVO; - } - - // 처리결과 확인 - String commonKeyList = "|resulttype|code|message|page|totpages|records|".toLowerCase(); - String lowerKey = null; - for( String key : map.keySet()) { - - lowerKey = key.toLowerCase(); - if(commonKeyList.contains("|" + lowerKey + "|")) { - - if(lowerKey.equals("resulttype")) { - String resultType = (String)map.get(key); - if(!StringUtil.isEmpty(resultType) && resultType.toLowerCase().compareTo("success") == 0) { - resVO.setResultCode("S0000"); - } - } - - if(lowerKey.equals("code")) { - String code = (String)map.get(key); - int codeInt = 0; - try { - codeInt = Integer.parseInt(code); - } catch(Exception e) { - log.error("회신 code 정보를 정수로 변환처리 중 오류가 발생하였습니다." + e.toString()); - codeInt = -1; - } - - if(codeInt != 0) { - resVO.setResultCode(String.format("ERR_BIZERR(%s)", code)); - } else { - resVO.setResultCode("S0000"); - } - } - - if(lowerKey.equals("message")) { - resVO.setResultMessage((String)map.get(key)); - } - - if(lowerKey.equals("page")) { - resVO.setPageNo(StringUtil.toNumber((String)map.get(key))); - } - - if(lowerKey.equals("totpages")) { - resVO.setPageTotCount(StringUtil.toNumber((String)map.get(key))); - } - - if(lowerKey.equals("records")) { - resVO.setRecordTotCount(StringUtil.toNumber((String)map.get(key), 0)); - } - } else { - if(resVO.getInfo() == null) resVO.setInfo(new HashMap()); - HashMap info = resVO.getInfo(); - info.put(key, map.get(key)); - } - } - - return resVO; - } -} +package nlib.restful.service; + +import java.util.HashMap; +import java.util.Map; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.http.HttpMethod; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; + +import nlib.util.StringUtil; + +/** + *
+ * @Class Name : DataApiInterface.java
+ * 
+ * @Description : DAO에서 상속할 DataApi의 부모 클래스들을 위한 인터페이스 
+ * 
+ * 
+ * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
+ *
+ * 
+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 7. 9. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 7. 9. + * @version 1.0 + * + */ +public interface DataApiInterface { + + static final Logger log = LoggerFactory.getLogger(DataApiInterface.class); + + /** + * 조회 + * + * @param reqVO + * @return + */ + public DataApiResVO get(DataApiReqVO reqVO); + + /** + * 등록 + * + * @param reqVO + * @return + */ + public DataApiResVO put(DataApiReqVO reqVO); + + /** + * 수정 + * + * @param reqVO + * @return + */ + public DataApiResVO post(DataApiReqVO reqVO); + + /** + * 삭제 + * + * @param reqVO + * @return + */ + public DataApiResVO delete (DataApiReqVO reqVO); + + /** + * 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다. + * + * @param reqVO + * @param method + * @return + */ + public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method); + + + /** + * 요청 VO를 Map 형태로 변환한다. + * + * @param reqVO + * @return + */ + public static MultiValueMap makeParamMap(DataApiReqVO reqVO) { + + MultiValueMap map = new LinkedMultiValueMap<>(); + + // 공통 + map.add("authKey", reqVO.getAuthKey()); + map.add("rows", "" + reqVO.getPageRows()); + map.add("page", "" + reqVO.getPageNo()); + + // 추가 정보 + if(reqVO.hasInfo()) { + HashMap info = reqVO.getInfo(); + for(String key : info.keySet()) { + Object val = info.get(key); + if(val instanceof HashMap) { + HashMap subInfo = (HashMap)val; + for(String subKey : subInfo.keySet()) { + String subVal = subInfo.get(subKey); + map.add(subKey, subVal); + } + } else { + map.add(key, (String)val); + } + } + } + + // 요청 파라메타 확인 + for(String key : map.keySet()) { + log.debug("MultiValueMap > " + key + "=" + map.get(key)); + } + + return map; + } + + + /** + * 요청전 공통 입력 파라메터를 확인한다. + * + * @param reqVO + * @return + * @throws Exception + */ + public static DataApiResVO checkReqCommonParams(DataApiReqVO reqVO) throws Exception { + + if(reqVO == null) { + return new DataApiResVO("ERR_NO_REQ", "데이터송수신 요청객체가 존재하지 않습니다."); + } + + if(StringUtil.isEmpty(reqVO.getReqUrl())) { + return new DataApiResVO("ERR_NO_RURL", "데이터 요청 업무ID에 대한 URL/RUI 정보가 존재하지 않습니다."); + } + if(StringUtil.isEmpty(reqVO.getAuthKey())) { + return new DataApiResVO("ERR_NO_AUTHKEY", "데이터 요청에 대한 권한키 정보가 존재하지 않습니다."); + } + + return null; + } + + /** + * 처리결과 정보를 입력받아 DataApiResVO를 생성한다. + * + * @param resultCode + * @param resultMessage + * @return + */ + public static DataApiResVO makeErrorRes(String resultCode, String resultMessage) { + return new DataApiResVO(resultCode, resultMessage); + } + + /** + * 응답받은 XML 문자열을 DataApiResVO (내부 Map객체 포함) 객체로 변환하여 리턴한다. + * + * @param xmlStr + * @return + */ + public static DataApiResVO convertXmlToResVO(String xmlStr) { + + DataApiResVO resVO = new DataApiResVO(); + Map map = null; + + try { + map = XmlConverter.convert(xmlStr); + } catch(Exception e) { + e.printStackTrace(); + + resVO.setResultCode("ERR_RES_XML_FORMAT"); + resVO.setResultMessage(String.format("올바르지 않은 XML 형식의 응답입니다. : [%s]", xmlStr)); + + return resVO; + } + + // 처리결과 확인 + String commonKeyList = "|resulttype|code|message|page|totpages|records|".toLowerCase(); + String lowerKey = null; + for( String key : map.keySet()) { + + lowerKey = key.toLowerCase(); + if(commonKeyList.contains("|" + lowerKey + "|")) { + + if(lowerKey.equals("resulttype")) { + String resultType = (String)map.get(key); + if(!StringUtil.isEmpty(resultType) && resultType.toLowerCase().compareTo("success") == 0) { + resVO.setResultCode("S0000"); + } + } + + if(lowerKey.equals("code")) { + String code = (String)map.get(key); + int codeInt = 0; + try { + codeInt = Integer.parseInt(code); + } catch(Exception e) { + log.error("회신 code 정보를 정수로 변환처리 중 오류가 발생하였습니다." + e.toString()); + codeInt = -1; + } + + if(codeInt != 0) { + resVO.setResultCode(String.format("ERR_BIZERR(%s)", code)); + } else { + resVO.setResultCode("S0000"); + } + } + + if(lowerKey.equals("message")) { + resVO.setResultMessage((String)map.get(key)); + } + + if(lowerKey.equals("page")) { + resVO.setPageNo(StringUtil.toNumber((String)map.get(key))); + } + + if(lowerKey.equals("totpages")) { + resVO.setPageTotCount(StringUtil.toNumber((String)map.get(key))); + } + + if(lowerKey.equals("records")) { + resVO.setRecordTotCount(StringUtil.toNumber((String)map.get(key), 0)); + } + } else { + if(resVO.getInfo() == null) resVO.setInfo(new HashMap()); + HashMap info = resVO.getInfo(); + info.put(key, map.get(key)); + } + } + + return resVO; + } +} diff --git a/src/main/java/nlib/restful/service/XmlConverter.java b/src/main/java/nlib/restful/service/XmlConverter.java index e869fe39..7c306e33 100644 --- a/src/main/java/nlib/restful/service/XmlConverter.java +++ b/src/main/java/nlib/restful/service/XmlConverter.java @@ -1,79 +1,239 @@ -package nlib.restful.service; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.util.HashMap; - -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; - -public class XmlConverter { - - @SuppressWarnings("restriction") - public static void main(String argv[]) { - - String inputFile = "C:/iams/workspace/nlib/data/dataxml/uac.service.board.qna.list_GET.xml"; - HashMap resMap = new HashMap(); - - try { - // First create a new XMLInputFactory - XMLInputFactory inputFactory = XMLInputFactory.newInstance(); - // Setup a new eventReader - InputStream in = new FileInputStream(inputFile); - XMLEventReader eventReader = inputFactory.createXMLEventReader(in); - // Read the XML document - - int depth = 0; - StartElement startElement = null; - - while (eventReader.hasNext()) { - XMLEvent event = eventReader.nextEvent(); - System.out.println(" -> " + event); - String elementName = null; - String elementValue = null; - HashMap elementValues = null; - - if (event.isStartElement()) { - - startElement = event.asStartElement(); - - if (startElement.getName().getLocalPart().equals("result")) { - depth++; - - event = eventReader.nextEvent(); - System.out.println(" > " + event); - - // result의 하위 엘리먼트 시작 찾기 - while (!event.isStartElement()) { - event = eventReader.nextEvent(); - System.out.println(" 하위엘리먼트 시작전: " + event); - } - - while (!event.isEndElement()) { - if (event.isCharacters()) { - String content = event.asCharacters().getData(); - System.out.println("content: -" + content + "_"); - } - event = eventReader.nextEvent(); - System.out.println(" >> " + event); - } - - event = eventReader.nextEvent(); - System.out.println(" >>> " + event); - - continue; - } - - } - } - } catch (FileNotFoundException e) { - System.out.println("File not Found: " + inputFile); - } catch (XMLStreamException e) { - e.printStackTrace(); - } - } -} +package nlib.restful.service; + +import java.io.ByteArrayInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import nlib.sample.web.SampleEncoderController; +import nlib.util.StringUtil; + +public class XmlConverter { + + private static final Logger log = LoggerFactory.getLogger(XmlConverter.class); + + public static HashMap convert(String xmlStr) throws Exception { + + if(xmlStr == null) return null; + + ByteArrayInputStream bIn = new ByteArrayInputStream(xmlStr.getBytes()); + HashMap resMap = new HashMap(); + + try { + XMLInputFactory inputFactory = XMLInputFactory.newInstance(); + XMLEventReader eventReader = inputFactory.createXMLEventReader(bIn); + + resMap = getElementValue("result", eventReader, null); + log.debug("Converting XML to HashMap : Done >> " + resMap); + } catch (XMLStreamException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + return resMap; + } + + /** + * @param rootElementName + * @param eventReader + * @param alreadyRootOpened : 부모 요소 찾기 없이 작업 진행할지 여부. false인 경우, rootElementName 요소를 찾아서 이후 값 추출 수행 + * @param startElement + * @return + * @throws Exception + */ + public static HashMap getElementValue( + String rootElementName + , XMLEventReader eventReader + , XMLEvent firstChildElement) throws Exception { + + HashMap retMap = new HashMap(); + + try { + + int depth = (firstChildElement == null ? 0 : 1); + StartElement startElement = null; + + XMLEvent event = firstChildElement; + + String upperElementName = null; + String elementName = null; //(firstChildElement == null ? null : firstChildElement.asStartElement().getName().getLocalPart()); + String content = null; + String elementValue = ""; + HashMap elementValues = null; + boolean hasSubElements = false; + boolean isFirst = true; + + while (eventReader.hasNext()) { + + // 이벤트가 함께 매개변수로 넘어온 경우, 처음 읽기 생략 + if(!isFirst || event == null) { + event = eventReader.nextEvent(); + } + + if(isFirst) isFirst = false; + + + // 1 레벨 엘리먼트 찾기 + if (depth == 0 && event.isStartElement() && event.asStartElement().getName().getLocalPart().equals(rootElementName)) { + depth++; + continue; + } + + // 1 레벨 엘리먼트내의 2 레벨 엘리먼트 찾기 + if(depth == 1 && elementName == null && event.isStartElement()) { + elementName = event.asStartElement().getName().getLocalPart(); + elementValue = ""; + elementValues = null; + hasSubElements = false; + depth++; + continue; + } + + // 2 레벨 엘리먼트 내용 찾기 + if(depth == 2 && elementName != null && event.isCharacters()) { + content = event.asCharacters().getData(); + if(StringUtil.isNotEmpty(content)) { + elementValue += content; + } + continue; + } + + // 2 레벨 엘리먼트 종료 + if(depth == 2 && elementName != null && event.isEndElement()) { + + if(!elementName.equals(event.asEndElement().getName().getLocalPart())) { + throw new Exception("XML문의 요소 시작/종료 태그가 일치하지 않습니다. : " + elementName + " 요소가 " + event.asEndElement().getName().getLocalPart() + "로 종료되었습니다."); + } + + addValue(retMap, elementName, elementValue); + System.out.println(elementName + " : -" + elementValue + "_"); + + elementName = null; + elementValue = ""; + depth--; + } + + // 2 레벨 엘리먼트 > 하위 엘리먼트 존재하는 경우 + if(depth == 2 && elementName != null && event.isStartElement()) { + HashMap subMap = getElementValue(elementName, eventReader, event); + addValue(retMap, elementName, subMap); + depth--; + elementName = null; + } + + // 1 레벨 엘리먼트 종료된 경우, 돌아가기 + if(depth == 1 && elementName == null && event.isEndElement() && rootElementName.equals(event.asEndElement().getName().getLocalPart())) { + depth--; + return retMap; + } + + } // while + + } catch (XMLStreamException e) { + e.printStackTrace(); + } catch (Exception e) { + e.printStackTrace(); + } + + System.out.println("END"); + return retMap; + } + + public static void addValue(HashMap map, String key, Object value) throws Exception { + if(map == null) throw new Exception("값을 넣을 Map 변수가 초기화되지 않았습니다."); + + if(key == null) return; + if(value == null) return; + + Object curValObj = map.get(key); + if(curValObj == null) { + map.put(key, value); + return; + } + + if(curValObj instanceof String || curValObj instanceof HashMap) { + List values = new ArrayList(); + values.add(curValObj); + values.add(value); + map.put(key, values); + } else if(curValObj instanceof List) { + ((ArrayList)curValObj).add(value); + } + + return; + } + +/* + public static void main(String argv[]) throws Exception { + + XmlConverter xmlConverter = new XmlConverter(); + String xmlStr = "\r\n" + + "\r\n" + + "\r\n" + + " S\r\n" + + " 성공적으로 조회되었습니다.\r\n" + + " 10\r\n" + + " 1\r\n" + + " 15\r\n" + + " \r\n" + + " 1\r\n" + + " 101\r\n" + + " 공지사항 테스트\r\n" + + " 15\r\n" + + " 2021-07-19\r\n" + + " \r\n" + + " \r\n" + + " 2\r\n" + + " 101\r\n" + + " 공지사항 테스트\r\n" + + " 55\r\n" + + " 2021-07-19\r\n" + + " \r\n" + + " \r\n" + + " 3\r\n" + + " 101\r\n" + + " 공지사항 테스트\r\n" + + " 55\r\n" + + " 2021-07-19\r\n" + + " \r\n" + + " \r\n" + + " 4\r\n" + + " 101\r\n" + + " 공지사항 테스트\r\n" + + " 55\r\n" + + " 2021-07-19\r\n" + + " \r\n" + + " \r\n" + + " 5\r\n" + + " 101\r\n" + + " 공지사항 테스트\r\n" + + " 55\r\n" + + " 2021-07-19\r\n" + + " \r\n" + + " \r\n" + + " 6\r\n" + + " 101\r\n" + + " 공지사항 테스트\r\n" + + " 55\r\n" + + " 2021-07-19\r\n" + + " \r\n" + + " 3333\r\n" + + ""; + + HashMap resMap = xmlConverter.convert(xmlStr); + } + */ +} diff --git a/src/main/java/nlib/security/SpringSecurityConfig.java b/src/main/java/nlib/security/SpringSecurityConfig.java index 76d6a447..4f411af7 100644 --- a/src/main/java/nlib/security/SpringSecurityConfig.java +++ b/src/main/java/nlib/security/SpringSecurityConfig.java @@ -1,107 +1,107 @@ -package nlib.security; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.authentication.AuthenticationManager; -import org.springframework.security.authentication.AuthenticationProvider; -import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; -import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.builders.WebSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.security.crypto.password.PasswordEncoder; - -import nlib.cmm.crypto.NlibPasswordEncoder; - -/** - *
- * @Class Name : SpringSecurityConfig.java
- * 
- * @Description : Spring Security 환경설정 클래스 
- * 
- * 
- * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
- *
- * 
- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 7. 6. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 7. 6. - * @version 1.0 - * - */ -@Configuration -@EnableWebSecurity -@EnableGlobalMethodSecurity(securedEnabled = true) -public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { - - @Override - public void configure(WebSecurity web) throws Exception { - web.ignoring() - .antMatchers("/resources/**") - .antMatchers("/css/**") - .antMatchers("/images/**") - .antMatchers("/js/**") - .antMatchers("/temp/**") - .antMatchers("/favicon/**") - .antMatchers("/*/*Ajax.do") - .antMatchers("/board/**") - ; - } - - @Override - protected void configure(HttpSecurity http) throws Exception { - http.authorizeRequests() - .antMatchers("/login/login*.do").permitAll() - .antMatchers("/login/logout*.do").permitAll() - .antMatchers("/login/naver*.do").permitAll() - .antMatchers("/member/*.do").permitAll() - .antMatchers("/member/*.ajax").permitAll() - .antMatchers("/userInfo/*.do").permitAll() - .antMatchers("/info/inform/*.do").permitAll() - .antMatchers("/").permitAll() - .antMatchers("/index.jsp").permitAll() - .antMatchers("/index.do").permitAll() - .antMatchers("/main/header.do").permitAll() - .antMatchers("/main/menu.do").permitAll() - .antMatchers("/sample/password/getSampleEncoder.do").permitAll() - .anyRequest().authenticated() - .and().formLogin() - .loginPage("/login/loginForm.do") - .permitAll() - .and().csrf() - .disable(); - - http.logout() - .logoutSuccessUrl("/login/loginForm.do?logout") - .invalidateHttpSession(true).deleteCookies("JSESSIONID") - ; - } - - @Bean - @Override - public AuthenticationManager authenticationManagerBean() throws Exception { - return super.authenticationManagerBean(); - } - - @Bean - public UserDetailsService userDetailsService() { - return new SecUserDetailsService(); - } - - @Bean - public PasswordEncoder getPasswordEncoder() { - return new NlibPasswordEncoder(); - } - -} - - +package nlib.security; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.dao.DaoAuthenticationProvider; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.password.PasswordEncoder; + +import nlib.cmm.crypto.NlibPasswordEncoder; + +/** + *
+ * @Class Name : SpringSecurityConfig.java
+ * 
+ * @Description : Spring Security 환경설정 클래스 
+ * 
+ * 
+ * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
+ *
+ * 
+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 7. 6. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 7. 6. + * @version 1.0 + * + */ +@Configuration +@EnableWebSecurity +@EnableGlobalMethodSecurity(securedEnabled = true) +public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + public void configure(WebSecurity web) throws Exception { + web.ignoring() + .antMatchers("/resources/**") + .antMatchers("/css/**") + .antMatchers("/images/**") + .antMatchers("/js/**") + .antMatchers("/temp/**") + .antMatchers("/favicon/**") + .antMatchers("/*/*Ajax.do") + .antMatchers("/board/**") + ; + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.authorizeRequests() + .antMatchers("/login/login*.do").permitAll() + .antMatchers("/login/logout*.do").permitAll() + .antMatchers("/login/naver*.do").permitAll() + .antMatchers("/member/*.do").permitAll() + .antMatchers("/member/*.ajax").permitAll() + .antMatchers("/userInfo/*.do").permitAll() + .antMatchers("/info/inform/*.do").permitAll() + .antMatchers("/").permitAll() + .antMatchers("/index.jsp").permitAll() + .antMatchers("/index.do").permitAll() + .antMatchers("/main/header.do").permitAll() + .antMatchers("/main/menu.do").permitAll() + .antMatchers("/sample/password/getSampleEncoder.do").permitAll() + .anyRequest().authenticated() + .and().formLogin() + .loginPage("/login/loginForm.do") + .permitAll() + .and().csrf() + .disable(); + + http.logout() + .logoutSuccessUrl("/login/loginForm.do?logout") + .invalidateHttpSession(true).deleteCookies("JSESSIONID") + ; + } + + @Bean + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } + + @Bean + public UserDetailsService userDetailsService() { + return new SecUserDetailsService(); + } + + @Bean + public PasswordEncoder getPasswordEncoder() { + return new NlibPasswordEncoder(); + } + +} + + diff --git a/src/main/java/nlib/user/service/NlibLoginVO.java b/src/main/java/nlib/user/service/NlibLoginVO.java index 0cda205d..6f90912b 100644 --- a/src/main/java/nlib/user/service/NlibLoginVO.java +++ b/src/main/java/nlib/user/service/NlibLoginVO.java @@ -32,56 +32,57 @@ public class NlibLoginVO implements Serializable { private static final long serialVersionUID = -8274004534207618049L; /** 아이디 */ - private String id; + private String id = null; /** 이름 */ - private String name; + private String name = null; /** 주민등록번호 */ - private String ihidNum; + private String ihidNum = null; /** 이메일주소 */ - private String email; + private String email = null; /** 비밀번호 */ - private String password; + private String password = null; /** 비밀번호 힌트 */ - private String passwordHint; + private String passwordHint = null; /** 비밀번호 정답 */ - private String passwordCnsr; + private String passwordCnsr = null; /** 사용자구분 */ - private String userSe; + private String userSe = null; /** 조직(부서)ID */ - private String orgnztId; + private String orgnztId = null; /** 조직(부서)명 */ - private String orgnztNm; + private String orgnztNm = null; /** 고유아이디 */ - private String uniqId; + private String uniqId = null; /** 로그인 후 이동할 페이지 */ - private String url; + private String url = null; /** 사용자 IP정보 */ - private String ip; + private String ip = null; /** GPKI인증 DN */ - private String dn; + private String dn = null; /** 인증키 */ - private String authKey; + private String authKey = null; + /** 페이지번호 */ - private String page; + private String page = null; /** 게시물 수 */ - private String rows; + private String rows = null; /** 핸드폰 번호 */ - private String phone; + private String phone = null; /** 우편번호 */ - private String zipNo; + private String zipNo = null; /** 도로명주소 */ - private String roadAddrPart; + private String roadAddrPart = null; /** 상세주소 */ - private String addrDetail; + private String addrDetail = null; /** 생년월일 */ - private String birthday; + private String birthday = null; /** 생일 년도 */ - private String birth_yy; + private String birth_yy = null; /** 생일 월 */ - private String birth_mm; + private String birth_mm = null; /** 생일 날짜 */ - private String birth_dd; + private String birth_dd = null; public String getAuthKey() { return authKey; diff --git a/src/main/java/nlib/util/StringUtil.java b/src/main/java/nlib/util/StringUtil.java index 20937383..ea832394 100644 --- a/src/main/java/nlib/util/StringUtil.java +++ b/src/main/java/nlib/util/StringUtil.java @@ -1,89 +1,99 @@ -package nlib.util; - -import java.sql.Timestamp; -import java.text.SimpleDateFormat; -import java.util.Locale; - -import egovframework.com.utl.fcc.service.EgovStringUtil; - -/** - *
- * @Class Name : StringUtil.java
- * 
- * @Description : 문자열 관련 공통 함수 모음 
- * 
- * 
- * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
- *
- * 
- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 6. 22. KNKIM 최초 생성 - * - * - * @author 이씨플라자 * DIGITALSHIP KNKIM - * @since 2021. 6. 22. - * @version 1.0 - * - */ -public class StringUtil extends EgovStringUtil { - - /** - * Null 이거나, 빈문자열(공백 포함)인 경우, true를 리턴한다. - * - * @param str - * @return - */ - public static boolean isEmpty(String str) { - return str == null || str.trim().length() == 0; - } - - /** - * 문자열을 정수형으로 변환하여 리턴한다. 만일 문자열이 null 또는 빈 문자열인 경우, -1을 리턴한다. - * - * @param str - * @return - */ - public static int toNumber(String str) { - return toNumber(str, -1); - } - - /** - * 문자열을 정수형으로 변환하여 리턴한다. 만일 문자열이 null 또는 빈 문자열인 경우, 기본값 정보 defaultInt를 리턴한다. - * - * @param str - * @param defaultInt - * @return - */ - public static int toNumber(String str, int defaultInt) { - if(isEmpty(str)) return defaultInt; - - try { - return Integer.parseInt(str.trim()); - } catch(Exception e) {} - - return defaultInt; - } - - /** - * 현재 시각을 yyyyMMddhhmmssSSS 형식으로 리턴한다. - * - * @return - */ - public static String getTimeStamp() { - - String rtnStr = null; - - // 문자열로 변환하기 위한 패턴 설정(년도-월-일 시:분:초:초(자정이후 초)) - String pattern = "yyyyMMddhhmmssSSS"; - - SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA); - Timestamp ts = new Timestamp(System.currentTimeMillis()); - - rtnStr = sdfCurrent.format(ts.getTime()); - - return rtnStr; - } -} +package nlib.util; + +import java.sql.Timestamp; +import java.text.SimpleDateFormat; +import java.util.Locale; + +import egovframework.com.utl.fcc.service.EgovStringUtil; + +/** + *
+ * @Class Name : StringUtil.java
+ * 
+ * @Description : 문자열 관련 공통 함수 모음 
+ * 
+ * 
+ * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
+ *
+ * 
+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 6. 22. KNKIM 최초 생성 + * + * + * @author 이씨플라자 * DIGITALSHIP KNKIM + * @since 2021. 6. 22. + * @version 1.0 + * + */ +public class StringUtil extends EgovStringUtil { + + /** + * Null 이거나, 빈문자열(공백 포함)인 경우, true를 리턴한다. + * + * @param str + * @return + */ + public static boolean isEmpty(String str) { + return str == null || str.trim().length() == 0; + } + + /** + * Null이 아니고 빈문자열(공백 포함)이 아닌 일반 문자가 존재하는 , true를 리턴한다. + * + * @param str + * @return + */ + public static boolean isNotEmpty(String str) { + return !isEmpty(str); + } + + /** + * 문자열을 정수형으로 변환하여 리턴한다. 만일 문자열이 null 또는 빈 문자열인 경우, -1을 리턴한다. + * + * @param str + * @return + */ + public static int toNumber(String str) { + return toNumber(str, -1); + } + + /** + * 문자열을 정수형으로 변환하여 리턴한다. 만일 문자열이 null 또는 빈 문자열인 경우, 기본값 정보 defaultInt를 리턴한다. + * + * @param str + * @param defaultInt + * @return + */ + public static int toNumber(String str, int defaultInt) { + if(isEmpty(str)) return defaultInt; + + try { + return Integer.parseInt(str.trim()); + } catch(Exception e) {} + + return defaultInt; + } + + /** + * 현재 시각을 yyyyMMddhhmmssSSS 형식으로 리턴한다. + * + * @return + */ + public static String getTimeStamp() { + + String rtnStr = null; + + // 문자열로 변환하기 위한 패턴 설정(년도-월-일 시:분:초:초(자정이후 초)) + String pattern = "yyyyMMddhhmmssSSS"; + + SimpleDateFormat sdfCurrent = new SimpleDateFormat(pattern, Locale.KOREA); + Timestamp ts = new Timestamp(System.currentTimeMillis()); + + rtnStr = sdfCurrent.format(ts.getTime()); + + return rtnStr; + } +} diff --git a/src/main/webapp/WEB-INF/jsp/nlib/board/listQnAs.jsp b/src/main/webapp/WEB-INF/jsp/nlib/board/listQnAs.jsp index 495d64b5..99c20e01 100644 --- a/src/main/webapp/WEB-INF/jsp/nlib/board/listQnAs.jsp +++ b/src/main/webapp/WEB-INF/jsp/nlib/board/listQnAs.jsp @@ -148,7 +148,9 @@ $("#jsGrid").jsGrid({ /* 이하만 설정 */ + /* data: clients, + */ fields: [ { title:"번호", name: "noticeNo" , type: "number" , width: 50, align: "center"}, @@ -177,8 +179,10 @@ function fn_search_article() { type: "post", data: JSON.stringify(inputData), dataType:'json', /* Server Response Data Type */ - success: function(returnData, status){ - alert("returnData=" + JSON.stringify(returnData)); + success: function(returnData, status){ + var jsonObj = JSON.parse(returnData); + alert("record=" + JSON.stringify(jsonObj.info.record)); + $("#jsGrid").jsGrid("loadData", jsonObj.info.record) }, error: function(data){ alert("조회에 실패하였습니다.\n" + data.code + " : " + data.message);