Refactor and improved to run with the split web app.
This commit is contained in:
parent
e44bda8db2
commit
f0f915ddc1
16 changed files with 396 additions and 169 deletions
|
@ -16,7 +16,7 @@
|
|||
* 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.core;
|
||||
package fr.devinsy.statoolinfos.app;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -28,8 +28,13 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||
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.metrics.Prober;
|
||||
import fr.devinsy.statoolinfos.metrics.httpaccess.HttpAccessLog;
|
||||
|
@ -53,11 +58,11 @@ import fr.devinsy.strings.StringList;
|
|||
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.
|
||||
|
@ -182,10 +187,6 @@ public class StatoolInfos
|
|||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -242,10 +243,6 @@ public class StatoolInfos
|
|||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1156,11 +1153,11 @@ public class StatoolInfos
|
|||
*/
|
||||
public static void uptime(final File configurationFile) throws StatoolInfosException, IOException
|
||||
{
|
||||
HtmlizerContext.instance().configure(configurationFile);
|
||||
StatoolInfosContext context = new StatoolInfosContext(configurationFile);
|
||||
|
||||
UptimeJournal journal = HtmlizerContext.instance().getUptimeJournal();
|
||||
Federation federation = HtmlizerContext.instance().getFederation();
|
||||
UptimeJournal journal = context.getUptimeJournal();
|
||||
Federation federation = context.getFederation();
|
||||
UptimeSurveyor.survey(journal, federation.getURLActiveAll());
|
||||
HtmlizerContext.instance().getCache().storeUptimeJournal(journal);
|
||||
context.getCache().storeUptimeJournal(journal);
|
||||
}
|
||||
}
|
|
@ -26,8 +26,8 @@ import org.apache.commons.lang3.math.NumberUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.app.StatoolInfosApp;
|
||||
import fr.devinsy.statoolinfos.core.BotFilter;
|
||||
import fr.devinsy.statoolinfos.core.StatoolInfos;
|
||||
import fr.devinsy.statoolinfos.util.BuildInformation;
|
||||
import fr.devinsy.statoolinfos.util.Chrono;
|
||||
import fr.devinsy.statoolinfos.util.Files;
|
||||
|
@ -249,7 +249,7 @@ public final class StatoolInfosCLI
|
|||
File configurationFile = new File(StringUtils.trim(args[1]));
|
||||
try
|
||||
{
|
||||
StatoolInfos.build(configurationFile);
|
||||
StatoolInfosApp.build(configurationFile);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -261,7 +261,7 @@ public final class StatoolInfosCLI
|
|||
File configurationFile = new File(StringUtils.trim(args[1]));
|
||||
try
|
||||
{
|
||||
StatoolInfos.clear(configurationFile);
|
||||
StatoolInfosApp.clear(configurationFile);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -275,7 +275,7 @@ public final class StatoolInfosCLI
|
|||
File configurationFile = new File(StringUtils.trim(args[1]));
|
||||
try
|
||||
{
|
||||
StatoolInfos.crawl(configurationFile);
|
||||
StatoolInfosApp.crawl(configurationFile);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -291,7 +291,7 @@ public final class StatoolInfosCLI
|
|||
{
|
||||
try
|
||||
{
|
||||
StatoolInfos.format(input);
|
||||
StatoolInfosApp.format(input);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -305,13 +305,13 @@ public final class StatoolInfosCLI
|
|||
BotFilter filter = parseLogFilterOption(args[2]);
|
||||
File configurationFile = new File(StringUtils.trim(args[3]));
|
||||
|
||||
StatoolInfos.listIps(configurationFile, filter);
|
||||
StatoolInfosApp.listIps(configurationFile, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatching(args, "list", "ip", ".+\\.conf"))
|
||||
{
|
||||
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)", ".+"))
|
||||
{
|
||||
|
@ -322,7 +322,7 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.listIps(source, filter);
|
||||
StatoolInfosApp.listIps(source, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "list", "ip", ".+"))
|
||||
{
|
||||
|
@ -332,13 +332,13 @@ public final class StatoolInfosCLI
|
|||
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"))
|
||||
{
|
||||
File configurationFile = new File(StringUtils.trim(args[2]));
|
||||
|
||||
StatoolInfos.listAccessFiles(configurationFile);
|
||||
StatoolInfosApp.listAccessFiles(configurationFile);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "list", "(file|files)", ".+"))
|
||||
{
|
||||
|
@ -348,13 +348,13 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.listAccessFiles(source);
|
||||
StatoolInfosApp.listAccessFiles(source);
|
||||
}
|
||||
else if (CLIUtils.isMatching(args, "list", "(errfile|errfiles)", ".+\\.conf"))
|
||||
{
|
||||
File configurationFile = new File(StringUtils.trim(args[2]));
|
||||
|
||||
StatoolInfos.listErrorFiles(configurationFile);
|
||||
StatoolInfosApp.listErrorFiles(configurationFile);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "list", "(errfile|errfiles)", ".+"))
|
||||
{
|
||||
|
@ -364,20 +364,20 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.listErrorFiles(source);
|
||||
StatoolInfosApp.listErrorFiles(source);
|
||||
}
|
||||
else if (CLIUtils.isMatching(args, "list", "(log|logs)", "(-all|-bot|-nobot)", ".+\\.conf*"))
|
||||
{
|
||||
BotFilter filter = parseLogFilterOption(args[2]);
|
||||
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"))
|
||||
{
|
||||
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)", ".+"))
|
||||
{
|
||||
|
@ -388,7 +388,7 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.listLogs(source, filter);
|
||||
StatoolInfosApp.listLogs(source, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "list", "(log|logs)", ".+"))
|
||||
{
|
||||
|
@ -398,13 +398,13 @@ public final class StatoolInfosCLI
|
|||
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"))
|
||||
{
|
||||
File configurationFile = new File(StringUtils.trim(args[2]));
|
||||
|
||||
StatoolInfos.listErrorLogs(configurationFile);
|
||||
StatoolInfosApp.listErrorLogs(configurationFile);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "list", "(errlog|errlogs)", ".+"))
|
||||
{
|
||||
|
@ -414,20 +414,20 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.listErrorLogs(source);
|
||||
StatoolInfosApp.listErrorLogs(source);
|
||||
}
|
||||
else if (CLIUtils.isMatching(args, "list", "(useragent|ua)", "(-all|-bot|-nobot)", ".+\\.conf*"))
|
||||
{
|
||||
BotFilter filter = parseLogFilterOption(args[2]);
|
||||
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"))
|
||||
{
|
||||
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)", ".+"))
|
||||
{
|
||||
|
@ -438,7 +438,7 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.listUserAgents(source, filter);
|
||||
StatoolInfosApp.listUserAgents(source, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "list", "(useragent|ua)", ".+"))
|
||||
{
|
||||
|
@ -448,20 +448,20 @@ public final class StatoolInfosCLI
|
|||
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*"))
|
||||
{
|
||||
BotFilter filter = parseLogFilterOption(args[2]);
|
||||
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"))
|
||||
{
|
||||
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)", ".+"))
|
||||
{
|
||||
|
@ -472,7 +472,7 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.listVisitors(source, filter);
|
||||
StatoolInfosApp.listVisitors(source, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "list", "(visitor|visitors)", ".+"))
|
||||
{
|
||||
|
@ -482,7 +482,7 @@ public final class StatoolInfosCLI
|
|||
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+)", ".+"))
|
||||
{
|
||||
|
@ -521,7 +521,7 @@ public final class StatoolInfosCLI
|
|||
try
|
||||
{
|
||||
System.out.println("Probing [" + input + "] with day count filter " + dayCountFilter);
|
||||
StatoolInfos.probe(input, dayCountFilter);
|
||||
StatoolInfosApp.probe(input, dayCountFilter);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -542,13 +542,13 @@ public final class StatoolInfosCLI
|
|||
BotFilter filter = parseLogFilterOption(args[2]);
|
||||
File configurationFile = new File(StringUtils.trim(args[3]));
|
||||
|
||||
StatoolInfos.statIps(configurationFile, filter);
|
||||
StatoolInfosApp.statIps(configurationFile, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatching(args, "stat", "ip", ".+\\.conf"))
|
||||
{
|
||||
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)", ".+"))
|
||||
{
|
||||
|
@ -559,7 +559,7 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.statIps(source, filter);
|
||||
StatoolInfosApp.statIps(source, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "stat", "ip", ".+"))
|
||||
{
|
||||
|
@ -569,20 +569,20 @@ public final class StatoolInfosCLI
|
|||
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*"))
|
||||
{
|
||||
BotFilter filter = parseLogFilterOption(args[2]);
|
||||
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"))
|
||||
{
|
||||
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)", ".+"))
|
||||
{
|
||||
|
@ -593,7 +593,7 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.statUserAgents(source, filter);
|
||||
StatoolInfosApp.statUserAgents(source, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "stat", "(useragent|ua)", ".+"))
|
||||
{
|
||||
|
@ -603,20 +603,20 @@ public final class StatoolInfosCLI
|
|||
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*"))
|
||||
{
|
||||
BotFilter filter = parseLogFilterOption(args[2]);
|
||||
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"))
|
||||
{
|
||||
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)", ".+"))
|
||||
{
|
||||
|
@ -627,7 +627,7 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.statVisitors(source, filter);
|
||||
StatoolInfosApp.statVisitors(source, filter);
|
||||
}
|
||||
else if (CLIUtils.isMatchingEllipsis(args, "stat", "(visitor|visitors)", ".+"))
|
||||
{
|
||||
|
@ -637,7 +637,7 @@ public final class StatoolInfosCLI
|
|||
source.add(new File(args[index]));
|
||||
}
|
||||
|
||||
StatoolInfos.statVisitors(source, BotFilter.ALL);
|
||||
StatoolInfosApp.statVisitors(source, BotFilter.ALL);
|
||||
}
|
||||
else if (CLIUtils.isMatching(args, "tagdate", ".+"))
|
||||
{
|
||||
|
@ -646,7 +646,7 @@ public final class StatoolInfosCLI
|
|||
{
|
||||
try
|
||||
{
|
||||
StatoolInfos.tagDate(input);
|
||||
StatoolInfosApp.tagDate(input);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
@ -662,7 +662,7 @@ public final class StatoolInfosCLI
|
|||
File configurationFile = new File(StringUtils.trim(args[1]));
|
||||
try
|
||||
{
|
||||
StatoolInfos.uptime(configurationFile);
|
||||
StatoolInfosApp.uptime(configurationFile);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
|
|
|
@ -167,10 +167,10 @@ public class Configuration extends PathPropertyList
|
|||
{
|
||||
File result;
|
||||
|
||||
String path = get("conf.htmlize.categories");
|
||||
String path = get("conf.categories");
|
||||
if (StringUtils.isBlank(path))
|
||||
{
|
||||
throw new StatoolInfosException("Entry conf.htmlize.categories is missing in configuration file.");
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -545,6 +545,28 @@ public class Configuration extends PathPropertyList
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -35,7 +35,6 @@ import fr.devinsy.statoolinfos.properties.PathProperty;
|
|||
import fr.devinsy.statoolinfos.properties.PathPropertyList;
|
||||
import fr.devinsy.statoolinfos.properties.PathPropertyUtils;
|
||||
import fr.devinsy.statoolinfos.properties.PropertyClassType;
|
||||
import fr.devinsy.statoolinfos.util.Chrono;
|
||||
import fr.devinsy.strings.StringList;
|
||||
import fr.devinsy.strings.StringSet;
|
||||
|
||||
|
@ -66,33 +65,9 @@ public class Factory
|
|||
{
|
||||
Categories result;
|
||||
|
||||
result = new Categories();
|
||||
|
||||
PathProperties properties = PathPropertyUtils.load(source);
|
||||
|
||||
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();
|
||||
result = loadCategories(properties);
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -130,6 +105,102 @@ public class Factory
|
|||
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.
|
||||
*
|
||||
|
@ -141,12 +212,19 @@ public class Factory
|
|||
* @throws IOException
|
||||
* 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;
|
||||
|
||||
PathProperties properties = PathPropertyUtils.load(configurationFile);
|
||||
result = new Configuration(properties);
|
||||
try
|
||||
{
|
||||
PathProperties properties = PathPropertyUtils.load(configurationFile);
|
||||
result = new Configuration(properties);
|
||||
}
|
||||
catch (IOException exception)
|
||||
{
|
||||
throw new StatoolInfosException("Error reading configuration file: " + configurationFile, exception);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -170,7 +248,6 @@ public class Factory
|
|||
Federation result;
|
||||
|
||||
System.out.println("Loading federation " + inputURL);
|
||||
Chrono chrono = new Chrono().start();
|
||||
|
||||
if (inputURL == null)
|
||||
{
|
||||
|
@ -201,7 +278,7 @@ public class Factory
|
|||
result = new Federation(properties);
|
||||
result.setInputURL(inputURL);
|
||||
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();
|
||||
PropertyChecks checks = checker.checkFederation(result.getInputFile());
|
||||
|
@ -227,7 +304,6 @@ public class Factory
|
|||
result.getCrawlJournal().addAll(cache.restoreCrawlJournal());
|
||||
}
|
||||
}
|
||||
System.out.println("Federation loaded in " + chrono.format());
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -253,7 +329,6 @@ public class Factory
|
|||
System.out.println("Loading metrics " + inputURL);
|
||||
|
||||
File inputFile = cache.restoreFile(inputURL);
|
||||
|
||||
if (inputFile == null)
|
||||
{
|
||||
logger.warn("WARNING: metrics not found in cache [{}]", inputURL);
|
||||
|
@ -310,7 +385,7 @@ public class Factory
|
|||
{
|
||||
result.setInputFile(inputFile);
|
||||
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();
|
||||
|
@ -386,7 +461,7 @@ public class Factory
|
|||
result.setOrganization(organization);
|
||||
result.setInputFile(inputFile);
|
||||
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");
|
||||
|
|
|
@ -42,8 +42,6 @@ import fr.devinsy.statoolinfos.util.URLUtils;
|
|||
*/
|
||||
public class Organization extends PathPropertyList
|
||||
{
|
||||
private static final long serialVersionUID = -2709210934548224213L;
|
||||
|
||||
public enum Status
|
||||
{
|
||||
ACTIVE,
|
||||
|
@ -62,6 +60,8 @@ public class Organization extends PathPropertyList
|
|||
OTHER
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -2709210934548224213L;
|
||||
|
||||
private Federation federation;
|
||||
private Services services;
|
||||
private File inputFile;
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -21,6 +21,9 @@ package fr.devinsy.statoolinfos.core;
|
|||
import java.time.Year;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* The Class Organizations.
|
||||
|
@ -37,6 +40,22 @@ public class Organizations extends ArrayList<Organization>
|
|||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new organizations.
|
||||
*
|
||||
* @param organization
|
||||
* the organization
|
||||
*/
|
||||
public Organizations(final Organization organization)
|
||||
{
|
||||
super();
|
||||
|
||||
if (organization != null)
|
||||
{
|
||||
add(organization);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter active.
|
||||
*
|
||||
|
@ -227,6 +246,43 @@ public class Organizations extends ArrayList<Organization>
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -22,6 +22,7 @@ import java.time.LocalDate;
|
|||
import java.time.Year;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
@ -42,6 +43,22 @@ public class Services extends ArrayList<Service>
|
|||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new services.
|
||||
*
|
||||
* @param service
|
||||
* the service
|
||||
*/
|
||||
public Services(final Service service)
|
||||
{
|
||||
super();
|
||||
|
||||
if (service != null)
|
||||
{
|
||||
add(service);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Count by year.
|
||||
*
|
||||
|
@ -190,6 +207,43 @@ public class Services extends ArrayList<Service>
|
|||
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.
|
||||
*
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -77,6 +77,8 @@ public class Softwares extends HashMap<String, Software>
|
|||
*/
|
||||
public void put(final Software software)
|
||||
{
|
||||
put(buildKey(software.getName()), software);
|
||||
|
||||
for (String alias : software.getAliases())
|
||||
{
|
||||
put(buildKey(alias), software);
|
||||
|
|
|
@ -16,30 +16,21 @@
|
|||
* 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;
|
||||
package fr.devinsy.statoolinfos.core;
|
||||
|
||||
import java.io.File;
|
||||
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.uptime.UptimeJournal;
|
||||
|
||||
/**
|
||||
* The Class HtmlizerContext.
|
||||
* The Class StatoolInfosContext.
|
||||
*/
|
||||
public class HtmlizerContext
|
||||
public class StatoolInfosContext
|
||||
{
|
||||
private static class SingletonHolder
|
||||
{
|
||||
private static final HtmlizerContext instance = new HtmlizerContext();
|
||||
}
|
||||
|
||||
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(HtmlizerContext.class);
|
||||
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(StatoolInfosContext.class);
|
||||
|
||||
private Configuration configuration;
|
||||
private Federation federation;
|
||||
|
@ -49,9 +40,13 @@ public class HtmlizerContext
|
|||
|
||||
/**
|
||||
* 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())
|
||||
{
|
||||
long startTime = System.currentTimeMillis();
|
||||
System.out.println("Loading configuration file.");
|
||||
this.federation = Factory.loadFederation(this.configuration.getHtmlizeInputURL(), this.cache);
|
||||
this.categories = Factory.loadCategories(this.configuration.getCategoryFile(), this.federation);
|
||||
if (this.configuration.isCategoryFileDefined())
|
||||
{
|
||||
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();
|
||||
System.out.println("Loaded configuration context in " + (System.currentTimeMillis() - startTime) + " ms.");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -152,14 +158,4 @@ public class HtmlizerContext
|
|||
{
|
||||
return this.uptimeJournal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @return the manager
|
||||
*/
|
||||
public static HtmlizerContext instance()
|
||||
{
|
||||
return SingletonHolder.instance;
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
*
|
||||
|
@ -46,14 +46,14 @@ import fr.devinsy.statoolinfos.util.URLUtils;
|
|||
*/
|
||||
public class CrawlCache
|
||||
{
|
||||
private static Logger logger = LoggerFactory.getLogger(CrawlCache.class);
|
||||
|
||||
public static enum DefaultLogoGenerator
|
||||
{
|
||||
CAT,
|
||||
BIRD
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(CrawlCache.class);
|
||||
|
||||
private File directory;
|
||||
|
||||
/**
|
||||
|
@ -234,7 +234,7 @@ public class CrawlCache
|
|||
}
|
||||
else
|
||||
{
|
||||
logger.info("CatGeneratoring from {}", url);
|
||||
logger.info("Restoring logo from {}", url);
|
||||
File logoFile = restoreFile(url);
|
||||
if (logoFile == null)
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -25,7 +25,6 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||
import fr.devinsy.statoolinfos.core.Categories;
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
import fr.devinsy.statoolinfos.core.Organizations;
|
||||
|
@ -80,13 +79,13 @@ public class CSVFile
|
|||
* @throws IOException
|
||||
* 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;
|
||||
try
|
||||
{
|
||||
out = new CSVWriter(file, ';');
|
||||
write(out, source);
|
||||
write(out, source, categories);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -155,7 +154,7 @@ public class CSVFile
|
|||
* @throws IOException
|
||||
* 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.
|
||||
StringList labels = new StringList(100);
|
||||
|
@ -188,8 +187,6 @@ public class CSVFile
|
|||
}
|
||||
out.writeEndRow();
|
||||
|
||||
Categories categories = HtmlizerContext.instance().getCategories();
|
||||
|
||||
// Write service lines.
|
||||
for (Service service : services)
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -27,7 +27,6 @@ import org.apache.commons.text.StringEscapeUtils;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.HtmlizerContext;
|
||||
import fr.devinsy.statoolinfos.core.Categories;
|
||||
import fr.devinsy.statoolinfos.core.Federation;
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
|
@ -238,11 +237,11 @@ public class JSONFile
|
|||
* the service
|
||||
* @return the string list
|
||||
*/
|
||||
public static StringList toJSON(final Service service)
|
||||
public static StringList toJSON(final Service service, final Categories categories)
|
||||
{
|
||||
StringList result;
|
||||
|
||||
result = toJSON((PathPropertyList) service);
|
||||
result = toJSON(service);
|
||||
|
||||
//
|
||||
result.removeLast();
|
||||
|
@ -266,7 +265,6 @@ public class JSONFile
|
|||
result.append(",");
|
||||
|
||||
//
|
||||
Categories categories = HtmlizerContext.instance().getCategories();
|
||||
result.append("\"");
|
||||
result.append("software.categories");
|
||||
result.append("\" : \"");
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -24,6 +24,7 @@ import java.io.IOException;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import fr.devinsy.statoolinfos.core.Categories;
|
||||
import fr.devinsy.statoolinfos.core.Organizations;
|
||||
import fr.devinsy.statoolinfos.core.Services;
|
||||
|
||||
|
@ -32,11 +33,11 @@ import fr.devinsy.statoolinfos.core.Services;
|
|||
*/
|
||||
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
|
||||
{
|
||||
MANDATORY,
|
||||
OPTIONAL
|
||||
|
@ -75,13 +76,13 @@ public class ODSFile
|
|||
* @param 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;
|
||||
try
|
||||
{
|
||||
out = new ODSWriter(file);
|
||||
CSVFile.write(out, source);
|
||||
CSVFile.write(out, source, categories);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -22,15 +22,17 @@ import java.net.URL;
|
|||
import java.time.LocalDateTime;
|
||||
|
||||
import fr.devinsy.statoolinfos.core.Organization;
|
||||
import fr.devinsy.statoolinfos.core.Service;
|
||||
|
||||
/**
|
||||
* The Class PropertiesFileStat.
|
||||
*/
|
||||
public class PropertiesFileStat
|
||||
{
|
||||
private String localName;
|
||||
private String urlName;
|
||||
private URL url;
|
||||
private Organization organization;
|
||||
private Service service;
|
||||
private int lineCount;
|
||||
private int activeLineCount;
|
||||
private int blankPropertyCount;
|
||||
|
@ -78,11 +80,6 @@ public class PropertiesFileStat
|
|||
return this.lineCount;
|
||||
}
|
||||
|
||||
public String getLocalName()
|
||||
{
|
||||
return this.localName;
|
||||
}
|
||||
|
||||
public Organization getOrganization()
|
||||
{
|
||||
return this.organization;
|
||||
|
@ -93,6 +90,11 @@ public class PropertiesFileStat
|
|||
return this.activeLineCount;
|
||||
}
|
||||
|
||||
public Service getService()
|
||||
{
|
||||
return this.service;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateDate()
|
||||
{
|
||||
return this.updateDate;
|
||||
|
@ -103,6 +105,11 @@ public class PropertiesFileStat
|
|||
return this.url;
|
||||
}
|
||||
|
||||
public String getURLName()
|
||||
{
|
||||
return this.urlName;
|
||||
}
|
||||
|
||||
public int getVoidCount()
|
||||
{
|
||||
return this.voidCount;
|
||||
|
@ -183,16 +190,16 @@ public class PropertiesFileStat
|
|||
this.lineCount = lineCount;
|
||||
}
|
||||
|
||||
public void setLocalName(final String localName)
|
||||
{
|
||||
this.localName = localName;
|
||||
}
|
||||
|
||||
public void setOrganization(final Organization organization)
|
||||
{
|
||||
this.organization = organization;
|
||||
}
|
||||
|
||||
public void setService(final Service service)
|
||||
{
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public void setUpdateDate(final LocalDateTime updateDate)
|
||||
{
|
||||
this.updateDate = updateDate;
|
||||
|
@ -203,6 +210,11 @@ public class PropertiesFileStat
|
|||
this.url = url;
|
||||
}
|
||||
|
||||
public void setURLName(final String localName)
|
||||
{
|
||||
this.urlName = localName;
|
||||
}
|
||||
|
||||
public void setVoidCount(final int voidCount)
|
||||
{
|
||||
this.voidCount = voidCount;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -238,7 +253,7 @@ public class PropertiesFileStatComparator implements Comparator<PropertiesFileSt
|
|||
}
|
||||
else
|
||||
{
|
||||
result = source.getLocalName();
|
||||
result = source.getURLName();
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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.
|
||||
*
|
||||
|
@ -274,13 +274,13 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
|
|||
* @throws IOException
|
||||
* 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());
|
||||
|
||||
stat.setURL(metrics.getInputURL());
|
||||
stat.setLocalName(metrics.getLocalFileName());
|
||||
stat.setOrganization(oranization);
|
||||
stat.setURLName(metrics.getLocalFileName());
|
||||
stat.setOrganization(organization);
|
||||
stat.setUpdateDate(metrics.getCrawledDate());
|
||||
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
|
@ -306,8 +306,9 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
|
|||
PropertiesFileStat stat = stat(organization.getInputFile());
|
||||
|
||||
stat.setURL(organization.getInputURL());
|
||||
stat.setLocalName(organization.getTechnicalName() + ".properties");
|
||||
stat.setURLName("/federation/organizations/" + organization.getTechnicalName() + "/" + organization.getTechnicalName() + ".properties");
|
||||
stat.setOrganization(organization);
|
||||
stat.setService(null);
|
||||
stat.setUpdateDate(organization.getCrawledDate());
|
||||
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
|
@ -333,8 +334,9 @@ public class PropertiesFileStats extends ArrayList<PropertiesFileStat>
|
|||
PropertiesFileStat stat = stat(service.getInputFile());
|
||||
|
||||
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.setService(service);
|
||||
stat.setUpdateDate(service.getCrawledDate());
|
||||
|
||||
PropertyChecker checker = new PropertyChecker();
|
||||
|
|
Loading…
Reference in a new issue