mirror of
https://github.com/graphhopper/jsprit.git
synced 2020-01-24 07:45:05 +01:00
fix file-access in AlgorithmConfigXmlReader
This commit is contained in:
parent
4ea045348b
commit
aa76b68685
2 changed files with 3 additions and 33 deletions
|
|
@ -90,38 +90,8 @@ public class AlgorithmConfigXmlReader {
|
|||
|
||||
public void read(String filename){
|
||||
log.info("read algorithm-config from file " + filename);
|
||||
algorithmConfig.getXMLConfiguration().setFileName(filename);
|
||||
algorithmConfig.getXMLConfiguration().setAttributeSplittingDisabled(true);
|
||||
algorithmConfig.getXMLConfiguration().setDelimiterParsingDisabled(true);
|
||||
|
||||
if(schemaValidation){
|
||||
final URL resource = Resource.getAsURL("algorithm_schema.xsd");
|
||||
if(resource != null) {
|
||||
EntityResolver resolver = new EntityResolver() {
|
||||
|
||||
@Override
|
||||
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
|
||||
{
|
||||
InputSource is = new InputSource(resource.getFile());
|
||||
return is;
|
||||
}
|
||||
}
|
||||
};
|
||||
algorithmConfig.getXMLConfiguration().setEntityResolver(resolver);
|
||||
algorithmConfig.getXMLConfiguration().setSchemaValidation(true);
|
||||
log.info("validating " + filename + " with xsd-schema");
|
||||
}
|
||||
else{
|
||||
log.warn("cannot find schema-xsd file (algorithm_xml_schema.xsd). try to read xml without xml-file-validation.");
|
||||
}
|
||||
}
|
||||
try {
|
||||
algorithmConfig.getXMLConfiguration().load();
|
||||
} catch (ConfigurationException e) {
|
||||
log.error(e);
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
URL url = Resource.getAsURL(filename);
|
||||
read(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public class Resource {
|
|||
*/
|
||||
public final static URL getAsURL(final String filename) {
|
||||
// look for the file locally
|
||||
File file = new File("/" + filename);
|
||||
File file = new File(filename);
|
||||
if (file.exists()) {
|
||||
try {
|
||||
return file.toURI().toURL();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue