diff options
author | Dan Timoney <dtimoney@att.com> | 2019-02-05 17:38:56 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-02-05 17:38:56 +0000 |
commit | 3848bf18d98c4814793eaaab3bd44c0a6522c4d0 (patch) | |
tree | 0b04881739a4c4dd106c0815a038b61045998f69 /components/core/src | |
parent | d9715aa832e972456ac02c3059d520456bc977d0 (diff) | |
parent | 73528fe9ce4471be5e76c042ea02b40199d36532 (diff) |
Merge "blueprint scripting services"
Diffstat (limited to 'components/core/src')
3 files changed, 46 insertions, 8 deletions
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index 4ef0e82b..b1a7daad 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -27,13 +27,13 @@ object BluePrintConstants { const val RESPONSE_HEADER_TRANSACTION_ID: String = "X-ONAP-RequestID"
const val RESPONSE_HEADER_MINOR_VERSION: String = "X-MinorVersion"
const val RESPONSE_HEADER_PATCH_VERSION: String = "X-PatchVersion"
- const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion" - - const val STATUS_SUCCESS: String = "success" - const val STATUS_PROCESSING: String = "processing" - const val STATUS_FAILURE: String = "failure" - - const val TYPE_DEFAULT: String = "default" + const val RESPONSE_HEADER_LATEST_VERSION: String = "X-LatestVersion"
+
+ const val STATUS_SUCCESS: String = "success"
+ const val STATUS_PROCESSING: String = "processing"
+ const val STATUS_FAILURE: String = "failure"
+
+ const val TYPE_DEFAULT: String = "default"
const val DATA_TYPE_STRING: String = "string"
const val DATA_TYPE_INTEGER: String = "integer"
@@ -102,6 +102,7 @@ object BluePrintConstants { const val MODEL_TYPE_NODES_COMPONENT_SCRIPT: String = "tosca.nodes.component.Script"
const val MODEL_TYPE_NODES_COMPONENT_PYTHON: String = "tosca.nodes.component.Python"
const val MODEL_TYPE_NODES_COMPONENT_JYTHON: String = "tosca.nodes.component.Jython"
+ const val MODEL_TYPE_NODES_COMPONENT_KOTLIN: String = "tosca.nodes.component.Kotlin"
const val MODEL_TYPE_NODES_COMPONENT_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"
@@ -148,6 +149,7 @@ object BluePrintConstants { const val TOSCA_SCRIPTS_DIR: String = "Scripts"
const val TOSCA_MAPPINGS_DIR: String = "Mappings"
const val TOSCA_TEMPLATES_DIR: String = "Templates"
+ const val TOSCA_SCRIPTS_KOTLIN_DIR: String = "$TOSCA_SCRIPTS_DIR/kotlin"
const val METADATA_USER_GROUPS = "user-groups"
const val METADATA_TEMPLATE_NAME = "template_name"
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt new file mode 100644 index 00000000..124c167a --- /dev/null +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/interfaces/BluePrintScriptsService.kt @@ -0,0 +1,25 @@ +/* + * Copyright © 2017-2018 AT&T Intellectual Property. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.interfaces + +import org.onap.ccsdk.apps.controllerblueprints.core.service.BluePrintContext + +interface BluePrintScriptsService{ + + fun <T> scriptInstance(blueprintContext: BluePrintContext, scriptClassName: String, + reCompile: Boolean): T +}
\ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt index 1a6d096d..79360451 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintContext.kt @@ -13,12 +13,14 @@ * See the License for the specific language governing permissions and
* limitations under the License.
*/
+@file:Suppress("unused")
package org.onap.ccsdk.apps.controllerblueprints.core.service
import com.att.eelf.configuration.EELFLogger
import com.att.eelf.configuration.EELFManager
import com.fasterxml.jackson.databind.JsonNode
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
import org.onap.ccsdk.apps.controllerblueprints.core.data.*
import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils
@@ -55,6 +57,15 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { return JacksonUtils.getJson(serviceTemplate, pretty)
}
+ fun name(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_NAME)
+ ?: throw BluePrintException("could't get template name from meta data")
+
+ fun version(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_VERSION)
+ ?: throw BluePrintException("could't get template version from meta data")
+
+ fun author(): String = metadata?.get(BluePrintConstants.METADATA_TEMPLATE_AUTHOR)
+ ?: throw BluePrintException("could't get template author from meta data")
+
// Workflow
val workflows: MutableMap<String, Workflow>? = serviceTemplate.topologyTemplate?.workflows
@@ -148,7 +159,7 @@ class BluePrintContext(val serviceTemplate: ServiceTemplate) { val nodeTemplates: MutableMap<String, NodeTemplate>? = serviceTemplate.topologyTemplate?.nodeTemplates
fun nodeTemplateByName(name: String): NodeTemplate =
- nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)") + nodeTemplates?.get(name) ?: throw BluePrintException("could't get node template for the name($name)")
fun nodeTemplateForNodeType(name: String): MutableMap<String, NodeTemplate>? {
return nodeTemplates?.filterValues { nodeTemplate -> nodeTemplate.type == name }?.toMutableMap()
|