Skip to content

Commit

Permalink
Add temp folder for schema cache and add dependencies
Browse files Browse the repository at this point in the history
like to /#548
  • Loading branch information
pierrejego committed Nov 20, 2021
1 parent 735fafb commit fabc4db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cadastrapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,11 @@
<artifactId>gt-wfs-ng</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-app-schema</artifactId>
<version>${geotools.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fabc4db

Please sign in to comment.