diff --git a/src/main/java/nlib/col/service/RisVO.java b/src/main/java/nlib/col/service/RisVO.java index d18f3cde..de440d9c 100644 --- a/src/main/java/nlib/col/service/RisVO.java +++ b/src/main/java/nlib/col/service/RisVO.java @@ -1,155 +1,152 @@ -package nlib.col.service; - -import java.io.Serializable; - -/** - *
- * @Class Name : RisVO.java - * - * @Description : Ris 통신규약 항목 VO - * - * - * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) - * - *- * - * @ ------------ -------- --------------------------- - * @ 수정일 수정자 수정내용 - * @ ------------ -------- --------------------------- - * @ 2021. 9. 23. JSYOO 최초 생성 - - * - * - * @author 이씨플라자 * DIGITALSHIP JSYOO - * @since 2021. 9. 23. - * @version 1.0 - * - */ -public class RisVO implements Serializable { - - /* 기존 지역 n 문화 사이트 RIS 항목 */ - private String TY; /* 참조유형 (ex: BOOK) */ - private String TI; /* 표제 (ex: 수원사랑 259호) */ - private String AB; /* 요약 */ - private String DA; /* 날짜 */ - private String PY; /* 발행 년도 (YYYY) */ - private String LA; /* 언어 (ex: Korean) */ - private String UR; /* URL */ - private String KW; /* 키워드 (ex: 수원사랑) */ - private String T2; /* 보조제목 (ex: 수원사랑 259호) */ - private String ER; /* 참조의 끝(비어있고 마지막 태그 여야 함) */ - - /* RIS 추가 항목 */ - private String ID; /* 자료번호 */ - private String T3; /* 자료제목 */ - private String M3; /* 주제분야명 */ - private String L4; /* 썸네일이미지 URL */ - private String M1; /* 관리 번호 */ - private String PB; /* 저자명 */ - private String LB; /* 상표 */ - - public String getTY() { - return TY; - } - public void setTY(String tY) { - TY = tY; - } - public String getTI() { - return TI; - } - public void setTI(String tI) { - TI = tI; - } - public String getAB() { - return AB; - } - public void setAB(String aB) { - AB = aB; - } - public String getDA() { - return DA; - } - public void setDA(String dA) { - DA = dA; - } - public String getPY() { - return PY; - } - public void setPY(String pY) { - PY = pY; - } - public String getLA() { - return LA; - } - public void setLA(String lA) { - LA = lA; - } - public String getUR() { - return UR; - } - public void setUR(String uR) { - UR = uR; - } - public String getKW() { - return KW; - } - public void setKW(String kW) { - KW = kW; - } - public String getT2() { - return T2; - } - public void setT2(String t2) { - T2 = t2; - } - public String getER() { - return ER; - } - public void setER(String eR) { - ER = eR; - } - public String getID() { - return ID; - } - public void setID(String iD) { - ID = iD; - } - public String getT3() { - return T3; - } - public void setT3(String t3) { - T3 = t3; - } - public String getM3() { - return M3; - } - public void setM3(String m3) { - M3 = m3; - } - public String getL4() { - return L4; - } - public void setL4(String l4) { - L4 = l4; - } - public String getM1() { - return M1; - } - public void setM1(String m1) { - M1 = m1; - } - public String getPB() { - return PB; - } - public void setPB(String pB) { - PB = pB; - } - public String getLB() { - return LB; - } - public void setLB(String lB) { - LB = lB; - } - - -} +package nlib.col.service; + +import java.io.Serializable; + +/** + *
+ * @Class Name : RisVO.java + * + * @Description : Ris 통신규약 항목 VO + * + * + * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021) + * + *+ * + * @ ------------ -------- --------------------------- + * @ 수정일 수정자 수정내용 + * @ ------------ -------- --------------------------- + * @ 2021. 9. 23. JSYOO 최초 생성 + + * + * + * @author 이씨플라자 * DIGITALSHIP JSYOO + * @since 2021. 9. 23. + * @version 1.0 + * + */ +public class RisVO implements Serializable { + + /* 기존 지역 n 문화 사이트 RIS 항목 */ + private String typeDivCd; /* 참조유형 TY */ + private String title; /* 제목 TI */ + private String subTitle; /* 부제목 T2 */ + private String creatYyyy; /* 생산일자 (YYYY) PY */ + private String keyword; /* 키워드 (ex: 수원사랑) KW */ + private String UR; /* URL */ + + /*private String AB; 요약 + private String DA; 날짜 + private String LA; 언어 (ex: Korean) */ + + /* RIS 추가 항목 */ + private String masterId; /* 자료번호 ID */ + private String M3; /* 주제분야명 */ + private String rprsThumbUrl; /* 썸네일이미지 URL L4 */ + private String stakrmMngNo; /* 관리번호 M1 */ + private String producer; /* 생산자(저자) A1 */ + private String orgNm; /* 생산기관명 PP */ + + public String getTypeDivCd() { + return typeDivCd; + } + public String getTy() { + return typeDivCd; + } + public void setTypeDivCd(String typeDivCd) { + this.typeDivCd = typeDivCd; + } + public String getTitle() { + return title; + } + public String getTt() { + return title; + } + public void setTitle(String title) { + this.title = title; + } + public String getSubTitle() { + return subTitle; + } + public String getT2() { + return subTitle; + } + public void setSubTitle(String subTitle) { + this.subTitle = subTitle; + } + public String getCreatYyyy() { + return creatYyyy; + } + public String getPy() { + return creatYyyy; + } + public void setCreatYyyy(String creatYyyy) { + this.creatYyyy = creatYyyy; + } + public String getKeyword() { + return keyword; + } + public String getKw() { + return keyword; + } + public void setKeyword(String keyword) { + this.keyword = keyword; + } + public String getUR() { + return UR; + } + public void setUR(String uR) { + UR = uR; + } + public String getMasterId() { + return masterId; + } + public String getId() { + return masterId; + } + public void setMasterId(String masterId) { + this.masterId = masterId; + } + public String getM3() { + return M3; + } + public void setM3(String m3) { + M3 = m3; + } + public String getRprsThumbUrl() { + return rprsThumbUrl; + } + public String getL4() { + return rprsThumbUrl; + } + public void setRprsThumbUrl(String rprsThumbUrl) { + this.rprsThumbUrl = rprsThumbUrl; + } + public String getStakrmMngNo() { + return stakrmMngNo; + } + public String getM1() { + return stakrmMngNo; + } + public void setStakrmMngNo(String stakrmMngNo) { + this.stakrmMngNo = stakrmMngNo; + } + public String getProducer() { + return producer; + } + public String getA1() { + return producer; + } + public void setProducer(String producer) { + this.producer = producer; + } + public String getOrgNm() { + return orgNm; + } + public String getPp() { + return orgNm; + } + public void setOrgNm(String orgNm) { + this.orgNm = orgNm; + } +} diff --git a/src/main/java/nlib/restful/DataApi.java b/src/main/java/nlib/restful/DataApi.java index feb2ebbb..b571f27a 100644 --- a/src/main/java/nlib/restful/DataApi.java +++ b/src/main/java/nlib/restful/DataApi.java @@ -2,20 +2,12 @@ package nlib.restful; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.MultiValueMap; -import org.springframework.web.client.RestTemplate; +import org.springframework.stereotype.Repository; import nlib.restful.service.DataApiReqVO; import nlib.restful.service.DataApiResVO; import nlib.restful.service.impl.DataApiTempXml; -import nlib.util.StringUtil; +import nlib.restful.service.impl.DataApiRESTful; /** @@ -45,49 +37,14 @@ import nlib.util.StringUtil; * @version 1.0 * */ -public class DataApi extends DataApiTempXml { +@Repository("dataApi") +public class DataApi extends DataApiRESTful { // RESTFul 서버에 접속하여 요청/응답처리를 수행하는 경우 +//public class DataApi extends DataApiTempXml { // 로컬파일에서 읽어와서 요청/응답처리를 수행하는 경우 private static final Logger log = LoggerFactory.getLogger(DataApi.class); - - /** - * 조회 - * - * @param reqVO - * @return - */ - public DataApiResVO get(DataApiReqVO reqVO) { - return super.get(reqVO); - } - - /** - * 등록 - * - * @param reqVO - * @return - */ - public DataApiResVO put(DataApiReqVO reqVO) { - return super.put(reqVO); - } - - /** - * 수정 - * - * @param reqVO - * @return - */ - public DataApiResVO post(DataApiReqVO reqVO) { - return super.post(reqVO); - } - - /** - * 삭제 - * - * @param reqVO - * @return - */ - public DataApiResVO delete (DataApiReqVO reqVO) { - return super.delete(reqVO); + public DataApiResVO request(DataApiReqVO reqVO) { + return super.request(reqVO); } } diff --git a/src/main/java/nlib/restful/service/DataApiInterface.java b/src/main/java/nlib/restful/service/DataApiInterface.java index 804ce6cf..f730e420 100644 --- a/src/main/java/nlib/restful/service/DataApiInterface.java +++ b/src/main/java/nlib/restful/service/DataApiInterface.java @@ -1,13 +1,19 @@ package nlib.restful.service; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; +import org.springframework.web.util.UriComponentsBuilder; import nlib.util.StringUtil; @@ -36,38 +42,6 @@ import nlib.util.StringUtil; 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에 담아서 리턴한다. @@ -76,39 +50,46 @@ public interface DataApiInterface { * @param method * @return */ - public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method); + public DataApiResVO request(DataApiReqVO reqVO); /** - * 요청 VO를 Map 형태로 변환한다. + * [POST용] 요청 VO의 입력변수값을 API 요청을 위한 MultiValueMap 형태로 변환한다. * * @param reqVO * @return */ - public static MultiValueMap
@@ -26,104 +25,52 @@ import java.util.Map;
* @version 1.0
*
*/
-public class DataApiReqVO {
+public class DataApiReqVO extends DataApiVO {
- public static final int DEFAULT_PAGE_SIZE = 10;
- public static final int DEFAULT_PAGE_INDEX = 1;
+ /**
+ * 메소드를 GET으로 기본설정하여 객체 생성하는 생성자
+ */
+ public DataApiReqVO() {
+ this(null, HttpMethod.GET);
+ }
- /* 페이징 정보 */
- private int pageIndex = 0; /* 요청 페이지 번호 */
- private int pageSize = 0; /* 페이지별 표출할 레코드 수 */
+ /**
+ * 요청 URL을 받아 객체 생성하는 생성자
+ * 메소드는 GET으로 설정된다.
+ *
+ * @param reqUrl
+ */
+ public DataApiReqVO(String reqUrl) {
+ this(reqUrl, HttpMethod.GET);
+ }
- /* 기본정보 */
- private HashMap info = null;
-
- public boolean hasInfo() {
- return (info != null && info.size() > 0);
+ /**
+ * 요청 URL과 메소드를 받아 객체 생성하는 생성자
+ *
+ * @param reqUrl
+ * @param reqMethod
+ */
+ public DataApiReqVO(String reqUrl, HttpMethod reqMethod) {
+ this.reqUrl = reqUrl;
+ this.reqMethod = reqMethod;
}
- /* 요청업무ID 및 처리URI */
- int reqMethod; /* 요청메소드구분값 */
- String reqUrl; /* 요청업무ID에 대한 통합시스템의 응답 처리 프로그램 URI */
-
- // GET/SET
-
- public int getPageIndex() {
- return (pageIndex < 1 ? DEFAULT_PAGE_INDEX : pageIndex);
- }
-
- public void setPageIndex(int pageIndex) {
- this.pageIndex = pageIndex;
- }
-
- public void setPageIndex(String pageIndex) {
- try {
- this.pageIndex = Integer.parseInt(pageIndex);
- } catch(Exception e) {
- this.pageIndex = DEFAULT_PAGE_INDEX;
- }
-
- }
-
- public int getPageSize() {
- return (pageSize < 1 ? DEFAULT_PAGE_SIZE : pageSize);
- }
-
- public void setPageSize(String pageSize) {
- try {
- this.pageSize = Integer.parseInt(pageSize);
- } catch(Exception e) {
- this.pageSize = DEFAULT_PAGE_SIZE;
- }
- }
-
- public void setPageSize(int pageSize) {
- this.pageSize = pageSize;
- }
-
- public HashMap getInfo() {
- return info;
- }
-
- public void setInfo(HashMap info) {
- this.info = info;
- }
-
- public String getReqUrl() {
- return reqUrl;
- }
- public void setReqUrl(String reqUrl) {
- this.reqUrl = reqUrl;
- }
-
- public int getReqMethod() {
- return reqMethod;
- }
-
- public void setReqMethod(int reqMethod) {
- this.reqMethod = reqMethod;
+ /**
+ * 사용자ID 값을 디코딩하여 리턴한다.
+ *
+ * @return
+ */
+ public String getMbInfoIdWithDec() {
+ return AriaCrypto.decode(getMbInfoId());
}
- public void addInfoItem(String key, String value) {
- if(key == null) return;
-
- if(info == null) info = new HashMap();
-
- info.put(key, value);
+ /**
+ * 사용자ID를 인코딩하여 설정한다.
+ *
+ * @param mbInfoId
+ */
+ public void setMbInfoIdWithEnc(String mbInfoId) {
+ setMbInfoId(mbInfoId);
}
- public String getInfoItem(String key) {
- if(key == null) return null;
- if(info == null) return null;
-
- return (String)info.get(key);
- }
-
- public void removeInfoItem(String key) {
- if(key == null) return;
- if(info == null) return;
-
- info.remove(key);
- }
-
}
diff --git a/src/main/java/nlib/restful/service/DataApiResVO.java b/src/main/java/nlib/restful/service/DataApiResVO.java
index f6e0b36d..779066dd 100644
--- a/src/main/java/nlib/restful/service/DataApiResVO.java
+++ b/src/main/java/nlib/restful/service/DataApiResVO.java
@@ -1,9 +1,5 @@
package nlib.restful.service;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import nlib.util.StringUtil;
/**
@@ -28,17 +24,21 @@ import nlib.util.StringUtil;
* @version 1.0
*
*/
-public class DataApiResVO {
+public class DataApiResVO extends DataApiVO {
/**
* 생성자
+ *
+ * @param resultCode
+ * @param resultMessage
*/
public DataApiResVO() {
- super();
+ this.resultCode = null;
+ this.resultMessage = null;
}
-
+
/**
- * 생성자
+ * 처리결과 코드와 메시지를 입력받아 객체를 생성하는 생성자
*
* @param resultCode
* @param resultMessage
@@ -48,24 +48,9 @@ public class DataApiResVO {
this.resultMessage = resultMessage;
}
-
- /* 처리결과 */
- String resultCode; /* 결과코드 */
- String resultMessage; /* 결과내용(오류내용) */
-
- /* 페이징 정보 */
- int pageIndex = 0; /* 요청 페이지 번호 (page) */
- int pageLastIndex = 0; /* 마지막페이지번호 (totPages) */
-
- /* 기본/추가 정보 */
- HashMap info = null;
-
- /* 목록정보 */
- int recordTotCount = 0; /* 총 레코드수 (records) */
-
/**
* 응답 처리결과가 성공인지의 여부를 리턴한다.
- * 결과코드(resultCode)의 값이 "S"로 시작하는 경우 true 리턴한다.
+ * 결과코드(resultCode)의 값이 "S"로 시작하는 경우 true 리턴한다. 이외 false 리턴한다.
*
* @return
*/
@@ -73,62 +58,5 @@ public class DataApiResVO {
if(StringUtil.isEmpty(resultCode)) return false;
return (resultCode.trim().charAt(0) == 'S');
}
-
- // GET/SET
-
- public String getResultCode() {
- return resultCode;
- }
- public void setResultCode(String resultCode) {
- this.resultCode = resultCode;
- }
- public String getResultMessage() {
- return resultMessage;
- }
- public void setResultMessage(String resultMessage) {
- this.resultMessage = resultMessage;
- }
- public int getPageIndex() {
- return pageIndex;
- }
- public void setPageIndex(int pageIndex) {
- this.pageIndex = pageIndex;
- }
- public int getPageLastIndex() {
- return pageLastIndex;
- }
- public void setPageLastIndex(int pageLastIndex) {
- this.pageLastIndex = pageLastIndex;
- }
- public HashMap getInfo() {
- return info;
- }
- public void setInfo(HashMap info) {
- this.info = info;
- }
- public int getRecordTotCount() {
- return recordTotCount;
- }
- public void setRecordTotCount(int recordTotCount) {
- this.recordTotCount = recordTotCount;
- }
-
- /**
- * 반복되는 목록용 리스트 정보를 가져온다.
- * - RESTful API : ""요소로 반복되는 요소를 반환한다.
- *
- * @return
- */
- public List> getList() {
- if(info == null) return null;
- return (List>)info.get("results");
- }
-
- public String getInfoItem(String key) {
- if(key == null) return null;
- if(info == null) return null;
-
- return (String)info.get(key);
- }
}
diff --git a/src/main/java/nlib/restful/service/DataApiVO.java b/src/main/java/nlib/restful/service/DataApiVO.java
new file mode 100644
index 00000000..061d8236
--- /dev/null
+++ b/src/main/java/nlib/restful/service/DataApiVO.java
@@ -0,0 +1,288 @@
+package nlib.restful.service;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpMethod;
+
+import nlib.cmm.crypto.AriaCrypto;
+import nlib.cmm.service.NlibProperty;
+import nlib.util.StringUtil;
+
+/**
+ *
+ * @Class Name : DataApiReqVO.java
+ *
+ * @Description : RESTful API 요청 VO
+ *
+ *
+ * @프로젝트명: 지방문화원 통합자료관리시스템 구축사업 (2021)
+ *
+ *
+ *
+ * @ ------------ -------- ---------------------------
+ * @ 수정일 수정자 수정내용
+ * @ ------------ -------- ---------------------------
+ * @ 2021. 6. 22. KNKIM 최초 생성
+ *
+ *
+ * @author 이씨플라자 * DIGITALSHIP KNKIM
+ * @since 2021. 6. 22.
+ * @version 1.0
+ *
+ */
+public class DataApiVO {
+
+ private static final Logger log = LoggerFactory.getLogger(DataApiVO.class);
+
+ /* 입출력 정보 중 공통 및 특정 항목들에 대한 처리를 위한 API 요소명 */
+ public static final String XML_EL_NAME_ROOT_NAME = "results"; // 결과값 최상위 요소명
+ public static final String XML_EL_NAME_PAGE_SIZE = "rows"; // 페이지크기 : 한페이지에 보여줄 레코드수
+ public static final String XML_EL_NAME_PAGE_INDEX = "page"; // 페이지번호
+ public static final String XML_EL_NAME_PAGE_LAST_INDEX = "totPages"; // 총페이지수
+ public static final String XML_EL_NAME_RECORD_TOT_COUNT = "records"; // 총레코드수
+ public static final String XML_EL_NAME_MB_INFO_ID = "mbInfoId"; // 시스템 내부 사용자ID
+ public static final String XML_EL_NAME_RECORD = "record"; // 다건 목록 자료인 레코드 요소명
+ public static final String XML_EL_NAME_RESULT_CODE = "resultCode"; // 처리결과 코드
+ public static final String XML_EL_NAME_RESULT_MESSAGE = "resultMessage"; // 처리결과 메시지
+
+ /* 페이지 처리 기본값 */
+ public static final int DEFAULT_PAGE_SIZE = NlibProperty.getInt("list.paging.page.size", 10);
+ public static final int DEFAULT_PAGE_INDEX = 1;
+
+ String reqUrl = null; /* 요청업무ID에 대한 통합시스템의 응답 처리 프로그램 URI */
+ HttpMethod reqMethod = HttpMethod.GET; /* 요청메소드구분값 */
+
+ String resultCode; /* 결과코드 */
+ String resultMessage; /* 결과내용(오류내용) */
+
+ HashMap info = null; /* 입출력 정보 맵 */
+ HashMap>> listMap = null; /* 다건 레코드 리스트를 관리하는 맵 */
+
+ public DataApiVO() {
+ super();
+ }
+
+ //--------------------------------------------------------------
+ // 정보 항목 관련 IN/OUT 함수
+ //--------------------------------------------------------------
+ public void putInfoItem(String key, String value) {
+ if(StringUtil.isEmpty(key)) return;
+ if(info == null) info = new HashMap();
+
+ info.put(key, value);
+ }
+ public String getInfoItem(String key) {
+ return getInfoItem(key, null);
+ }
+ public String getInfoItem(String key, String defValue) {
+ if(StringUtil.isEmpty(key)) return defValue;
+ if(info == null) return defValue;
+
+ String value = info.get(key);
+
+ return StringUtil.isEmpty(value) ? defValue : value;
+ }
+ public void removeInfoItem(String key) {
+ if(StringUtil.isEmpty(key)) return;
+ if(info == null) return;
+ info.remove(key);
+ }
+ public boolean hasInfo() {
+ return (info != null && info.size() > 0);
+ }
+
+ public boolean hasList() {
+ return (listMap != null && listMap.size() > 0);
+ }
+
+ public boolean hasList(String listName) {
+ List list = getList(listName);
+ return (list != null && list.size() > 0);
+ }
+
+ //--------------------------------------------------------------
+ // 다건 레코드관련 함수
+ //--------------------------------------------------------------
+ public void addListItem(String listName, HashMap map) {
+ if(StringUtil.isEmpty(listName)) return;
+ List> list = getList(listName);
+
+ if(list == null) list = new ArrayList>();
+ list.add(map);
+ setList(listName, list);
+ return;
+ }
+
+ public void removeListItem(String listName, int idx) {
+ if(StringUtil.isEmpty(listName)) return;
+ if(idx < 0) return;
+
+ List> list = getList(listName);
+ if(list != null && list.size() > idx) list.remove(idx);
+ return;
+ }
+
+ public void clearList(String listName) {
+ if(StringUtil.isEmpty(listName)) return;
+
+ List> list = getList(listName);
+ if(list != null) list.clear();
+ return;
+ }
+
+ public List> getList(String listName) {
+ if(StringUtil.isEmpty(listName)) return null;
+ if(listMap == null && listMap.size() < 1) return null;
+
+ return listMap.get(listName);
+ }
+
+ public void setList(String listName, List> list) {
+ if(StringUtil.isEmpty(listName)) return;
+ if(listMap == null) initList();
+
+ List> listOld = getList(listName);
+ if(listOld != null) listOld.clear();
+
+ listMap.put(listName, list);
+ return;
+ }
+
+ private void initList() {
+ if(listMap == null) listMap = new HashMap>>();
+ return;
+ }
+
+ //--------------------------------------------------------------
+ // 페이징 처리 관련
+ //--------------------------------------------------------------
+ public int getPageIndex() {
+ int pageIndex = 0;
+ try {
+ pageIndex = Integer.parseInt(getInfoItem(XML_EL_NAME_PAGE_INDEX, "0"));
+ } catch(Exception e) {
+ log.error("getPageIndex > " + e.toString());
+ return 0;
+ }
+ return pageIndex;
+ }
+ public void setPageIndex(int pageIndex) {
+ setPageIndex("" + pageIndex);
+ }
+ public void setPageIndex(String pageIndex) {
+ putInfoItem("XML_EL_NAME_PAGE_INDEX", pageIndex);
+ }
+ public int getPageLastIndex() {
+ int pageLastIndex = 0;
+ try {
+ pageLastIndex = Integer.parseInt(getInfoItem(XML_EL_NAME_PAGE_LAST_INDEX, "0"));
+ } catch(Exception e) {
+ log.error("getPageLastIndex > " + e.toString());
+ return 0;
+ }
+ return pageLastIndex;
+ }
+ public void setPageLastIndex(int pageLastIndex) {
+ setPageLastIndex("" + pageLastIndex);
+ }
+ public void setPageLastIndex(String pageLastIndex) {
+ putInfoItem("XML_EL_NAME_PAGE_LAST_INDEX", pageLastIndex);
+ }
+ public int getPageSize() {
+ int pageSize = 0;
+ try {
+ pageSize = Integer.parseInt(getInfoItem(XML_EL_NAME_PAGE_SIZE, "0"));
+ } catch(Exception e) {
+ log.error("getPageSize > " + e.toString());
+ return 0;
+ }
+ return pageSize;
+ }
+ public void setPageSize(int pageSize) {
+ setPageSize("" + pageSize);
+ }
+ public void setPageSize(String pageSize) {
+ putInfoItem("XML_EL_NAME_PAGE_SIZE", pageSize);
+ }
+ public int getRecordTotCount() {
+ int recordTotCount = 0;
+ try {
+ recordTotCount = Integer.parseInt(getInfoItem(XML_EL_NAME_RECORD_TOT_COUNT, "0"));
+ } catch(Exception e) {
+ log.error("getRecordTotCount > " + e.toString());
+ return 0;
+ }
+ return recordTotCount;
+ }
+ public void setRecordTotCount(int recordTotCount) {
+ setRecordTotCount("" + recordTotCount);
+ }
+ public void setRecordTotCount(String recordTotCount) {
+ putInfoItem(XML_EL_NAME_RECORD_TOT_COUNT, recordTotCount);
+ }
+
+ //--------------------------------------------------------------
+ // 사용자ID 처리 관련
+ //--------------------------------------------------------------
+ public String getMbInfoId() {
+ return getInfoItem("XML_EL_NAME_MB_INFO_ID");
+ }
+ public String getEncMbInfoId() {
+ return AriaCrypto.encode(getInfoItem("XML_EL_NAME_MB_INFO_ID"));
+ }
+ public void setMbInfoId(String mbInfoId) {
+ putInfoItem("XML_EL_NAME_MB_INFO_ID", mbInfoId);
+ }
+
+ //--------------------------------------------------------------
+ // GET & SET
+ //--------------------------------------------------------------
+ public String getReqUrl() {
+ return reqUrl;
+ }
+
+ public void setReqUrl(String reqUrl) {
+ this.reqUrl = reqUrl;
+ }
+
+ public HttpMethod getReqMethod() {
+ return reqMethod;
+ }
+
+ public void setReqMethod(HttpMethod reqMethod) {
+ this.reqMethod = reqMethod;
+ }
+
+ public String getResultCode() {
+ return resultCode;
+ }
+
+ public void setResultCode(String resultCode) {
+ this.resultCode = resultCode;
+ }
+
+ public String getResultMessage() {
+ return resultMessage;
+ }
+
+ public void setResultMessage(String resultMessage) {
+ this.resultMessage = resultMessage;
+ }
+
+ public HashMap getInfo() {
+ return info;
+ }
+
+ public void setInfo(HashMap info) {
+ this.info = info;
+ }
+
+ public HashMap>> getListMap() {
+ return listMap;
+ }
+
+}
diff --git a/src/main/java/nlib/restful/service/XmlConverter.java b/src/main/java/nlib/restful/service/XmlConverter.java
index 66580e5c..ae9125d6 100644
--- a/src/main/java/nlib/restful/service/XmlConverter.java
+++ b/src/main/java/nlib/restful/service/XmlConverter.java
@@ -24,7 +24,7 @@ public class XmlConverter {
private static final Logger log = LoggerFactory.getLogger(XmlConverter.class);
- public static HashMap convert(String xmlStr) throws Exception {
+ public static HashMap convert(String xmlStr, String rootEleName) throws Exception {
if(xmlStr == null) return null;
@@ -35,7 +35,7 @@ public class XmlConverter {
XMLInputFactory inputFactory = XMLInputFactory.newInstance();
XMLEventReader eventReader = inputFactory.createXMLEventReader(bIn);
- resMap = getElementValue("result", eventReader, null);
+ resMap = getElementValue(rootEleName, eventReader, null);
//log.debug("Converting XML to HashMap : Done >> " + resMap);
} catch (XMLStreamException e) {
e.printStackTrace();
diff --git a/src/main/java/nlib/restful/service/impl/DataApiRESTful.java b/src/main/java/nlib/restful/service/impl/DataApiRESTful.java
index 8723c6f4..74b1921e 100644
--- a/src/main/java/nlib/restful/service/impl/DataApiRESTful.java
+++ b/src/main/java/nlib/restful/service/impl/DataApiRESTful.java
@@ -1,5 +1,7 @@
package nlib.restful.service.impl;
+import java.nio.charset.StandardCharsets;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -9,12 +11,13 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
+import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
+import nlib.restful.service.DataApiInterface;
import nlib.restful.service.DataApiReqVO;
import nlib.restful.service.DataApiResVO;
-import nlib.restful.service.DataApiInterface;
import nlib.util.StringUtil;
/**
@@ -53,48 +56,6 @@ public class DataApiRESTful implements DataApiInterface {
@Value("#{properties['dataapi.server.protocol']}")
private String DAPI_SERVER_PROTOCOL;
-
- /**
- * 조회
- *
- * @param reqVO
- * @return
- */
- public DataApiResVO get(DataApiReqVO reqVO) {
-
- return send(reqVO, HttpMethod.GET);
- }
-
- /**
- * 등록
- *
- * @param reqVO
- * @return
- */
- public DataApiResVO put(DataApiReqVO reqVO) {
- return send(reqVO, HttpMethod.PUT);
- }
-
- /**
- * 수정
- *
- * @param reqVO
- * @return
- */
- public DataApiResVO post(DataApiReqVO reqVO) {
- return send(reqVO, HttpMethod.POST);
- }
-
- /**
- * 삭제
- *
- * @param reqVO
- * @return
- */
- public DataApiResVO delete (DataApiReqVO reqVO) {
- return send(reqVO, HttpMethod.DELETE);
- }
-
/**
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
*
@@ -102,42 +63,79 @@ public class DataApiRESTful implements DataApiInterface {
* @param method
* @return
*/
- public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) {
+ public DataApiResVO request(DataApiReqVO reqVO) {
+
+ log.debug("request > " + reqVO.getReqMethod());
DataApiResVO resVO = null;
try {
+
//-----------------------------------
// 입력값 검증작업
//-----------------------------------
resVO = DataApiInterface.checkReqCommonParams(reqVO);
if(resVO != null) return resVO;
- if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다.");
+ HttpMethod method = reqVO.getReqMethod();
//-----------------------------------
- // 폼 파라메터 생성 작업
+ // 폼 파라메터 생성 작업 및 요청 처리
//-----------------------------------
+ String url = DAPI_SERVER_PROTOCOL + "://" + DAPI_SERVER_IP + ("80".equals(DAPI_SERVER_PORT) ? "" : ":" + DAPI_SERVER_PORT) + reqVO.getReqUrl();
+ log.debug("REQ URL : " + url);
+
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- MultiValueMap parameters = DataApiInterface.makeParamMap(reqVO);
- HttpEntity> requestEntity = new HttpEntity(parameters, headers);
+
+ ResponseEntity responseEntity = null;
+ RestTemplate restTemplate = new RestTemplate();
+ restTemplate.getMessageConverters()
+ .add(0, new StringHttpMessageConverter(StandardCharsets.UTF_8));
+
+ if(method == HttpMethod.GET) {
+ HttpEntity requestEntity = new HttpEntity(headers);
+ responseEntity = restTemplate.exchange (DataApiInterface.makeRequestParamUrl(url, reqVO), method, requestEntity, String.class);
+ } else if(method == HttpMethod.POST) {
+ MultiValueMap parameters = DataApiInterface.makeRequestParamMultiValueMap(reqVO);
+ parameters.forEach((k, v) -> log.debug("params > " + k + " : " + v));
+ HttpEntity> requestEntity = new HttpEntity(parameters, headers);
+ responseEntity = restTemplate.postForEntity(url, requestEntity , String.class);
+ } else {
+ String message = "RESTFul API Http Method 설정 오류입니다. : POST, GET 방식만 허용됩니다.";
+ log.error("request > " + message);
+ return DataApiInterface.makeErrorRes("E_ERR_METHOD", message);
+ }
//-----------------------------------
// 요청 처리
//-----------------------------------
- RestTemplate restTemplate = new RestTemplate();
- String url = DAPI_SERVER_PROTOCOL + "://" + DAPI_SERVER_IP + ("80".equals(DAPI_SERVER_PORT) ? "" : ":" + DAPI_SERVER_PORT) + reqVO.getReqUrl();
- log.debug("REQ URL : " + reqVO.getReqUrl());
+// RestTemplate restTemplate = new RestTemplate();
+ //restTemplate.setMessageConverters(msgConverters);
+
+ //ResponseEntity responseEntity = restTemplate.exchange(url, method, requestEntity, String.class);
+// ResponseEntity responseEntity = restTemplate.exchange (url, method, requestEntity, String.class);
+ //ResponseEntity responseEntity = restTemplate.exchange (url, HttpMethod.GET, requestEntity, String.class, parameters);
+ //ResponseEntity responseEntity = restTemplate.postForEntity( url, requestEntity , String.class ); // working well
+ //ResponseEntity responseEntity = restTemplate.getForEntity(url, String.class, parameters); // not working
+
+ /*
+ // GET // OK
+ UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
+ .queryParam("mngOrgCd", "SU01")
+ .queryParam("masterId", "UR-408A9832D25C42289D9B1FC81FDA8360")
+ .queryParam("typeDivCd", "IT_MUSE");
+ HttpEntity> entity = new HttpEntity<>(headers);
+ RestTemplate restTemplate = new RestTemplate();
+ ResponseEntity responseEntity = restTemplate.exchange (builder.toUriString(), method, entity, String.class);
+ */
- ResponseEntity responseEntity = restTemplate.exchange(url, method, requestEntity, String.class);
//-----------------------------------
// 응답 처리
//-----------------------------------
HttpStatus statusCode = responseEntity.getStatusCode();
log.debug("RES StatusCode : " + statusCode);
- String resultXML = "";
- resultXML = responseEntity.getBody();
+ String resultXML = responseEntity.getBody();
log.debug("RES resultXML : " + resultXML);
// 응답 자료 객체화
@@ -145,19 +143,22 @@ public class DataApiRESTful implements DataApiInterface {
// 처리결과 코드 확인
if(StringUtil.isEmpty(resVO.getResultCode())) {
+ String resultMessage = resVO.getResultMessage();
if (statusCode == HttpStatus.OK) {
resVO.setResultCode("S_HTTP_STATUS_OK");
- resVO.setResultMessage("정상처리되었습니다.");
+ resVO.setResultMessage(StringUtil.isEmpty(resultMessage) ? "정상처리되었습니다." : resultMessage);
} else {
resVO.setResultCode("E_STATUS_CODE_FAIL");
- resVO.setResultMessage(String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()));
+ resVO.setResultMessage(StringUtil.isEmpty(resultMessage) ? String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()) : resultMessage);
}
}
- //log.debug("RES resVO : " + resVO);
+ log.debug("RES resVO : resultCode = " + resVO.getResultCode());
+ log.debug("RES resVO : resultMessage = " + resVO.getResultMessage());
} catch(Exception e) {
e.printStackTrace();
+ log.error("request > Exception 발생 : " + e.toString());
return DataApiInterface.makeErrorRes("E_REQ_EXCEPTION", e.toString());
}
diff --git a/src/main/java/nlib/restful/service/impl/DataApiTempXml.java b/src/main/java/nlib/restful/service/impl/DataApiTempXml.java
index 7c085675..0720fa8e 100644
--- a/src/main/java/nlib/restful/service/impl/DataApiTempXml.java
+++ b/src/main/java/nlib/restful/service/impl/DataApiTempXml.java
@@ -10,7 +10,6 @@ import java.nio.charset.StandardCharsets;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
-import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
@@ -19,10 +18,11 @@ import org.springframework.util.MultiValueMap;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+import nlib.restful.service.DataApiInterface;
import nlib.restful.service.DataApiReqVO;
import nlib.restful.service.DataApiResVO;
import nlib.restful.service.DataApiServerResponseVO;
-import nlib.restful.service.DataApiInterface;
+import nlib.restful.service.DataApiVO;
import nlib.util.StringUtil;
/**
@@ -55,47 +55,6 @@ public class DataApiTempXml implements DataApiInterface {
@Value("#{properties['dataapi.temp.xml.path']}")
private String DAPI_TEMP_XML_PATH;
-
- /**
- * 조회
- *
- * @param reqVO
- * @return
- */
- public DataApiResVO get(DataApiReqVO reqVO) {
-
- return send(reqVO, HttpMethod.GET);
- }
-
- /**
- * 등록
- *
- * @param reqVO
- * @return
- */
- public DataApiResVO put(DataApiReqVO reqVO) {
- return send(reqVO, HttpMethod.PUT);
- }
-
- /**
- * 수정
- *
- * @param reqVO
- * @return
- */
- public DataApiResVO post(DataApiReqVO reqVO) {
- return send(reqVO, HttpMethod.POST);
- }
-
- /**
- * 삭제
- *
- * @param reqVO
- * @return
- */
- public DataApiResVO delete (DataApiReqVO reqVO) {
- return send(reqVO, HttpMethod.DELETE);
- }
/**
* 실제 RESTful API 서버로 요청을 전송하고, 응답받은 자료를 응답VO에 담아서 리턴한다.
@@ -104,8 +63,10 @@ public class DataApiTempXml implements DataApiInterface {
* @param method
* @return
*/
- public DataApiResVO send(DataApiReqVO reqVO, HttpMethod method) {
-
+ public DataApiResVO request(DataApiReqVO reqVO) {
+
+ log.debug("request > " + reqVO.getReqMethod());
+
DataApiResVO resVO = null;
try {
@@ -114,21 +75,20 @@ public class DataApiTempXml implements DataApiInterface {
//-----------------------------------
resVO = DataApiInterface.checkReqCommonParams(reqVO);
if(resVO != null) return resVO;
- if(method == null) return new DataApiResVO("ERR_NO_METHOD", "HTTP 요청 Method가 유효하지 않습니다.");
-
+ HttpMethod method = reqVO.getReqMethod();
+
//-----------------------------------
- // 폼 파라메터 생성 작업
+ // 폼 파라메터 생성 작업 (요청데이터 확인용)
//-----------------------------------
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
- MultiValueMap parameters = DataApiInterface.makeParamMap(reqVO);
- HttpEntity> requestEntity = new HttpEntity(parameters, headers);
+ MultiValueMap parameters = DataApiInterface.makeRequestParamMultiValueMap(reqVO);
//-----------------------------------
// 응답 처리
//-----------------------------------
HttpStatus statusCode = HttpStatus.OK;
- String resultXML = getTempDataFromXmlFile(reqVO, method);
+ String resultXML = getTempDataFromXmlFile(reqVO);
//log.debug("RES resultXML : " + resultXML);
// 응답 자료 객체화
@@ -136,16 +96,18 @@ public class DataApiTempXml implements DataApiInterface {
// 처리결과 코드 확인
if(StringUtil.isEmpty(resVO.getResultCode())) {
+ String resultMessage = resVO.getResultMessage();
if (statusCode == HttpStatus.OK) {
resVO.setResultCode("S_HTTP_STATUS_OK");
- resVO.setResultMessage("정상처리되었습니다.");
+ resVO.setResultMessage(StringUtil.isEmpty(resultMessage) ? "정상처리되었습니다." : resultMessage);
} else {
resVO.setResultCode("E_STATUS_CODE_FAIL");
- resVO.setResultMessage(String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()));
+ resVO.setResultMessage(StringUtil.isEmpty(resultMessage) ? String.format("처리에 실패하였습니다. (HTTP상태코드 : %s)", statusCode.toString()) : resultMessage);
}
}
- //log.debug("RES resVO : " + resVO);
+ log.debug("RES resVO : resultCode = " + resVO.getResultCode());
+ log.debug("RES resVO : resultMessage = " + resVO.getResultMessage());
} catch(Exception e) {
e.printStackTrace();
@@ -163,54 +125,55 @@ public class DataApiTempXml implements DataApiInterface {
* @return
* @throws Exception
*/
- private String getTempDataFromXmlFile(DataApiReqVO reqVO, HttpMethod method) throws Exception {
-
- String fileName = reqVO.getReqUrl().substring(1).replaceAll("/", ".");
- String xmlPath = DAPI_TEMP_XML_PATH + "/" + fileName + "_" + method.toString().toUpperCase() + ".xml";
- String returnXmlStr = null;
+ private String getTempDataFromXmlFile(DataApiReqVO reqVO) throws Exception {
+
+ HttpMethod method = reqVO.getReqMethod();
+ String fileName = reqVO.getReqUrl().substring(1).replaceAll("/", ".");
+ String xmlPath = DAPI_TEMP_XML_PATH + "/" + fileName + "_" + method.toString().toUpperCase() + ".xml";
+ String returnXmlStr = null;
+
+ log.info("XML FILE PATH : " + xmlPath);
+
+
+ DataApiServerResponseVO resVO = null;
+
+ File xmlFile = new File(xmlPath);
+ if(!xmlFile.exists()) {
+ resVO = new DataApiServerResponseVO("-20", String.format("%s 파일을 찾을 수 없습니다.",xmlPath));
+ XmlMapper mapper = new XmlMapper();
+ returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
+ }
+
+ if(resVO == null && !xmlFile.isFile()) {
+ resVO = new DataApiServerResponseVO("-21", String.format("%s는 파일이어야 합니다.",xmlPath));
+ XmlMapper mapper = new XmlMapper();
+ returnXmlStr = mapper.writer().withRootName(DataApiVO.XML_EL_NAME_ROOT_NAME).writeValueAsString(resVO);
+ }
+
+ if(resVO == null) {
+ StringBuilder strBd = new StringBuilder();
- log.info("XML FILE PATH : " + xmlPath);
-
-
- DataApiServerResponseVO resVO = null;
-
- File xmlFile = new File(xmlPath);
- if(!xmlFile.exists()) {
- resVO = new DataApiServerResponseVO("-20", String.format("%s 파일을 찾을 수 없습니다.",xmlPath));
- XmlMapper mapper = new XmlMapper();
- returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
- }
-
- if(resVO == null && !xmlFile.isFile()) {
- resVO = new DataApiServerResponseVO("-21", String.format("%s는 파일이어야 합니다.",xmlPath));
- XmlMapper mapper = new XmlMapper();
- returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
- }
-
- if(resVO == null) {
- StringBuilder strBd = new StringBuilder();
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(xmlPath),StandardCharsets.UTF_8))) {
- try (BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(xmlPath),StandardCharsets.UTF_8))) {
-
- String line;
- int i = 0;
- while ((line = br.readLine()) != null) {
- strBd.append(line + "\n");
- }
- returnXmlStr = strBd.toString();
- } catch (IOException e) {
- log.error("XML 파일 읽는 중 오류 발생 : " + e.toString());
- e.printStackTrace();
-
- resVO = new DataApiServerResponseVO("-22", String.format("%s 파일을 읽는 중 오류가 발생하였습니다(%s). ",xmlPath, e.toString()));
- XmlMapper mapper = new XmlMapper();
- returnXmlStr = mapper.writer().withRootName("result").writeValueAsString(resVO);
- }
+ String line;
+ int i = 0;
+ while ((line = br.readLine()) != null) {
+ strBd.append(line + "\n");
+ }
+ returnXmlStr = strBd.toString();
+ } catch (IOException e) {
+ log.error("XML 파일 읽는 중 오류 발생 : " + e.toString());
+ e.printStackTrace();
+ resVO = new DataApiServerResponseVO("-22", String.format("%s 파일을 읽는 중 오류가 발생하였습니다(%s). ",xmlPath, e.toString()));
+ XmlMapper mapper = new XmlMapper();
+ returnXmlStr = mapper.writer().withRootName(DataApiVO.XML_EL_NAME_ROOT_NAME).writeValueAsString(resVO);
}
- //log.info("RESUTN XML STR : " + returnXmlStr);
- return returnXmlStr;
+ }
+
+ //log.info("RESUTN XML STR : " + returnXmlStr);
+ return returnXmlStr;
}
}
diff --git a/src/main/java/nlib/sample/service/SampleDataApiService.java b/src/main/java/nlib/sample/service/SampleDataApiService.java
index 6be6c327..4cca94d2 100644
--- a/src/main/java/nlib/sample/service/SampleDataApiService.java
+++ b/src/main/java/nlib/sample/service/SampleDataApiService.java
@@ -29,4 +29,5 @@ public interface SampleDataApiService {
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception;
+ public DataApiResVO getItemInfo(DataApiReqVO reqVO) throws Exception;
}
diff --git a/src/main/java/nlib/sample/service/impl/SampleDataApiServiceImpl.java b/src/main/java/nlib/sample/service/impl/SampleDataApiServiceImpl.java
index 10d87081..25cb9642 100644
--- a/src/main/java/nlib/sample/service/impl/SampleDataApiServiceImpl.java
+++ b/src/main/java/nlib/sample/service/impl/SampleDataApiServiceImpl.java
@@ -4,6 +4,7 @@ import javax.annotation.Resource;
import org.springframework.stereotype.Service;
+import nlib.restful.DataApi;
import nlib.restful.service.DataApiReqVO;
import nlib.restful.service.DataApiResVO;
import nlib.sample.service.SampleDataApiService;
@@ -33,12 +34,15 @@ import nlib.sample.service.SampleDataApiService;
@Service("sampleDataApiService")
public class SampleDataApiServiceImpl implements SampleDataApiService {
- /** SampleDataApiDAO */
- @Resource(name = "sampleDataApiDAO")
- private SampleDataApiDAO sampleDataApiDAO;
+ /** RESTFul API 송수신 모듈 */
+ @Resource(name = "dataApi")
+ private DataApi dataApi;
public DataApiResVO getSampleInfo(DataApiReqVO reqVO) throws Exception {
- return sampleDataApiDAO.getSampleInfo(reqVO);
+ return dataApi.request(reqVO);
}
+ public DataApiResVO getItemInfo(DataApiReqVO reqVO) throws Exception {
+ return dataApi.request(reqVO);
+ }
}
diff --git a/src/main/java/nlib/sample/web/SampleDataApiController.java b/src/main/java/nlib/sample/web/SampleDataApiController.java
index 0a5c55f8..c3c0b38f 100644
--- a/src/main/java/nlib/sample/web/SampleDataApiController.java
+++ b/src/main/java/nlib/sample/web/SampleDataApiController.java
@@ -3,16 +3,22 @@ package nlib.sample.web;
import java.util.Map;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
+import nlib.cmm.NlibCommonController;
import nlib.restful.service.DataApiReqVO;
import nlib.restful.service.DataApiResVO;
+import nlib.restful.service.DataApiVO;
import nlib.sample.service.SampleDataApiService;
+import nlib.user.service.NlibLoginVO;
+import nlib.util.StringUtil;
/**
*
@@ -37,7 +43,7 @@ import nlib.sample.service.SampleDataApiService;
*
*/
@Controller
-public class SampleDataApiController {
+public class SampleDataApiController extends NlibCommonController {
/** SampleDataApiService */
@Resource(name = "sampleDataApiService")
@@ -80,4 +86,91 @@ public class SampleDataApiController {
return "nlib/sample/getSampleInfo";
}
+ @RequestMapping("/sample/getItemInfo.do")
+ public String getItemInfo(HttpServletRequest request, @RequestParam Map commandMap, ModelMap model) throws Exception {
+
+ String message = null;
+
+ DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/col/getItemInfo", HttpMethod.GET);
+
+ String mngOrgCd = commandMap.get("mngOrgCd");
+ String masterId = commandMap.get("masterId");
+ String typeDivCd = commandMap.get("typeDivCd");
+
+ if(StringUtil.isEmpty(mngOrgCd) || StringUtil.isEmpty(masterId) || StringUtil.isEmpty(typeDivCd)) {
+ message = "필수정보값이 입력되지 않았습니다.";
+ model.addAttribute("message", message);
+ return "nlib/sample/getItemInfo";
+ }
+
+ // 변수 설정
+ reqVO.putInfoItem("mngOrgCd", mngOrgCd);
+ reqVO.putInfoItem("masterId", masterId);
+ reqVO.putInfoItem("typeDivCd", typeDivCd);
+
+ // 사용자ID 설정
+ NlibLoginVO nlibLoginVO = getNlibLoginVO(request);
+ if(nlibLoginVO != null && !StringUtil.isEmpty(nlibLoginVO.getMbInfoId())) {
+ reqVO.setMbInfoId(nlibLoginVO.getMbInfoId());
+ }
+
+ // API 호출
+ DataApiResVO resVO = sampleDataApiService.getItemInfo(reqVO);
+
+ // 결과값 전달
+ model.addAttribute("resultCode", resVO.getResultCode());
+ model.addAttribute("resultMessage", resVO.getResultMessage());
+ model.addAttribute("info", resVO.getInfo());
+
+ // 참고 정보 : API 접속 서버 정보
+ model.addAttribute("serverProtocol", dataapiServerIp);
+ model.addAttribute("serverIp", dataapiServerPort);
+ model.addAttribute("serverPort", dataapiServerProtocol);
+
+ return "nlib/sample/getItemInfo";
+ }
+
+ @RequestMapping("/sample/listRentItem.do")
+ public String listRentItem(HttpServletRequest request, @RequestParam Map commandMap, ModelMap model) throws Exception {
+
+ String message = null;
+
+ DataApiReqVO reqVO = new DataApiReqVO("/uac/service/nlib/rent/listRentItem", HttpMethod.GET);
+
+ // 변수 설정
+ reqVO.putInfoItem("rows", getParamStr(commandMap, "rows", "10"));
+ reqVO.putInfoItem("page", getParamStr(commandMap, "rows", "1"));
+ reqVO.putInfoItem("mngOrgCd", getParamStr(commandMap, "mngOrgCd", "KCCF"));
+ reqVO.putInfoItem("mbInfoId", getParamStr(commandMap, "mbInfoId", "BDCCAF34CF8AA365C660ADB121CE6741"));
+
+ // 사용자ID 설정
+// NlibLoginVO nlibLoginVO = getNlibLoginVO(request);
+// if(nlibLoginVO != null && !StringUtil.isEmpty(nlibLoginVO.getMbInfoId())) {
+// reqVO.setMbInfoId(nlibLoginVO.getMbInfoId());
+// }
+
+ // API 호출
+ DataApiResVO resVO = sampleDataApiService.getItemInfo(reqVO);
+
+ // 입력 매개변수 전달
+ model.addAttribute("rows", resVO.getRecordTotCount());
+ model.addAttribute("page", resVO.getPageIndex());
+ model.addAttribute("mngOrgCd", resVO.getInfoItem("mngOrgCd"));
+ model.addAttribute("mbInfoId", resVO.getInfoItem("mbInfoId"));
+
+ // 결과값 전달
+ model.addAttribute("resultCode", resVO.getResultCode());
+ model.addAttribute("resultMessage", resVO.getResultMessage());
+ model.addAttribute("info", resVO.getInfo());
+ model.addAttribute("list", resVO.getList(DataApiVO.XML_EL_NAME_RECORD));
+
+ // 참고 정보 : API 접속 서버 정보
+ model.addAttribute("serverProtocol", dataapiServerIp);
+ model.addAttribute("serverIp", dataapiServerPort);
+ model.addAttribute("serverPort", dataapiServerProtocol);
+
+ return "nlib/sample/listRentItem";
+ }
+
+
}
diff --git a/src/main/java/nlib/security/SpringSecurityConfig.java b/src/main/java/nlib/security/SpringSecurityConfig.java
index 7859a0ed..61ea8099 100644
--- a/src/main/java/nlib/security/SpringSecurityConfig.java
+++ b/src/main/java/nlib/security/SpringSecurityConfig.java
@@ -77,10 +77,12 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {
.antMatchers("/rent/*.do").permitAll()
.antMatchers("/collection/*.do").permitAll()
.antMatchers("/sample/password/getSampleEncoder.do").permitAll()
+ .antMatchers("/sample/*.do").permitAll()
.antMatchers("/*/*Ajax.do").permitAll()
.antMatchers("/fileupload/**").permitAll()
.antMatchers("/board/**").permitAll()
.antMatchers("/inform/**").permitAll()
+ .antMatchers("/test/**").permitAll()
.antMatchers("/alert/**").permitAll()
.antMatchers("/code/**").permitAll()
.antMatchers("/homes/**").permitAll()
diff --git a/src/main/resources/nlib/nlib.properties b/src/main/resources/nlib/nlib.properties
index 601796ba..5bcc4653 100644
--- a/src/main/resources/nlib/nlib.properties
+++ b/src/main/resources/nlib/nlib.properties
@@ -54,11 +54,16 @@ nlib.council.dns.host = nlib
#dataapi.server.port = 80
#dataapi.server.protocol = http
-# \ub85c\uceec \uc11c\ubc84
-dataapi.server.ip = localhost
-dataapi.server.port = 8088
+# \uc784\uc2dc PC \uac1c\ubc1c \uc11c\ubc84
+dataapi.server.ip = 192.168.25.87
+dataapi.server.port = 8080
dataapi.server.protocol = http
+# \ub85c\uceec \uc11c\ubc84
+#dataapi.server.ip = localhost
+#dataapi.server.port = 8088
+#dataapi.server.protocol = http
+
# \ub85c\uceec \uac1c\ubc1c\uc6a9 XML \ud30c\uc77c \uc704\uce58
dataapi.temp.xml.path = C:/iams/workspace/nlib/data/dataxml
diff --git a/src/main/webapp/WEB-INF/tiles/inc/menu.jsp b/src/main/webapp/WEB-INF/tiles/inc/menu.jsp
index 7c0b11d0..b19a97fa 100644
--- a/src/main/webapp/WEB-INF/tiles/inc/menu.jsp
+++ b/src/main/webapp/WEB-INF/tiles/inc/menu.jsp
@@ -22,7 +22,7 @@
대출
예약
열람요청
- 관심자료
+ 관심자료
알림
@@ -31,6 +31,8 @@
암호화
프로퍼티갱신
코드조회
+ 자료상세조회:API샘플
+ 목록조회:API샘플