From 9e8e374f6ded40ef9dcce4985e9ae012aaf6f095 Mon Sep 17 00:00:00 2001 From: "m.lettere" Date: Tue, 1 Mar 2022 16:36:01 +0100 Subject: [PATCH] handle gateway --- templates/group_created.json.j2 | 43 ++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/templates/group_created.json.j2 b/templates/group_created.json.j2 index f417d9a..d4da503 100644 --- a/templates/group_created.json.j2 +++ b/templates/group_created.json.j2 @@ -15,8 +15,8 @@ "root_vo": "{{ root_vo }}", "keycloak": "{{ keycloak }}/{{ keycloak_realm }}", "keycloak_admin" : "{{ keycloak_admin }}/{{ keycloak_realm }}", - "clientId" : "${workflow.input.group}", - "scriptExpression": "var tree = $.clientId.split('%2F'); return { 'tree' : tree, 'child': tree[tree.length-1], 'append' : tree.slice(0,-1).join('/'), 'name' : tree.join('/'), encoded_root_vo : encodeURI($.root_vo)}" + "group" : "${workflow.input.group}", + "scriptExpression": "function e(v){ return (v == null || (v.trim && v.trim() === ''))}; if(e($.group)) throw('Group must not be empty'); var tree = $.group.startsWith('%2F') ? $.group.split('%2F') : [$.group]; return { 'tree' : tree, 'child': tree[tree.length-1], 'append' : tree.slice(0,-1).join('/'), 'name' : tree.join('/'), encoded_root_vo : encodeURI($.root_vo)}" } }, { @@ -36,6 +36,43 @@ } } }, + { + "name" : "check_is_gateway", + "taskReferenceName" : "check_is_gateway", + "type" : "DECISION", + "inputParameters" :{ + "group" : "${init.output.result.group}" + }, + "caseExpression": "$.group.toLowerCase().endsWith(" gateway") || $.group.toLowerCase().endsWith("+gateway") ? 'gateway' : ''", + "decisionCases" : { + "gateway" : [ + { + "name" : "pyrest", + "taskReferenceName" : "create_gateway_group", + "type" : "SIMPLE", + "inputParameters" : { + "url" : "${init.input.keycloak_admin}/groups", + "body" : { + "name" : "${init.output.result.child}" + }, + "method" : "POST", + "headers" : { + "Authorization" : "Bearer ${authorize.output.body.access_token}", + "Content-Type" : "application/json" + } + } + }, + { + "name" : "terminate", + "taskReferenceName" : "terminate_when_gateway", + "type" : "TERMINATE", + "inputParameters" : { + "terminationStatus" : "COMPLETED" + } + } + ] + } + }, { "name" : "fork_join", "taskReferenceName" : "preliminary_fork", @@ -49,7 +86,7 @@ "inputParameters" : { "url" : "${init.input.keycloak_admin}/clients", "body" : { - "clientId": "${init.input.clientId}", + "clientId": "${init.input.group}", "name": "${init.output.result.name}", "description": "Client representation for ${init.output.result.name} context", "rootUrl": "http://localhost${init.output.result.name}",