Skip to content

Commit

Permalink
suite dev saas
Browse files Browse the repository at this point in the history
  • Loading branch information
khergalant committed Feb 15, 2024
1 parent a0b3221 commit 96f1236
Show file tree
Hide file tree
Showing 22 changed files with 612 additions and 431 deletions.
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
<!-- WS Apogee -->
<apo.ws.version>6.40.30</apo.ws.version>
<apo.ws.prod.version>6.40.30</apo.ws.prod.version>
<apo.ws-utils.version>1.0.2</apo.ws-utils.version>
<apo.ws-utils.version>1.0.3</apo.ws-utils.version>

<!-- Outils -->
<commons.beanutils.version>1.9.4</commons.beanutils.version>
Expand Down Expand Up @@ -144,6 +144,11 @@
<name>Repository local</name>
<layout>default</layout>
<url>file://${basedir}/src/main/resources/repository</url>
<releases>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
</repository>

</repositories>
Expand Down
33 changes: 19 additions & 14 deletions src/main/java/fr/univlorraine/ecandidat/AppServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,18 @@
*/
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;
Expand All @@ -41,14 +37,13 @@
import com.vaadin.server.CustomizedSystemMessages;
import com.vaadin.spring.server.SpringVaadinServlet;

import fr.univlorraine.ecandidat.controllers.ConfigController;
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,
Expand Down Expand Up @@ -105,16 +100,26 @@ 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) {
try {
final ConfigController configController = (ConfigController) applicationContext.getBean("configController");
final String faviconBase64 = configController.getFaviconBase64();
if (faviconBase64 != null) {
head.getElementsByAttributeValue("rel", "icon").attr("href", "data:image/x-icon;base64," + faviconBase64);
}
} catch (final Exception e) {
e.printStackTrace();
}

// 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);
//
// } catch (final Exception e) {
// }
// }
}

/** @see com.vaadin.server.BootstrapListener#modifyBootstrapFragment(com.vaadin.server.BootstrapFragmentResponse) */
Expand Down
19 changes: 4 additions & 15 deletions src/main/java/fr/univlorraine/ecandidat/MainUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package fr.univlorraine.ecandidat;

import java.io.EOFException;
import java.io.File;
import java.net.SocketTimeoutException;
import java.net.URISyntaxException;
import java.util.HashMap;
Expand Down Expand Up @@ -46,11 +45,9 @@
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.navigator.ViewProvider;
import com.vaadin.server.FileResource;
import com.vaadin.server.FontAwesome;
import com.vaadin.server.Page;
import com.vaadin.server.Responsive;
import com.vaadin.server.ThemeResource;
import com.vaadin.server.UploadException;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinSession;
Expand All @@ -69,6 +66,7 @@

import fr.univlorraine.ecandidat.controllers.AlertSvaController;
import fr.univlorraine.ecandidat.controllers.CandidatController;
import fr.univlorraine.ecandidat.controllers.ConfigController;
import fr.univlorraine.ecandidat.controllers.I18nController;
import fr.univlorraine.ecandidat.controllers.LoadBalancingController;
import fr.univlorraine.ecandidat.controllers.LockCandidatController;
Expand Down Expand Up @@ -209,6 +207,8 @@ public class MainUI extends UI {
@Resource
private transient TagController tagController;
@Resource
private transient ConfigController configController;
@Resource
private transient LockCandidatController lockCandidatController;

/* Propriétés */
Expand All @@ -230,9 +230,6 @@ public class MainUI extends UI {
@Value("${sessionTimeOut:}")
private transient String sessionTimeOut;

@Value("${external.ressource:}")
private transient String externalRessource;

@Value("#{'${hideMenu:}'.split(',')}")
private List<String> hideMenu;

Expand Down Expand Up @@ -489,15 +486,7 @@ public void navigateToAccueilView() {

/** Construit le titre de l'application */
private void buildTitle() {
com.vaadin.server.Resource logo;
final File fileExternal = MethodUtils.getExternalResource(externalRessource, ConstanteUtils.EXTERNAL_RESSOURCE_IMG_FOLDER, ConstanteUtils.EXTERNAL_RESSOURCE_IMG_LOGO_FILE);
if (fileExternal != null) {
logo = new FileResource(fileExternal);
} else {
logo = new ThemeResource("logo.png");
}

final OneClickButton itemBtn = new OneClickButton(appName, logo);
final OneClickButton itemBtn = new OneClickButton(appName, configController.getLogoRessource());
try {
itemBtn.setCaption(applicationContext.getMessage("app.name", null, getLocale()));
} catch (final NoSuchMessageException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ public class CacheConfig extends CachingConfigurerSupport {

//private final Logger logger = LoggerFactory.getLogger(CacheConfig.class);
public static final String CACHE_MANAGER_NAME = "cacheManager";
public static final String CACHE_CONF = "conf";
public static final String CACHE_CONF_PEGASE = "conf_pegase";
public static final String CACHE_CONF_RESSOURCE = "conf_ressource";

@Override
@Bean(name = "cacheManager")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package fr.univlorraine.ecandidat.config;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
Expand All @@ -41,6 +42,7 @@
import fr.opensagres.xdocreport.document.registry.XDocReportRegistry;
import fr.opensagres.xdocreport.template.IContext;
import fr.opensagres.xdocreport.template.TemplateEngineKind;
import fr.univlorraine.apowsutils.WSUtils;
import fr.univlorraine.ecandidat.controllers.BatchController;
import fr.univlorraine.ecandidat.controllers.LoadBalancingController;
import fr.univlorraine.ecandidat.controllers.LockCandidatController;
Expand Down Expand Up @@ -68,6 +70,9 @@ public class LaunchAppConfig implements ApplicationListener<ContextRefreshedEven
@Resource
private transient BatchController batchController;

@Value("${external.ressource:}")
private transient String externalRessource;

/* Le service SI Scol */
@Resource(name = "${siscol.implementation}")
private SiScolGenericService siScolService;
Expand All @@ -85,6 +90,7 @@ public void onApplicationEvent(final ContextRefreshedEvent event) {
preprocessCache();
preprocessVersions();
preprocessAnnotations();
preprocessConfigUrlServicesLocation();
}

/** Affiche les données de config de LimeSurvey */
Expand Down Expand Up @@ -188,4 +194,21 @@ private void changeAnnotationAdresse(final String fieldName, final int size) thr
throw e;
}
}

/**
* Charge éventuellement un fichier de config externe pour les fichiers SiScol --> util dans WSutil
*/
private void preprocessConfigUrlServicesLocation() {
try {
if (StringUtils.isNotBlank(externalRessource)) {
final String path = externalRessource + ConstanteUtils.EXTERNAL_RESSOURCE_SISCOL_FOLDER + File.separator;
final File fileExternal = new File(path);
if (fileExternal.exists() && fileExternal.isDirectory()) {
System.setProperty(WSUtils.PROPERTY_FILE_PATH, path);
}
}
} catch (final Exception e) {

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
@EnableVaadin
@EnableScheduling
// @EnableVaadinNavigation
@PropertySource(value = "file:${app.home}", ignoreResourceNotFound = true)
@PropertySource(value = "file:${app.home}/application.properties", ignoreResourceNotFound = true)
@PropertySource("classpath:/app.properties")
public class SpringConfig {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1112,14 +1112,14 @@ public void askToReloadData(final String code) {
* Invalide le cache des url pegase
*/
public void invalidConfCacheWithoutAskToReloadData() {
cacheManager.getCache(CacheConfig.CACHE_CONF).clear();
cacheManager.getCache(CacheConfig.CACHE_CONF_PEGASE).clear();
}

/**
* Invalide le cache des url pegase
*/
public void invalidConfCache() {
cacheManager.getCache(CacheConfig.CACHE_CONF).clear();
cacheManager.getCache(CacheConfig.CACHE_CONF_PEGASE).clear();
loadBalancingController.askToReloadData(ConstanteUtils.CACHE_SPRING_CONF, true);
}
}
Loading

0 comments on commit 96f1236

Please sign in to comment.