From 52090b363719d8a02d2feb51efaab29784014c02 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Tue, 9 May 2023 10:30:36 +0200 Subject: [PATCH] Added multi sources for Http log file search. --- .../statoolinfos/core/Configuration.java | 31 +++++++++ .../devinsy/statoolinfos/util/FilesUtils.java | 65 ++++++++++++++++++- 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/Configuration.java b/src/fr/devinsy/statoolinfos/core/Configuration.java index 29dfa8e..c27a701 100644 --- a/src/fr/devinsy/statoolinfos/core/Configuration.java +++ b/src/fr/devinsy/statoolinfos/core/Configuration.java @@ -397,6 +397,37 @@ public class Configuration extends PathPropertyList return result; } + /** + * Gets the probe http access log sources. + * + * @param source + * the source + * @return the probe http access log sources + */ + public StringList getProbeHttpAccessLogSources() + { + StringList result; + + result = new StringList(); + String source = getProbeHttpAccessLogSource(); + + if (StringUtils.isNotBlank(source)) + { + String[] paths = source.split(","); + + for (String path : paths) + { + if (StringUtils.isNotBlank(path)) + { + result.add(StringUtils.trim(path)); + } + } + } + + // + return result; + } + /** * Gets the probe http error log source. * diff --git a/src/fr/devinsy/statoolinfos/util/FilesUtils.java b/src/fr/devinsy/statoolinfos/util/FilesUtils.java index 7ba8b39..cac5fd7 100644 --- a/src/fr/devinsy/statoolinfos/util/FilesUtils.java +++ b/src/fr/devinsy/statoolinfos/util/FilesUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020-2022 Christian Pierre MOMON + * Copyright (C) 2020-2023 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -23,6 +23,8 @@ import java.util.regex.Pattern; import org.apache.commons.lang3.StringUtils; +import fr.devinsy.strings.StringList; + /** * The Class FilesUtils. */ @@ -117,7 +119,11 @@ public class FilesUtils result = new Files(); - if (!StringUtils.isBlank(source)) + if (StringUtils.contains(source, ',')) + { + result.addAll(searchByWildcardFromMany(source)); + } + else if (StringUtils.isNotBlank(source)) { // Get the first parent without wildcard. File parent = null; @@ -156,6 +162,61 @@ public class FilesUtils return result; } + /** + * Search by wildcard. + * + * @param sources + * the sources + * @return the files + */ + public static Files searchByWildcard(final StringList sources) + { + Files result; + + result = new Files(); + + if (sources != null) + { + for (String source : sources) + { + result.addAll(searchByWildcard(source)); + } + } + + // + return result; + } + + /** + * Search by wildcard from many. + * + * @param source + * the source + * @return the files + */ + public static Files searchByWildcardFromMany(final String source) + { + Files result; + + result = new Files(); + + if (StringUtils.isNotBlank(source)) + { + String[] paths = source.split(","); + + for (String path : paths) + { + if (StringUtils.isNotBlank(path)) + { + result.addAll(searchByWildcard(StringUtils.trim(path))); + } + } + } + + // + return result; + } + /** * List recursively. *