From 72fed8f256ca2298f2d22dd70595803911a0b2b8 Mon Sep 17 00:00:00 2001 From: Brinda Santh Date: Fri, 26 Jul 2019 10:22:16 -0400 Subject: Upgrade cds spring and kotlin versions. Change-Id: I0f323bd13c433d9ef0e207f51234d10cd8c22858 Issue-ID: CCSDK-1352 Signed-off-by: Brinda Santh --- .../core/scripts/BluePrintScriptingHost.kt | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'ms/controllerblueprints/modules/blueprint-core') diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt index 05a147171..d35f2b49b 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintScriptingHost.kt @@ -31,14 +31,13 @@ val blueprintScriptCompiler = JvmScriptCompiler(defaultJvmScriptingHostConfigura open class BlueprintScriptingHost(evaluator: ScriptEvaluator) : BasicScriptingHost(blueprintScriptCompiler, evaluator) { - override fun eval(script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration, - configuration: ScriptEvaluationConfiguration?): ResultWithDiagnostics = + override fun eval(script: SourceCode, compilationConfiguration: ScriptCompilationConfiguration, + evaluationConfiguration: ScriptEvaluationConfiguration?): ResultWithDiagnostics = runInCoroutineContext { - - blueprintScriptCompiler(script, scriptCompilationConfiguration) - .onSuccess { - evaluator(it, configuration) + blueprintScriptCompiler(script, compilationConfiguration) + .onSuccess { compiledScript -> + evaluator(compiledScript, evaluationConfiguration ?: ScriptEvaluationConfiguration.Default) }.onFailure { failedResult -> val messages = failedResult.reports.joinToString("\n") throw BluePrintProcessorException(messages) @@ -51,7 +50,7 @@ open class BluePrintScriptEvaluator(private val scriptClassName: String) : Scrip private val log = LoggerFactory.getLogger(BluePrintScriptEvaluator::class.java)!! override suspend operator fun invoke(compiledScript: CompiledScript<*>, - scriptEvaluationConfiguration: ScriptEvaluationConfiguration? + scriptEvaluationConfiguration: ScriptEvaluationConfiguration ): ResultWithDiagnostics = try { log.debug("Getting script class name($scriptClassName) from the compiled sources ") @@ -59,20 +58,19 @@ open class BluePrintScriptEvaluator(private val scriptClassName: String) : Scrip val bluePrintCompiledScript = compiledScript as BluePrintCompiledScript bluePrintCompiledScript.scriptClassFQName = scriptClassName - val classResult = compiledScript.getClass(scriptEvaluationConfiguration) - when (classResult) { + when (val classResult = compiledScript.getClass(scriptEvaluationConfiguration)) { is ResultWithDiagnostics.Failure -> classResult is ResultWithDiagnostics.Success -> { val scriptClass = classResult.value val args = ArrayList() - scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.providedProperties)?.forEach { + scriptEvaluationConfiguration.get(ScriptEvaluationConfiguration.providedProperties)?.forEach { args.add(it.value) } - scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.implicitReceivers)?.let { + scriptEvaluationConfiguration.get(ScriptEvaluationConfiguration.implicitReceivers)?.let { args.addAll(it) } - scriptEvaluationConfiguration?.get(ScriptEvaluationConfiguration.constructorArgs)?.let { + scriptEvaluationConfiguration.get(ScriptEvaluationConfiguration.constructorArgs)?.let { args.addAll(it) } -- cgit 1.2.3-korg