Refactored URL properties management.

This commit is contained in:
Christian P. MOMON 2021-06-08 19:01:11 +02:00
parent 2c477e9e44
commit a163cfed18
13 changed files with 252 additions and 166 deletions

View file

@ -32,6 +32,7 @@ import fr.devinsy.statoolinfos.htmlize.charts.WeekValues;
import fr.devinsy.statoolinfos.htmlize.charts.YearValues; import fr.devinsy.statoolinfos.htmlize.charts.YearValues;
import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.statoolinfos.properties.PathPropertyList;
import fr.devinsy.statoolinfos.util.URLUtils;
/** /**
* The Class PathProperty. * The Class PathProperty.
@ -115,15 +116,15 @@ public class Federation extends PathPropertyList
} }
/** /**
* Gets the contact website. * Gets the contact URL.
* *
* @return the contact website * @return the contact URL
*/ */
public String getContactWebsite() public URL getContactURL()
{ {
String result; URL result;
result = get("federation.contact.url"); result = getURL("federation.contact.url");
// //
return result; return result;
@ -226,11 +227,13 @@ public class Federation extends PathPropertyList
* *
* @return the legal website * @return the legal website
*/ */
public String getLegalWebsite() public URL getLegalURL()
{ {
String result; URL result;
result = get("federation.legal.url", "federation.legal"); String value = get("federation.legal.url", "federation.legal");
result = URLUtils.of(value);
// //
return result; return result;
@ -281,15 +284,22 @@ public class Federation extends PathPropertyList
{ {
URL result; URL result;
String path = get("federation.logo"); try
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http"))) {
String path = get("federation.logo");
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http")))
{
result = null;
}
else
{
result = new URL(path);
}
}
catch (MalformedURLException exception)
{ {
result = null; result = null;
} }
else
{
result = new URL(path);
}
// //
return result; return result;
@ -464,11 +474,13 @@ public class Federation extends PathPropertyList
* *
* @return the technical doc website * @return the technical doc website
*/ */
public String getTechnicalDocWebsite() public URL getTechnicalGuideURL()
{ {
String result; URL result;
result = get("federation.guide.technical", "federation.guide.technical.url"); String value = get("federation.guide.technical", "federation.guide.technical.url");
result = URLUtils.of(value);
// //
return result; return result;
@ -494,15 +506,21 @@ public class Federation extends PathPropertyList
* *
* @return the user doc website * @return the user doc website
*/ */
public String getUserDocWebsite() public URL getUserGuideURL()
{ {
String result; URL result;
result = get("federation.documentation", "federation.documentation.url", "federation.documentation.user", "federation.documentation.user.url", "service.documentation.tutorial", String value = get("federation.documentation",
"federation.documentation.url",
"federation.documentation.user",
"federation.documentation.user.url",
"service.documentation.tutorial",
"federation.documentation.tutorial.url", "federation.documentation.tutorial.url",
"federation.guide.user", "federation.guide.user",
"federation.guide.user.url"); "federation.guide.user.url");
result = URLUtils.of(value);
// //
return result; return result;
} }
@ -512,11 +530,11 @@ public class Federation extends PathPropertyList
* *
* @return the website * @return the website
*/ */
public String getWebsite() public URL getWebsiteURL()
{ {
String result; URL result;
result = get("federation.website"); result = getURL("federation.website");
// //
return result; return result;

View file

@ -19,7 +19,6 @@
package fr.devinsy.statoolinfos.core; package fr.devinsy.statoolinfos.core;
import java.io.File; import java.io.File;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -34,6 +33,7 @@ import fr.devinsy.statoolinfos.htmlize.charts.WeekValues;
import fr.devinsy.statoolinfos.htmlize.charts.YearValues; import fr.devinsy.statoolinfos.htmlize.charts.YearValues;
import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.statoolinfos.properties.PathPropertyList;
import fr.devinsy.statoolinfos.util.URLUtils;
/** /**
* The Class PathProperty. * The Class PathProperty.
@ -112,11 +112,11 @@ public class Organization extends PathPropertyList
* *
* @return the contact website * @return the contact website
*/ */
public String getContactWebsite() public URL getContactURL()
{ {
String result; URL result;
result = get("organization.contact.url"); result = getURL("organization.contact.url");
// //
return result; return result;
@ -288,11 +288,13 @@ public class Organization extends PathPropertyList
* *
* @return the legal website * @return the legal website
*/ */
public String getLegalWebsite() public URL getLegalURL()
{ {
String result; URL result;
result = get("organization.legal.url", "organization.legal"); String value = get("organization.legal.url", "organization.legal");
result = URLUtils.of(value);
// //
return result; return result;
@ -347,22 +349,12 @@ public class Organization extends PathPropertyList
* Gets the logo URL. * Gets the logo URL.
* *
* @return the logo URL * @return the logo URL
* @throws MalformedURLException
* the malformed URL exception
*/ */
public URL getLogoURL() throws MalformedURLException public URL getLogoURL()
{ {
URL result; URL result;
String path = getLogoURLValue(); result = URLUtils.of(getLogoURLValue());
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http")))
{
result = null;
}
else
{
result = new URL(path);
}
// //
return result; return result;
@ -663,11 +655,13 @@ public class Organization extends PathPropertyList
* *
* @return the technical guide website * @return the technical guide website
*/ */
public String getTechnicalGuideWebsite() public URL getTechnicalGuideURL()
{ {
String result; URL result;
result = get("organization.guide.technical", "organization.guide.technical.url"); String value = get("organization.guide.technical", "organization.guide.technical.url");
result = URLUtils.of(value);
// //
return result; return result;
@ -708,11 +702,13 @@ public class Organization extends PathPropertyList
* *
* @return the user guide website * @return the user guide website
*/ */
public String getUserGuideWebsite() public URL getUserGuideURL()
{ {
String result; URL result;
result = get("organization.guide.user", "organization.guide.user.url"); String value = get("organization.guide.user", "organization.guide.user.url");
result = URLUtils.of(value);
// //
return result; return result;
@ -723,11 +719,11 @@ public class Organization extends PathPropertyList
* *
* @return the website * @return the website
*/ */
public String getWebsite() public URL getWebsiteURL()
{ {
String result; URL result;
result = get("organization.website"); result = getURL("organization.website");
// //
return result; return result;

View file

@ -35,6 +35,7 @@ import fr.devinsy.statoolinfos.crawl.CrawlJournal;
import fr.devinsy.statoolinfos.htmlize.charts.MonthValues; import fr.devinsy.statoolinfos.htmlize.charts.MonthValues;
import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathProperties;
import fr.devinsy.statoolinfos.properties.PathPropertyList; import fr.devinsy.statoolinfos.properties.PathPropertyList;
import fr.devinsy.statoolinfos.util.URLUtils;
/** /**
* The Class Service. * The Class Service.
@ -164,11 +165,11 @@ public class Service extends PathPropertyList
* *
* @return the contact website * @return the contact website
*/ */
public String getContactWebsite() public URL getContactURL()
{ {
String result; URL result;
result = get("service.contact.url"); result = getURL("service.contact.url");
// //
return result; return result;
@ -364,11 +365,13 @@ public class Service extends PathPropertyList
* *
* @return the legal website * @return the legal website
*/ */
public String getLegalWebsite() public URL getLegalURL()
{ {
String result; URL result;
result = get("service.legal.url", "service.legal"); String value = get("service.legal.url", "service.legal");
result = getURL(value);
// //
return result; return result;
@ -435,15 +438,7 @@ public class Service extends PathPropertyList
{ {
URL result; URL result;
String path = get("service.logo"); result = getURL("service.logo");
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http")))
{
result = null;
}
else
{
result = new URL(path);
}
// //
return result; return result;
@ -602,11 +597,11 @@ public class Service extends PathPropertyList
* *
* @return the software license webpage * @return the software license webpage
*/ */
public String getSoftwareLicenseWebpage() public URL getSoftwareLicenseURL()
{ {
String result; URL result;
result = get("software.license.url"); result = getURL("software.license.url");
// //
return result; return result;
@ -628,15 +623,15 @@ public class Service extends PathPropertyList
} }
/** /**
* Gets the software source website. * Gets the software source URL.
* *
* @return the software source website * @return the software source URL
*/ */
public String getSoftwareSourceWebsite() public URL getSoftwareSourceURL()
{ {
String result; URL result;
result = get("software.source.url"); result = getURL("software.source.url");
// //
return result; return result;
@ -677,11 +672,11 @@ public class Service extends PathPropertyList
* *
* @return the software website * @return the software website
*/ */
public String getSoftwareWebsite() public URL getSoftwareWebsite()
{ {
String result; URL result;
result = get("software.website"); result = getURL("software.website");
// //
return result; return result;
@ -760,11 +755,13 @@ public class Service extends PathPropertyList
/** /**
* @return * @return
*/ */
public String getTechnicalDocWebsite() public URL getTechnicalGuideURL()
{ {
String result; URL result;
result = get("service.guide.technical", "service.guide.technical.url"); String value = get("service.guide.technical", "service.guide.technical.url");
result = URLUtils.of(value);
// //
return result; return result;
@ -805,15 +802,21 @@ public class Service extends PathPropertyList
* *
* @return the user doc * @return the user doc
*/ */
public String getUserDocWebsite() public URL getUserGuideURL()
{ {
String result; URL result;
result = get("service.documentation", "service.documentation.url", "service.documentation.user", "service.documentation.user.url", "service.documentation.tutorial", String value = get("service.documentation",
"service.documentation.url",
"service.documentation.user",
"service.documentation.user.url",
"service.documentation.tutorial",
"service.documentation.tutorial.url", "service.documentation.tutorial.url",
"service.guide.user", "service.guide.user",
"service.guide.user.url"); "service.guide.user.url");
result = URLUtils.of(value);
// //
return result; return result;
} }
@ -823,11 +826,11 @@ public class Service extends PathPropertyList
* *
* @return the website * @return the website
*/ */
public String getWebsite() public URL getWebsiteURL()
{ {
String result; URL result;
result = get("service.website"); result = getURL("service.website");
// //
return result; return result;

View file

@ -63,8 +63,11 @@ public class FederationHeaderView
data.setEscapedContent("federationName", federation.getName()); data.setEscapedContent("federationName", federation.getName());
data.setEscapedContent("federationDescription", federation.getDescription()); data.setEscapedContent("federationDescription", federation.getDescription());
data.setEscapedContent("federationURL", federation.getWebsite()); if (federation.getWebsiteURL() != null)
data.setEscapedAttribute("federationURL", "href", federation.getWebsite()); {
data.setEscapedContent("federationURL", federation.getWebsiteURL().toString());
data.setEscapedAttribute("federationURL", "href", federation.getWebsiteURL().toString());
}
data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDate(), "n/a")); data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDate(), "n/a"));
data.setAttribute("subsLink", "href", "index.xhtml"); data.setAttribute("subsLink", "href", "index.xhtml");
@ -93,15 +96,15 @@ public class FederationHeaderView
data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-checkalerts.xhtml"); data.setAttribute("alertLink", "href", federation.getTechnicalName() + "-checkalerts.xhtml");
} }
if (StringUtils.isNotBlank(federation.getLegalWebsite())) if (federation.getLegalURL() != null)
{ {
data.setEscapedAttribute("legalLink", "href", federation.getLegalWebsite()); data.setEscapedAttribute("legalLink", "href", federation.getLegalURL().toString());
data.setAttribute("legalLinkImg", "class", ""); data.setAttribute("legalLinkImg", "class", "");
data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(federation.getContactWebsite())) if (federation.getContactURL() != null)
{ {
data.setEscapedAttribute("contactLink", "href", federation.getContactWebsite()); data.setEscapedAttribute("contactLink", "href", federation.getContactURL().toString());
data.setAttribute("contactLinkImg", "class", ""); data.setAttribute("contactLinkImg", "class", "");
data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
@ -111,15 +114,15 @@ public class FederationHeaderView
data.setAttribute("emailLinkImg", "class", ""); data.setAttribute("emailLinkImg", "class", "");
data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(federation.getUserDocWebsite())) if (federation.getUserGuideURL() != null)
{ {
data.setEscapedAttribute("userDocLink", "href", federation.getUserDocWebsite()); data.setEscapedAttribute("userDocLink", "href", federation.getUserGuideURL().toString());
data.setAttribute("userDocLinkImg", "class", ""); data.setAttribute("userDocLinkImg", "class", "");
data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(federation.getTechnicalDocWebsite())) if (federation.getTechnicalGuideURL() != null)
{ {
data.setEscapedAttribute("technicalDocLink", "href", federation.getTechnicalDocWebsite()); data.setEscapedAttribute("technicalDocLink", "href", federation.getTechnicalGuideURL().toString());
data.setAttribute("technicalDocLinkImg", "class", ""); data.setAttribute("technicalDocLinkImg", "class", "");
data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }

View file

@ -128,9 +128,11 @@ public class FederationPage
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName()); data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName()); data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite()); if (organization.getWebsiteURL() != null)
data.setEscapedAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite()); {
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString());
data.setEscapedAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString());
}
data.setContent("organizationListLine", index, "organizationListLineServiceCount", organization.getServiceCount()); data.setContent("organizationListLine", index, "organizationListLineServiceCount", organization.getServiceCount());
data.setContent("organizationListLine", index, "organizationListLineUserCount", organization.getPreviousMonthUserCount()); data.setContent("organizationListLine", index, "organizationListLineUserCount", organization.getPreviousMonthUserCount());
data.setContent("organizationListLine", index, "organizationListLineVisitCount", organization.getPreviousMonthVisitCount()); data.setContent("organizationListLine", index, "organizationListLineVisitCount", organization.getPreviousMonthVisitCount());

View file

@ -62,9 +62,11 @@ public class OrganizationHeaderView
data.setAttribute("organizationLogo", "src", organization.getLogoFileName()); data.setAttribute("organizationLogo", "src", organization.getLogoFileName());
data.setEscapedContent("organizationName", organization.get("organization.name")); data.setEscapedContent("organizationName", organization.get("organization.name"));
data.setEscapedContent("organizationURL", organization.getWebsite()); if (organization.getWebsiteURL() != null)
data.setEscapedAttribute("organizationURL", "href", organization.getWebsite()); {
data.setEscapedContent("organizationURL", organization.getWebsiteURL().toString());
data.setEscapedAttribute("organizationURL", "href", organization.getWebsiteURL().toString());
}
data.setEscapedContent("organizationDescription", organization.get("organization.description")); data.setEscapedContent("organizationDescription", organization.get("organization.description"));
data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a")); data.setEscapedContent("organizationMemberOfName", StringUtils.defaultIfBlank(organization.getFederation().getName(), "n/a"));
@ -120,15 +122,15 @@ public class OrganizationHeaderView
data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-checkalerts.xhtml"); data.setAttribute("alertLink", "href", organization.getTechnicalName() + "-checkalerts.xhtml");
} }
if (StringUtils.isNotBlank(organization.getLegalWebsite())) if (organization.getLegalURL() != null)
{ {
data.setEscapedAttribute("legalLink", "href", organization.getLegalWebsite()); data.setEscapedAttribute("legalLink", "href", organization.getLegalURL().toString());
data.setAttribute("legalLinkImg", "class", ""); data.setAttribute("legalLinkImg", "class", "");
data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(organization.getContactWebsite())) if (organization.getContactURL() != null)
{ {
data.setEscapedAttribute("contactLink", "href", organization.getContactWebsite()); data.setEscapedAttribute("contactLink", "href", organization.getContactURL().toString());
data.setAttribute("contactLinkImg", "class", ""); data.setAttribute("contactLinkImg", "class", "");
data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
@ -138,15 +140,15 @@ public class OrganizationHeaderView
data.setAttribute("emailLinkImg", "class", ""); data.setAttribute("emailLinkImg", "class", "");
data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(organization.getUserGuideWebsite())) if (organization.getUserGuideURL() != null)
{ {
data.setEscapedAttribute("userDocLink", "href", organization.getUserGuideWebsite()); data.setEscapedAttribute("userDocLink", "href", organization.getUserGuideURL().toString());
data.setAttribute("userDocLinkImg", "class", ""); data.setAttribute("userDocLinkImg", "class", "");
data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(organization.getTechnicalGuideWebsite())) if (organization.getTechnicalGuideURL() != null)
{ {
data.setEscapedAttribute("technicalDocLink", "href", organization.getTechnicalGuideWebsite()); data.setEscapedAttribute("technicalDocLink", "href", organization.getTechnicalGuideURL().toString());
data.setAttribute("technicalDocLinkImg", "class", ""); data.setAttribute("technicalDocLinkImg", "class", "");
data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }

View file

@ -165,8 +165,6 @@ public class OrganizationPage
*/ */
private static void htmlizeOrganizationLogo(final Organization organization, final CrawlCache cache, final File htmlizeDirectory) throws IOException private static void htmlizeOrganizationLogo(final Organization organization, final CrawlCache cache, final File htmlizeDirectory) throws IOException
{ {
logger.info("Htmlize organization logo.");
File target = new File(htmlizeDirectory, organization.getLogoFileName()); File target = new File(htmlizeDirectory, organization.getLogoFileName());
File logoFile = cache.restoreFile(organization.getLogoURL()); File logoFile = cache.restoreFile(organization.getLogoURL());

View file

@ -60,10 +60,12 @@ public class ServiceHeaderView
data.setAttribute("serviceLogo", "src", service.getLogoFileName()); data.setAttribute("serviceLogo", "src", service.getLogoFileName());
data.setEscapedContent("serviceName", service.getName()); data.setEscapedContent("serviceName", service.getName());
data.setEscapedAttribute("serviceName", "href", service.getWebsite()); if (service.getWebsiteURL() != null)
{
data.setEscapedContent("serviceURL", service.getWebsite()); data.setEscapedAttribute("serviceName", "href", service.getWebsiteURL().toString());
data.setEscapedAttribute("serviceURL", "href", service.getWebsite()); data.setEscapedContent("serviceURL", service.getWebsiteURL().toString());
data.setEscapedAttribute("serviceURL", "href", service.getWebsiteURL().toString());
}
data.setEscapedContent("serviceDescription", StringUtils.defaultIfBlank(service.getDescription(), "n/a")); data.setEscapedContent("serviceDescription", StringUtils.defaultIfBlank(service.getDescription(), "n/a"));
@ -88,15 +90,15 @@ public class ServiceHeaderView
data.setAttribute("statsLink", "href", service.getLocalFileBaseName() + ".xhtml"); data.setAttribute("statsLink", "href", service.getLocalFileBaseName() + ".xhtml");
data.setAttribute("metricsLink", "href", service.getLocalFileBaseName() + "-metrics-summary-months-last.xhtml"); data.setAttribute("metricsLink", "href", service.getLocalFileBaseName() + "-metrics-summary-months-last.xhtml");
if (StringUtils.isNotBlank(service.getLegalWebsite())) if (service.getLegalURL() != null)
{ {
data.setEscapedAttribute("legalLink", "href", service.getLegalWebsite()); data.setEscapedAttribute("legalLink", "href", service.getLegalURL().toString());
data.setAttribute("legalLinkImg", "class", ""); data.setAttribute("legalLinkImg", "class", "");
data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getContactWebsite())) if (service.getContactURL() != null)
{ {
data.setEscapedAttribute("contactLink", "href", service.getContactWebsite()); data.setEscapedAttribute("contactLink", "href", service.getContactURL().toString());
data.setAttribute("contactLinkImg", "class", ""); data.setAttribute("contactLinkImg", "class", "");
data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
@ -106,15 +108,15 @@ public class ServiceHeaderView
data.setAttribute("emailLinkImg", "class", ""); data.setAttribute("emailLinkImg", "class", "");
data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getUserDocWebsite())) if (service.getUserGuideURL() != null)
{ {
data.setEscapedAttribute("userDocLink", "href", service.getUserDocWebsite()); data.setEscapedAttribute("userDocLink", "href", service.getUserGuideURL().toString());
data.setAttribute("userDocLinkImg", "class", ""); data.setAttribute("userDocLinkImg", "class", "");
data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getTechnicalDocWebsite())) if (service.getTechnicalGuideURL() != null)
{ {
data.setEscapedAttribute("technicalDocLink", "href", service.getTechnicalDocWebsite()); data.setEscapedAttribute("technicalDocLink", "href", service.getTechnicalGuideURL().toString());
data.setAttribute("technicalDocLinkImg", "class", ""); data.setAttribute("technicalDocLinkImg", "class", "");
data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
@ -150,21 +152,21 @@ public class ServiceHeaderView
data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a")); data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a"));
data.setContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "n/a")); data.setContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "n/a"));
data.setEscapedContent("softwareLicenseName", StringUtils.defaultIfBlank(service.getSoftwareLicenseName(), "n/a")); data.setEscapedContent("softwareLicenseName", StringUtils.defaultIfBlank(service.getSoftwareLicenseName(), "n/a"));
if (StringUtils.isNotBlank(service.getSoftwareWebsite())) if (service.getSoftwareWebsite() != null)
{ {
data.setEscapedAttribute("softwareWebsiteLink", "href", service.getSoftwareWebsite()); data.setEscapedAttribute("softwareWebsiteLink", "href", service.getSoftwareWebsite().toString());
data.setAttribute("softwareWebsiteLinkImg", "class", ""); data.setAttribute("softwareWebsiteLinkImg", "class", "");
data.getIdData("softwareWebsiteLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("softwareWebsiteLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getSoftwareLicenseWebpage())) if (service.getSoftwareLicenseURL() != null)
{ {
data.setEscapedAttribute("softwareLicenseLink", "href", service.getSoftwareLicenseWebpage()); data.setEscapedAttribute("softwareLicenseLink", "href", service.getSoftwareLicenseURL().toString());
data.setAttribute("softwareLicenseLinkImg", "class", ""); data.setAttribute("softwareLicenseLinkImg", "class", "");
data.getIdData("softwareLicenseLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("softwareLicenseLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getSoftwareSourceWebsite())) if (service.getSoftwareSourceURL() != null)
{ {
data.setEscapedAttribute("softwareSourceLink", "href", service.getSoftwareSourceWebsite()); data.setEscapedAttribute("softwareSourceLink", "href", service.getSoftwareSourceURL().toString());
data.setAttribute("softwareSourceLinkImg", "class", ""); data.setAttribute("softwareSourceLinkImg", "class", "");
data.getIdData("softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }

View file

@ -78,9 +78,12 @@ public class ServiceListView
data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getLogoFileName()); data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getLogoFileName());
data.setEscapedContent("serviceListLine", index, "serviceListLineOrganizationValue", service.getOrganization().getName()); data.setEscapedContent("serviceListLine", index, "serviceListLineOrganizationValue", service.getOrganization().getName());
data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsite()); if (service.getWebsiteURL() != null)
data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsite()); {
data.setEscapedAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsite()); data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsiteURL().toString());
data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsiteURL().toString());
data.setEscapedAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsiteURL().toString());
}
data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName()); data.setEscapedContent("serviceListLine", index, "serviceListLineSoftwareLink", service.getSoftwareName());
data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml"); data.setAttribute("serviceListLine", index, "serviceListLineSoftwareLink", "href", "software-" + service.getSoftwareTechnicalName() + ".xhtml");
@ -95,15 +98,15 @@ public class ServiceListView
data.setAttribute("serviceListLine", index, "serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png"); data.setAttribute("serviceListLine", index, "serviceStatusImg", "src", "status-" + service.getStatus().toString().toLowerCase() + ".png");
data.setAttribute("serviceListLine", index, "serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString())); data.setAttribute("serviceListLine", index, "serviceStatusImg", "title", StringUtils.defaultIfBlank(service.getStatusDescription(), service.getStatus().toString()));
if (StringUtils.isNotBlank(service.getLegalWebsite())) if (service.getLegalURL() != null)
{ {
data.setEscapedAttribute("serviceListLine", index, "legalLink", "href", service.getLegalWebsite()); data.setEscapedAttribute("serviceListLine", index, "legalLink", "href", service.getLegalURL().toString());
data.setAttribute("serviceListLine", index, "legalLinkImg", "class", ""); data.setAttribute("serviceListLine", index, "legalLinkImg", "class", "");
data.getIdData("serviceListLine", index, "legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("serviceListLine", index, "legalLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getContactWebsite())) if (service.getContactURL() != null)
{ {
data.setEscapedAttribute("serviceListLine", index, "contactLink", "href", service.getContactWebsite()); data.setEscapedAttribute("serviceListLine", index, "contactLink", "href", service.getContactURL().toString());
data.setAttribute("serviceListLine", index, "contactLinkImg", "class", ""); data.setAttribute("serviceListLine", index, "contactLinkImg", "class", "");
data.getIdData("serviceListLine", index, "contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("serviceListLine", index, "contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
@ -113,15 +116,15 @@ public class ServiceListView
data.setAttribute("serviceListLine", index, "emailLinkImg", "class", ""); data.setAttribute("serviceListLine", index, "emailLinkImg", "class", "");
data.getIdData("serviceListLine", index, "emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("serviceListLine", index, "emailLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getUserDocWebsite())) if (service.getUserGuideURL() != null)
{ {
data.setEscapedAttribute("serviceListLine", index, "userDocLink", "href", service.getUserDocWebsite()); data.setEscapedAttribute("serviceListLine", index, "userDocLink", "href", service.getUserGuideURL().toString());
data.setAttribute("serviceListLine", index, "userDocLinkImg", "class", ""); data.setAttribute("serviceListLine", index, "userDocLinkImg", "class", "");
data.getIdData("serviceListLine", index, "userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("serviceListLine", index, "userDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getTechnicalDocWebsite())) if (service.getTechnicalGuideURL() != null)
{ {
data.setEscapedAttribute("serviceListLine", index, "technicalDocLink", "href", service.getTechnicalDocWebsite()); data.setEscapedAttribute("serviceListLine", index, "technicalDocLink", "href", service.getTechnicalGuideURL().toString());
data.setAttribute("serviceListLine", index, "technicalDocLinkImg", "class", ""); data.setAttribute("serviceListLine", index, "technicalDocLinkImg", "class", "");
data.getIdData("serviceListLine", index, "technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("serviceListLine", index, "technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
@ -157,21 +160,21 @@ public class ServiceListView
data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a")); data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a"));
data.setEscapedContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "n/a")); data.setEscapedContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "n/a"));
data.setEscapedContent("softwareLicenseName", StringUtils.defaultIfBlank(service.getSoftwareLicenseName(), "n/a")); data.setEscapedContent("softwareLicenseName", StringUtils.defaultIfBlank(service.getSoftwareLicenseName(), "n/a"));
if (StringUtils.isNotBlank(service.getSoftwareWebsite())) if (service.getSoftwareWebsite() != null)
{ {
data.setEscapedAttribute("serviceListLine", index, "softwareWebsiteLink", "href", service.getSoftwareWebsite()); data.setEscapedAttribute("serviceListLine", index, "softwareWebsiteLink", "href", service.getSoftwareWebsite().toString());
data.setAttribute("serviceListLine", index, "softwareWebsiteLinkImg", "class", ""); data.setAttribute("serviceListLine", index, "softwareWebsiteLinkImg", "class", "");
data.getIdData("serviceListLine", index, "softwareWebsiteLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("serviceListLine", index, "softwareWebsiteLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getSoftwareLicenseWebpage())) if (service.getSoftwareLicenseURL() != null)
{ {
data.setEscapedAttribute("serviceListLine", index, "softwareLicenseLink", "href", service.getSoftwareLicenseWebpage()); data.setEscapedAttribute("serviceListLine", index, "softwareLicenseLink", "href", service.getSoftwareLicenseURL().toString());
data.setAttribute("serviceListLine", index, "softwareLicenseLinkImg", "class", ""); data.setAttribute("serviceListLine", index, "softwareLicenseLinkImg", "class", "");
data.getIdData("serviceListLine", index, "softwareLicenseLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("serviceListLine", index, "softwareLicenseLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }
if (StringUtils.isNotBlank(service.getSoftwareSourceWebsite())) if (service.getSoftwareSourceURL() != null)
{ {
data.setEscapedAttribute("serviceListLine", index, "softwareSourceLink", "href", service.getSoftwareSourceWebsite()); data.setEscapedAttribute("serviceListLine", index, "softwareSourceLink", "href", service.getSoftwareSourceURL().toString());
data.setAttribute("serviceListLine", index, "softwareSourceLinkImg", "class", ""); data.setAttribute("serviceListLine", index, "softwareSourceLinkImg", "class", "");
data.getIdData("serviceListLine", index, "softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); data.getIdData("serviceListLine", index, "softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE);
} }

View file

@ -104,9 +104,11 @@ public class SocialNetworksPage
data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName()); data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName()); data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName());
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite()); if (organization.getWebsiteURL() != null)
data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite()); {
data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString());
data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString());
}
if (StringUtils.isNotBlank(organization.getDiasporaWebpage())) if (StringUtils.isNotBlank(organization.getDiasporaWebpage()))
{ {
data.setAttribute("organizationListLine", index, "organizationListLineDiasporaImg", "class", ""); data.setAttribute("organizationListLine", index, "organizationListLineDiasporaImg", "class", "");

View file

@ -18,7 +18,6 @@
*/ */
package fr.devinsy.statoolinfos.properties; package fr.devinsy.statoolinfos.properties;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.Iterator; import java.util.Iterator;
@ -96,7 +95,7 @@ public interface PathProperties extends Iterable<PathProperty>
* the path * the path
* @return the url * @return the url
*/ */
URL getURL(String path) throws MalformedURLException; URL getURL(String path);
/** /**
* Iterator. * Iterator.

View file

@ -699,28 +699,30 @@ public class PathPropertyList extends ArrayList<PathProperty> implements PathPro
return result; return result;
} }
/** /* (non-Javadoc)
* Gets the url. * @see fr.devinsy.statoolinfos.properties.PathProperties#getURL(java.lang.String)
*
* @param path
* the path
* @return the url
* @throws MalformedURLException
*/ */
@Override @Override
public URL getURL(final String path) throws MalformedURLException public URL getURL(final String path)
{ {
URL result; URL result;
String value = get(path); try
if ((path == null) || (!StringUtils.startsWith(value, "http"))) {
String value = get(path);
if ((path == null) || (!StringUtils.startsWith(value, "http")))
{
result = null;
}
else
{
result = new URL(value);
}
}
catch (MalformedURLException exception)
{ {
result = null; result = null;
} }
else
{
result = new URL(value);
}
// //
return result; return result;

View file

@ -21,6 +21,7 @@ package fr.devinsy.statoolinfos.util;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.net.JarURLConnection; import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.Enumeration; import java.util.Enumeration;
@ -211,4 +212,59 @@ public final class URLUtils
// //
return result; return result;
} }
/**
* Checks if is valid.
*
* @param value
* the value
* @return true, if is valid
*/
public static boolean isValid(final String value)
{
boolean result;
if ((StringUtils.isBlank(value)) || (!StringUtils.startsWith(value, "http")))
{
result = false;
}
else
{
result = true;
}
//
return result;
}
/**
* Of.
*
* @param path
* the path
* @return the url
*/
public static URL of(final String path)
{
URL result;
try
{
if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http")))
{
result = null;
}
else
{
result = new URL(path);
}
}
catch (MalformedURLException exception)
{
result = null;
}
//
return result;
}
} }