From e1bf86fa63524d86098c0d003fef3ebbb690aa93 Mon Sep 17 00:00:00 2001 From: Joze RIHTARSIC <joze.rihtarsic@ext.ec.europa.eu> Date: Fri, 14 Dec 2018 08:10:52 +0100 Subject: [PATCH] quick fix of index.html --- .../ec/edelivery/smp/ui/SearchResource.java | 21 ++++++++++++++++--- .../smp/ui/ServiceGroupResource.java | 19 ++++++++++++++--- smp-webapp/src/main/resources/html/index.html | 2 +- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/SearchResource.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/SearchResource.java index df6f2ae10..844c95c74 100644 --- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/SearchResource.java +++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/SearchResource.java @@ -15,7 +15,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.PostConstruct; +import java.io.UnsupportedEncodingException; import java.net.URLDecoder; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; import java.util.Optional; import static eu.europa.ec.edelivery.smp.exceptions.ErrorCode.DOMAIN_NOT_EXISTS; @@ -50,9 +53,9 @@ public class SearchResource { @RequestParam(value = "domain", required = false) String domainCode ) { - String participantIdentifierDecoded =StringUtils.isBlank(participantIdentifier)?null:URLDecoder.decode(participantIdentifier); - String participantSchemeDecoded = StringUtils.isBlank(participantScheme)?null:URLDecoder.decode(participantScheme); - String domainCodeDecoded = StringUtils.isBlank(domainCode)?null:URLDecoder.decode(domainCode); + String participantIdentifierDecoded =decodeUrlToUTF8(participantIdentifier); + String participantSchemeDecoded = decodeUrlToUTF8(participantScheme); + String domainCodeDecoded = decodeUrlToUTF8(domainCode); LOG.info("Search for page: {}, page size: {}, part. id: {}, part sch: {}, domain {}", page, pageSize, participantIdentifierDecoded, participantSchemeDecoded, domainCodeDecoded); @@ -65,4 +68,16 @@ public class SearchResource { return uiServiceGroupService.getTableList(page, pageSize, orderBy, orderType, sgf); } + + private String decodeUrlToUTF8(String value){ + if (StringUtils.isBlank(value)){ + return null; + } + try { + return URLDecoder.decode(value, "UTF-8"); + } catch (UnsupportedEncodingException ex){ + LOG.error("Unsupported UTF-8 encoding while converting: " + value, ex); + } + return value; + } } diff --git a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceGroupResource.java b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceGroupResource.java index 12e354ea3..3427b4ba3 100644 --- a/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceGroupResource.java +++ b/smp-webapp/src/main/java/eu/europa/ec/edelivery/smp/ui/ServiceGroupResource.java @@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.PostConstruct; import javax.servlet.http.HttpServletRequest; +import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.Arrays; @@ -61,9 +62,9 @@ public class ServiceGroupResource { @RequestParam(value = "domain", required = false) String domainCode ) { - String participantIdentifierDecoded =StringUtils.isBlank(participantIdentifier)?null:URLDecoder.decode(participantIdentifier); - String participantSchemeDecoded = StringUtils.isBlank(participantScheme)?null:URLDecoder.decode(participantScheme); - String domainCodeDecoded = StringUtils.isBlank(domainCode)?null:URLDecoder.decode(domainCode); + String participantIdentifierDecoded =decodeUrlToUTF8(participantIdentifier); + String participantSchemeDecoded = decodeUrlToUTF8(participantScheme); + String domainCodeDecoded = decodeUrlToUTF8(domainCode); LOG.info("Search for page: {}, page size: {}, part. id: {}, part sch: {}, domain {}",page, pageSize, participantIdentifierDecoded, participantSchemeDecoded, domainCodeDecoded ); @@ -121,5 +122,17 @@ public class ServiceGroupResource { LOG.info("GOT LIST OF ServiceGroupRO to UPDATE: " + updateEntities.length); uiServiceGroupService.updateServiceGroupList(Arrays.asList(updateEntities)); } + + private String decodeUrlToUTF8(String value){ + if (StringUtils.isBlank(value)){ + return null; + } + try { + return URLDecoder.decode(value, "UTF-8"); + } catch (UnsupportedEncodingException ex){ + LOG.error("Unsupported UTF-8 encoding while converting: " + value, ex); + } + return value; + } } diff --git a/smp-webapp/src/main/resources/html/index.html b/smp-webapp/src/main/resources/html/index.html index 0340764a4..3f5273e65 100644 --- a/smp-webapp/src/main/resources/html/index.html +++ b/smp-webapp/src/main/resources/html/index.html @@ -27,6 +27,6 @@ <h2>Version: ${project.version}</h2> <h6>Build timestamp: ${buildtimestamp}</h6> <h6>Specification: <a href="http://docs.oasis-open.org/bdxr/bdx-smp/v1.0/bdx-smp-v1.0.html" target="_blank">http://docs.oasis-open.org/bdxr/bdx-smp/v1.0/bdx-smp-v1.0.html</a></h6> - <h6>UI: <a href="../../../../../smp-angular/src/main/resources/META-INF/resources/ui/index.html" target="_blank">eDelivery SMP</a></h6> + <h6>UI: <a href="ui/index.html" target="_blank">eDelivery SMP</a></h6> </body> </html> -- GitLab