Step in dev.

This commit is contained in:
Christian P. MOMON 2020-09-19 02:37:52 +02:00
parent 8d95c0e62b
commit 350df0bfa2
22 changed files with 248 additions and 95 deletions

View file

@ -2,11 +2,12 @@
# #################
# priority setting: DEBUG < INFO < WARN < ERROR
log4j.rootLogger = DEBUG, console
log4j.rootLogger = INFO, console
log4j.logger.fr.devinsy.statoolinfos = INFO
log4j.logger.fr.devinsy.xidyn = WARN
#--
log4j.appender.console = org.apache.log4j.ConsoleAppender
log4j.appender.console.layout = org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern = %d{ISO8601} - StatoolInfos [%-5p] %34.34c.%25M - %m%n
#log4j.appender.console.layout.ConversionPattern = %d{ISO8601} - StatoolInfos [%-5p] %34.34c.%25M - %m%n
log4j.appender.console.layout.ConversionPattern = %m%n

View file

@ -1,3 +0,0 @@
Manifest-Version: 1.0
Class-Path:

View file

@ -1,9 +0,0 @@
<Context>
<Resource name="jdbc/kiwa-devdb" auth="Container" type="javax.sql.DataSource"
maxActive="50" maxIdle="30" maxWait="10000"
username="kiwa-devdb-admin" password="12345678"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/kiwa-devdb?useUnicode=true&amp;characterEncoding=UTF-8"/>
</Context>

View file

@ -52,7 +52,7 @@ public final class StatoolInfosLauncher
public static void main(final String[] args)
{
// Configure log.
File loggerConfig = new File("log4j.peroperties");
File loggerConfig = new File("log4j.properties");
if (loggerConfig.exists())
{
PropertyConfigurator.configure(loggerConfig.getAbsolutePath());

View file

@ -26,9 +26,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.StatoolInfos;
import fr.devinsy.statoolinfos.utils.Files;
import fr.devinsy.statoolinfos.util.BuildInformation;
import fr.devinsy.statoolinfos.util.Files;
import fr.devinsy.strings.StringList;
import utils.BuildInformation;
/**
* The Class <code>StatoolInfosCLI</code> manages a Command Line Interface for
@ -292,5 +292,8 @@ public final class StatoolInfosCLI
logger.info("Bad usage.");
displayHelp();
}
//
logger.info("Done.");
}
}

View file

@ -152,31 +152,56 @@ public class CrawlCache
}
/**
* Restore file to.
* Restore logo to.
*
* @param url
* the url
* @param targetDirectory
* the target directory
* @param target
* the target
* @param seed
* the seed
* @throws IOException
* Signals that an I/O exception has occurred.
*/
public void restoreLogoTo(final URL url, final File target) throws IOException
public void restoreLogoTo(final URL url, final File target, final String seed) throws IOException
{
if (url == null)
if ((target == null) || (seed == null))
{
StatoolInfosUtils.generateCatLogo(target.getName(), target);
throw new IllegalArgumentException("Null parameter.");
}
else
{
File logoFile = restoreFile(url);
if (logoFile == null)
if (url == null)
{
StatoolInfosUtils.generateCatLogo(target.getName(), target);
try
{
StatoolInfosUtils.generateCatLogo(seed, target);
}
catch (IOException exception)
{
logger.warn("CatGeneratoring failed for {}: {}", seed, exception.getMessage());
StatoolInfosUtils.copyRessource("/fr/devinsy/statoolinfos/htmlize/stuff/default-organization-logo.png", target);
}
}
else
{
FileUtils.copyFile(logoFile, target);
File logoFile = restoreFile(url);
if (logoFile == null)
{
try
{
StatoolInfosUtils.generateCatLogo(seed, target);
}
catch (IOException exception)
{
logger.warn("CatGeneratoring failed for {}: {}", seed, exception.getMessage());
StatoolInfosUtils.copyRessource("/fr/devinsy/statoolinfos/htmlize/stuff/default-organization-logo.png", target);
}
}
else
{
FileUtils.copyFile(logoFile, target);
}
}
}
}

View file

@ -80,6 +80,11 @@ public class Federation extends PathPropertyList
return result;
}
/**
* Gets the local file.
*
* @return the local file
*/
public File getLocalFile()
{
return this.localFile;
@ -124,11 +129,45 @@ public class Federation extends PathPropertyList
return result;
}
/**
* Gets the organiation count.
*
* @return the organiation count
*/
public int getOrganiationCount()
{
int result;
result = this.organizations.size();
//
return result;
}
public Organizations getOrganizations()
{
return this.organizations;
}
/**
* Gets the service count.
*
* @return the service count
*/
public int getServiceCount()
{
int result;
result = 0;
for (Organization organization : this.organizations)
{
result += organization.getServiceCount();
}
//
return result;
}
/**
* Gets the technical name.
*

View file

@ -19,6 +19,8 @@
package fr.devinsy.statoolinfos.core;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.lang3.StringUtils;
@ -78,6 +80,31 @@ public class Organization extends PathPropertyList
return this.localFile;
}
/**
* Gets the logo URL.
*
* @return the logo URL
* @throws MalformedURLException
* the malformed URL exception
*/
public URL getLogoURL() throws MalformedURLException
{
URL result;
String path = get("organization.logo");
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http")))
{
result = null;
}
else
{
result = new URL(path);
}
//
return result;
}
/**
* Gets the name.
*
@ -93,6 +120,21 @@ public class Organization extends PathPropertyList
return result;
}
/**
* Gets the service count.
*
* @return the service count
*/
public int getServiceCount()
{
int result;
result = this.services.size();
//
return result;
}
public Services getServices()
{
return this.services;

View file

@ -19,12 +19,16 @@
package fr.devinsy.statoolinfos.core;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.apache.commons.lang3.StringUtils;
import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathPropertyList;
/**
* The Class PathProperty.
* The Class Service.
*/
public class Service extends PathPropertyList
{
@ -70,6 +74,31 @@ public class Service extends PathPropertyList
return this.localFile;
}
/**
* Gets the logo URL.
*
* @return the logo URL
* @throws MalformedURLException
* the malformed URL exception
*/
public URL getLogoURL() throws MalformedURLException
{
URL result;
String path = get("service.logo");
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http")))
{
result = null;
}
else
{
result = new URL(path);
}
//
return result;
}
/**
* Gets the name.
*

View file

@ -215,11 +215,7 @@ public class StatoolInfos
PathProperties input = PathPropertyUtils.load(configuration.getCrawlInput());
cache.storeQuietly(input.getURL("federation.logo"));
cache.storeQuietly(input.getURL("federation.logo.url"));
cache.storeQuietly(input.getURL("organization.logo"));
cache.storeQuietly(input.getURL("organization.logo.url"));
cache.storeQuietly(input.getURL("service.logo"));
cache.storeQuietly(input.getURL("service.logo.url"));
PathProperties subs = input.getByPrefix("subs");
for (PathProperty property : subs)
@ -255,12 +251,8 @@ public class StatoolInfos
properties.add(crawlSection);
cache.storeProperties(url, properties);
cache.storeQuietly(properties.getURL("federation.logo"));
cache.storeQuietly(properties.getURL("federation.logo.url"));
cache.storeQuietly(properties.getURL("organization.logo"));
cache.storeQuietly(properties.getURL("organization.logo.url"));
cache.storeQuietly(properties.getURL("service.logo"));
cache.storeQuietly(properties.getURL("service.logo.url"));
//
PathProperties subs = properties.getByPrefix("subs");

View file

@ -28,10 +28,10 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Federation;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.util.BuildInformation;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
import utils.BuildInformation;
/**
* The Class OrganizationPage.
@ -62,19 +62,23 @@ public class FederationPage
data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
data.setAttribute("federationRawButton", "href", federation.getTechnicalName() + "-raw.properties");
data.setAttribute("federationLogo", "src", federation.getTechnicalName() + "-logo.jpg");
data.setEscapedContent("federationName", federation.getName());
data.setEscapedContent("federationDescription", federation.getDescription());
data.setContent("organizationCount", federation.getOrganizations().size());
data.setAttribute("federationRawButton", "href", federation.getTechnicalName() + "-origin.properties");
data.setContent("serviceCount", federation.getServiceCount());
int index = 0;
for (Organization organization : federation.getOrganizations())
{
data.setEscapedContent("organizationListLine", index, "organizationListLineNameLink", organization.getName());
data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml");
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.jpg");
data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite());
data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite());
data.setContent("organizationListLine", index, "organizationListLineServiceCount", organization.getServiceCount());
index += 1;
}

View file

@ -93,7 +93,10 @@ public class Htmlizer
Federation federation = Factory.loadFederation(htmlizeInput, cache);
copyStuff(htmlizeDirectory);
cache.restoreLogoTo(federation.getLogoURL(), new File(htmlizeDirectory, federation.getTechnicalName() + "-logo.jpg"));
// Manage the logo file.
cache.restoreLogoTo(federation.getLogoURL(), new File(htmlizeDirectory, federation.getTechnicalName() + "-logo.jpg"), federation.getTechnicalName());
FileUtils.copyFile(federation.getLocalFile(), new File(htmlizeDirectory, federation.getTechnicalName() + "-raw.properties"));
//
String page = FederationPage.build(federation);
@ -101,11 +104,20 @@ public class Htmlizer
for (Organization organization : federation.getOrganizations())
{
// Manage the logo file.
cache.restoreLogoTo(organization.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-logo.jpg"), organization.getTechnicalName());
FileUtils.copyFile(organization.getLocalFile(), new File(htmlizeDirectory, organization.getTechnicalName() + "-raw.properties"));
//
page = OrganizationPage.build(organization);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
for (Service service : organization.getServices())
{
// Manage the logo file.
cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, service.getTechnicalName() + "-logo.jpg"), service.getTechnicalName());
FileUtils.copyFile(service.getLocalFile(), new File(htmlizeDirectory, service.getTechnicalName() + "-raw.properties"));
page = ServicePage.build(service);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
}
@ -135,42 +147,38 @@ public class Htmlizer
public static void htmlizeOrganisation(final Configuration configuration) throws IOException, StatoolInfosException
{
CrawlCache cache = configuration.getCrawlCache();
File htmlizeInput = configuration.getHtmlizeInput();
File htmlizeDirectory = configuration.getHtmlizeDirectory();
Organization organization = Factory.loadOrganization(configuration.getBuildInput(), cache);
File targetDirectory = new File(organization.get("conf.htmlize.directory"));
logger.info("Htmlize target directory: {}", targetDirectory.getAbsoluteFile());
copyStuff(htmlizeDirectory);
if (!targetDirectory.exists())
// Manage the logo file.
cache.restoreLogoTo(organization.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-logo.jpg"), organization.getTechnicalName());
//
String page = OrganizationPage.build(organization);
FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8);
for (Service service : organization.getServices())
{
throw new IllegalArgumentException("Htmlize target directory is missing.");
}
else if (!targetDirectory.isDirectory())
{
throw new IllegalArgumentException("Htmlize target directory is not a directory.");
}
else
{
copyStuff(targetDirectory);
// Manage the logo file.
cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, service.getTechnicalName() + "-logo.jpg"), service.getTechnicalName());
//
String page = OrganizationPage.build(organization);
FileUtils.write(new File(targetDirectory, "index.xhtml"), page, StandardCharsets.UTF_8);
for (Service service : organization.getServices())
{
page = ServicePage.build(service);
FileUtils.write(new File(targetDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
}
// Download federation stuff (favicon, logo).
// Build the federation page.
// For each organization
// Download organization stuff (favicon, logo).
// Build organization page.
// for each service
// Download service stuff (favicon, logo).
// Build service page.
page = ServicePage.build(service);
FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8);
}
// Download federation stuff (favicon, logo).
// Build the federation page.
// For each organization
// Download organization stuff (favicon, logo).
// Build organization page.
// for each service
// Download service stuff (favicon, logo).
// Build service page.
}
}

View file

@ -28,10 +28,10 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Organization;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.util.BuildInformation;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
import utils.BuildInformation;
/**
* The Class OrganizationPage.
@ -62,6 +62,9 @@ public class OrganizationPage
data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
data.setAttribute("organizationRawButton", "href", organization.getTechnicalName() + "-raw.properties");
data.setAttribute("organizationLogo", "src", organization.getTechnicalName() + "-logo.jpg");
data.setEscapedContent("organizationName", organization.get("organization.name"));
data.setEscapedContent("organizationDescription", organization.get("organization.description"));
data.setContent("serviceCount", organization.getServices().size());

View file

@ -27,10 +27,10 @@ import org.slf4j.LoggerFactory;
import fr.devinsy.statoolinfos.core.Service;
import fr.devinsy.statoolinfos.core.StatoolInfosException;
import fr.devinsy.statoolinfos.util.BuildInformation;
import fr.devinsy.xidyn.XidynException;
import fr.devinsy.xidyn.data.TagDataManager;
import fr.devinsy.xidyn.presenters.PresenterUtils;
import utils.BuildInformation;
/**
* The Class OrganizationPage.
@ -61,6 +61,9 @@ public class ServicePage
data.setContent("versionsup", BuildInformation.instance().version());
data.setContent("lastUpdateDate", LocalDateTime.now().format(DateTimeFormatter.ofPattern("dd/MM/yyyy HH':'mm", Locale.FRANCE)));
data.setAttribute("serviceRawButton", "href", service.getTechnicalName() + "-raw.properties");
data.setAttribute("serviceLogo", "src", service.getTechnicalName() + "-logo.jpg");
data.setEscapedContent("serviceName", service.getName());
data.setEscapedContent("serviceDescription", service.getDescription());

View file

@ -13,22 +13,34 @@
<body>
<div style="margin: 5px 10px 10px 10px;">
<h1><a href="index.xhtml"><img src="logo.jpg" style="width: 35px;"/> StatoolInfos</a><sup id="versionsup" style="font-size: 9px;">v0.0.14</sup> <a href="about.xhtml">About</a><span style="font-size: 9px; float: right;">Page updated on<br/><span id="lastUpdateDate" style="font-size: 9px;">xx/xx/xxxx xx:xx</span></span></h1>
<h2><img id="federationLogo" src="#" style="width: 100px; heigth: 100px;"/> <span id="federationName">Federation name</span></h2>
<p id="federationDescription">Bla bla description</p>
<div>Nombre de membres : <span id="organizationCount">n/a</span></div>
<div>
<table class="table_classic">
<tr>
<th class="">Nom du membre</th>
<th class="">URL</th>
</tr>
<tr id="organizationListLine">
<td id="organizationListLineName"><a href="#" id="organizationListLineNameLink">n/a</a></td>
<td id="organizationListLineUrl"><a href="#" id="organizationListLineUrlLink">n/a</a></td>
</tr>
</table>
<div class="center">
<h2><img id="federationLogo" src="#" style="width: 100px; heigth: 100px; vertical-align: middle;"/> <span id="federationName">Federation name</span></h2>
<div style="margin: 5px;">
<a id="federationRawButton" href="#" class="button">Raw</a>
</div>
<p id="federationDescription">Bla bla description</p>
<div>Nombre de membres : <span id="organizationCount">n/a</span></div>
<div>Nombre de services : <span id="serviceCount">n/a</span></div>
<div class="left">
<table class="table_classic center_table" style="width: 600px; margin-left: auto; margin-right: auto;">
<tr>
<th style="width: 200px;">Nom du membre</th>
<th style="width: 250px;">URL</th>
<th style="width: 10px;">Services</th>
</tr>
<tr id="organizationListLine">
<td id="organizationListLineName" style="padding-top: 0; padding-bottom: 0;">
<a href="#" id="organizationListLineNameLink">
<img id="organizationListLineLogo" src="" style="width: 26px; height: 26px; padding-top:0; padding-bottom: 0; vertical-align: middle;"/>
&#160;<span id="organizationListLineNameValue">n/a</span>
</a>
</td>
<td id="organizationListLineUrl"><a href="#" id="organizationListLineUrlLink">n/a</a></td>
<td id="organizationListLineServiceCount" class="center">n/a</td>
</tr>
</table>
</div>
</div>
</div>
</body>

View file

@ -14,10 +14,10 @@
<div style="margin: 5px 10px 10px 10px;">
<h1><a href="index.xhtml"><img src="logo.jpg" style="width: 35px;"/> StatoolInfos</a><sup id="versionsup" style="font-size: 9px;">v0.0.14</sup> <a href="about.xhtml">About</a><span style="font-size: 9px; float: right;">Page updated on<br/><span id="lastUpdateDate" style="font-size: 9px;">xx/xx/xxxx xx:xx</span></span></h1>
<h2 id="organizationName">Organization name</h2>
<h2><img id="organizationLogo" src="#" style="width: 100px; heigth: 100px;"/> <span id="organizationName">Organization name</span></h2>
<div style="margin: 5px;">
<a id="federationRawButton" href="#" class="button">Raw properties</a>
<a id="organizationRawButton" href="#" class="button">Raw</a>
</div>
<p id="organizationDescription">Bla bla description</p>

View file

@ -14,7 +14,11 @@
<div style="margin: 5px 10px 10px 10px;">
<h1><a href="index.xhtml"><img src="logo.jpg" style="width: 35px;"/> StatoolInfos</a><sup id="versionsup" style="font-size: 9px;">v0.0.14</sup> <a href="about.xhtml">About</a><span style="font-size: 9px; float: right;">Page updated on<br/><span id="lastUpdateDate" style="font-size: 9px;">xx/xx/xxxx xx:xx</span></span></h1>
<h2 id="serviceName">Service name</h2>
<h2><img id="serviceLogo" src="#" style="width: 100px; heigth: 100px;"/> <span id="serviceName">Service name</span></h2>
<div style="margin: 5px;">
<a id="serviceRawButton" href="#" class="button">Raw</a>
</div>
<p id="serviceDescription">Bla bla description</p>
<div>&#160;</div>
<div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View file

@ -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 utils;
package fr.devinsy.statoolinfos.util;
import java.io.IOException;
import java.net.URL;

View file

@ -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.utils;
package fr.devinsy.statoolinfos.util;
import java.time.LocalDateTime;

View file

@ -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.utils;
package fr.devinsy.statoolinfos.util;
import java.io.File;
import java.util.ArrayList;

View file

@ -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.utils;
package fr.devinsy.statoolinfos.util;
import java.sql.Connection;
import java.sql.DriverManager;