diff --git a/src/fr/devinsy/statoolinfos/core/Federation.java b/src/fr/devinsy/statoolinfos/core/Federation.java index 83b4895..1f7b933 100644 --- a/src/fr/devinsy/statoolinfos/core/Federation.java +++ b/src/fr/devinsy/statoolinfos/core/Federation.java @@ -32,6 +32,7 @@ import fr.devinsy.statoolinfos.htmlize.charts.WeekValues; import fr.devinsy.statoolinfos.htmlize.charts.YearValues; import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathPropertyList; +import fr.devinsy.statoolinfos.util.URLUtils; /** * 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; @@ -226,11 +227,13 @@ public class Federation extends PathPropertyList * * @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; @@ -281,15 +284,22 @@ public class Federation extends PathPropertyList { URL result; - String path = get("federation.logo"); - if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http"))) + try + { + 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; } - else - { - result = new URL(path); - } // return result; @@ -464,11 +474,13 @@ public class Federation extends PathPropertyList * * @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; @@ -494,15 +506,21 @@ public class Federation extends PathPropertyList * * @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.guide.user", "federation.guide.user.url"); + result = URLUtils.of(value); + // return result; } @@ -512,11 +530,11 @@ public class Federation extends PathPropertyList * * @return the website */ - public String getWebsite() + public URL getWebsiteURL() { - String result; + URL result; - result = get("federation.website"); + result = getURL("federation.website"); // return result; diff --git a/src/fr/devinsy/statoolinfos/core/Organization.java b/src/fr/devinsy/statoolinfos/core/Organization.java index 8cc7bc1..814b362 100644 --- a/src/fr/devinsy/statoolinfos/core/Organization.java +++ b/src/fr/devinsy/statoolinfos/core/Organization.java @@ -19,7 +19,6 @@ package fr.devinsy.statoolinfos.core; import java.io.File; -import java.net.MalformedURLException; import java.net.URL; import java.time.LocalDate; 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.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathPropertyList; +import fr.devinsy.statoolinfos.util.URLUtils; /** * The Class PathProperty. @@ -112,11 +112,11 @@ public class Organization extends PathPropertyList * * @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; @@ -288,11 +288,13 @@ public class Organization extends PathPropertyList * * @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; @@ -347,22 +349,12 @@ public class Organization extends PathPropertyList * Gets the logo URL. * * @return the logo URL - * @throws MalformedURLException - * the malformed URL exception */ - public URL getLogoURL() throws MalformedURLException + public URL getLogoURL() { URL result; - String path = getLogoURLValue(); - if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http"))) - { - result = null; - } - else - { - result = new URL(path); - } + result = URLUtils.of(getLogoURLValue()); // return result; @@ -663,11 +655,13 @@ public class Organization extends PathPropertyList * * @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; @@ -708,11 +702,13 @@ public class Organization extends PathPropertyList * * @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; @@ -723,11 +719,11 @@ public class Organization extends PathPropertyList * * @return the website */ - public String getWebsite() + public URL getWebsiteURL() { - String result; + URL result; - result = get("organization.website"); + result = getURL("organization.website"); // return result; diff --git a/src/fr/devinsy/statoolinfos/core/Service.java b/src/fr/devinsy/statoolinfos/core/Service.java index 6f615fe..b5eef5d 100644 --- a/src/fr/devinsy/statoolinfos/core/Service.java +++ b/src/fr/devinsy/statoolinfos/core/Service.java @@ -35,6 +35,7 @@ import fr.devinsy.statoolinfos.crawl.CrawlJournal; import fr.devinsy.statoolinfos.htmlize.charts.MonthValues; import fr.devinsy.statoolinfos.properties.PathProperties; import fr.devinsy.statoolinfos.properties.PathPropertyList; +import fr.devinsy.statoolinfos.util.URLUtils; /** * The Class Service. @@ -164,11 +165,11 @@ public class Service extends PathPropertyList * * @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; @@ -364,11 +365,13 @@ public class Service extends PathPropertyList * * @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; @@ -435,15 +438,7 @@ public class Service extends PathPropertyList { URL result; - String path = get("service.logo"); - if ((StringUtils.isBlank(path)) || (!StringUtils.startsWith(path, "http"))) - { - result = null; - } - else - { - result = new URL(path); - } + result = getURL("service.logo"); // return result; @@ -602,11 +597,11 @@ public class Service extends PathPropertyList * * @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; @@ -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; @@ -677,11 +672,11 @@ public class Service extends PathPropertyList * * @return the software website */ - public String getSoftwareWebsite() + public URL getSoftwareWebsite() { - String result; + URL result; - result = get("software.website"); + result = getURL("software.website"); // return result; @@ -760,11 +755,13 @@ public class Service extends PathPropertyList /** * @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; @@ -805,15 +802,21 @@ public class Service extends PathPropertyList * * @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.guide.user", "service.guide.user.url"); + result = URLUtils.of(value); + // return result; } @@ -823,11 +826,11 @@ public class Service extends PathPropertyList * * @return the website */ - public String getWebsite() + public URL getWebsiteURL() { - String result; + URL result; - result = get("service.website"); + result = getURL("service.website"); // return result; diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java index 8ba1bff..f303d04 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationHeaderView.java @@ -63,8 +63,11 @@ public class FederationHeaderView data.setEscapedContent("federationName", federation.getName()); data.setEscapedContent("federationDescription", federation.getDescription()); - data.setEscapedContent("federationURL", federation.getWebsite()); - data.setEscapedAttribute("federationURL", "href", federation.getWebsite()); + if (federation.getWebsiteURL() != null) + { + data.setEscapedContent("federationURL", federation.getWebsiteURL().toString()); + data.setEscapedAttribute("federationURL", "href", federation.getWebsiteURL().toString()); + } data.setContent("federationStartDate", StringUtils.defaultIfBlank(federation.getStartDate(), "n/a")); data.setAttribute("subsLink", "href", "index.xhtml"); @@ -93,15 +96,15 @@ public class FederationHeaderView 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.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.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } @@ -111,15 +114,15 @@ public class FederationHeaderView data.setAttribute("emailLinkImg", "class", ""); 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.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.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java index cf621dc..0b0d3fe 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/FederationPage.java @@ -128,9 +128,11 @@ public class FederationPage data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName()); data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName()); - data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite()); - data.setEscapedAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite()); - + if (organization.getWebsiteURL() != null) + { + 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, "organizationListLineUserCount", organization.getPreviousMonthUserCount()); data.setContent("organizationListLine", index, "organizationListLineVisitCount", organization.getPreviousMonthVisitCount()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java index df79108..b436a75 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationHeaderView.java @@ -62,9 +62,11 @@ public class OrganizationHeaderView data.setAttribute("organizationLogo", "src", organization.getLogoFileName()); data.setEscapedContent("organizationName", organization.get("organization.name")); - data.setEscapedContent("organizationURL", organization.getWebsite()); - data.setEscapedAttribute("organizationURL", "href", organization.getWebsite()); - + if (organization.getWebsiteURL() != null) + { + data.setEscapedContent("organizationURL", organization.getWebsiteURL().toString()); + data.setEscapedAttribute("organizationURL", "href", organization.getWebsiteURL().toString()); + } data.setEscapedContent("organizationDescription", organization.get("organization.description")); 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"); } - 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.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.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } @@ -138,15 +140,15 @@ public class OrganizationHeaderView data.setAttribute("emailLinkImg", "class", ""); 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.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.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java index 83f2f40..8afdc54 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/OrganizationPage.java @@ -165,8 +165,6 @@ public class OrganizationPage */ 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 logoFile = cache.restoreFile(organization.getLogoURL()); diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java index 237dfb3..488cb8e 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceHeaderView.java @@ -60,10 +60,12 @@ public class ServiceHeaderView data.setAttribute("serviceLogo", "src", service.getLogoFileName()); data.setEscapedContent("serviceName", service.getName()); - data.setEscapedAttribute("serviceName", "href", service.getWebsite()); - - data.setEscapedContent("serviceURL", service.getWebsite()); - data.setEscapedAttribute("serviceURL", "href", service.getWebsite()); + if (service.getWebsiteURL() != null) + { + data.setEscapedAttribute("serviceName", "href", service.getWebsiteURL().toString()); + data.setEscapedContent("serviceURL", service.getWebsiteURL().toString()); + data.setEscapedAttribute("serviceURL", "href", service.getWebsiteURL().toString()); + } 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("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.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.getIdData("contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } @@ -106,15 +108,15 @@ public class ServiceHeaderView data.setAttribute("emailLinkImg", "class", ""); 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.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.getIdData("technicalDocLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } @@ -150,21 +152,21 @@ public class ServiceHeaderView data.setEscapedContent("softwareName", StringUtils.defaultIfBlank(service.getSoftwareName(), "n/a")); data.setContent("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "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.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.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.getIdData("softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java b/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java index 4a089bf..3ff1ba7 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java +++ b/src/fr/devinsy/statoolinfos/htmlize/ServiceListView.java @@ -78,9 +78,12 @@ public class ServiceListView data.setAttribute("serviceListLine", index, "serviceListLineOrganizationLogo", "src", service.getOrganization().getLogoFileName()); data.setEscapedContent("serviceListLine", index, "serviceListLineOrganizationValue", service.getOrganization().getName()); - data.setEscapedContent("serviceListLine", index, "serviceListLineUrlLink", service.getWebsite()); - data.setEscapedContent("serviceListLine", index, "serviceListLineWebsiteLink", service.getWebsite()); - data.setEscapedAttribute("serviceListLine", index, "serviceListLineWebsiteLink", "href", service.getWebsite()); + if (service.getWebsiteURL() != null) + { + 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.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", "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.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.getIdData("serviceListLine", index, "contactLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } @@ -113,15 +116,15 @@ public class ServiceListView data.setAttribute("serviceListLine", index, "emailLinkImg", "class", ""); 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.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.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("softwareVersion", StringUtils.defaultIfBlank(service.getSoftwareVersion(), "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.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.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.getIdData("serviceListLine", index, "softwareSourceLinkImg").getAttribute("class").setMode(DisplayMode.REPLACE); } diff --git a/src/fr/devinsy/statoolinfos/htmlize/SocialNetworksPage.java b/src/fr/devinsy/statoolinfos/htmlize/SocialNetworksPage.java index 9c3b912..cadc278 100644 --- a/src/fr/devinsy/statoolinfos/htmlize/SocialNetworksPage.java +++ b/src/fr/devinsy/statoolinfos/htmlize/SocialNetworksPage.java @@ -104,9 +104,11 @@ public class SocialNetworksPage data.setAttribute("organizationListLine", index, "organizationListLineLogo", "alt", organization.getName()); data.setEscapedContent("organizationListLine", index, "organizationListLineNameValue", organization.getName()); - data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsite()); - data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsite()); - + if (organization.getWebsiteURL() != null) + { + data.setEscapedContent("organizationListLine", index, "organizationListLineUrlLink", organization.getWebsiteURL().toString()); + data.setAttribute("organizationListLine", index, "organizationListLineUrlLink", "href", organization.getWebsiteURL().toString()); + } if (StringUtils.isNotBlank(organization.getDiasporaWebpage())) { data.setAttribute("organizationListLine", index, "organizationListLineDiasporaImg", "class", ""); diff --git a/src/fr/devinsy/statoolinfos/properties/PathProperties.java b/src/fr/devinsy/statoolinfos/properties/PathProperties.java index b3cfedf..a3c528e 100644 --- a/src/fr/devinsy/statoolinfos/properties/PathProperties.java +++ b/src/fr/devinsy/statoolinfos/properties/PathProperties.java @@ -18,7 +18,6 @@ */ package fr.devinsy.statoolinfos.properties; -import java.net.MalformedURLException; import java.net.URL; import java.util.Iterator; @@ -96,7 +95,7 @@ public interface PathProperties extends Iterable * the path * @return the url */ - URL getURL(String path) throws MalformedURLException; + URL getURL(String path); /** * Iterator. diff --git a/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java b/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java index 835655a..c8f3b98 100644 --- a/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java +++ b/src/fr/devinsy/statoolinfos/properties/PathPropertyList.java @@ -699,28 +699,30 @@ public class PathPropertyList extends ArrayList implements PathPro return result; } - /** - * Gets the url. - * - * @param path - * the path - * @return the url - * @throws MalformedURLException + /* (non-Javadoc) + * @see fr.devinsy.statoolinfos.properties.PathProperties#getURL(java.lang.String) */ @Override - public URL getURL(final String path) throws MalformedURLException + public URL getURL(final String path) { URL result; - String value = get(path); - if ((path == null) || (!StringUtils.startsWith(value, "http"))) + try + { + String value = get(path); + if ((path == null) || (!StringUtils.startsWith(value, "http"))) + { + result = null; + } + else + { + result = new URL(value); + } + } + catch (MalformedURLException exception) { result = null; } - else - { - result = new URL(value); - } // return result; diff --git a/src/fr/devinsy/statoolinfos/util/URLUtils.java b/src/fr/devinsy/statoolinfos/util/URLUtils.java index d77d5ad..47e47a2 100644 --- a/src/fr/devinsy/statoolinfos/util/URLUtils.java +++ b/src/fr/devinsy/statoolinfos/util/URLUtils.java @@ -21,6 +21,7 @@ package fr.devinsy.statoolinfos.util; import java.io.File; import java.io.IOException; import java.net.JarURLConnection; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.util.Enumeration; @@ -211,4 +212,59 @@ public final class URLUtils // 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; + } } \ No newline at end of file