@Test public void test_V61標準() { String layout = LogLayoutDefinitions.getStandardTransitionLogLayout(Version.V61); layout = LogLayoutDefinitions.convertV6toV7(layout); TransitionLogParser parser = new TransitionLogParser(new ParserParameter(), layout); parser.setLogFile(new File("C:/test.log")); String logText = StringUtils.join(new String[] { "[2012-01-05 18:46:10,213]", "FORWARD", "0:0:0:0:0:0:0:1", "0:0:0:0:0:0:0:1", "system", "abccjNJunB67b7RyUqTst", "/system/security/common/page_requester.jssp", "367", "-", "-", "/system.admin" }, "\t"); TransitionLog log = parser.parse(logText); assertEquals("2012-01-05 18:46:10,213", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS").format(log.date)); assertEquals(TransitionType.FORWARD, log.type); assertEquals("0:0:0:0:0:0:0:1", log.requestRemoteAddress); assertEquals("0:0:0:0:0:0:0:1", log.requestRemoteHost); assertEquals("system", log.transitionAccessUserId); assertEquals("abccjNJunB67b7RyUqTst", log.clientSessionId); assertEquals("/system/security/common/page_requester.jssp", log.transitionPathPageNext); assertEquals(367L, log.transitionTimeResponse); assertEquals("-", log.transitionExceptionName); assertEquals("-", log.transitionExceptionMessage); assertEquals("/system.admin", log.transitionPathPagePrevious); }
public TransitionLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } TransitionLog log = new TransitionLog(); populate(lineMap, log); if (!isInRange(log) || !isTargetTenant(log)) { return null; } log.type = (TransitionType) lineMap.get(LogLayoutItemType.MDC_TRANSITION_LOG_TYPE_ID); log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.transitionAccessUserId = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_ACCESS_USER_ID); log.transitionPathPageNext = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_NEXT); log.transitionExceptionName = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_NAME); log.transitionExceptionMessage = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_MESSAGE); log.transitionPathPagePrevious = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_PREVIOUS); Long transitionTimeResponse = (Long) lineMap.get(LogLayoutItemType.MDC_TRANSITION_TIME_RESPONSE); if (transitionTimeResponse != null) { log.transitionTimeResponse = transitionTimeResponse; } return log; }
TransitionLogParser extends LineLogParser implements LogParser<TransitionLog> { public TransitionLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } TransitionLog log = new TransitionLog(); populate(lineMap, log); if (!isInRange(log) || !isTargetTenant(log)) { return null; } log.type = (TransitionType) lineMap.get(LogLayoutItemType.MDC_TRANSITION_LOG_TYPE_ID); log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.transitionAccessUserId = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_ACCESS_USER_ID); log.transitionPathPageNext = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_NEXT); log.transitionExceptionName = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_NAME); log.transitionExceptionMessage = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_MESSAGE); log.transitionPathPagePrevious = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_PREVIOUS); Long transitionTimeResponse = (Long) lineMap.get(LogLayoutItemType.MDC_TRANSITION_TIME_RESPONSE); if (transitionTimeResponse != null) { log.transitionTimeResponse = transitionTimeResponse; } return log; } }
TransitionLogParser extends LineLogParser implements LogParser<TransitionLog> { public TransitionLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } TransitionLog log = new TransitionLog(); populate(lineMap, log); if (!isInRange(log) || !isTargetTenant(log)) { return null; } log.type = (TransitionType) lineMap.get(LogLayoutItemType.MDC_TRANSITION_LOG_TYPE_ID); log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.transitionAccessUserId = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_ACCESS_USER_ID); log.transitionPathPageNext = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_NEXT); log.transitionExceptionName = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_NAME); log.transitionExceptionMessage = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_MESSAGE); log.transitionPathPagePrevious = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_PREVIOUS); Long transitionTimeResponse = (Long) lineMap.get(LogLayoutItemType.MDC_TRANSITION_TIME_RESPONSE); if (transitionTimeResponse != null) { log.transitionTimeResponse = transitionTimeResponse; } return log; } TransitionLogParser(ParserParameter parameter, String layout); }
TransitionLogParser extends LineLogParser implements LogParser<TransitionLog> { public TransitionLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } TransitionLog log = new TransitionLog(); populate(lineMap, log); if (!isInRange(log) || !isTargetTenant(log)) { return null; } log.type = (TransitionType) lineMap.get(LogLayoutItemType.MDC_TRANSITION_LOG_TYPE_ID); log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.transitionAccessUserId = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_ACCESS_USER_ID); log.transitionPathPageNext = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_NEXT); log.transitionExceptionName = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_NAME); log.transitionExceptionMessage = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_MESSAGE); log.transitionPathPagePrevious = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_PREVIOUS); Long transitionTimeResponse = (Long) lineMap.get(LogLayoutItemType.MDC_TRANSITION_TIME_RESPONSE); if (transitionTimeResponse != null) { log.transitionTimeResponse = transitionTimeResponse; } return log; } TransitionLogParser(ParserParameter parameter, String layout); TransitionLog parse(String line); }
TransitionLogParser extends LineLogParser implements LogParser<TransitionLog> { public TransitionLog parse(String line) { Map<LogLayoutItemType, Object> lineMap = parseLine(line); if (lineMap == null) { return null; } TransitionLog log = new TransitionLog(); populate(lineMap, log); if (!isInRange(log) || !isTargetTenant(log)) { return null; } log.type = (TransitionType) lineMap.get(LogLayoutItemType.MDC_TRANSITION_LOG_TYPE_ID); log.requestRemoteHost = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_HOST); log.requestRemoteAddress = (String) lineMap.get(LogLayoutItemType.MDC_REQUEST_REMOTE_ADDRESS); log.transitionAccessUserId = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_ACCESS_USER_ID); log.transitionPathPageNext = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_NEXT); log.transitionExceptionName = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_NAME); log.transitionExceptionMessage = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_EXCEPTION_MESSAGE); log.transitionPathPagePrevious = (String) lineMap.get(LogLayoutItemType.MDC_TRANSITION_PATH_PAGE_PREVIOUS); Long transitionTimeResponse = (Long) lineMap.get(LogLayoutItemType.MDC_TRANSITION_TIME_RESPONSE); if (transitionTimeResponse != null) { log.transitionTimeResponse = transitionTimeResponse; } return log; } TransitionLogParser(ParserParameter parameter, String layout); TransitionLog parse(String line);  }