diff --git a/log4j.properties b/log4j.properties
index 8a18d37..7b82791 100644
--- a/log4j.properties
+++ b/log4j.properties
@@ -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
diff --git a/src/META-INF/MANIFEST.MF b/src/META-INF/MANIFEST.MF
deleted file mode 100644
index 5e94951..0000000
--- a/src/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,3 +0,0 @@
-Manifest-Version: 1.0
-Class-Path:
-
diff --git a/src/META-INF/context.xml b/src/META-INF/context.xml
deleted file mode 100644
index e7fe6fb..0000000
--- a/src/META-INF/context.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-StatoolInfosCLI
manages a Command Line Interface for
@@ -292,5 +292,8 @@ public final class StatoolInfosCLI
logger.info("Bad usage.");
displayHelp();
}
+
+ //
+ logger.info("Done.");
}
}
diff --git a/src/fr/devinsy/statoolinfos/core/CrawlCache.java b/src/fr/devinsy/statoolinfos/core/CrawlCache.java
index 76fff07..776d3b0 100644
--- a/src/fr/devinsy/statoolinfos/core/CrawlCache.java
+++ b/src/fr/devinsy/statoolinfos/core/CrawlCache.java
@@ -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);
+ }
}
}
}
diff --git a/src/fr/devinsy/statoolinfos/core/Federation.java b/src/fr/devinsy/statoolinfos/core/Federation.java
index 4eb7cf7..030c741 100644
--- a/src/fr/devinsy/statoolinfos/core/Federation.java
+++ b/src/fr/devinsy/statoolinfos/core/Federation.java
@@ -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.
*
diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java
index 61e859f..a555f3a 100644
--- a/src/fr/devinsy/statoolinfos/core/Organization.java
+++ b/src/fr/devinsy/statoolinfos/core/Organization.java
@@ -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;
diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java
index bfab9d5..8f74448 100644
--- a/src/fr/devinsy/statoolinfos/core/Service.java
+++ b/src/fr/devinsy/statoolinfos/core/Service.java
@@ -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.
*
diff --git a/src/fr/devinsy/statoolinfos/core/StatoolInfos.java b/src/fr/devinsy/statoolinfos/core/StatoolInfos.java
index f79b407..fa8b4f4 100644
--- a/src/fr/devinsy/statoolinfos/core/StatoolInfos.java
+++ b/src/fr/devinsy/statoolinfos/core/StatoolInfos.java
@@ -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");
diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java
index 3b977d1..ec9bf56 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java
@@ -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;
}
diff --git a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
index fed2cfc..bfe97dc 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/Htmlizer.java
@@ -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.
}
}
diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java
index cad1e91..09ba4b5 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java
@@ -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());
diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java
index 90ee6d8..78d02da 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java
+++ b/src/fr/devinsy/statoolinfos/htmlize/ServicePage.java
@@ -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());
diff --git a/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml b/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml
index c1bcbbd..96ce1a3 100644
--- a/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml
+++ b/src/fr/devinsy/statoolinfos/htmlize/federation.xhtml
@@ -13,22 +13,34 @@
Bla bla description
-Bla bla description
diff --git a/src/fr/devinsy/statoolinfos/htmlize/service.xhtml b/src/fr/devinsy/statoolinfos/htmlize/service.xhtml index 5318718..b2efdc6 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/service.xhtml +++ b/src/fr/devinsy/statoolinfos/htmlize/service.xhtml @@ -14,7 +14,11 @@Bla bla description