Compare commits

..

No commits in common. "580d2ff447f86d4990fc9ed26f8edf3d2a3ab6c7" and "ec9f8ede3ca4e834772489a26f05584a7be24636" have entirely different histories.

6 changed files with 49 additions and 89 deletions

View file

@ -39,7 +39,7 @@ public class PropertyChecker
public static final String BOM = "\ufeff";
public static final String COMMENT = "^#.*$";
public static final String STRING = "^.+$";
public static final String DATETIME = "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}([\\.,]\\d+)?)?([+-]\\d\\d:\\d\\d|Z)?";
public static final String DATETIME = "\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}(:\\d{2}([\\.,]\\d+)?)?([+-]\\d\\d:\\d\\d)?";
public static final String DATE = "^(\\d{4}-\\d{2}-\\d{2}|\\d{2}/\\d{2}/\\d{4}|\\d{2}/\\d{4})";
public static final String URL = "^https?://[\\w-_\\.]+(\\.\\w+)+(:\\d+)?(/.*)?$";
public static final String EMAIL = "^.*@.*$";

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -32,9 +32,7 @@ import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.crawl.CrawlJournal;
import fr.devinsy.statoolinfos.properties.PathProperties;
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;
@ -374,51 +372,43 @@ public class Factory
}
else
{
PathPropertyList properties = PathPropertyUtils.load(inputFile);
if (properties.getClassType() != PropertyClassType.SERVICE)
{
logger.warn("WARNING: not file class service [{}]", inputURL);
result = null;
}
else
{
result = new Service(properties);
result.setOrganization(organization);
result.setInputFile(inputFile);
result.setInputURL(inputURL);
result.setLogoFileName(organization.getTechnicalName() + "-" + result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png"));
PathProperties properties = PathPropertyUtils.load(inputFile);
result = new Service(properties);
result.setOrganization(organization);
result.setInputFile(inputFile);
result.setInputURL(inputURL);
result.setLogoFileName(organization.getTechnicalName() + "-" + result.getTechnicalName() + "-logo" + StringUtils.defaultIfBlank(cache.getExtension(result.getLogoURL()), ".png"));
//
PathProperties subs = result.getByPrefix("subs");
for (PathProperty property : subs)
//
PathProperties subs = result.getByPrefix("subs");
for (PathProperty property : subs)
{
if (StringUtils.startsWith(property.getValue(), "http"))
{
if (StringUtils.startsWith(property.getValue(), "http"))
URL metricsInputURL = new URL(property.getValue());
Metrics metrics = loadMetrics(metricsInputURL, cache, organization.getTechnicalName() + "-" + result.getTechnicalName());
if (metrics != null)
{
URL metricsInputURL = new URL(property.getValue());
Metrics metrics = loadMetrics(metricsInputURL, cache, organization.getTechnicalName() + "-" + result.getTechnicalName());
if (metrics != null)
{
result.getMetrics().add(metrics);
}
result.getMetrics().add(metrics);
}
}
}
//
PropertyChecker checker = new PropertyChecker();
PropertyChecks checks = checker.checkService(result.getInputFile());
checks.setFileName(result.getLocalFileName());
result.getInputChecks().addAll(checks);
//
PropertyChecker checker = new PropertyChecker();
PropertyChecks checks = checker.checkService(result.getInputFile());
checks.setFileName(result.getLocalFileName());
result.getInputChecks().addAll(checks);
//
CrawlJournal journal = cache.restoreCrawlJournal();
result.getCrawlJournal().add(journal.getByUrl(inputURL));
result.getCrawlJournal().addAll(journal.searchByParent(result.getInputURL()));
//
CrawlJournal journal = cache.restoreCrawlJournal();
result.getCrawlJournal().add(journal.getByUrl(inputURL));
result.getCrawlJournal().addAll(journal.searchByParent(result.getInputURL()));
//
for (Metrics metrics : result.getMetrics())
{
result.addAll(metrics.getByPrefix("metrics."));
}
//
for (Metrics metrics : result.getMetrics())
{
result.addAll(metrics.getByPrefix("metrics."));
}
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2021-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -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.properties;
package fr.devinsy.statoolinfos.core;
import org.apache.commons.lang3.StringUtils;
@ -25,7 +25,6 @@ public enum PropertyClassType
FEDERATION,
ORGANIZATION,
SERVICE,
HOSTING,
METRICS;
/**
@ -71,16 +70,6 @@ public enum PropertyClassType
result = false;
}
break;
case HOSTING:
if (parent == ORGANIZATION)
{
result = true;
}
else
{
result = false;
}
break;
case METRICS:
if (parent == METRICS)
{
@ -128,10 +117,6 @@ public enum PropertyClassType
{
result = SERVICE;
}
else if (StringUtils.equals(target, "hosting"))
{
result = HOSTING;
}
else if (StringUtils.equals(target, "metrics"))
{
result = METRICS;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -32,13 +32,13 @@ import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.PropertyClassType;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathProperty;
import fr.devinsy.statoolinfos.properties.PathPropertyList;
import fr.devinsy.statoolinfos.properties.PathPropertyUtils;
import fr.devinsy.statoolinfos.properties.PropertyClassType;
/**
* The Class Crawler.
@ -151,8 +151,8 @@ public class Crawler
}
else
{
PathPropertyList downloadProperties = PathPropertyUtils.load(downloadFile);
PropertyClassType downloadClass = downloadProperties.getClassType();
PathProperties downloadProperties = PathPropertyUtils.load(downloadFile);
PropertyClassType downloadClass = PropertyClassType.of(downloadProperties.get("file.class"));
if ((downloadClass == null) || (!downloadClass.isChildOf(parent)))
{

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -319,21 +319,6 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
return result;
}
/**
* Gets the file class.
*
* @return the file class
*/
public PropertyClassType getClassType()
{
PropertyClassType result;
result = PropertyClassType.of(get("file.class"));
//
return result;
}
/**
* Gets the index property.
*

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2023 Christian Pierre MOMON <christian@momon.org>
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org>
*
* This file is part of StatoolInfos, simple service statistics tool.
*
@ -78,9 +78,9 @@ public class PathPropertyUtils
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static PathPropertyList load(final File file) throws IOException
public static PathProperties load(final File file) throws IOException
{
PathPropertyList result;
PathProperties result;
result = load(file, StandardCharsets.UTF_8);
@ -99,9 +99,9 @@ public class PathPropertyUtils
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static PathPropertyList load(final File file, final Charset charset) throws IOException
public static PathProperties load(final File file, final Charset charset) throws IOException
{
PathPropertyList result;
PathProperties result;
if (file == null)
{
@ -136,9 +136,9 @@ public class PathPropertyUtils
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static PathPropertyList load(final URL url) throws IOException
public static PathProperties load(final URL url) throws IOException
{
PathPropertyList result;
PathProperties result;
StringList lines = StringsUtils.load(url);
@ -157,9 +157,9 @@ public class PathPropertyUtils
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static PathPropertyList read(final BufferedReader in) throws IOException
public static PathProperties read(final BufferedReader in) throws IOException
{
PathPropertyList result;
PathProperties result;
result = new PathPropertyList();
@ -191,9 +191,9 @@ public class PathPropertyUtils
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public static PathPropertyList read(final StringList source) throws IOException
public static PathProperties read(final StringList source) throws IOException
{
PathPropertyList result;
PathProperties result;
result = new PathPropertyList();