user-group-role_created does not fail now on non-existing client

This commit is contained in:
dcore94 2020-07-23 16:46:53 +02:00
parent 74d400fa9d
commit e1fac00cc1
1 changed files with 37 additions and 23 deletions

View File

@ -4,7 +4,7 @@
"createBy" : "Marco Lettere",
"description": "Handle workflow related to Portal event user-group-role_created",
"version" : 1,
"ownerEmail" : "marco.lettere@nubisware.com",
"ownerEmail" : "m.lettere@gmail.com",
"inputParameters" : ["role", "user", "group"],
"tasks" : [
{
@ -68,6 +68,7 @@
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/clients/${lookup_client.output.body[0].id}/roles",
"method" : "GET",
"expect" : [200,404],
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}",
"Accept" : "application/json"
@ -75,28 +76,41 @@
}
},
{
"name": "LAMBDA_TASK",
"taskReferenceName": "select_role",
"type": "LAMBDA",
"inputParameters": {
"role": "${workflow.input.role}",
"roles" : "${get_client_roles.output.body}",
"scriptExpression": "for(var i=0; i < $.roles.length;i++){if($.roles[i]['name'] == $.role) return Java.to([$.roles[i]], 'java.lang.Object[]')}"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "assign_role_to_user",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/users/${lookup_user.output.body[0].id}/role-mappings/clients/${lookup_client.output.body[0].id}",
"expect" : [204, 404],
"method" : "POST",
"body" : "${select_role.output.result}",
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}",
"Content-Type" : "application/json"
}
"name": "check_task",
"taskReferenceName": "check",
"inputParameters": {
"prev_status": "${get_client_roles.output.status}"
},
"type": "DECISION",
"caseValueParam": "prev_status",
"decisionCases": {
"200": [
{
"name": "LAMBDA_TASK",
"taskReferenceName": "select_role",
"type": "LAMBDA",
"inputParameters": {
"role": "${workflow.input.role}",
"roles" : "${get_client_roles.output.body}",
"scriptExpression": "for(var i=0; i < $.roles.length;i++){if($.roles[i]['name'] == $.role) return Java.to([$.roles[i]], 'java.lang.Object[]')}"
}
},
{
"name" : "pyrest",
"taskReferenceName" : "assign_role_to_user",
"type" : "SIMPLE",
"inputParameters" : {
"url" : "${init.input.keycloak_admin}/users/${lookup_user.output.body[0].id}/role-mappings/clients/${lookup_client.output.body[0].id}",
"expect" : [204, 404],
"method" : "POST",
"body" : "${select_role.output.result}",
"headers" : {
"Authorization" : "Bearer ${authorize.output.body.access_token}",
"Content-Type" : "application/json"
}
}
}
]
}
}
]