From e3fe658512098d167002a24b611111b065b52a56 Mon Sep 17 00:00:00 2001 From: Mehdi Mehtarizadeh Date: Tue, 10 Sep 2024 16:20:41 +0100 Subject: [PATCH 1/5] Replaced loclhost with base URL placeholder. --- static.conversion/public/conversion_tool.json | 2 +- static.emf/public/emf_tool.json | 2 +- static.emfatic/public/emfatic_tool.json | 4 ++-- static.ocl/public/ocl_tool.json | 2 +- static.ocl/public/ocl_tool.yml | 2 +- xtext/static.xtext/public/xtext_tool.json | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/static.conversion/public/conversion_tool.json b/static.conversion/public/conversion_tool.json index cfba7b1..3ac12e7 100755 --- a/static.conversion/public/conversion_tool.json +++ b/static.conversion/public/conversion_tool.json @@ -23,7 +23,7 @@ "returnType": "xmi", - "path": "http://127.0.0.1:8069/services/FlexmiToXmi" + "path": "{{BASE-URL}}:8069/services/FlexmiToXmi" } diff --git a/static.emf/public/emf_tool.json b/static.emf/public/emf_tool.json index b8c0a4c..a22fc97 100755 --- a/static.emf/public/emf_tool.json +++ b/static.emf/public/emf_tool.json @@ -25,7 +25,7 @@ "returnType": "diagram", - "path": "http://127.0.0.1:8070/emfatic2plantuml" + "path": "{{BASE-URL}}:8070/emfatic2plantuml" }, diff --git a/static.emfatic/public/emfatic_tool.json b/static.emfatic/public/emfatic_tool.json index a6be150..348bdaa 100755 --- a/static.emfatic/public/emfatic_tool.json +++ b/static.emfatic/public/emfatic_tool.json @@ -23,7 +23,7 @@ "returnType": "emfatic", - "path": "http://127.0.0.1:8071/services/EcoreToEmfatic" + "path": "{{BASE-URL}}:8071/services/EcoreToEmfatic" }, @@ -37,7 +37,7 @@ "returnType": "ecore", - "path": "http://127.0.0.1:8071/services/EmfaticToEcore" + "path": "{{BASE-URL}}:8071/services/EmfaticToEcore" } diff --git a/static.ocl/public/ocl_tool.json b/static.ocl/public/ocl_tool.json index e283b09..8880cdf 100755 --- a/static.ocl/public/ocl_tool.json +++ b/static.ocl/public/ocl_tool.json @@ -26,7 +26,7 @@ "returnType": "text", - "path": "http://127.0.0.1:8072/services/RunOclFunction" + "path": "{{BASE-URL}}:8072/services/RunOclFunction" } diff --git a/static.ocl/public/ocl_tool.yml b/static.ocl/public/ocl_tool.yml index 86b149f..b70f534 100644 --- a/static.ocl/public/ocl_tool.yml +++ b/static.ocl/public/ocl_tool.yml @@ -17,7 +17,7 @@ tool: type: xmi - name: language type: text - path: http://127.0.0.1:8072/services/RunOclFunction + path: {{BASE-URL}}:8072/services/RunOclFunction returnType: text panelDefs: - buttons: diff --git a/xtext/static.xtext/public/xtext_tool.json b/xtext/static.xtext/public/xtext_tool.json index 711978a..77e72fa 100644 --- a/xtext/static.xtext/public/xtext_tool.json +++ b/xtext/static.xtext/public/xtext_tool.json @@ -19,7 +19,7 @@ {"name":"language", "type":"text"}], "returnType": "text", - "path": "http://127.0.0.1:9000" + "path": "{{BASE-URL}}:9000" } ], From 2cb4a03bcd1697fc7fff50ae4345a73b23d7ffc2 Mon Sep 17 00:00:00 2001 From: Mehdi Mehtarizadeh Date: Tue, 10 Sep 2024 16:21:18 +0100 Subject: [PATCH 2/5] Added TRUSTED_ORIGINS env variable. --- xtext/Dockerfile | 7 ++++++- xtext/editorserver/src/config.js | 4 ++-- xtext/start.sh | 7 ++++++- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/xtext/Dockerfile b/xtext/Dockerfile index b4a83f2..0e0dea4 100644 --- a/xtext/Dockerfile +++ b/xtext/Dockerfile @@ -3,6 +3,8 @@ FROM node:19-bullseye AS toolstaticbuild +ARG TRUSTED_ORIGINS + RUN apt-get update && apt-get install -y --no-install-recommends zip WORKDIR /usr/src/mdenet-tool @@ -19,6 +21,8 @@ RUN npm install; npm run build; chmod -R 755 dist/ # CORS configuration for webapp COPY xtext/acemodebundler/web.xml /usr/src/mdenet-tool/dist/WEB-INF/web.xml +RUN sed -i "s|http://127.0.0.1:8080|$TRUSTED_ORIGINS|g" /usr/src/mdenet-tool/dist/WEB-INF/web.xml + RUN cd dist && zip -r ROOT.war . @@ -43,6 +47,7 @@ RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.6.0:get -Dartifact=co FROM tomcat:9.0.76-jdk17-temurin +ARG ES_ADDRESS # toolserice main endpoint port ENV TS_PORT=9000 @@ -109,4 +114,4 @@ ENV XTEXT_ES_STOP_CRON_TIME="* 4 * * *" # setup cron job to periodically stop the server RUN ./cron-setup.sh -ENTRYPOINT [ "/bin/bash", "start.sh" ] \ No newline at end of file +ENTRYPOINT [ "/bin/bash", "start.sh" ] diff --git a/xtext/editorserver/src/config.js b/xtext/editorserver/src/config.js index 2b9d006..6bfc249 100644 --- a/xtext/editorserver/src/config.js +++ b/xtext/editorserver/src/config.js @@ -14,7 +14,7 @@ export const config = { endpointsPrefix: process.env.ES_ENDPOINT_PREFIX || "", - trustedWebOrigins: ['http://127.0.0.1:8080'], + trustedWebOrigins: [process.env.TRUSTED_ORIGIN || "http://127.0.0.1:8080"], -} \ No newline at end of file +} diff --git a/xtext/start.sh b/xtext/start.sh index a0fcac5..c14c71c 100755 --- a/xtext/start.sh +++ b/xtext/start.sh @@ -1,5 +1,10 @@ #! /bin/bash +if [ -n "${TRUSTED_ORIGINS}" ]; then + sed -i "s|http://127.0.0.1:8080|${TRUSTED_ORIGINS}|g" ${ES_DEPLOY_FILE_LOCATION}/ROOT/WEB-INF/web.xml + sed -i "s|http://127.0.0.1:8080|${TRUSTED_ORIGINS}|g" ../acemodebundler/web.xml +fi + # clean any previous editor instances and builds rm -rf ${ES_BUILD_LOCATION}/* echo Old builds cleaned. @@ -27,4 +32,4 @@ node ./src/server.js & cron # wait for them all -wait -n \ No newline at end of file +wait -n From b791ad7464a44eed316f64d6e87e8b03a5ff0b4e Mon Sep 17 00:00:00 2001 From: Mehdi Mehtarizadeh <50746457+aryaei2000@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:39:23 +0000 Subject: [PATCH 3/5] Replaced baseName with languageName --- .../com/mdenetnetwork/ep/toolfunctions/xtext/XtextTool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/com.mde-network.ep.toolfunctions.xtext/src/main/java/com/mdenetnetwork/ep/toolfunctions/xtext/XtextTool.java b/services/com.mde-network.ep.toolfunctions.xtext/src/main/java/com/mdenetnetwork/ep/toolfunctions/xtext/XtextTool.java index b974b9d..1db446f 100644 --- a/services/com.mde-network.ep.toolfunctions.xtext/src/main/java/com/mdenetnetwork/ep/toolfunctions/xtext/XtextTool.java +++ b/services/com.mde-network.ep.toolfunctions.xtext/src/main/java/com/mdenetnetwork/ep/toolfunctions/xtext/XtextTool.java @@ -70,7 +70,7 @@ public void run( String languageName, String baseName, String extension, CliProjectsCreatorMain.main(args); // Add activity files - final String basePackage = baseName.substring(0, baseName.lastIndexOf(".")); // Everything but last segment which is the language java class + final String basePackage = languageName.substring(0, languageName.lastIndexOf(".")); // Everything but last segment which is the language java class final String shortName = languageName.substring(languageName.lastIndexOf(".") + 1); // The last segment final String languagePath = PROJECT_PATH + baseName + "/src/" + basePackage.replace('.', '/'); From 2ffd55e3fdac668004974e90babf6e86b3b98232 Mon Sep 17 00:00:00 2001 From: Mehdi Mehtarizadeh <50746457+aryaei2000@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:48:18 +0000 Subject: [PATCH 4/5] Update xtext/Dockerfile Co-authored-by: Steffen Zschaler --- xtext/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/xtext/Dockerfile b/xtext/Dockerfile index 0e0dea4..902cae8 100644 --- a/xtext/Dockerfile +++ b/xtext/Dockerfile @@ -3,6 +3,7 @@ FROM node:19-bullseye AS toolstaticbuild +# comma delimited whitelist of base URLs (with no trailing slash) for CORS aware endpoints ARG TRUSTED_ORIGINS RUN apt-get update && apt-get install -y --no-install-recommends zip From c316ffd799d26bf56a93c98777fa5306845d5e6a Mon Sep 17 00:00:00 2001 From: Mehdi Mehtarizadeh <50746457+aryaei2000@users.noreply.github.com> Date: Wed, 27 Nov 2024 14:48:35 +0000 Subject: [PATCH 5/5] Update xtext/Dockerfile Co-authored-by: Steffen Zschaler --- xtext/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/xtext/Dockerfile b/xtext/Dockerfile index 902cae8..b7e9e44 100644 --- a/xtext/Dockerfile +++ b/xtext/Dockerfile @@ -48,6 +48,7 @@ RUN mvn org.apache.maven.plugins:maven-dependency-plugin:3.6.0:get -Dartifact=co FROM tomcat:9.0.76-jdk17-temurin +# See https://github.com/mdenet/educationplatform-docker/blob/development_server/README.md#environment-variables ARG ES_ADDRESS # toolserice main endpoint port