From fabc4db5f2e372c6be35285c7676f1052e444964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20J=C3=A9go?= Date: Sat, 20 Nov 2021 17:52:35 +0100 Subject: [PATCH] Add temp folder for schema cache and add dependencies like to /georchestra/cadastrapp#548 --- cadastrapp/pom.xml | 5 +++++ .../context/CadastrappContextListener.java | 13 +++++++++++++ 2 files changed, 18 insertions(+) diff --git a/cadastrapp/pom.xml b/cadastrapp/pom.xml index 5e137da2..30d06f13 100644 --- a/cadastrapp/pom.xml +++ b/cadastrapp/pom.xml @@ -251,6 +251,11 @@ gt-wfs-ng ${geotools.version} + + org.geotools + gt-app-schema + ${geotools.version} + org.quartz-scheduler quartz diff --git a/cadastrapp/src/main/java/org/georchestra/cadastrapp/context/CadastrappContextListener.java b/cadastrapp/src/main/java/org/georchestra/cadastrapp/context/CadastrappContextListener.java index 7fe22516..4f93b7ff 100644 --- a/cadastrapp/src/main/java/org/georchestra/cadastrapp/context/CadastrappContextListener.java +++ b/cadastrapp/src/main/java/org/georchestra/cadastrapp/context/CadastrappContextListener.java @@ -9,6 +9,7 @@ import org.apache.commons.io.FileUtils; import org.georchestra.cadastrapp.configuration.CadastrappPlaceHolder; +import org.geotools.xml.resolver.SchemaCache; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.context.ConfigurableApplicationContext; @@ -43,6 +44,18 @@ public void contextInitialized(ServletContextEvent sce) { if(writeTest.createNewFile()){ logger.debug("Init config - folder " + tempFolder + " exist and is writable"); writeTest.delete(); + + // update the schemaCache key and create folder if not already exist + if(System.getProperty(SchemaCache.PROVIDED_CACHE_LOCATION_KEY, null) == null){ + logger.debug("Init SchemaCache property and folder"); + File schemaCacheFolder = new File(tempFolder+File.separator, "app-schema-cache"); + // remove previous folder + schemaCacheFolder.delete(); + // create folder + schemaCacheFolder.mkdirs(); + System.setProperty(SchemaCache.PROVIDED_CACHE_LOCATION_KEY, schemaCacheFolder.getAbsolutePath()); + } + // else directory should have been created by admin when adding -Dschema.cache.dir= }else{ logger.error("Init config - folder " + tempFolder + " exist but is not writable"); // Throw an exception to stop deploiement in init phase