From a9688259ebaf924a8ea2da6df17e63928392281f Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Wed, 16 Jun 2021 01:33:43 +0200 Subject: [PATCH] Refactored property check and alerts page. --- .../htmlize/FederationHeaderView.java | 4 +- .../statoolinfos/htmlize/FederationPage.java | 4 - .../htmlize/FederationPropertyAlertPage.java | 154 ++++++++++++++++++ ....java => FederationPropertyCheckPage.java} | 10 +- .../statoolinfos/htmlize/Htmlizer.java | 13 +- .../htmlize/OrganizationHeaderView.java | 4 +- .../htmlize/OrganizationPage.java | 3 +- .../OrganizationPropertyAlertPage.java | 99 +++++++++++ ...ava => OrganizationPropertyCheckPage.java} | 10 +- .../htmlize/PropertiesFilesPage.java | 6 +- ...sCheckPage.java => PropertyAlertPage.java} | 6 +- .../htmlize/PropertyAlertView.java | 139 ++++++++++++++++ ...eCheckView.java => PropertyCheckView.java} | 14 +- .../htmlize/ServiceHeaderView.java | 7 +- .../statoolinfos/htmlize/ServicePage.java | 2 - .../htmlize/ServicePropertyAlertPage.java | 146 +++++++++++++++++ ...age.java => ServicePropertyCheckPage.java} | 18 +- .../htmlize/federationHeaderView.xhtml | 2 +- .../htmlize/federationPropertyAlertView.xhtml | 24 +++ ...lesCheck.xhtml => propertyAlertView.xhtml} | 9 +- ...ileCheck.xhtml => propertyCheckView.xhtml} | 0 21 files changed, 611 insertions(+), 63 deletions(-) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/FederationPropertyAlertPage.java rename src/fr/devinsy/statoolinfos/htmlize/{FederationPropertyFileCheckPage.java => FederationPropertyCheckPage.java} (91%) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyAlertPage.java rename src/fr/devinsy/statoolinfos/htmlize/{OrganizationPropertyFileCheckPage.java => OrganizationPropertyCheckPage.java} (91%) rename src/fr/devinsy/statoolinfos/htmlize/{PropertyFilesCheckPage.java => PropertyAlertPage.java} (97%) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/PropertyAlertView.java rename src/fr/devinsy/statoolinfos/htmlize/{PropertyFileCheckView.java => PropertyCheckView.java} (95%) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/ServicePropertyAlertPage.java rename src/fr/devinsy/statoolinfos/htmlize/{ServicePropertyFileCheckPage.java => ServicePropertyCheckPage.java} (90%) create mode 100644 src/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml rename src/fr/devinsy/statoolinfos/htmlize/{propertyFilesCheck.xhtml => propertyAlertView.xhtml} (75%) rename src/fr/devinsy/statoolinfos/htmlize/{propertyFileCheck.xhtml => propertyCheckView.xhtml} (100%) diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java index 62d10b5..652ce9c 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java @@ -73,7 +73,7 @@ public class FederationHeaderView data.setAttribute("subsLink", "href", "index.xhtml"); data.setAttribute("rawLink", "href", federation.getTechnicalName() + ".properties"); - data.setAttribute("rawCheckLink", "href", federation.getTechnicalName() + "-check.xhtml"); + data.setAttribute("propertyCheckLink", "href", federation.getTechnicalName() + "-propertycheck.xhtml"); data.setAttribute("statsLink", "href", federation.getTechnicalName() + "-stats.xhtml"); data.setAttribute("metricsLink", "href", federation.getTechnicalName() + "-metrics-summary-months-last.xhtml"); @@ -105,7 +105,7 @@ public class FederationHeaderView data.setContent("warningCount", checks.getWarningCount()); data.setContent("voidCount", checks.getVoidCount()); - data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-checkalerts.xhtml"); + data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-propertyalerts.xhtml"); } if (federation.getLegalURL() != null) diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java index 0b0d3fe..2215659 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java @@ -71,10 +71,6 @@ public class FederationPage String page = htmlize(federation); FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8); - // - page = PropertyFilesCheckPage.htmlize(federation.getName(), federation.getInputChecksAll().getAlertLines()); - FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8); - // logger.info("Htmlize federation metric pages: {}.", federation.getName()); for (ViewMenu view : ViewMenu.values()) diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyAlertPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyAlertPage.java new file mode 100644 index 0000000..0f874de --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyAlertPage.java @@ -0,0 +1,154 @@ +/* + * Copyright (C) 2020-2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.HtmlizerContext; +import fr.devinsy.statoolinfos.checker.PropertyChecks; +import fr.devinsy.statoolinfos.core.Federation; +import fr.devinsy.statoolinfos.core.Organization; +import fr.devinsy.statoolinfos.core.Service; +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; + +/** + * The Class FederationPropertyCheckAlertPage. + */ +public class FederationPropertyAlertPage +{ + private static Logger logger = LoggerFactory.getLogger(FederationPropertyAlertPage.class); + + public enum PropertyAlertScope + { + ALL, + FEDERATION, + ORGANIZATIONS, + SERVICES, + METRICS + } + + /** + * Builds the all. + * + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws StatoolInfosException + * the statool infos exception + */ + public static void buildAll() throws IOException, StatoolInfosException + { + Federation federation = HtmlizerContext.instance().getFederation(); + File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); + + String page = htmlize(PropertyAlertScope.ALL); + FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8); + + page = htmlize(PropertyAlertScope.FEDERATION); + FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-federation.xhtml"), page, StandardCharsets.UTF_8); + + page = htmlize(PropertyAlertScope.ORGANIZATIONS); + FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-organizations.xhtml"), page, StandardCharsets.UTF_8); + + page = htmlize(PropertyAlertScope.SERVICES); + FileUtils.write(new File(htmlizeDirectory, federation.getLocalFileBaseName() + "-propertyalerts-services.xhtml"), page, StandardCharsets.UTF_8); + } + + /** + * Htmlize. + * + * @param federation + * the federation + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final PropertyAlertScope scope) throws StatoolInfosException + { + String result; + + try + { + Federation federation = HtmlizerContext.instance().getFederation(); + + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", FederationHeaderView.htmlize(federation)); + // TODO submenu + data.setAttribute("allButton", "href", federation.getLocalFileBaseName() + "-propertyalerts.xhtml"); + data.setAttribute("federationButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-federation.xhtml"); + data.setAttribute("organizationButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-organizations.xhtml"); + data.setAttribute("serviceButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-services.xhtml"); + data.setAttribute("metricsButton", "href", federation.getLocalFileBaseName() + "-propertyalerts-metrics.xhtml"); + + PropertyChecks checks; + if (scope == PropertyAlertScope.ALL) + { + checks = federation.getInputChecksAll().getAlertLines(); + } + else if (scope == PropertyAlertScope.FEDERATION) + { + checks = federation.getInputChecks().getAlertLines(); + } + else if (scope == PropertyAlertScope.ORGANIZATIONS) + { + checks = new PropertyChecks(); + for (Organization organization : federation.getOrganizations()) + { + checks.addAll(organization.getInputChecks().getAlertLines()); + } + } + else if (scope == PropertyAlertScope.SERVICES) + { + checks = new PropertyChecks(); + for (Service service : federation.getServicesAll()) + { + checks.addAll(service.getInputChecksAll().getAlertLines()); + } + } + else + { + checks = new PropertyChecks(); + } + data.setContent("contentView", PropertyAlertView.htmlize(checks)); + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add("Propriétés en alertes", federation.getLocalFileBaseName() + "-propertyalerts.xhtml"); + + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building federation property file check alert page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyCheckPage.java similarity index 91% rename from src/fr/devinsy/statoolinfos/htmlize/FederationPropertyFileCheckPage.java rename to src/fr/devinsy/statoolinfos/htmlize/FederationPropertyCheckPage.java index 2bc0052..d458a26 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyFileCheckPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPropertyCheckPage.java @@ -36,9 +36,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils; /** * The Class PropertyFileCheckPage. */ -public class FederationPropertyFileCheckPage +public class FederationPropertyCheckPage { - private static Logger logger = LoggerFactory.getLogger(FederationPropertyFileCheckPage.class); + private static Logger logger = LoggerFactory.getLogger(FederationPropertyCheckPage.class); /** * Builds the. @@ -54,7 +54,7 @@ public class FederationPropertyFileCheckPage File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); String page = htmlize(federation); - FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, federation.getTechnicalName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8); } /** @@ -75,12 +75,12 @@ public class FederationPropertyFileCheckPage TagDataManager data = new TagDataManager(); data.setContent("headerView", FederationHeaderView.htmlize(federation)); - data.setContent("contentView", PropertyFileCheckView.htmlize(federation.getInputChecks())); + data.setContent("contentView", PropertyCheckView.htmlize(federation.getInputChecks())); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); BreadcrumbTrail trail = new BreadcrumbTrail(); - trail.add("Propriétés", federation.getLocalFileBaseName() + "-check.xhtml"); + trail.add("Propriétés", federation.getLocalFileBaseName() + "-propertycheck.xhtml"); result = WebCharterView.build(content, trail); } catch (XidynException exception) diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index 4de74b8..e783bd7 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -163,24 +163,27 @@ public class Htmlizer EditoPage.build(); ExportsPage.build(); FederationPage.build(); - FederationStatsPage.build(); FederationCrawlJournalPage.build(); + FederationPropertyCheckPage.build(); + FederationPropertyAlertPage.buildAll(); + FederationStatsPage.build(); FederationUptimePage.build(); - FederationPropertyFileCheckPage.build(); OrganizationPage.buildAll(); OrganizationCrawlJournalPage.buildAll(); OrganizationUptimePage.buildAll(); - OrganizationPropertyFileCheckPage.buildAll(); + OrganizationPropertyCheckPage.buildAll(); + OrganizationPropertyAlertPage.buildAll(); PropertiesFilesPage.build(); PropertyStatsPage.buildAll(); ServicePage.buildAll(); ServiceCrawlJournalPage.buildAll(); + ServicePropertyCheckPage.buildAll(); + ServicePropertyAlertPage.buildAll(); ServiceUptimePage.buildAll(); - ServicePropertyFileCheckPage.buildAll(); ServicesPage.build(); SoftwaresPage.build(); SoftwarePage.buildAll(); SocialNetworksPage.buildAll(); - PropertyFileCheckView.buildAll(); + // PropertyCheckView.buildAll(); } } diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java index 90bca5e..aeb4879 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java @@ -98,7 +98,7 @@ public class OrganizationHeaderView data.setAttribute("subsLink", "href", organization.getTechnicalName() + ".xhtml"); data.setAttribute("rawLink", "href", organization.getTechnicalName() + ".properties"); - data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-check.xhtml"); + data.setAttribute("rawCheckLink", "href", organization.getTechnicalName() + "-propertycheck.xhtml"); data.setAttribute("statsLink", "href", organization.getTechnicalName() + "-stats.xhtml"); data.setAttribute("metricsLink", "href", organization.getTechnicalName() + "-metrics-summary-months-last.xhtml"); @@ -130,7 +130,7 @@ public class OrganizationHeaderView data.setContent("warningCount", checks.getWarningCount()); data.setContent("voidCount", checks.getVoidCount()); - data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-checkalerts.xhtml"); + data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-propertyalerts.xhtml"); } if (organization.getLegalURL() != null) diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index 8afdc54..ce9b6b7 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -71,8 +71,7 @@ public class OrganizationPage FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); // - page = PropertyFilesCheckPage.htmlize(organization.getName(), organization.getInputChecksAll().getAlertLines()); - FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-checkalerts.xhtml"), page, StandardCharsets.UTF_8); + OrganizationPropertyAlertPage.buildAll(); // logger.info("Htmlize organization general stats page: {}.", organization.getName()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyAlertPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyAlertPage.java new file mode 100644 index 0000000..bd5c79c --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyAlertPage.java @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2020-2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.HtmlizerContext; +import fr.devinsy.statoolinfos.core.Federation; +import fr.devinsy.statoolinfos.core.Organization; +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; + +/** + * The Class OrganizationPropertyFileAlertPage. + */ +public class OrganizationPropertyAlertPage +{ + private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyAlertPage.class); + + /** + * Builds the all 1. + * + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws StatoolInfosException + * the statool infos exception + */ + public static void buildAll() throws IOException, StatoolInfosException + { + Federation federation = HtmlizerContext.instance().getFederation(); + File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); + + for (Organization organization : federation.getOrganizations()) + { + String page = htmlize(organization); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8); + } + } + + /** + * Htmlize. + * + * @param organization + * the organization + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Organization organization) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); + data.setContent("contentView", PropertyAlertView.htmlize(organization.getInputChecksAll().getAlertLines())); + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); + trail.add("Propriétés en alertes", organization.getLocalFileBaseName() + "-propertyalerts.xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building organization property check alert page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyCheckPage.java similarity index 91% rename from src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyFileCheckPage.java rename to src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyCheckPage.java index 9e567ad..73e9bd7 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyFileCheckPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPropertyCheckPage.java @@ -37,9 +37,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils; /** * The Class OrganizationPropertyFileCheckView. */ -public class OrganizationPropertyFileCheckPage +public class OrganizationPropertyCheckPage { - private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyFileCheckPage.class); + private static Logger logger = LoggerFactory.getLogger(OrganizationPropertyCheckPage.class); /** * Builds the all 1. @@ -57,7 +57,7 @@ public class OrganizationPropertyFileCheckPage for (Organization organization : federation.getOrganizations()) { String page = htmlize(organization); - FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, organization.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8); } } @@ -79,13 +79,13 @@ public class OrganizationPropertyFileCheckPage TagDataManager data = new TagDataManager(); data.setContent("headerView", OrganizationHeaderView.htmlize(organization)); - data.setContent("contentView", PropertyFileCheckView.htmlize(organization.getInputChecks())); + data.setContent("contentView", PropertyCheckView.htmlize(organization.getInputChecks())); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add(organization.getName(), organization.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés", organization.getLocalFileBaseName() + "-check.xhtml"); + trail.add("Propriétés", organization.getLocalFileBaseName() + "-propertycheck.xhtml"); result = WebCharterView.build(content, trail); } catch (XidynException exception) diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java index f9459a2..28b3cbe 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertiesFilesPage.java @@ -111,7 +111,7 @@ public class PropertiesFilesPage if (stat.getWarningCount() > 0) { - data.setAttribute("fileListLine", index, "fileListLineWarningCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); + data.setAttribute("fileListLine", index, "fileListLineWarningCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml")); data.setContent("fileListLine", index, "fileListLineWarningCountLink", stat.getWarningCount()); data.setAttribute("fileListLine", index, "fileListLineWarningCount", "style", "background-color: yellow;"); } @@ -122,7 +122,7 @@ public class PropertiesFilesPage if (stat.getErrorCount() > 0) { - data.setAttribute("fileListLine", index, "fileListLineErrorCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); + data.setAttribute("fileListLine", index, "fileListLineErrorCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml")); data.setContent("fileListLine", index, "fileListLineErrorCountLink", stat.getErrorCount()); data.setAttribute("fileListLine", index, "fileListLineErrorCount", "style", "background-color: red;"); } @@ -133,7 +133,7 @@ public class PropertiesFilesPage if (stat.getVoidCount() > 0) { - data.setAttribute("fileListLine", index, "fileListLineVoidCountLink", "href", stat.getLocalName().replace(".properties", "-check.xhtml")); + data.setAttribute("fileListLine", index, "fileListLineVoidCountLink", "href", stat.getLocalName().replace(".properties", "-propertycheck.xhtml")); data.setContent("fileListLine", index, "fileListLineVoidCountLink", stat.getVoidCount()); data.setAttribute("fileListLine", index, "fileListLineVoidCount", "style", "background-color: rgb(54, 162, 235, 0.2);"); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyFilesCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertPage.java similarity index 97% rename from src/fr/devinsy/statoolinfos/htmlize/PropertyFilesCheckPage.java rename to src/fr/devinsy/statoolinfos/htmlize/PropertyAlertPage.java index e57a9b1..30f2e3f 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyFilesCheckPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertPage.java @@ -32,9 +32,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils; /** * The Class PropertyFileCheckPage. */ -public class PropertyFilesCheckPage +public class PropertyAlertPage { - private static Logger logger = LoggerFactory.getLogger(PropertyFilesCheckPage.class); + private static Logger logger = LoggerFactory.getLogger(PropertyAlertPage.class); /** * Builds the. @@ -87,7 +87,7 @@ public class PropertyFilesCheckPage } // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyCheck.xhtml", data).toString(); BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add("Propriétés", "propertyStats.xhtml"); diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertView.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertView.java new file mode 100644 index 0000000..c7bc385 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyAlertView.java @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2020-2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.checker.PropertyCheck; +import fr.devinsy.statoolinfos.checker.PropertyChecks; +import fr.devinsy.statoolinfos.core.Service.Status; +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; +import fr.devinsy.xidyn.utils.XidynUtils; + +/** + * The Class PropertyFileAlertView. + */ +public class PropertyAlertView +{ + private static Logger logger = LoggerFactory.getLogger(PropertyAlertView.class); + + /** + * Builds the. + * + * @param title + * the title + * @param checks + * the checks + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final PropertyChecks checks) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("lineCount", checks.size()); + data.setContent("errorCount", checks.getErrorCount()); + data.setContent("warningCount", checks.getWarningCount()); + data.setContent("voidCount", checks.getVoidCount()); + + // + int index = 0; + if (checks.isEmpty()) + { + data.setAttribute("blockTable", "class", "xid:nodisplay"); + } + else + { + for (PropertyCheck check : checks) + { + // + data.setEscapedContent("line", index, "lineFileName", check.getFileName()); + data.setContent("line", index, "lineIndex", check.getIndex()); + data.setEscapedContent("line", index, "lineComment", check.getComment()); + data.setEscapedContent("line", index, "lineContent", check.getLine()); + data.setAttribute("line", index, "lineContent", "class", statusToCSS(check.getStatus())); + + index += 1; + } + } + + // + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyAlertView.xhtml", data).toString(); + result = XidynUtils.extractBodyContent(content); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building property file alert view: " + exception.getMessage(), exception); + } + + // + return result; + } + + /** + * Status to CSS. + * + * @param status + * the status + * @return the string + */ + public static String statusToCSS(final Status status) + { + String result; + + switch (status) + { + case OK: + result = "bg_ok"; + break; + + case WARNING: + result = "bg_warning"; + break; + + case ALERT: + result = "bg_alert"; + break; + + case ERROR: + result = "bg_error"; + break; + + case OVER: + result = "bg_over"; + break; + + case VOID: + default: + result = "bg_void"; + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckView.java b/src/fr/devinsy/statoolinfos/htmlize/PropertyCheckView.java similarity index 95% rename from src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckView.java rename to src/fr/devinsy/statoolinfos/htmlize/PropertyCheckView.java index 3e12cbe..3ebaa4c 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/PropertyFileCheckView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/PropertyCheckView.java @@ -43,9 +43,9 @@ import fr.devinsy.xidyn.utils.XidynUtils; /** * The Class PropertyFileCheckView. */ -public class PropertyFileCheckView +public class PropertyCheckView { - private static Logger logger = LoggerFactory.getLogger(PropertyFileCheckView.class); + private static Logger logger = LoggerFactory.getLogger(PropertyCheckView.class); /** * Builds the all. @@ -99,16 +99,16 @@ public class PropertyFileCheckView } // - String page = PropertyFilesCheckPage.htmlize("Tous", allAlertChecks); + String page = PropertyAlertPage.htmlize("Tous", allAlertChecks); FileUtils.write(new File(htmlizeDirectory, "alertChecks.xhtml"), page, StandardCharsets.UTF_8); - page = PropertyFilesCheckPage.htmlize("Fédération", federationAlertChecks); + page = PropertyAlertPage.htmlize("Fédération", federationAlertChecks); FileUtils.write(new File(htmlizeDirectory, "alertChecks-federation.xhtml"), page, StandardCharsets.UTF_8); - page = PropertyFilesCheckPage.htmlize("Membres", organizationAlertChecks); + page = PropertyAlertPage.htmlize("Membres", organizationAlertChecks); FileUtils.write(new File(htmlizeDirectory, "alertChecks-organizations.xhtml"), page, StandardCharsets.UTF_8); - page = PropertyFilesCheckPage.htmlize("Services", serviceAlertChecks); + page = PropertyAlertPage.htmlize("Services", serviceAlertChecks); FileUtils.write(new File(htmlizeDirectory, "alertChecks-services.xhtml"), page, StandardCharsets.UTF_8); } @@ -197,7 +197,7 @@ public class PropertyFileCheckView } // - String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml", data).toString(); + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/propertyCheckView.xhtml", data).toString(); result = XidynUtils.extractBodyContent(content); } catch (XidynException exception) diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java index d39c742..05a1dde 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java @@ -55,8 +55,6 @@ public class ServiceHeaderView try { - logger.debug("htmlizing service header page {}…", service.get("service.name")); - TagDataManager data = new TagDataManager(); data.setAttribute("serviceLogo", "src", service.getLogoFileName()); @@ -87,7 +85,7 @@ public class ServiceHeaderView data.setAttribute("serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString())); data.setAttribute("rawLink", "href", service.getLocalFileBaseName() + ".properties"); - data.setAttribute("rawCheckLink", "href", service.getLocalFileBaseName() + "-check.xhtml"); + data.setAttribute("rawCheckLink", "href", service.getLocalFileBaseName() + "-propertycheck.xhtml"); data.setAttribute("statsLink", "href", service.getLocalFileBaseName() + ".xhtml"); data.setAttribute("metricsLink", "href", service.getLocalFileBaseName() + "-metrics-summary-months-last.xhtml"); @@ -201,12 +199,11 @@ public class ServiceHeaderView data.setContent("warningCount", checks.getWarningCount()); data.setContent("voidCount", checks.getVoidCount()); - data.setAttribute("alertLink", "href", service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + "-check.xhtml#alerts"); + data.setAttribute("alertLink", "href", service.getLocalFileBaseName() + "-propertyalerts.xhtml"); } // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceHeaderView.xhtml", data).toString(); - result = XidynUtils.extractBodyContent(content); } catch (XidynException exception) diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java index b5dc908..c28b2bb 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java @@ -167,8 +167,6 @@ public class ServicePage */ private static void htmlizeServiceLogo(final Service service, final CrawlCache cache, final File htmlizeDirectory) throws IOException { - logger.info("Htmlize organization logo."); - File target = new File(htmlizeDirectory, service.getLogoFileName()); File logoFile = cache.restoreFile(service.getLogoURL()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyAlertPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyAlertPage.java new file mode 100644 index 0000000..03ce2f3 --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyAlertPage.java @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2020-2021 Christian Pierre MOMON + * + * This file is part of StatoolInfos, simple service statistics tool. + * + * StatoolInfos is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * StatoolInfos is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with StatoolInfos. If not, see . + */ +package fr.devinsy.statoolinfos.htmlize; + +import java.io.File; +import java.io.IOException; +import java.nio.charset.StandardCharsets; + +import org.apache.commons.io.FileUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import fr.devinsy.statoolinfos.HtmlizerContext; +import fr.devinsy.statoolinfos.core.Federation; +import fr.devinsy.statoolinfos.core.Metrics; +import fr.devinsy.statoolinfos.core.Service; +import fr.devinsy.statoolinfos.core.StatoolInfosException; +import fr.devinsy.xidyn.XidynException; +import fr.devinsy.xidyn.data.TagDataManager; +import fr.devinsy.xidyn.presenters.PresenterUtils; + +/** + * The Class ServicePropertyCheckAlertPage. + */ +public class ServicePropertyAlertPage +{ + private static Logger logger = LoggerFactory.getLogger(ServicePropertyAlertPage.class); + + /** + * Builds the all. + * + * @throws IOException + * Signals that an I/O exception has occurred. + * @throws StatoolInfosException + * the statool infos exception + */ + public static void buildAll() throws IOException, StatoolInfosException + { + Federation federation = HtmlizerContext.instance().getFederation(); + File htmlizeDirectory = HtmlizerContext.instance().getHtmlizeDirectory(); + + for (Service service : federation.getServicesAll()) + { + String page = htmlize(service); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8); + + for (Metrics metrics : service.getMetrics()) + { + page = htmlize(service, metrics); + FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-propertyalerts.xhtml"), page, StandardCharsets.UTF_8); + } + } + } + + /** + * Htmlize. + * + * @param service + * the service + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Service service) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", ServiceHeaderView.htmlize(service)); + data.setContent("contentView", PropertyAlertView.htmlize(service.getInputChecksAll().getAlertLines())); + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); + trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); + trail.add("Propriétés en alertes", service.getLocalFileBaseName() + "-propertyalerts.xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building service property file alert page: " + exception.getMessage(), exception); + } + + // + return result; + } + + /** + * Htmlize. + * + * @param service + * the service + * @param metrics + * the metrics + * @return the string + * @throws StatoolInfosException + * the statool infos exception + */ + public static String htmlize(final Service service, final Metrics metrics) throws StatoolInfosException + { + String result; + + try + { + TagDataManager data = new TagDataManager(); + + data.setContent("headerView", ServiceHeaderView.htmlize(service)); + data.setContent("contentView", PropertyAlertView.htmlize(metrics.getInputChecks().getAlertLines())); + + String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); + + BreadcrumbTrail trail = new BreadcrumbTrail(); + trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); + trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); + trail.add("Propriétés en alertes", service.getLocalFileBaseName() + "-propertyalerts.xhtml"); + result = WebCharterView.build(content, trail); + } + catch (XidynException exception) + { + throw new StatoolInfosException("Error building metrics property file check alert page: " + exception.getMessage(), exception); + } + + // + return result; + } +} diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyFileCheckPage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyCheckPage.java similarity index 90% rename from src/fr/devinsy/statoolinfos/htmlize/ServicePropertyFileCheckPage.java rename to src/fr/devinsy/statoolinfos/htmlize/ServicePropertyCheckPage.java index 732211d..25a6c1b 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyFileCheckPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePropertyCheckPage.java @@ -38,9 +38,9 @@ import fr.devinsy.xidyn.presenters.PresenterUtils; /** * The Class ServicePropertyFileCheckView. */ -public class ServicePropertyFileCheckPage +public class ServicePropertyCheckPage { - private static Logger logger = LoggerFactory.getLogger(ServicePropertyFileCheckPage.class); + private static Logger logger = LoggerFactory.getLogger(ServicePropertyCheckPage.class); /** * Builds the all. @@ -58,12 +58,12 @@ public class ServicePropertyFileCheckPage for (Service service : federation.getServicesAll()) { String page = htmlize(service); - FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, service.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8); for (Metrics metrics : service.getMetrics()) { page = htmlize(service, metrics); - FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-check.xhtml"), page, StandardCharsets.UTF_8); + FileUtils.write(new File(htmlizeDirectory, metrics.getLocalFileBaseName() + "-propertycheck.xhtml"), page, StandardCharsets.UTF_8); } } } @@ -86,14 +86,14 @@ public class ServicePropertyFileCheckPage TagDataManager data = new TagDataManager(); data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("contentView", PropertyFileCheckView.htmlize(service.getInputChecks())); + data.setContent("contentView", PropertyCheckView.htmlize(service.getInputChecks())); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés", service.getLocalFileBaseName() + "-check.xhtml"); + trail.add("Propriétés", service.getLocalFileBaseName() + "-propertycheck.xhtml"); result = WebCharterView.build(content, trail); } catch (XidynException exception) @@ -125,15 +125,15 @@ public class ServicePropertyFileCheckPage TagDataManager data = new TagDataManager(); data.setContent("headerView", ServiceHeaderView.htmlize(service)); - data.setContent("contentView", PropertyFileCheckView.htmlize(metrics.getInputChecks())); + data.setContent("contentView", PropertyCheckView.htmlize(metrics.getInputChecks())); String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/headerContentView.xhtml", data).toString(); BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add(service.getOrganization().getName(), service.getOrganization().getLocalFileBaseName() + ".xhtml"); trail.add(service.getName(), service.getLocalFileBaseName() + ".xhtml"); - trail.add("Propriétés", service.getLocalFileBaseName() + "-check.xhtml"); - trail.add("Propriétés", metrics.getLocalFileBaseName() + "-check.xhtml"); + trail.add("Propriétés", service.getLocalFileBaseName() + "-propertycheck.xhtml"); + trail.add("Propriétés", metrics.getLocalFileBaseName() + "-propertycheck.xhtml"); result = WebCharterView.build(content, trail); } catch (XidynException exception) diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml index febec58..3af7013 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/federationHeaderView.xhtml @@ -29,7 +29,7 @@ - + diff --git a/src/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml new file mode 100644 index 0000000..2e6792a --- /dev/null +++ b/src/fr/devinsy/statoolinfos/htmlize/federationPropertyAlertView.xhtml @@ -0,0 +1,24 @@ + + + + + StatoolInfos + + + + + + + +
+ +
+ + diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyAlertView.xhtml similarity index 75% rename from src/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml rename to src/fr/devinsy/statoolinfos/htmlize/propertyAlertView.xhtml index f5f43a3..402e84d 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/propertyFilesCheck.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/propertyAlertView.xhtml @@ -12,15 +12,8 @@
-
-

n/a

+

Propriétés en alertes

Statistiques : diff --git a/src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml b/src/fr/devinsy/statoolinfos/htmlize/propertyCheckView.xhtml similarity index 100% rename from src/fr/devinsy/statoolinfos/htmlize/propertyFileCheck.xhtml rename to src/fr/devinsy/statoolinfos/htmlize/propertyCheckView.xhtml