diff --git a/src/fr/devinsy/statoolinfos/crawl/Crawler.java b/src/fr/devinsy/statoolinfos/crawl/Crawler.java index bd30884..04959d4 100644 --- a/src/fr/devinsy/statoolinfos/crawl/Crawler.java +++ b/src/fr/devinsy/statoolinfos/crawl/Crawler.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Christian Pierre MOMON + * Copyright (C) 2020-2021 Christian Pierre MOMON * * This file is part of StatoolInfos, simple service statistics tool. * @@ -115,7 +115,7 @@ public class Crawler try { URL subUrl = new URL(property.getValue()); - crawl(subUrl, cache); + crawl(subUrl, cache, input.get("file.class")); } catch (java.net.MalformedURLException exception) { @@ -162,7 +162,7 @@ public class Crawler * @throws IOException * Signals that an I/O exception has occurred. */ - public static void crawl(final URL url, final CrawlCache cache) throws StatoolInfosException, IOException + public static void crawl(final URL url, final CrawlCache cache, final String parentFileClass) throws StatoolInfosException, IOException { logger.info("Crawling " + url); @@ -190,25 +190,33 @@ public class Crawler cache.storeQuietly(properties.getURL("service.logo")); // Crawl subs. - PathProperties subs = properties.getByPrefix("subs"); - for (PathProperty property : subs) + String fileClass = properties.get("file.class"); + if (StringUtils.equalsIgnoreCase(fileClass, parentFileClass)) { - if (StringUtils.isNotBlank(property.getValue())) + logger.warn("WARNING: file class same than parent for [{}]", url); + } + else + { + PathProperties subs = properties.getByPrefix("subs"); + for (PathProperty property : subs) { - try + if (StringUtils.isNotBlank(property.getValue())) { - URL subUrl = new URL(property.getValue()); - crawl(subUrl, cache); - } - catch (java.net.MalformedURLException exception) - { - logger.error("ERROR: subcrawl failed for [{}][{}][{}]: {}", url.toString(), property.getPath(), property.getValue(), exception.getMessage()); - exception.printStackTrace(); - } - catch (java.net.ConnectException | FileNotFoundException exception) - { - logger.error("ERROR: subcrawl failed for [{}][{}][{}]: {}", url.toString(), property.getPath(), property.getValue(), exception.getMessage()); - exception.printStackTrace(); + try + { + URL subUrl = new URL(property.getValue()); + crawl(subUrl, cache, fileClass); + } + catch (java.net.MalformedURLException exception) + { + logger.error("ERROR: subcrawl failed for [{}][{}][{}]: {}", url.toString(), property.getPath(), property.getValue(), exception.getMessage()); + exception.printStackTrace(); + } + catch (java.net.ConnectException | FileNotFoundException exception) + { + logger.error("ERROR: subcrawl failed for [{}][{}][{}]: {}", url.toString(), property.getPath(), property.getValue(), exception.getMessage()); + exception.printStackTrace(); + } } } }