Refactor and improved to run with the split web app.

This commit is contained in:
Christian P. MOMON 2024-08-08 17:13:28 +02:00
parent e44bda8db2
commit f0f915ddc1
16 changed files with 396 additions and 169 deletions

View file

@ -16,7 +16,7 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>. * along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/ */
package fr.devinsy.statoolinfos.core; package fr.devinsy.statoolinfos.app;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -28,8 +28,13 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.build.Builder; import fr.devinsy.statoolinfos.build.Builder;
import fr.devinsy.statoolinfos.core.BotFilter;
import fr.devinsy.statoolinfos.core.Configuration;
import fr.devinsy.statoolinfos.core.Factory;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosContext;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.Crawler; import fr.devinsy.statoolinfos.crawl.Crawler;
import fr.devinsy.statoolinfos.metrics.Prober; import fr.devinsy.statoolinfos.metrics.Prober;
import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLog; import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLog;
@ -53,11 +58,11 @@ import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringsUtils; import fr.devinsy.strings.StringsUtils;
/** /**
* The Class StatoolInfos. * The Class StatoolInfosApp.
*/ */
public class StatoolInfos public class StatoolInfosApp
{ {
private static Logger logger = LoggerFactory.getLogger(StatoolInfos.class); private static Logger logger = LoggerFactory.getLogger(StatoolInfosApp.class);
/** /**
* Builds the. * Builds the.
@ -182,10 +187,6 @@ public class StatoolInfos
{ {
exception.printStackTrace(); exception.printStackTrace();
} }
catch (IOException exception)
{
exception.printStackTrace();
}
} }
/** /**
@ -242,10 +243,6 @@ public class StatoolInfos
{ {
exception.printStackTrace(); exception.printStackTrace();
} }
catch (IOException exception)
{
exception.printStackTrace();
}
} }
/** /**
@ -1156,11 +1153,11 @@ public class StatoolInfos
*/ */
public static void uptime(final File configurationFile) throws StatoolInfosException, IOException public static void uptime(final File configurationFile) throws StatoolInfosException, IOException
{ {
HtmlizerContext.instance().configure(configurationFile); StatoolInfosContext context = new StatoolInfosContext(configurationFile);
UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal(); UptimeJournal journal = context.getUptimeJournal();
Federation federation = HtmlizerContext.instance().getFederation(); Federation federation = context.getFederation();
UptimeSurveyor.survey(journal, federation.getURLActiveAll()); UptimeSurveyor.survey(journal, federation.getURLActiveAll());
HtmlizerContext.instance().getCache().storeUptimeJournal(journal); context.getCache().storeUptimeJournal(journal);
} }
} }

View file

@ -26,8 +26,8 @@ import org.apache.commons.lang3.math.NumberUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.app.StatoolInfosApp;
import fr.devinsy.statoolinfos.core.BotFilter; import fr.devinsy.statoolinfos.core.BotFilter;
import fr.devinsy.statoolinfos.core.StatoolInfos;
import fr.devinsy.statoolinfos.util.BuildInformation; import fr.devinsy.statoolinfos.util.BuildInformation;
import fr.devinsy.statoolinfos.util.Chrono; import fr.devinsy.statoolinfos.util.Chrono;
import fr.devinsy.statoolinfos.util.Files; import fr.devinsy.statoolinfos.util.Files;
@ -249,7 +249,7 @@ public final class StatoolInfosCLI
File configurationFile = new File(StringUtils.trim(args[1])); File configurationFile = new File(StringUtils.trim(args[1]));
try try
{ {
StatoolInfos.build(configurationFile); StatoolInfosApp.build(configurationFile);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -261,7 +261,7 @@ public final class StatoolInfosCLI
File configurationFile = new File(StringUtils.trim(args[1])); File configurationFile = new File(StringUtils.trim(args[1]));
try try
{ {
StatoolInfos.clear(configurationFile); StatoolInfosApp.clear(configurationFile);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -275,7 +275,7 @@ public final class StatoolInfosCLI
File configurationFile = new File(StringUtils.trim(args[1])); File configurationFile = new File(StringUtils.trim(args[1]));
try try
{ {
StatoolInfos.crawl(configurationFile); StatoolInfosApp.crawl(configurationFile);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -291,7 +291,7 @@ public final class StatoolInfosCLI
{ {
try try
{ {
StatoolInfos.format(input); StatoolInfosApp.format(input);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -305,13 +305,13 @@ public final class StatoolInfosCLI
BotFilter filter = parseLogFilterOption(args[2]); BotFilter filter = parseLogFilterOption(args[2]);
File configurationFile = new File(StringUtils.trim(args[3])); File configurationFile = new File(StringUtils.trim(args[3]));
StatoolInfos.listIps(configurationFile, filter); StatoolInfosApp.listIps(configurationFile, filter);
} }
else if (CLIUtils.isMatching(args, "list", "ip", ".+\\.conf")) else if (CLIUtils.isMatching(args, "list", "ip", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.listIps(configurationFile, BotFilter.ALL); StatoolInfosApp.listIps(configurationFile, BotFilter.ALL);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "ip", "(-all|-bot|-nobot)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "ip", "(-all|-bot|-nobot)", ".+"))
{ {
@ -322,7 +322,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listIps(source, filter); StatoolInfosApp.listIps(source, filter);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "ip", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "ip", ".+"))
{ {
@ -332,13 +332,13 @@ public final class StatoolInfosCLI
files.add(new File(args[source])); files.add(new File(args[source]));
} }
StatoolInfos.listIps(files, BotFilter.ALL); StatoolInfosApp.listIps(files, BotFilter.ALL);
} }
else if (CLIUtils.isMatching(args, "list", "(file|files)", ".+\\.conf")) else if (CLIUtils.isMatching(args, "list", "(file|files)", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.listAccessFiles(configurationFile); StatoolInfosApp.listAccessFiles(configurationFile);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(file|files)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(file|files)", ".+"))
{ {
@ -348,13 +348,13 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listAccessFiles(source); StatoolInfosApp.listAccessFiles(source);
} }
else if (CLIUtils.isMatching(args, "list", "(errfile|errfiles)", ".+\\.conf")) else if (CLIUtils.isMatching(args, "list", "(errfile|errfiles)", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.listErrorFiles(configurationFile); StatoolInfosApp.listErrorFiles(configurationFile);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(errfile|errfiles)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(errfile|errfiles)", ".+"))
{ {
@ -364,20 +364,20 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listErrorFiles(source); StatoolInfosApp.listErrorFiles(source);
} }
else if (CLIUtils.isMatching(args, "list", "(log|logs)", "(-all|-bot|-nobot)", ".+\\.conf*")) else if (CLIUtils.isMatching(args, "list", "(log|logs)", "(-all|-bot|-nobot)", ".+\\.conf*"))
{ {
BotFilter filter = parseLogFilterOption(args[2]); BotFilter filter = parseLogFilterOption(args[2]);
File configurationFile = new File(StringUtils.trim(args[3])); File configurationFile = new File(StringUtils.trim(args[3]));
StatoolInfos.listLogs(configurationFile, filter); StatoolInfosApp.listLogs(configurationFile, filter);
} }
else if (CLIUtils.isMatching(args, "list", "(log|logs)", ".+\\.conf")) else if (CLIUtils.isMatching(args, "list", "(log|logs)", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.listLogs(configurationFile, BotFilter.ALL); StatoolInfosApp.listLogs(configurationFile, BotFilter.ALL);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(log|logs)", "(-all|-bot|-nobot)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(log|logs)", "(-all|-bot|-nobot)", ".+"))
{ {
@ -388,7 +388,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listLogs(source, filter); StatoolInfosApp.listLogs(source, filter);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(log|logs)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(log|logs)", ".+"))
{ {
@ -398,13 +398,13 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listLogs(source, BotFilter.ALL); StatoolInfosApp.listLogs(source, BotFilter.ALL);
} }
else if (CLIUtils.isMatching(args, "list", "(errlog|errlogs)", ".+\\.conf")) else if (CLIUtils.isMatching(args, "list", "(errlog|errlogs)", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.listErrorLogs(configurationFile); StatoolInfosApp.listErrorLogs(configurationFile);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(errlog|errlogs)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(errlog|errlogs)", ".+"))
{ {
@ -414,20 +414,20 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listErrorLogs(source); StatoolInfosApp.listErrorLogs(source);
} }
else if (CLIUtils.isMatching(args, "list", "(useragent|ua)", "(-all|-bot|-nobot)", ".+\\.conf*")) else if (CLIUtils.isMatching(args, "list", "(useragent|ua)", "(-all|-bot|-nobot)", ".+\\.conf*"))
{ {
BotFilter filter = parseLogFilterOption(args[2]); BotFilter filter = parseLogFilterOption(args[2]);
File configurationFile = new File(StringUtils.trim(args[3])); File configurationFile = new File(StringUtils.trim(args[3]));
StatoolInfos.listUserAgents(configurationFile, filter); StatoolInfosApp.listUserAgents(configurationFile, filter);
} }
else if (CLIUtils.isMatching(args, "list", "(useragent|ua)", ".+\\.conf")) else if (CLIUtils.isMatching(args, "list", "(useragent|ua)", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.listUserAgents(configurationFile, BotFilter.ALL); StatoolInfosApp.listUserAgents(configurationFile, BotFilter.ALL);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(useragent|ua)", "(-all|-bot|-nobot)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(useragent|ua)", "(-all|-bot|-nobot)", ".+"))
{ {
@ -438,7 +438,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listUserAgents(source, filter); StatoolInfosApp.listUserAgents(source, filter);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(useragent|ua)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(useragent|ua)", ".+"))
{ {
@ -448,20 +448,20 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listUserAgents(source, BotFilter.ALL); StatoolInfosApp.listUserAgents(source, BotFilter.ALL);
} }
else if (CLIUtils.isMatching(args, "list", "(visitor|visitors)", "(-all|-bot|-nobot)", ".+\\.conf*")) else if (CLIUtils.isMatching(args, "list", "(visitor|visitors)", "(-all|-bot|-nobot)", ".+\\.conf*"))
{ {
BotFilter filter = parseLogFilterOption(args[2]); BotFilter filter = parseLogFilterOption(args[2]);
File configurationFile = new File(StringUtils.trim(args[3])); File configurationFile = new File(StringUtils.trim(args[3]));
StatoolInfos.listVisitors(configurationFile, filter); StatoolInfosApp.listVisitors(configurationFile, filter);
} }
else if (CLIUtils.isMatching(args, "list", "(visitor|visitors)", ".+\\.conf")) else if (CLIUtils.isMatching(args, "list", "(visitor|visitors)", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.listVisitors(configurationFile, BotFilter.ALL); StatoolInfosApp.listVisitors(configurationFile, BotFilter.ALL);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(visitor|visitors)", "(-all|-bot|-nobot)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(visitor|visitors)", "(-all|-bot|-nobot)", ".+"))
{ {
@ -472,7 +472,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listVisitors(source, filter); StatoolInfosApp.listVisitors(source, filter);
} }
else if (CLIUtils.isMatchingEllipsis(args, "list", "(visitor|visitors)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "list", "(visitor|visitors)", ".+"))
{ {
@ -482,7 +482,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.listVisitors(source, BotFilter.ALL); StatoolInfosApp.listVisitors(source, BotFilter.ALL);
} }
else if (CLIUtils.isMatching(args, "probe", "(-full|-today|-previousday|-\\d+)", ".+")) else if (CLIUtils.isMatching(args, "probe", "(-full|-today|-previousday|-\\d+)", ".+"))
{ {
@ -521,7 +521,7 @@ public final class StatoolInfosCLI
try try
{ {
System.out.println("Probing [" + input + "] with day count filter " + dayCountFilter); System.out.println("Probing [" + input + "] with day count filter " + dayCountFilter);
StatoolInfos.probe(input, dayCountFilter); StatoolInfosApp.probe(input, dayCountFilter);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -542,13 +542,13 @@ public final class StatoolInfosCLI
BotFilter filter = parseLogFilterOption(args[2]); BotFilter filter = parseLogFilterOption(args[2]);
File configurationFile = new File(StringUtils.trim(args[3])); File configurationFile = new File(StringUtils.trim(args[3]));
StatoolInfos.statIps(configurationFile, filter); StatoolInfosApp.statIps(configurationFile, filter);
} }
else if (CLIUtils.isMatching(args, "stat", "ip", ".+\\.conf")) else if (CLIUtils.isMatching(args, "stat", "ip", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.statIps(configurationFile, BotFilter.ALL); StatoolInfosApp.statIps(configurationFile, BotFilter.ALL);
} }
else if (CLIUtils.isMatchingEllipsis(args, "stat", "ip", "(-all|-bot|-nobot)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "stat", "ip", "(-all|-bot|-nobot)", ".+"))
{ {
@ -559,7 +559,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.statIps(source, filter); StatoolInfosApp.statIps(source, filter);
} }
else if (CLIUtils.isMatchingEllipsis(args, "stat", "ip", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "stat", "ip", ".+"))
{ {
@ -569,20 +569,20 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.statIps(source, BotFilter.ALL); StatoolInfosApp.statIps(source, BotFilter.ALL);
} }
else if (CLIUtils.isMatching(args, "stat", "(useragent|ua)", "(-all|-bot|-nobot)", ".+\\.conf*")) else if (CLIUtils.isMatching(args, "stat", "(useragent|ua)", "(-all|-bot|-nobot)", ".+\\.conf*"))
{ {
BotFilter filter = parseLogFilterOption(args[2]); BotFilter filter = parseLogFilterOption(args[2]);
File configurationFile = new File(StringUtils.trim(args[3])); File configurationFile = new File(StringUtils.trim(args[3]));
StatoolInfos.statUserAgents(configurationFile, filter); StatoolInfosApp.statUserAgents(configurationFile, filter);
} }
else if (CLIUtils.isMatching(args, "stat", "(useragent|ua)", ".+\\.conf")) else if (CLIUtils.isMatching(args, "stat", "(useragent|ua)", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.statUserAgents(configurationFile, BotFilter.ALL); StatoolInfosApp.statUserAgents(configurationFile, BotFilter.ALL);
} }
else if (CLIUtils.isMatchingEllipsis(args, "stat", "(useragent|ua)", "(-all|-bot|-nobot)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "stat", "(useragent|ua)", "(-all|-bot|-nobot)", ".+"))
{ {
@ -593,7 +593,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.statUserAgents(source, filter); StatoolInfosApp.statUserAgents(source, filter);
} }
else if (CLIUtils.isMatchingEllipsis(args, "stat", "(useragent|ua)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "stat", "(useragent|ua)", ".+"))
{ {
@ -603,20 +603,20 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.statUserAgents(source, BotFilter.ALL); StatoolInfosApp.statUserAgents(source, BotFilter.ALL);
} }
else if (CLIUtils.isMatching(args, "stat", "(visitor|visitors)", "(-all|-bot|-nobot)", ".+\\.conf*")) else if (CLIUtils.isMatching(args, "stat", "(visitor|visitors)", "(-all|-bot|-nobot)", ".+\\.conf*"))
{ {
BotFilter filter = parseLogFilterOption(args[2]); BotFilter filter = parseLogFilterOption(args[2]);
File configurationFile = new File(StringUtils.trim(args[3])); File configurationFile = new File(StringUtils.trim(args[3]));
StatoolInfos.statVisitors(configurationFile, filter); StatoolInfosApp.statVisitors(configurationFile, filter);
} }
else if (CLIUtils.isMatching(args, "stat", "(visitor|visitors)", ".+\\.conf")) else if (CLIUtils.isMatching(args, "stat", "(visitor|visitors)", ".+\\.conf"))
{ {
File configurationFile = new File(StringUtils.trim(args[2])); File configurationFile = new File(StringUtils.trim(args[2]));
StatoolInfos.statVisitors(configurationFile, BotFilter.ALL); StatoolInfosApp.statVisitors(configurationFile, BotFilter.ALL);
} }
else if (CLIUtils.isMatchingEllipsis(args, "stat", "(visitor|visitors)", "(-all|-bot|-nobot)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "stat", "(visitor|visitors)", "(-all|-bot|-nobot)", ".+"))
{ {
@ -627,7 +627,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.statVisitors(source, filter); StatoolInfosApp.statVisitors(source, filter);
} }
else if (CLIUtils.isMatchingEllipsis(args, "stat", "(visitor|visitors)", ".+")) else if (CLIUtils.isMatchingEllipsis(args, "stat", "(visitor|visitors)", ".+"))
{ {
@ -637,7 +637,7 @@ public final class StatoolInfosCLI
source.add(new File(args[index])); source.add(new File(args[index]));
} }
StatoolInfos.statVisitors(source, BotFilter.ALL); StatoolInfosApp.statVisitors(source, BotFilter.ALL);
} }
else if (CLIUtils.isMatching(args, "tagdate", ".+")) else if (CLIUtils.isMatching(args, "tagdate", ".+"))
{ {
@ -646,7 +646,7 @@ public final class StatoolInfosCLI
{ {
try try
{ {
StatoolInfos.tagDate(input); StatoolInfosApp.tagDate(input);
} }
catch (Exception exception) catch (Exception exception)
{ {
@ -662,7 +662,7 @@ public final class StatoolInfosCLI
File configurationFile = new File(StringUtils.trim(args[1])); File configurationFile = new File(StringUtils.trim(args[1]));
try try
{ {
StatoolInfos.uptime(configurationFile); StatoolInfosApp.uptime(configurationFile);
} }
catch (Exception exception) catch (Exception exception)
{ {

View file

@ -167,10 +167,10 @@ public class Configuration extends PathPropertyList
{ {
File result; File result;
String path = get("conf.htmlize.categories"); String path = get("conf.categories");
if (StringUtils.isBlank(path)) if (StringUtils.isBlank(path))
{ {
throw new StatoolInfosException("Entry conf.htmlize.categories is missing in configuration file."); result = null;
} }
else else
{ {
@ -545,6 +545,28 @@ public class Configuration extends PathPropertyList
return result; return result;
} }
/**
* Checks if is category file defined.
*
* @return true, if is category file defined
*/
public boolean isCategoryFileDefined()
{
boolean result;
if (StringUtils.isBlank(get("conf.categories")))
{
result = false;
}
else
{
result = true;
}
//
return result;
}
/** /**
* Checks if is federation. * Checks if is federation.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2023 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -35,7 +35,6 @@ import fr.devinsy.statoolinfos.properties.PathProperty;
import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.statoolinfos.properties.PathPropertyList;
import fr.devinsy.statoolinfos.properties.PathPropertyUtils; import fr.devinsy.statoolinfos.properties.PathPropertyUtils;
import fr.devinsy.statoolinfos.properties.PropertyClassType; import fr.devinsy.statoolinfos.properties.PropertyClassType;
import fr.devinsy.statoolinfos.util.Chrono;
import fr.devinsy.strings.StringList; import fr.devinsy.strings.StringList;
import fr.devinsy.strings.StringSet; import fr.devinsy.strings.StringSet;
@ -66,33 +65,9 @@ public class Factory
{ {
Categories result; Categories result;
result = new Categories();
PathProperties properties = PathPropertyUtils.load(source); PathProperties properties = PathPropertyUtils.load(source);
StringSet prefixes = properties.getSubPrefixes(); result = loadCategories(properties);
for (String prefix : prefixes)
{
String name = properties.get(prefix + ".name");
String description = properties.get(prefix + ".description");
String softwares = properties.get(prefix + ".softwares");
String logoPath = properties.get(prefix + ".logo");
StringList softwareList = new StringList();
if (StringUtils.isNotBlank(softwares))
{
for (String string : softwares.split("[;,]"))
{
softwareList.add(string.trim());
}
}
Category category = new Category(name, description, softwareList);
category.setLogoPath(logoPath);
result.add(category);
}
result.sortByName();
// //
return result; return result;
@ -130,6 +105,102 @@ public class Factory
return result; return result;
} }
/**
* Load categories.
*
* @param properties
* the properties
* @return the categories
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static Categories loadCategories(final PathProperties properties) throws IOException
{
Categories result;
result = new Categories();
StringSet prefixes = properties.getSubPrefixes();
for (String prefix : prefixes)
{
String name = properties.get(prefix + ".name");
String description = properties.get(prefix + ".description");
String softwares = properties.get(prefix + ".softwares");
String logoPath = properties.get(prefix + ".logo");
StringList softwareList = new StringList();
if (StringUtils.isNotBlank(softwares))
{
for (String string : softwares.split("[;,]"))
{
softwareList.add(string.trim());
}
}
Category category = new Category(name, description, softwareList);
category.setLogoPath(logoPath);
result.add(category);
}
result.sortByName();
//
return result;
}
/**
* Load categories.
*
* @param source
* the source
* @return the categories
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static Categories loadCategories(final URL source) throws IOException
{
Categories result;
PathProperties properties = PathPropertyUtils.load(source);
result = loadCategories(properties);
//
return result;
}
/**
* Load categories.
*
* @param source
* the source
* @param federation
* the federation
* @return the categories
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static Categories loadCategories(final URL source, final Federation federation) throws IOException
{
Categories result;
result = loadCategories(source);
Category other = new Category("Autres", "Qui ne rentre pas dans une catégorie existante.");
result.add(other);
for (Software software : federation.getSoftwares().values())
{
if (!result.matches(software.getName()))
{
other.getSoftwares().add(software.getName());
}
}
//
return result;
}
/** /**
* Load configuration. * Load configuration.
* *
@ -141,12 +212,19 @@ public class Factory
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred. * Signals that an I/O exception has occurred.
*/ */
public static Configuration loadConfiguration(final File configurationFile) throws StatoolInfosException, IOException public static Configuration loadConfiguration(final File configurationFile) throws StatoolInfosException
{ {
Configuration result; Configuration result;
try
{
PathProperties properties = PathPropertyUtils.load(configurationFile); PathProperties properties = PathPropertyUtils.load(configurationFile);
result = new Configuration(properties); result = new Configuration(properties);
}
catch (IOException exception)
{
throw new StatoolInfosException("Error reading configuration file: " + configurationFile, exception);
}
// //
return result; return result;
@ -170,7 +248,6 @@ public class Factory
Federation result; Federation result;
System.out.println("Loading federation " + inputURL); System.out.println("Loading federation " + inputURL);
Chrono chrono = new Chrono().start();
if (inputURL == null) if (inputURL == null)
{ {
@ -201,7 +278,7 @@ public class Factory
result = new Federation(properties); result = new Federation(properties);
result.setInputURL(inputURL); result.setInputURL(inputURL);
result.setInputFile(federationFile); result.setInputFile(federationFile);
result.setLogoFileName(result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png")); result.setLogoFileName("logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png"));
PropertyChecker checker = new PropertyChecker(); PropertyChecker checker = new PropertyChecker();
PropertyChecks checks = checker.checkFederation(result.getInputFile()); PropertyChecks checks = checker.checkFederation(result.getInputFile());
@ -227,7 +304,6 @@ public class Factory
result.getCrawlJournal().addAll(cache.restoreCrawlJournal()); result.getCrawlJournal().addAll(cache.restoreCrawlJournal());
} }
} }
System.out.println("Federation loaded in " + chrono.format());
// //
return result; return result;
@ -253,7 +329,6 @@ public class Factory
System.out.println("Loading metrics " + inputURL); System.out.println("Loading metrics " + inputURL);
File inputFile = cache.restoreFile(inputURL); File inputFile = cache.restoreFile(inputURL);
if (inputFile == null) if (inputFile == null)
{ {
logger.warn("WARNING: metrics not found in cache [{}]", inputURL); logger.warn("WARNING: metrics not found in cache [{}]", inputURL);
@ -310,7 +385,7 @@ public class Factory
{ {
result.setInputFile(inputFile); result.setInputFile(inputFile);
result.setInputURL(inputURL); result.setInputURL(inputURL);
result.setLogoFileName(result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png")); result.setLogoFileName("logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png"));
// //
PropertyChecker checker = new PropertyChecker(); PropertyChecker checker = new PropertyChecker();
@ -386,7 +461,7 @@ public class Factory
result.setOrganization(organization); result.setOrganization(organization);
result.setInputFile(inputFile); result.setInputFile(inputFile);
result.setInputURL(inputURL); result.setInputURL(inputURL);
result.setLogoFileName(organization.getTechnicalName() + "-" + result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png")); result.setLogoFileName("logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png"));
// //
PathProperties subs = result.getByPrefix("subs"); PathProperties subs = result.getByPrefix("subs");

View file

@ -42,8 +42,6 @@ import fr.devinsy.statoolinfos.util.URLUtils;
*/ */
public class Organization extends PathPropertyList public class Organization extends PathPropertyList
{ {
private static final long serialVersionUID = -2709210934548224213L;
public enum Status public enum Status
{ {
ACTIVE, ACTIVE,
@ -62,6 +60,8 @@ public class Organization extends PathPropertyList
OTHER OTHER
} }
private static final long serialVersionUID = -2709210934548224213L;
private Federation federation; private Federation federation;
private Services services; private Services services;
private File inputFile; private File inputFile;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -21,6 +21,9 @@ package fr.devinsy.statoolinfos.core;
import java.time.Year; import java.time.Year;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import org.apache.commons.lang3.StringUtils;
/** /**
* The Class Organizations. * The Class Organizations.
@ -37,6 +40,22 @@ public class Organizations extends ArrayList<Organization>
super(); super();
} }
/**
* Instantiates a new organizations.
*
* @param organization
* the organization
*/
public Organizations(final Organization organization)
{
super();
if (organization != null)
{
add(organization);
}
}
/** /**
* Filter active. * Filter active.
* *
@ -227,6 +246,43 @@ public class Organizations extends ArrayList<Organization>
return result; return result;
} }
/**
* Gets the by technical name.
*
* @param technicalName
* the technical name
* @return the by technical name
*/
public Organization getByTechnicalName(final String technicalName)
{
Organization result;
Iterator<Organization> iterator = this.iterator();
boolean ended = false;
result = null;
while (!ended)
{
if (iterator.hasNext())
{
Organization organization = iterator.next();
if (StringUtils.equals(organization.getTechnicalName(), technicalName))
{
ended = true;
result = organization;
}
}
else
{
ended = true;
result = null;
}
}
//
return result;
}
/** /**
* Gets the idles. * Gets the idles.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -22,6 +22,7 @@ import java.time.LocalDate;
import java.time.Year; import java.time.Year;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -42,6 +43,22 @@ public class Services extends ArrayList<Service>
super(); super();
} }
/**
* Instantiates a new services.
*
* @param service
* the service
*/
public Services(final Service service)
{
super();
if (service != null)
{
add(service);
}
}
/** /**
* Count by year. * Count by year.
* *
@ -190,6 +207,43 @@ public class Services extends ArrayList<Service>
return result; return result;
} }
/**
* Gets the by technical name.
*
* @param technicalName
* the technical name
* @return the by technical name
*/
public Service getByTechnicalName(final String technicalName)
{
Service result;
Iterator<Service> iterator = this.iterator();
boolean ended = false;
result = null;
while (!ended)
{
if (iterator.hasNext())
{
Service service = iterator.next();
if (StringUtils.equals(service.getTechnicalName(), technicalName))
{
ended = true;
result = service;
}
}
else
{
ended = true;
result = null;
}
}
//
return result;
}
/** /**
* Gets the older. * Gets the older.
* *

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -77,6 +77,8 @@ public class Softwares extends HashMap<String, Software>
*/ */
public void put(final Software software) public void put(final Software software)
{ {
put(buildKey(software.getName()), software);
for (String alias : software.getAliases()) for (String alias : software.getAliases())
{ {
put(buildKey(alias), software); put(buildKey(alias), software);

View file

@ -16,30 +16,21 @@
* You should have received a copy of the GNU Affero General Public License * You should have received a copy of the GNU Affero General Public License
* along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>. * along with StatoolInfos. If not, see <http://www.gnu.org/licenses/>.
*/ */
package fr.devinsy.statoolinfos; package fr.devinsy.statoolinfos.core;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.URL;
import fr.devinsy.statoolinfos.core.Categories;
import fr.devinsy.statoolinfos.core.Configuration;
import fr.devinsy.statoolinfos.core.Factory;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.crawl.CrawlCache; import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.uptime.UptimeJournal; import fr.devinsy.statoolinfos.uptime.UptimeJournal;
/** /**
* The Class HtmlizerContext. * The Class StatoolInfosContext.
*/ */
public class HtmlizerContext public class StatoolInfosContext
{ {
private static class SingletonHolder private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatoolInfosContext.class);
{
private static final HtmlizerContext instance = new HtmlizerContext();
}
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(HtmlizerContext.class);
private Configuration configuration; private Configuration configuration;
private Federation federation; private Federation federation;
@ -49,9 +40,13 @@ public class HtmlizerContext
/** /**
* Instantiates a new manager. * Instantiates a new manager.
*
* @throws IOException
* @throws StatoolInfosException
*/ */
private HtmlizerContext() public StatoolInfosContext(final File configurationFile) throws StatoolInfosException, IOException
{ {
configure(configurationFile);
} }
/** /**
@ -73,9 +68,20 @@ public class HtmlizerContext
if (this.configuration.isFederation()) if (this.configuration.isFederation())
{ {
long startTime = System.currentTimeMillis();
System.out.println("Loading configuration file.");
this.federation = Factory.loadFederation(this.configuration.getHtmlizeInputURL(), this.cache); this.federation = Factory.loadFederation(this.configuration.getHtmlizeInputURL(), this.cache);
if (this.configuration.isCategoryFileDefined())
{
this.categories = Factory.loadCategories(this.configuration.getCategoryFile(), this.federation); this.categories = Factory.loadCategories(this.configuration.getCategoryFile(), this.federation);
}
else
{
URL categoriesURL = StatoolInfosContext.class.getResource("/fr/devinsy/statoolinfos/core/categories.properties");
this.categories = Factory.loadCategories(categoriesURL, this.federation);
}
this.uptimeJournal = this.cache.restoreUptimeJournal(); this.uptimeJournal = this.cache.restoreUptimeJournal();
System.out.println("Loaded configuration context in " + (System.currentTimeMillis() - startTime) + " ms.");
} }
else else
{ {
@ -152,14 +158,4 @@ public class HtmlizerContext
{ {
return this.uptimeJournal; return this.uptimeJournal;
} }
/**
* Instance.
*
* @return the manager
*/
public static HtmlizerContext instance()
{
return SingletonHolder.instance;
}
} }

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -46,14 +46,14 @@ import fr.devinsy.statoolinfos.util.URLUtils;
*/ */
public class CrawlCache public class CrawlCache
{ {
private static Logger logger = LoggerFactory.getLogger(CrawlCache.class);
public static enum DefaultLogoGenerator public static enum DefaultLogoGenerator
{ {
CAT, CAT,
BIRD BIRD
} }
private static Logger logger = LoggerFactory.getLogger(CrawlCache.class);
private File directory; private File directory;
/** /**
@ -234,7 +234,7 @@ public class CrawlCache
} }
else else
{ {
logger.info("CatGeneratoring from {}", url); logger.info("Restoring logo from {}", url);
File logoFile = restoreFile(url); File logoFile = restoreFile(url);
if (logoFile == null) if (logoFile == null)
{ {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2021-2023 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -25,7 +25,6 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Categories; import fr.devinsy.statoolinfos.core.Categories;
import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Organizations; import fr.devinsy.statoolinfos.core.Organizations;
@ -80,13 +79,13 @@ public class CSVFile
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred. * Signals that an I/O exception has occurred.
*/ */
public static void save(final File file, final Services source) throws IOException public static void save(final File file, final Services source, final Categories categories) throws IOException
{ {
CSVWriter out = null; CSVWriter out = null;
try try
{ {
out = new CSVWriter(file, ';'); out = new CSVWriter(file, ';');
write(out, source); write(out, source, categories);
} }
finally finally
{ {
@ -155,7 +154,7 @@ public class CSVFile
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred. * Signals that an I/O exception has occurred.
*/ */
public static void write(final SpreadsheetWriter out, final Services services) throws IOException public static void write(final SpreadsheetWriter out, final Services services, final Categories categories) throws IOException
{ {
// Build label list. // Build label list.
StringList labels = new StringList(100); StringList labels = new StringList(100);
@ -188,8 +187,6 @@ public class CSVFile
} }
out.writeEndRow(); out.writeEndRow();
Categories categories = HtmlizerContext.instance().getCategories();
// Write service lines. // Write service lines.
for (Service service : services) for (Service service : services)
{ {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -27,7 +27,6 @@ import org.apache.commons.text.StringEscapeUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.HtmlizerContext;
import fr.devinsy.statoolinfos.core.Categories; import fr.devinsy.statoolinfos.core.Categories;
import fr.devinsy.statoolinfos.core.Federation; import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Organization;
@ -238,11 +237,11 @@ public class JSONFile
* the service * the service
* @return the string list * @return the string list
*/ */
public static StringList toJSON(final Service service) public static StringList toJSON(final Service service, final Categories categories)
{ {
StringList result; StringList result;
result = toJSON((PathPropertyList) service); result = toJSON(service);
// //
result.removeLast(); result.removeLast();
@ -266,7 +265,6 @@ public class JSONFile
result.append(","); result.append(",");
// //
Categories categories = HtmlizerContext.instance().getCategories();
result.append("\""); result.append("\"");
result.append("software.categories"); result.append("software.categories");
result.append("\" : \""); result.append("\" : \"");

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2021-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -24,6 +24,7 @@ import java.io.IOException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Categories;
import fr.devinsy.statoolinfos.core.Organizations; import fr.devinsy.statoolinfos.core.Organizations;
import fr.devinsy.statoolinfos.core.Services; import fr.devinsy.statoolinfos.core.Services;
@ -32,9 +33,9 @@ import fr.devinsy.statoolinfos.core.Services;
*/ */
public class ODSFile public class ODSFile
{ {
public static final int MAX_LINE_SIZE = 1024; private static final Logger logger = LoggerFactory.getLogger(ODSFile.class);
private static final Logger logger = LoggerFactory.getLogger(ODSFile.class);; public static final int MAX_LINE_SIZE = 1024;;
protected enum Status protected enum Status
{ {
@ -75,13 +76,13 @@ public class ODSFile
* @param source * @param source
* the source * the source
*/ */
public static void save(final File file, final Services source) throws IOException public static void save(final File file, final Services source, final Categories categories) throws IOException
{ {
ODSWriter out = null; ODSWriter out = null;
try try
{ {
out = new ODSWriter(file); out = new ODSWriter(file);
CSVFile.write(out, source); CSVFile.write(out, source, categories);
} }
finally finally
{ {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -22,15 +22,17 @@ import java.net.URL;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import fr.devinsy.statoolinfos.core.Organization; import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Service;
/** /**
* The Class PropertiesFileStat. * The Class PropertiesFileStat.
*/ */
public class PropertiesFileStat public class PropertiesFileStat
{ {
private String localName; private String urlName;
private URL url; private URL url;
private Organization organization; private Organization organization;
private Service service;
private int lineCount; private int lineCount;
private int activeLineCount; private int activeLineCount;
private int blankPropertyCount; private int blankPropertyCount;
@ -78,11 +80,6 @@ public class PropertiesFileStat
return this.lineCount; return this.lineCount;
} }
public String getLocalName()
{
return this.localName;
}
public Organization getOrganization() public Organization getOrganization()
{ {
return this.organization; return this.organization;
@ -93,6 +90,11 @@ public class PropertiesFileStat
return this.activeLineCount; return this.activeLineCount;
} }
public Service getService()
{
return this.service;
}
public LocalDateTime getUpdateDate() public LocalDateTime getUpdateDate()
{ {
return this.updateDate; return this.updateDate;
@ -103,6 +105,11 @@ public class PropertiesFileStat
return this.url; return this.url;
} }
public String getURLName()
{
return this.urlName;
}
public int getVoidCount() public int getVoidCount()
{ {
return this.voidCount; return this.voidCount;
@ -183,16 +190,16 @@ public class PropertiesFileStat
this.lineCount = lineCount; this.lineCount = lineCount;
} }
public void setLocalName(final String localName)
{
this.localName = localName;
}
public void setOrganization(final Organization organization) public void setOrganization(final Organization organization)
{ {
this.organization = organization; this.organization = organization;
} }
public void setService(final Service service)
{
this.service = service;
}
public void setUpdateDate(final LocalDateTime updateDate) public void setUpdateDate(final LocalDateTime updateDate)
{ {
this.updateDate = updateDate; this.updateDate = updateDate;
@ -203,6 +210,11 @@ public class PropertiesFileStat
this.url = url; this.url = url;
} }
public void setURLName(final String localName)
{
this.urlName = localName;
}
public void setVoidCount(final int voidCount) public void setVoidCount(final int voidCount)
{ {
this.voidCount = voidCount; this.voidCount = voidCount;

View file

@ -1,5 +1,20 @@
/* /*
* Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
* *
* 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 <http://www.gnu.org/licenses/>.
*/ */
package fr.devinsy.statoolinfos.stats.propertyfiles; package fr.devinsy.statoolinfos.stats.propertyfiles;
@ -238,7 +253,7 @@ public class PropertiesFileStatComparator implements Comparator<PropertiesFileSt
} }
else else
{ {
result = source.getLocalName(); result = source.getURLName();
} }
// //

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2024 Christian Pierre MOMON <christian@momon.org>
* *
* This file is part of StatoolInfos, simple service statistics tool. * This file is part of StatoolInfos, simple service statistics tool.
* *
@ -274,13 +274,13 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred. * Signals that an I/O exception has occurred.
*/ */
public void stat(final Metrics metrics, final Organization oranization) throws IOException public void stat(final Metrics metrics, final Organization organization) throws IOException
{ {
PropertiesFileStat stat = stat(metrics.getInputFile()); PropertiesFileStat stat = stat(metrics.getInputFile());
stat.setURL(metrics.getInputURL()); stat.setURL(metrics.getInputURL());
stat.setLocalName(metrics.getLocalFileName()); stat.setURLName(metrics.getLocalFileName());
stat.setOrganization(oranization); stat.setOrganization(organization);
stat.setUpdateDate(metrics.getCrawledDate()); stat.setUpdateDate(metrics.getCrawledDate());
PropertyChecker checker = new PropertyChecker(); PropertyChecker checker = new PropertyChecker();
@ -306,8 +306,9 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
PropertiesFileStat stat = stat(organization.getInputFile()); PropertiesFileStat stat = stat(organization.getInputFile());
stat.setURL(organization.getInputURL()); stat.setURL(organization.getInputURL());
stat.setLocalName(organization.getTechnicalName() + ".properties"); stat.setURLName("/federation/organizations/" + organization.getTechnicalName() + "/" + organization.getTechnicalName() + ".properties");
stat.setOrganization(organization); stat.setOrganization(organization);
stat.setService(null);
stat.setUpdateDate(organization.getCrawledDate()); stat.setUpdateDate(organization.getCrawledDate());
PropertyChecker checker = new PropertyChecker(); PropertyChecker checker = new PropertyChecker();
@ -333,8 +334,9 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
PropertiesFileStat stat = stat(service.getInputFile()); PropertiesFileStat stat = stat(service.getInputFile());
stat.setURL(service.getInputURL()); stat.setURL(service.getInputURL());
stat.setLocalName(service.getOrganization().getTechnicalName() + "-" + service.getTechnicalName() + ".properties"); stat.setURLName("/federation/organizations/" + service.getOrganization().getTechnicalName() + "/services/" + service.getTechnicalName() + "/" + service.getTechnicalName() + ".properties");
stat.setOrganization(service.getOrganization()); stat.setOrganization(service.getOrganization());
stat.setService(service);
stat.setUpdateDate(service.getCrawledDate()); stat.setUpdateDate(service.getCrawledDate());
PropertyChecker checker = new PropertyChecker(); PropertyChecker checker = new PropertyChecker();