diff --git a/src/main/java/cokr/xit/fims/framework/core/aop/LogAopAdvice.java b/src/main/java/cokr/xit/fims/framework/core/aop/LogAopAdvice.java deleted file mode 100644 index 58b5eb1c..00000000 --- a/src/main/java/cokr/xit/fims/framework/core/aop/LogAopAdvice.java +++ /dev/null @@ -1,196 +0,0 @@ -package cokr.xit.fims.framework.core.aop; - -import cokr.xit.fims.framework.support.mybatis.PagingConstants; -import cokr.xit.fims.framework.support.mybatis.paging.domain.Paginator; -import lombok.extern.slf4j.Slf4j; -import org.aspectj.lang.JoinPoint; -import org.aspectj.lang.ProceedingJoinPoint; -import org.aspectj.lang.annotation.AfterThrowing; -import org.aspectj.lang.annotation.Around; -import org.aspectj.lang.annotation.Aspect; -import org.aspectj.lang.annotation.Pointcut; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Component; -import org.springframework.ui.Model; -import org.springframework.web.context.request.RequestAttributes; -import org.springframework.web.context.request.RequestContextHolder; -import org.springframework.web.context.request.ServletRequestAttributes; -import org.springframework.web.servlet.ModelAndView; - -import javax.servlet.http.HttpServletRequest; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Slf4j -@Component -@Aspect -public class LogAopAdvice { - - - private boolean isRsltLog = true; - - @Pointcut("execution(public * cokr.xit..web.*.*(..))") - public void pointCut() {} - - // @Before("pointCut()") - // public void beforeProcess(JoinPoint joinPoint) { - // MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); - // Method method = methodSignature.getMethod(); - // Object[] objs = joinPoint.getArgs(); - // log.info("Start-{} ", methodSignature.getDeclaringTypeName() + "." + method.getName()); - // log.info("Request Param : {} ", objs); - // } - // - // @AfterReturning(value = "pointCut()", returning = "returnValue") - // public void afterReturning(JoinPoint joinPoint, Object returnValue) { - // MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature(); - // Method method = methodSignature.getMethod(); - // log.info("End-{} ", methodSignature.getDeclaringTypeName() + "." + method.getName()); - // log.info("Response Param : {} ", returnValue); - // } - - @Around("pointCut()") - public Object aroundProceed(ProceedingJoinPoint pjp) throws Throwable { - - //StopWatch sw = new StopWatch();// -// sw.start(methodName); - - // Parameter log - RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); - ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) requestAttributes; - HttpServletRequest request = servletRequestAttributes.getRequest(); - //Object[] args = pjp.getArgs(); - requestLog(request); - - //TODO 필요시 insert log - //logInsert(methodName, request, paraMap+""); - - Object rtnObj = pjp.proceed(); - //sw.stop(); - if(isRsltLog) { - StringBuilder sb = new StringBuilder(); - sb.append("//==============================Result====================================").append("\n"); - sb.append("Execution : ").append(pjp.getSignature()).append("\n"); - sb.append("return : ").append(rtnObj).append("\n"); - sb.append("=========================================================================//"); - log.debug(sb.toString()); - }else { - // log.info("실행시간 : {}", sw.getTotalTimeSeconds()); - } - Object pageObject = RequestContextHolder.getRequestAttributes().getAttribute(PagingConstants.Session.PAGE_INFO.getCode(), RequestAttributes.SCOPE_REQUEST); - if(pageObject != null && rtnObj != null){ - Paginator paginator = (Paginator)pageObject; - - log.debug("###################################{}",rtnObj.getClass()); - - //if(rtnObj instanceof Map){ - if(Map.class.isAssignableFrom(rtnObj.getClass())){ - Map map = (Map)rtnObj; - map.putAll(getPageInfoMap(paginator)); - return map; - - //}else if(rtnObj instanceof List){ - }else if(List.class.isAssignableFrom(rtnObj.getClass())){ - Map map = new HashMap(); - map.put("rows", rtnObj); - map.putAll(getPageInfoMap(paginator)); - return map; - - }else if(ModelAndView.class.isAssignableFrom(rtnObj.getClass())){ - ModelAndView mav = (ModelAndView)rtnObj; - ((Map)mav.getModelMap().get("data")).put("pagination", getPageInfoMap(paginator)); - return mav; - - }else if(Model.class.isAssignableFrom(rtnObj.getClass())){ - Model mav = (Model)rtnObj; - mav.addAttribute("pagination", getPageInfoMap(paginator)); - return mav; - - }else if(String.class.isAssignableFrom(rtnObj.getClass())){ - //String jsonObj = (String)rtnObj; - return rtnObj; - - }else{ - throw new IllegalArgumentException("Paging works Illegal argument type, must be : ModelAndView, Map, List:" + rtnObj.getClass()); - } - } - - //TODO update Log - //update(rtnObj); -// sw.stop(); -// log.info(sw.prettyPrint()); - - return rtnObj; - } - - @AfterThrowing(pointcut="execution(public * cokr.xit.fims.framework..*.*(..))||execution(public * cokr.xit.fims..*.*(..))", throwing="error") - public void afterThrowingProceed(JoinPoint jp, Throwable error) { - error.printStackTrace(); - log.error("@@@(THROWS) Method called: {}", jp.getSignature()); - if(jp.getArgs().length ==0 ) log.error("@@@@(THROWS) No arguments passed."); - for(Object arg:jp.getArgs()) log.error("@@@@(THROWS) Argument passed:{}", arg); - log.error("@@@(THORWS) getMessage: {}", error.getMessage()); - log.error("@@@(THORWS) getCause: {}", error.getCause()); - } - - private void requestLog(HttpServletRequest request) { - - if (log.isDebugEnabled()) { - String method = request.getMethod(); - StringBuilder sb = new StringBuilder("\n"); - sb.append("//=========================================================================\n"); - //sb.append("Ajax Call : " + "XMLHttpRequest".equals(request.getHeader(Globals.AJAX_HEADER))).append("\n"); - sb.append("URI : " + request.getRequestURI()).append("\n"); - sb.append("URL : " + request.getRequestURL()).append("\n"); - sb.append("IP : " + request.getRemoteAddr()).append("\n"); - sb.append("Referer URI : " + request.getHeader("referer")).append("\n"); - sb.append("Method : " + request.getMethod()).append("\n"); - sb.append("User Agent : " + request.getHeader("User-Agent")).append("\n"); - sb.append("Session : " + request.getSession().getId()).append("\n"); - sb.append("Locale : " + request.getLocale().getCountry()).append("\n"); - sb.append("ContentType : " + request.getContentType()).append("\n"); - - sb.append("----- Parameters ----- \n"); - - Enumeration e = request.getParameterNames(); - if (e.hasMoreElements()) { - String pName = ""; - String pValue = ""; - do { - pName = (String) e.nextElement(); - pValue = request.getParameter(pName); - sb.append(pName + ": " + pValue + "\n"); - } while (e.hasMoreElements()); - } else { - sb.append(" is Empty \n"); - } - sb.append("=========================================================================//"); - - log.debug(sb.toString()); - sb = null; - } - } - - private Map getPageInfoMap(Paginator paginator){ - Map map = new HashMap(); - map.put("totalPage", paginator.getTotalPages()); - map.put("totalSize", paginator.getTotalSize()); - map.put("pageNum", paginator.getPageNum()); -// -// // Query Data : Paging 정보만 set 하면 되므로 필요 없다 -// //map.put(FwConstants.DEFAULT_RESPONSE_BODY_DATA_NAME, new ArrayList(pageList)); -// map.put("startRow", paginator.getStartRow()); -// map.put("endRow", paginator.getEndRow()); -// map.put("offset", paginator.getOffset()); -// //map.put("slider", paginator.getSlider()); -// map.put("prePage", paginator.getPrePage()); -// map.put("nextPage", paginator.getNextPage()); -// map.put("firstPage", paginator.isFirstPage()); -// map.put("hasNextPage", paginator.isHasNextPage()); -// map.put("hasPrePage", paginator.isHasPrePage()); -// map.put("lastPage", paginator.isLastPage()); - return map; - } -} diff --git a/src/main/java/cokr/xit/fims/framework/core/aop/XitLoginLogAspect.java b/src/main/java/cokr/xit/fims/framework/core/aop/XitLoginLogAspect.java deleted file mode 100644 index bec278c3..00000000 --- a/src/main/java/cokr/xit/fims/framework/core/aop/XitLoginLogAspect.java +++ /dev/null @@ -1,119 +0,0 @@ -package cokr.xit.fims.framework.core.aop; - -import cokr.xit.fims.framework.biz.cmm.XitConectLogVO; -import cokr.xit.fims.framework.biz.cmm.XitLoginVO; -import cokr.xit.fims.framework.biz.cmm.service.XitFrameCrudService; -import org.springframework.context.support.ReloadableResourceBundleMessageSource; -import cokr.xit.fims.framework.core.utils.XitCmmnUtil; -import cokr.xit.fims.framework.core.utils.XitHttpRequestHelper; -import org.egovframe.rte.fdl.cmmn.exception.FdlException; - -import org.egovframe.rte.fdl.security.userdetails.util.EgovUserDetailsHelper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; - -/** - * - * @업무그룹명: 로그인 로그 관리 - * @설명: 사용자의 로그인/로그아웃 로그를 관리 한다. - * @최초작성일: 2020. 5. 6. 오후 4:32:05 - * @최초작성자: 박민규 - * @author (주)엑스아이티 개발팀 - * @since 2002. 2. 2. - * @version 1.0 Copyright(c) XIT All rights reserved. - */ -public class XitLoginLogAspect { - @Resource - private XitFrameCrudService xitFrameCrudService; - - - - - /** - *
메소드 설명: 사용자의 로그인 로그를 생성 한다. 
- * void 요청처리 후 응답객체 - * @author: 박민규 - * @date: 2020. 5. 6. - */ - public void addLogLogin() throws Throwable { - String uniqId = ""; - String ip = ""; - - /** - * 사용자의 인증 여부 확인 - */ - Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated(); - if(isAuthenticated) { - XitLoginVO user = (XitLoginVO)EgovUserDetailsHelper.getAuthenticatedUser(); - uniqId = user.getUniqId(); -// ip = user.getIp(); - HttpServletRequest request = XitHttpRequestHelper.getCurrentRequest(); - ip = XitCmmnUtil.getClientIpAddr(request); - } -// XitLoginVO user = XitCmmnUtil.getSession(req); -// uniqId = user.getUniqId(); -// ip = user.getIp(); - - /** - * 필수값 설정 - */ - XitConectLogVO vo = new XitConectLogVO(); - - vo.setLogId("nextstringid"); - - vo.setConectId(uniqId); - vo.setConectIp(ip); - vo.setConectMthd("I"); // 로그인:I, 로그아웃:O - vo.setErrorOccrrncYn("N"); - vo.setErrorCode(""); - - /** - * 처리 - */ - xitFrameCrudService.addXitConectLog(vo); - } - - /** - *
메소드 설명: 사용자의 로그아웃 로그를 생성 한다.
- * void 요청처리 후 응답객체 - * @author: 박민규 - * @date: 2020. 5. 6. - */ - public void addLogLogout() throws Throwable { - String uniqId = ""; - String ip = ""; - - /** - * 사용자의 인증 여부 확인 - */ - Boolean isAuthenticated = EgovUserDetailsHelper.isAuthenticated(); - if(isAuthenticated) { - XitLoginVO user = (XitLoginVO)EgovUserDetailsHelper.getAuthenticatedUser(); - uniqId = user.getUniqId(); -// ip = user.getIp(); - HttpServletRequest request = XitHttpRequestHelper.getCurrentRequest(); - ip = XitCmmnUtil.getClientIpAddr(request); - } - - /** - * 필수값 설정 - */ - XitConectLogVO vo = new XitConectLogVO(); - - vo.setLogId("nextstringid"); - - vo.setConectId(uniqId); - vo.setConectIp(ip); - vo.setConectMthd("O"); // 로그인:I, 로그아웃:O - vo.setErrorOccrrncYn("N"); - vo.setErrorCode(""); - - /** - * 처리 - */ - xitFrameCrudService.addXitConectLog(vo); - } -}