diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index b55325b77..55ac7d7ae 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -55,8 +55,9 @@ A reset of the database is needed. - https://github.com/eclipse-syson/syson/issues/388[#388] [details] Add Transition source and target to Core properties in the Details view - https://github.com/eclipse-syson/syson/issues/394[#394] [metamodel] All _redefines_ references have been implemented. - https://github.com/eclipse-syson/syson/issues/416[#416] [import] Improve textual import running process. -End users don't have to copy _syside-cli.js_ near the _syson-application_ jar anymore. -_org.eclipse.syson.syside.path_ application option is not useful and has been removed. +By default, end users don't have to copy _syside-cli.js_ near the _syson-application_ jar anymore. +The embedded _syside-cli.js_ is copied in a system temp folder and executed from there (with node). +But, if you encounter execution rights problem, you can still copy _syside-cli.js_ in a place where you have the appropriate rights and use the _org.eclipse.syson.syside.path_ application option. === New features diff --git a/backend/application/syson-application/src/main/resources/application.properties b/backend/application/syson-application/src/main/resources/application.properties index dcb3d3638..1ab67d12b 100644 --- a/backend/application/syson-application/src/main/resources/application.properties +++ b/backend/application/syson-application/src/main/resources/application.properties @@ -34,3 +34,16 @@ logging.level.org.eclipse.sirius.web.diagrams.layout.LayoutService=OFF # ################################################## org.eclipse.syson.customImages.pattern=classpath*:/sysonCustomImages/** + +################################################## +# +# SYSIDE-CLI PATH (NEEDED FOR TEXTUAL IMPORT) +# By default, the embedded syside-cli.js is copied +# in a system temp folder and executed from there +# (with node). +# If you encountered acess rights problems, you +# can provide your own syside-cli.js located in a +# place where you have the appropriate execution +# rights. +################################################## +#org.eclipse.syson.syside.path=add_path_to_your_syside-cli.js diff --git a/backend/application/syson-sysml-import/src/main/java/org/eclipse/syson/sysml/SysmlToAst.java b/backend/application/syson-sysml-import/src/main/java/org/eclipse/syson/sysml/SysmlToAst.java index acd9a425e..332f17e80 100644 --- a/backend/application/syson-sysml-import/src/main/java/org/eclipse/syson/sysml/SysmlToAst.java +++ b/backend/application/syson-sysml-import/src/main/java/org/eclipse/syson/sysml/SysmlToAst.java @@ -26,6 +26,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.core.io.support.ResourcePatternResolver; @@ -41,17 +42,27 @@ public class SysmlToAst { private final Logger logger = LoggerFactory.getLogger(SysmlToAst.class); + private final String cliPath; + + public SysmlToAst(@Value("${org.eclipse.syson.syside.path:}") String cliPath) { + this.cliPath = cliPath; + } + public InputStream convert(InputStream input, String fileExtension) { InputStream output = null; try { Path sysmlInputPath = this.createTempFile(input, "syson", fileExtension); - PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); - Resource resource = resolver.getResource(ResourcePatternResolver.CLASSPATH_URL_PREFIX + "syside-cli.js"); - InputStream sysIdeInputStream = resource.getInputStream(); - - Path sysIdeInputPath = this.createTempFile(sysIdeInputStream, "syside-cli", "js"); + Path sysIdeInputPath = null; + if (this.cliPath != null) { + sysIdeInputPath = Path.of(this.cliPath); + } else { + PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); + Resource resource = resolver.getResource(ResourcePatternResolver.CLASSPATH_URL_PREFIX + "syside-cli.js"); + InputStream sysIdeInputStream = resource.getInputStream(); + sysIdeInputPath = this.createTempFile(sysIdeInputStream, "syside-cli", "js"); + } this.logger.info("Call syside application : node " + sysIdeInputPath.toString() + " dump " + sysmlInputPath.toString()); String[] args = { "node", sysIdeInputPath.toString(), "dump", sysmlInputPath.toString() }; @@ -82,7 +93,9 @@ public InputStream convert(InputStream input, String fileExtension) { output = new ByteArrayInputStream(builder.toString().getBytes()); sysmlInputPath.toFile().delete(); - sysIdeInputPath.toFile().delete(); + if (this.cliPath == null) { + sysIdeInputPath.toFile().delete(); + } } catch (IOException e) { this.logger.error(e.getMessage());