From a0b322141d4e7a97aa5a7d44297c9a17343ab45e Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 14 Feb 2024 15:12:15 +0100 Subject: [PATCH] gestion favicon --- .../fr/univlorraine/ecandidat/AppServlet.java | 16 ++++++++++++++++ .../ecandidat/config/CacheConfig.java | 1 - .../ecandidat/controllers/rest/CandidatRest.java | 10 ---------- .../ecandidat/views/AccueilView.java | 1 - 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/main/java/fr/univlorraine/ecandidat/AppServlet.java b/src/main/java/fr/univlorraine/ecandidat/AppServlet.java index d3890a09..d1d2fda0 100644 --- a/src/main/java/fr/univlorraine/ecandidat/AppServlet.java +++ b/src/main/java/fr/univlorraine/ecandidat/AppServlet.java @@ -16,18 +16,22 @@ */ package fr.univlorraine.ecandidat; +import java.io.File; import java.io.Serializable; +import java.util.Base64; import java.util.Locale; import javax.servlet.ServletException; import javax.servlet.annotation.WebInitParam; import javax.servlet.annotation.WebServlet; +import org.apache.commons.io.FileUtils; import org.atmosphere.cpr.ApplicationConfig; import org.jsoup.nodes.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Configuration; import org.springframework.web.context.support.WebApplicationContextUtils; import com.vaadin.server.BootstrapFragmentResponse; @@ -38,11 +42,13 @@ import com.vaadin.spring.server.SpringVaadinServlet; import fr.univlorraine.ecandidat.utils.ConstanteUtils; +import fr.univlorraine.ecandidat.utils.MethodUtils; /** * Servlet principale. * @author Adrien Colson */ +@Configuration @SuppressWarnings("serial") @WebServlet(value = ConstanteUtils.SERVLET_ALL_MATCH, asyncSupported = true, @@ -99,6 +105,16 @@ public void modifyBootstrapPage(final BootstrapPageResponse response) { head.appendElement("meta").attr("name", "viewport").attr("content", "width=device-width, initial-scale=1"); head.appendElement("meta").attr("name", "apple-mobile-web-app-capable").attr("content", "yes"); head.appendElement("meta").attr("name", "apple-mobile-web-app-status-bar-style").attr("content", "black"); + final File fileExternal = + MethodUtils.getExternalResource(applicationContext.getEnvironment().getProperty("external.ressource"), ConstanteUtils.EXTERNAL_RESSOURCE_IMG_FOLDER, ConstanteUtils.EXTERNAL_RESSOURCE_IMG_FAV_FILE); + if (fileExternal != null) { + try { + final byte[] fileContent = FileUtils.readFileToByteArray(fileExternal); + final String encodedString = Base64.getEncoder().encodeToString(fileContent); + head.getElementsByAttributeValue("rel", "icon").attr("href", "data:image/x-icon;base64," + encodedString); + } catch (final Exception e) { + } + } } /** @see com.vaadin.server.BootstrapListener#modifyBootstrapFragment(com.vaadin.server.BootstrapFragmentResponse) */ diff --git a/src/main/java/fr/univlorraine/ecandidat/config/CacheConfig.java b/src/main/java/fr/univlorraine/ecandidat/config/CacheConfig.java index f1ee693d..4b332bb5 100644 --- a/src/main/java/fr/univlorraine/ecandidat/config/CacheConfig.java +++ b/src/main/java/fr/univlorraine/ecandidat/config/CacheConfig.java @@ -40,7 +40,6 @@ public KeyGenerator keyGenerator() { sbKey.append("#" + param.toString()); } } - System.out.println(sbKey.toString()); return sbKey.toString(); }; } diff --git a/src/main/java/fr/univlorraine/ecandidat/controllers/rest/CandidatRest.java b/src/main/java/fr/univlorraine/ecandidat/controllers/rest/CandidatRest.java index 873f3c73..1629a012 100644 --- a/src/main/java/fr/univlorraine/ecandidat/controllers/rest/CandidatRest.java +++ b/src/main/java/fr/univlorraine/ecandidat/controllers/rest/CandidatRest.java @@ -46,16 +46,6 @@ public class CandidatRest { @Resource private transient UserController userController; - /** - * sonde liveness - */ - @RequestMapping(value = "/liveness/{test}", method = RequestMethod.GET) - public String sondeLiveness(@PathVariable final String test) { - //return "OK"; - System.out.println(test); - return test; - } - /** * valide le compte */ diff --git a/src/main/java/fr/univlorraine/ecandidat/views/AccueilView.java b/src/main/java/fr/univlorraine/ecandidat/views/AccueilView.java index b0b23b0b..68ce2646 100644 --- a/src/main/java/fr/univlorraine/ecandidat/views/AccueilView.java +++ b/src/main/java/fr/univlorraine/ecandidat/views/AccueilView.java @@ -285,7 +285,6 @@ private void addMentionCnil() { /** Met a jour la mention CNIL */ private void updateMentionCnil() { - System.out.println("1 " + configController.getConfigEtab()); final String mentionCnil = configController.getConfigEtab().getCnil(); if (StringUtils.isNotBlank(mentionCnil)) { labelCnil.setValue(mentionCnil);