From a2ff39faaa26ef176d66049c71ae5294f99bd1ec Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sat, 19 Sep 2020 03:36:41 +0200 Subject: [PATCH] Added CatGenerator management. Improved logo links and properties file links. --- .../devinsy/statoolinfos/core/CrawlCache.java | 7 +++-- .../statoolinfos/htmlize/FederationPage.java | 6 ++--- .../statoolinfos/htmlize/Htmlizer.java | 26 +++++++++++++------ .../htmlize/OrganizationPage.java | 5 ++-- .../statoolinfos/htmlize/ServicePage.java | 7 ++--- 5 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/core/CrawlCache.java b/src/fr/devinsy/statoolinfos/core/CrawlCache.java index 776d3b0..4e02ff9 100644 --- a/src/fr/devinsy/statoolinfos/core/CrawlCache.java +++ b/src/fr/devinsy/statoolinfos/core/CrawlCache.java @@ -28,6 +28,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import fr.devinsy.catgenerator.core.CatGenerator; import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.statoolinfos.properties.PathPropertyUtils; @@ -175,7 +176,8 @@ public class CrawlCache { try { - StatoolInfosUtils.generateCatLogo(seed, target); + logger.info("CatGeneratoring cat avatar (1): {}", target.getAbsoluteFile()); + CatGenerator.buildAvatarTo(seed, target); } catch (IOException exception) { @@ -190,7 +192,8 @@ public class CrawlCache { try { - StatoolInfosUtils.generateCatLogo(seed, target); + logger.info("CatGeneratoring cat avatar (2): {}", target.getAbsoluteFile()); + CatGenerator.buildAvatarTo(seed, target); } catch (IOException exception) { diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java index ec9bf56..a25a14e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java @@ -62,9 +62,9 @@ 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("federationRawButton", "href", federation.getTechnicalName() + ".properties"); - data.setAttribute("federationLogo", "src", federation.getTechnicalName() + "-logo.jpg"); + data.setAttribute("federationLogo", "src", federation.getTechnicalName() + "-logo.png"); data.setEscapedContent("federationName", federation.getName()); data.setEscapedContent("federationDescription", federation.getDescription()); data.setContent("organizationCount", federation.getOrganizations().size()); @@ -74,7 +74,7 @@ public class FederationPage for (Organization organization : federation.getOrganizations()) { data.setAttribute("organizationListLine", index, "organizationListLineNameLink", "href", organization.getTechnicalName() + ".xhtml"); - data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.jpg"); + data.setAttribute("organizationListLine", index, "organizationListLineLogo", "src", organization.getTechnicalName() + "-logo.png"); data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName()); data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite()); data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java index bfe97dc..98d68cb 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java +++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java @@ -95,30 +95,40 @@ public class Htmlizer copyStuff(htmlizeDirectory); // 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")); + logger.info("Htmlize federation logo."); + cache.restoreLogoTo(federation.getLogoURL(), new File(htmlizeDirectory, federation.getTechnicalName() + "-logo.png"), federation.getTechnicalName()); + logger.info("Htmlize federation properties file."); + FileUtils.copyFile(federation.getLocalFile(), new File(htmlizeDirectory, federation.getTechnicalName() + ".properties")); // + logger.info("Htmlize federation page: {}.", federation.getName()); String page = FederationPage.build(federation); FileUtils.write(new File(htmlizeDirectory, "index.xhtml"), page, StandardCharsets.UTF_8); 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")); + logger.info("Htmlize organization logo: {}.", organization.getName()); + cache.restoreLogoTo(organization.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-logo.png"), organization.getTechnicalName()); + logger.info("Htmlize organization properties file: {}.", organization.getName()); + FileUtils.copyFile(organization.getLocalFile(), new File(htmlizeDirectory, organization.getTechnicalName() + ".properties")); // + logger.info("Htmlize organization page: {}.", organization.getName()); 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")); + logger.info("Htmlize service logo: {}.", service.getName()); + cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png"), service.getTechnicalName()); + logger.info("Htmlize service properties file: {}.", service.getName()); + FileUtils.copyFile(service.getLocalFile(), + new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".properties")); - page = ServicePage.build(service); + logger.info("Htmlize service page: {}.", service.getName()); + page = ServicePage.build(organization, service); FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); } } @@ -167,7 +177,7 @@ public class Htmlizer cache.restoreLogoTo(service.getLogoURL(), new File(htmlizeDirectory, service.getTechnicalName() + "-logo.jpg"), service.getTechnicalName()); // - page = ServicePage.build(service); + page = ServicePage.build(organization, service); FileUtils.write(new File(htmlizeDirectory, organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"), page, StandardCharsets.UTF_8); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index 09ba4b5..fefb946 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -62,9 +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("organizationRawButton", "href", organization.getTechnicalName() + ".properties"); - data.setAttribute("organizationLogo", "src", organization.getTechnicalName() + "-logo.jpg"); + data.setAttribute("organizationLogo", "src", organization.getTechnicalName() + "-logo.png"); data.setEscapedContent("organizationName", organization.get("organization.name")); data.setEscapedContent("organizationDescription", organization.get("organization.description")); data.setContent("serviceCount", organization.getServices().size()); @@ -72,6 +72,7 @@ public class OrganizationPage int index = 0; for (Service service : organization.getServices()) { + data.setAttribute("serviceListLine", index, "serviceListLineLogo", "src", service.getTechnicalName() + "-logo.png"); data.setEscapedContent("serviceListLine", index, "serviceListLineNameLink", service.getName()); data.setAttribute("serviceListLine", index, "serviceListLineNameLink", "href", organization.getTechnicalName() + "-" + service.getTechnicalName() + ".xhtml"); data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsite()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java index 78d02da..052837c 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java @@ -25,6 +25,7 @@ import java.util.Locale; import org.slf4j.Logger; 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; @@ -48,7 +49,7 @@ public class ServicePage * @throws StatoolInfosException * the statool infos exception */ - public static String build(final Service service) throws StatoolInfosException + public static String build(final Organization organization, final Service service) throws StatoolInfosException { String result; @@ -61,9 +62,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("serviceRawButton", "href", organization.getTechnicalName() + "-" + service.getTechnicalName() + ".properties"); - data.setAttribute("serviceLogo", "src", service.getTechnicalName() + "-logo.jpg"); + data.setAttribute("serviceLogo", "src", organization.getTechnicalName() + "-" + service.getTechnicalName() + "-logo.png"); data.setEscapedContent("serviceName", service.getName()); data.setEscapedContent("serviceDescription", service.getDescription());