/* * 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.core.Federation; import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.PeriodMenu; import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.TypeMenu; import fr.devinsy.statoolinfos.htmlize.FederationMetricMenuView.ViewMenu; import fr.devinsy.statoolinfos.htmlize.charts.ChartColor; import fr.devinsy.xidyn.XidynException; import fr.devinsy.xidyn.data.TagDataManager; import fr.devinsy.xidyn.presenters.PresenterUtils; /** * The Class FederationMetricWebPage. */ public class FederationMetricWebPage { private static Logger logger = LoggerFactory.getLogger(FederationMetricWebPage.class); /** * Builds the. * * @throws StatoolInfosException * the statool infos exception * @throws IOException * Signals that an I/O exception has occurred. */ public static void build(final File htmlizeDirectory, final Federation federation, final ViewMenu view, final PeriodMenu period) throws StatoolInfosException, IOException { try { TagDataManager data = new TagDataManager(); data.setContent("headerView", FederationHeaderView.htmlize(federation)); data.setContent("metricMenuView", FederationMetricMenuView.htmlize(federation, TypeMenu.WEB, view, period)); // FederationMetricHtmlizer.htmlize(data, "http.hits", federation, view, period, "metrics.http.hits", ChartColor.BLUE); FederationMetricHtmlizer.htmlize(data, "http.hits-ipv4ipv6", federation, view, period, "http.hits (ipv4 + ipv6)", "metrics.http.hits.ipv4", ChartColor.YELLOW, "metrics.http.hits.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.hits.ipv4", federation, view, period, "metrics.http.hits.ipv4", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.hits.ipv6", federation, view, period, "metrics.http.hits.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.hits-humansbots", federation, view, period, "http.hits (humans + bots)", "metrics.http.hits.humans", ChartColor.GREEN, "metrics.http.hits.bots", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.hits.humans", federation, view, period, "metrics.http.hits.humans", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.hits.bots", federation, view, period, "metrics.http.hits.bots", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.hits.humans-ipv4ipv6", federation, view, period, "http.hits.humans (ipv4 + ipv6)", "metrics.http.hits.humans.ipv4", ChartColor.YELLOW, "metrics.http.hits.humans.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv4", federation, view, period, "metrics.http.hits.humans.ipv4", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.hits.humans.ipv6", federation, view, period, "metrics.http.hits.humans.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.errors", federation, view, period, "metrics.http.errors", ChartColor.RED); FederationMetricHtmlizer.htmlize(data, "http.errors.php", federation, view, period, "metrics.http.errors.php", ChartColor.RED); FederationMetricHtmlizer.htmlize(data, "http.files", federation, view, period, "metrics.http.files", ChartColor.BLUE); FederationMetricHtmlizer.htmlize(data, "http.pages", federation, view, period, "metrics.http.pages", ChartColor.BLUE); FederationMetricHtmlizer.htmlize(data, "http.bytes", federation, view, period, "metrics.http.bytes", ChartColor.BLUE); FederationMetricHtmlizer.htmlize(data, "http.ip", federation, view, period, "metrics.http.ip", ChartColor.BLUE); FederationMetricHtmlizer.htmlize(data, "http.ip-humansbots", federation, view, period, "http.ip (humans + bots)", "metrics.http.ip.humans", ChartColor.GREEN, "metrics.http.ip.bots", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.ip.humans", federation, view, period, "metrics.http.ip.humans", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.ip.bots", federation, view, period, "metrics.http.ip.bots", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.ip-ipv4ipv6", federation, view, period, "http.ip (ipv4 + ipv6)", "metrics.http.ip.ipv4", ChartColor.YELLOW, "metrics.http.ip.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.ip.ipv4", federation, view, period, "metrics.http.ip.ipv4", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.ip.ipv6", federation, view, period, "metrics.http.ip.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.requesters", federation, view, period, "metrics.http.requesters", ChartColor.BLUE); FederationMetricHtmlizer.htmlize(data, "http.requesters-humansbots", federation, view, period, "http.requesters (humans + bots)", "metrics.http.requesters.humans", ChartColor.GREEN, "metrics.http.requesters.bots", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.requesters.humans", federation, view, period, "metrics.http.requesters.humans", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.requesters.bots", federation, view, period, "metrics.http.requesters.bots", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.requesters-ipv4ipv6", federation, view, period, "http.requesters (ipv4 + ipv6)", "metrics.http.requesters.ipv4", ChartColor.YELLOW, "metrics.http.requesters.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.requesters.ipv4", federation, view, period, "metrics.http.requesters.ipv4", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.requesters.ipv6", federation, view, period, "metrics.http.requesters.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.visitors", federation, view, period, "metrics.http.visitors", ChartColor.BLUE); FederationMetricHtmlizer.htmlize(data, "http.visitors-ipv4ipv6", federation, view, period, "http.visitors (ipv4 + ipv6)", "metrics.http.visitors.ipv4", ChartColor.YELLOW, "metrics.http.visitors.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.visitors.ipv4", federation, view, period, "metrics.http.visitors.ipv4", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.visitors.ipv6", federation, view, period, "metrics.http.visitors.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.visits", federation, view, period, "metrics.http.visits", ChartColor.BLUE); FederationMetricHtmlizer.htmlize(data, "http.visits-ipv4ipv6", federation, view, period, "http.visits (ipv4 + ipv6)", "metrics.http.visits.ipv4", ChartColor.YELLOW, "metrics.http.visits.ipv6", ChartColor.GREEN); FederationMetricHtmlizer.htmlize(data, "http.visits.ipv4", federation, view, period, "metrics.http.visits.ipv4", ChartColor.YELLOW); FederationMetricHtmlizer.htmlize(data, "http.visits.ipv6", federation, view, period, "metrics.http.visits.ipv6", ChartColor.GREEN); // String content = PresenterUtils.dynamize("/fr/devinsy/statoolinfos/htmlize/serviceMetricWebView.xhtml", data).toString(); // BreadcrumbTrail trail = new BreadcrumbTrail(); trail.add("Metrics web"); String page = WebCharterView.build(content, trail); String filename = String.format("%s-metrics-web-%s-%s.xhtml", federation.getLocalFileBaseName(), view.getName(), period.getName()); FileUtils.write(new File(htmlizeDirectory, filename), page, StandardCharsets.UTF_8); } catch (XidynException exception) { throw new StatoolInfosException("Error building federation metrics page: " + exception.getMessage(), exception); } } }