Fixed hosting properties file management.

This commit is contained in:
Christian P. MOMON 2023-02-25 23:24:09 +01:00
parent ad7494c01f
commit 580d2ff447
5 changed files with 88 additions and 48 deletions

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2023 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.
* *
@ -32,7 +32,9 @@ import fr.devinsy.statoolinfos.crawl.CrawlCache;
import fr.devinsy.statoolinfos.crawl.CrawlJournal; import fr.devinsy.statoolinfos.crawl.CrawlJournal;
import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathProperty; import fr.devinsy.statoolinfos.properties.PathProperty;
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.util.Chrono; 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;
@ -372,7 +374,14 @@ public class Factory
} }
else else
{ {
PathProperties properties = PathPropertyUtils.load(inputFile); 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 = new Service(properties);
result.setOrganization(organization); result.setOrganization(organization);
result.setInputFile(inputFile); result.setInputFile(inputFile);
@ -411,6 +420,7 @@ public class Factory
result.addAll(metrics.getByPrefix("metrics.")); result.addAll(metrics.getByPrefix("metrics."));
} }
} }
}
// //
return result; return result;

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2021 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2023 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.
* *
@ -32,13 +32,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.core.PropertyClassType;
import fr.devinsy.statoolinfos.core.StatoolInfosException; import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.core.StatoolInfosUtils; import fr.devinsy.statoolinfos.core.StatoolInfosUtils;
import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathProperty; 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;
/** /**
* The Class Crawler. * The Class Crawler.
@ -151,8 +151,8 @@ public class Crawler
} }
else else
{ {
PathProperties downloadProperties = PathPropertyUtils.load(downloadFile); PathPropertyList downloadProperties = PathPropertyUtils.load(downloadFile);
PropertyClassType downloadClass = PropertyClassType.of(downloadProperties.get("file.class")); PropertyClassType downloadClass = downloadProperties.getClassType();
if ((downloadClass == null) || (!downloadClass.isChildOf(parent))) if ((downloadClass == null) || (!downloadClass.isChildOf(parent)))
{ {

View file

@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2020-2022 Christian Pierre MOMON <christian@momon.org> * Copyright (C) 2020-2023 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.
* *
@ -319,6 +319,21 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
return result; 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. * Gets the index property.
* *

View file

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

View file

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