Skip to content

Commit 96dfcec

Browse files
committed
Pull request #301: Configurable support for FTP and JAR URIs in OWL imports (disabled by default)
Merge in ITB/shacl-validator from development to master * commit '12b0820789bf9bcf65b81f44b6c67c15b0384608': Configurable support for FTP and JAR URIs in OWL imports (disabled by default)
2 parents b087703 + 12b0820 commit 96dfcec

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

‎shaclvalidator-common/src/main/java/eu/europa/ec/itb/shacl/ApplicationConfig.java‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,36 @@ public class ApplicationConfig extends eu.europa.ec.itb.validation.commons.confi
5555
private String defaultRdfReportQueryDescription;
5656
private String defaultLocaleDescription;
5757
private Integer maximumConcurrentValidations;
58+
private boolean allowUriImportsFromFtpSources = false;
59+
private boolean allowUriImportsFromJarSources = false;
60+
61+
/**
62+
* @return Whether URIs for resource imports can use the FTP scheme.
63+
*/
64+
public boolean isAllowUriImportsFromFtpSources() {
65+
return allowUriImportsFromFtpSources;
66+
}
67+
68+
/**
69+
* @param allowUriImportsFromFtpSources Whether URIs for resource imports can use the FTP scheme.
70+
*/
71+
public void setAllowUriImportsFromFtpSources(boolean allowUriImportsFromFtpSources) {
72+
this.allowUriImportsFromFtpSources = allowUriImportsFromFtpSources;
73+
}
74+
75+
/**
76+
* @return Whether URIs for resource imports can use the JAR scheme.
77+
*/
78+
public boolean isAllowUriImportsFromJarSources() {
79+
return allowUriImportsFromJarSources;
80+
}
81+
82+
/**
83+
* @param allowUriImportsFromJarSources Whether URIs for resource imports can use the JAR scheme.
84+
*/
85+
public void setAllowUriImportsFromJarSources(boolean allowUriImportsFromJarSources) {
86+
this.allowUriImportsFromJarSources = allowUriImportsFromJarSources;
87+
}
5888

5989
/**
6090
* @return The maximum number of concurrent validations to perform.

‎shaclvalidator-common/src/main/java/eu/europa/ec/itb/shacl/config/BeanConfiguration.java‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
package eu.europa.ec.itb.shacl.config;
1717

18+
import eu.europa.ec.itb.shacl.ApplicationConfig;
1819
import eu.europa.ec.itb.shacl.CustomJenaFileManager;
1920
import eu.europa.ec.itb.shacl.DomainConfig;
2021
import eu.europa.ec.itb.shacl.validation.CustomReadFailureHandler;
@@ -23,6 +24,7 @@
2324
import org.apache.jena.ontology.OntDocumentManager;
2425
import org.apache.jena.riot.system.stream.LocatorFTP;
2526
import org.apache.jena.riot.system.stream.LocatorFile;
27+
import org.springframework.beans.factory.annotation.Autowired;
2628
import org.springframework.context.annotation.Bean;
2729
import org.springframework.context.annotation.Configuration;
2830

@@ -33,6 +35,9 @@
3335
@Configuration
3436
public class BeanConfiguration {
3537

38+
@Autowired
39+
private ApplicationConfig appConfig;
40+
3641
/**
3742
* Support the definition of plugins.
3843
*
@@ -50,7 +55,12 @@ public void initialise() {
5055
fileManager.getStreamManager().clearLocators();
5156
fileManager.getStreamManager().addLocator(new CustomLocatorFile());
5257
fileManager.getStreamManager().addLocator(new CustomLocatorHTTP());
53-
fileManager.getStreamManager().addLocator(new CustomClassLoaderLocator(fileManager.getStreamManager().getClass().getClassLoader()));
58+
if (appConfig.isAllowUriImportsFromFtpSources()) {
59+
fileManager.getStreamManager().addLocator(new LocatorFTP()) ;
60+
}
61+
if (appConfig.isAllowUriImportsFromJarSources()) {
62+
fileManager.getStreamManager().addLocator(new CustomClassLoaderLocator(fileManager.getStreamManager().getClass().getClassLoader()));
63+
}
5464
fileManager.setModelCaching(true);
5565
// Setup OntDocumentManager.
5666
var ontDocumentManager = OntDocumentManager.getInstance();

0 commit comments

Comments
 (0)