Commit 79b5f827 authored by Evgeny Kusmenko's avatar Evgeny Kusmenko
Browse files

Merge branch 'conflang-mc5' into 'master'

Initialize file system before accessing file

See merge request !24
parents 6d1ec62e dd23d0fe
Pipeline #591379 passed with stage
in 1 minute and 2 seconds
...@@ -32,10 +32,7 @@ import java.nio.file.FileSystem; ...@@ -32,10 +32,7 @@ import java.nio.file.FileSystem;
import java.nio.file.FileSystems; import java.nio.file.FileSystems;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Collection; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import static de.monticore.lang.monticar.cnnarch.generator.validation.Constants.ROOT_SCHEMA; import static de.monticore.lang.monticar.cnnarch.generator.validation.Constants.ROOT_SCHEMA;
import static de.monticore.lang.monticar.cnnarch.generator.validation.Constants.ROOT_SCHEMA_MODEL_PATH; import static de.monticore.lang.monticar.cnnarch.generator.validation.Constants.ROOT_SCHEMA_MODEL_PATH;
...@@ -56,9 +53,15 @@ public abstract class CNNTrainGenerator { ...@@ -56,9 +53,15 @@ public abstract class CNNTrainGenerator {
setInstanceName(rootModelName); setInstanceName(rootModelName);
URL schemasResource = getClass().getClassLoader().getResource(ROOT_SCHEMA_MODEL_PATH); URL schemasResource = getClass().getClassLoader().getResource(ROOT_SCHEMA_MODEL_PATH);
URL url = getClass().getResource(ROOT_SCHEMA_MODEL_PATH + ROOT_SCHEMA); try {
String path = getClass().getProtectionDomain().getCodeSource().getLocation()
.toURI().getPath();
System.out.println("path:");
System.out.println(path);
} catch (URISyntaxException e) {
e.printStackTrace();
}
System.out.println("urls:"); System.out.println("urls:");
System.out.println(url);
System.out.println(schemasResource); System.out.println(schemasResource);
List<SchemaDefinitionSymbol> schemaDefinitionSymbols; List<SchemaDefinitionSymbol> schemaDefinitionSymbols;
try { try {
...@@ -68,6 +71,8 @@ public abstract class CNNTrainGenerator { ...@@ -68,6 +71,8 @@ public abstract class CNNTrainGenerator {
System.out.println(fileSystem); System.out.println(fileSystem);
Path path = fileSystem.getPath(schemasResource.getPath()); Path path = fileSystem.getPath(schemasResource.getPath());
ModelPath modelPath = new ModelPath(path); ModelPath modelPath = new ModelPath(path);
System.out.println("modelPath:");
System.out.println(modelPath);
SchemaDefinitionSymbol schema = resolveSchemaDefinition(ROOT_SCHEMA, modelPath); SchemaDefinitionSymbol schema = resolveSchemaDefinition(ROOT_SCHEMA, modelPath);
SchemaLangCoCoChecker checkerWithAllCoCos = SchemaLangCocoFactory.getCheckerWithAllCoCos(); SchemaLangCoCoChecker checkerWithAllCoCos = SchemaLangCocoFactory.getCheckerWithAllCoCos();
checkerWithAllCoCos.checkAll(schema.getSchemaDefinitionNode().get()); checkerWithAllCoCos.checkAll(schema.getSchemaDefinitionNode().get());
...@@ -91,9 +96,15 @@ public abstract class CNNTrainGenerator { ...@@ -91,9 +96,15 @@ public abstract class CNNTrainGenerator {
private FileSystem initFileSystem(URI uri) throws IOException { private FileSystem initFileSystem(URI uri) throws IOException {
try { try {
return FileSystems.getDefault(); FileSystem aDefault = FileSystems.getDefault();
System.out.println("Returning default");
return aDefault;
} catch(Exception e) { } catch(Exception e) {
return FileSystems.newFileSystem(uri, Collections.emptyMap()); Map<String, String> env = new HashMap<>();
env.put("create", "true");
FileSystem fileSystem = FileSystems.newFileSystem(uri, env);
System.out.println("Returning not default");
return fileSystem;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment