| | |
| | | |
| | | public static boolean shouldExclude(HttpServletRequest request, HttpAuditProperties props) { |
| | | String path = safePath(request); |
| | | for (String p : props.getExcludePathPrefixes()) { |
| | | for (String p : props.getEffectiveExcludePrefixes()) { |
| | | if (p != null && !p.isEmpty() && path.startsWith(p)) { |
| | | return true; |
| | | } |
| | |
| | | } |
| | | return s.substring(0, maxChars) + "...(truncated,len=" + s.length() + ")"; |
| | | } |
| | | |
| | | /** maxChars<0 不截断 */ |
| | | public static String storeWithCharLimit(String s, int maxChars) { |
| | | if (s == null) { |
| | | return null; |
| | | } |
| | | if (maxChars < 0) { |
| | | return s; |
| | | } |
| | | return truncateForStore(s, maxChars); |
| | | } |
| | | |
| | | public static boolean overCharLimit(String s, int maxChars) { |
| | | return s != null && maxChars >= 0 && s.length() > maxChars; |
| | | } |
| | | |
| | | public static String truncateUriForStore(String uri, int maxLen) { |
| | | if (uri == null) { |
| | | return ""; |
| | | } |
| | | if (maxLen <= 0 || uri.length() <= maxLen) { |
| | | return uri; |
| | | } |
| | | return uri.substring(0, maxLen - 3) + "..."; |
| | | } |
| | | } |