diff --git a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java index 1db92a8..fc85bb5 100644 --- a/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java +++ b/src/fr/devinsy/statoolinfos/metrics/http/HttpAccessLogAnalyzer.java @@ -169,7 +169,7 @@ public class HttpAccessLogAnalyzer } // metrics.http.pages.* = - if (StringUtils.endsWithAny(log.getRequest(), ".html", ".htm", ".xhtml", ".cgi", "/")) + if ((isPage(log.getRequest())) && (log.getStatus().getCategory() == HttpStatusCategory.SUCCESS)) { this.counters.inc("metrics.http.pages", year, yearMonth, yearWeek, date); } @@ -214,6 +214,45 @@ public class HttpAccessLogAnalyzer } } + /** + * Checks if is page. + * + * @param request + * the request + * @return true, if is page + */ + public static boolean isPage(final String request) + { + boolean result; + + if (StringUtils.isBlank(request)) + { + result = false; + } + else + { + Pattern PAGE_PATTERN = Pattern.compile("^.* (?/[^ \\?]*)(\\?.*| .*)?$"); + + Matcher matcher = PAGE_PATTERN.matcher(request); + if (matcher.find()) + { + String path = matcher.group("path").toLowerCase(); + + result = path.matches("^.*(/|/[^/]*\\.html|/[^/]*\\.htm|/[^/]*\\.xhtml|/[^/]*\\.cgi|/[^/]*\\.php|/[^/\\.]*[a-z0-9])$"); + + // System.out.println(result + " [" + path + "] [" + request + + // "]"); + } + else + { + result = false; + } + } + + // + return result; + } + /** * Parses the log. *