diff options
author | Dan Timoney <dtimoney@att.com> | 2019-01-18 14:23:41 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-01-18 14:23:41 +0000 |
commit | 2147df2f4237657e713ea3c7216713424e2ee896 (patch) | |
tree | 5c7b4b0e9adc89923ced18f8779cfe5fd988e688 /components | |
parent | 5c0d285ad38120a757ccbb92ae520b6b77f717eb (diff) | |
parent | 67a076b19d69441ae8e695f1d0f67620dacf719d (diff) |
Merge "Resource Resolution Service"
Diffstat (limited to 'components')
7 files changed, 248 insertions, 360 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 4c2d6e2fc..68037387f 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 @@ -1,172 +1,173 @@ -/* - * Copyright © 2017-2018 AT&T Intellectual Property. - * Modifications Copyright © 2018 IBM. - * - * 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 - -/** - * BluePrintConstants - * - * @author Brinda Santh - */ -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_FAILURE: String = "failure" - - const val TYPE_DEFAULT: String = "default" - - const val DATA_TYPE_STRING: String = "string" - const val DATA_TYPE_INTEGER: String = "integer" - const val DATA_TYPE_FLOAT: String = "float" - const val DATA_TYPE_BOOLEAN: String = "boolean" - const val DATA_TYPE_TIMESTAMP: String = "timestamp" - const val DATA_TYPE_NULL: String = "null" - const val DATA_TYPE_LIST: String = "list" - const val DATA_TYPE_MAP: String = "map" - - const val USER_SYSTEM: String = "System" - - const val PATH_DIVIDER: String = "/" - const val PATH_SERVICE_TEMPLATE: String = "service_template" - const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template" - const val PATH_METADATA: String = "metadata" - const val PATH_NODE_TYPES: String = "node_types" - const val PATH_POLICY_TYPES: String = "policy_types" - const val PATH_RELATIONSHIP_TYPES: String = "relationship_types" - const val PATH_ARTIFACT_TYPES: String = "artifact_types" - const val PATH_DATA_TYPES: String = "data_types" - const val PATH_INPUTS: String = "inputs" - const val PATH_NODE_WORKFLOWS: String = "workflows" - const val PATH_NODE_TEMPLATES: String = "node_templates" - const val PATH_CAPABILITIES: String = "capabilities" - const val PATH_REQUIREMENTS: String = "requirements" - const val PATH_INTERFACES: String = "interfaces" - const val PATH_OPERATIONS: String = "operations" - const val PATH_OUTPUTS: String = "outputs" - const val PATH_PROPERTIES: String = "properties" - const val PATH_ATTRIBUTES: String = "attributes" - const val PATH_ARTIFACTS: String = "artifacts" - - const val MODEL_DIR_MODEL_TYPE: String = "definition-type" - - const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type" - const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type" - const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type" - const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type" - const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type" - - const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root" - const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root" - const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root" - const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root" - const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root" - const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root" - const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root" - - const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn" - const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn" - const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo" - const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo" - const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo" - - const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG" - const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component" - const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf" - @Deprecated("Artifacts will be attached to Node Template") - const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact" - const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource" - - const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java" - const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle" - 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_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript" - - const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation" - - const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic" - - const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node" - const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute" - const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network" - const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin" - const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database" - const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment" - const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem" - const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable" - // Custom capabilities - const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content" - const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping" - const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf" - const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh" - const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp" - - const val EXPRESSION_GET_INPUT: String = "get_input" - const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute" - const val EXPRESSION_GET_ARTIFACT: String = "get_artifact" - const val EXPRESSION_GET_PROPERTY: String = "get_property" - const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output" - const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type" - - const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id" - const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath" - const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime" - const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data" - const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context" - const val PROPERTY_BLUEPRINT_NAME: String = "template_name" - const val PROPERTY_BLUEPRINT_VERSION: String = "template_version" - - const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata" - const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta" - const val TOSCA_DEFINITIONS_DIR: String = "Definitions" - const val TOSCA_PLANS_DIR: String = "Plans" - const val TOSCA_SCRIPTS_DIR: String = "Scripts" - const val TOSCA_MAPPINGS_DIR: String = "Mappings" - const val TOSCA_TEMPLATES_DIR: String = "Templates" - - const val METADATA_USER_GROUPS = "user-groups" - const val METADATA_TEMPLATE_NAME = "template_name" - const val METADATA_TEMPLATE_VERSION = "template_version" - const val METADATA_TEMPLATE_AUTHOR = "template_author" - const val METADATA_TEMPLATE_TAGS = "template_tags" - const val METADATA_WORKFLOW_NAME = "workflow_name" - - const val PAYLOAD_DATA = "payload-data" - const val PROPERTY_CURRENT_STEP = "current-step" - const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template" - const val PROPERTY_CURRENT_INTERFACE = "current-interface" - const val PROPERTY_CURRENT_OPERATION = "current-operation" - const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation" - const val PROPERTY_EXECUTION_REQUEST = "execution-request" - - const val OPERATION_PROCESS = "process" - const val OPERATION_PREPARE = "prepare" - - const val BLUEPRINT_RETRIEVE_TYPE_DB = "db" - const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file" - const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo" - +/*
+ * Copyright © 2017-2018 AT&T Intellectual Property.
+ * Modifications Copyright © 2018 IBM.
+ *
+ * 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
+
+/**
+ * BluePrintConstants
+ *
+ * @author Brinda Santh
+ */
+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_FAILURE: String = "failure"
+
+ const val TYPE_DEFAULT: String = "default"
+
+ const val DATA_TYPE_STRING: String = "string"
+ const val DATA_TYPE_INTEGER: String = "integer"
+ const val DATA_TYPE_FLOAT: String = "float"
+ const val DATA_TYPE_DOUBLE: String = "double"
+ const val DATA_TYPE_BOOLEAN: String = "boolean"
+ const val DATA_TYPE_TIMESTAMP: String = "timestamp"
+ const val DATA_TYPE_NULL: String = "null"
+ const val DATA_TYPE_LIST: String = "list"
+ const val DATA_TYPE_MAP: String = "map"
+
+ const val USER_SYSTEM: String = "System"
+
+ const val PATH_DIVIDER: String = "/"
+ const val PATH_SERVICE_TEMPLATE: String = "service_template"
+ const val PATH_TOPOLOGY_TEMPLATE: String = "topology_template"
+ const val PATH_METADATA: String = "metadata"
+ const val PATH_NODE_TYPES: String = "node_types"
+ const val PATH_POLICY_TYPES: String = "policy_types"
+ const val PATH_RELATIONSHIP_TYPES: String = "relationship_types"
+ const val PATH_ARTIFACT_TYPES: String = "artifact_types"
+ const val PATH_DATA_TYPES: String = "data_types"
+ const val PATH_INPUTS: String = "inputs"
+ const val PATH_NODE_WORKFLOWS: String = "workflows"
+ const val PATH_NODE_TEMPLATES: String = "node_templates"
+ const val PATH_CAPABILITIES: String = "capabilities"
+ const val PATH_REQUIREMENTS: String = "requirements"
+ const val PATH_INTERFACES: String = "interfaces"
+ const val PATH_OPERATIONS: String = "operations"
+ const val PATH_OUTPUTS: String = "outputs"
+ const val PATH_PROPERTIES: String = "properties"
+ const val PATH_ATTRIBUTES: String = "attributes"
+ const val PATH_ARTIFACTS: String = "artifacts"
+
+ const val MODEL_DIR_MODEL_TYPE: String = "definition-type"
+
+ const val MODEL_DEFINITION_TYPE_NODE_TYPE: String = "node_type"
+ const val MODEL_DEFINITION_TYPE_ARTIFACT_TYPE: String = "artifact_type"
+ const val MODEL_DEFINITION_TYPE_CAPABILITY_TYPE: String = "capability_type"
+ const val MODEL_DEFINITION_TYPE_RELATIONSHIP_TYPE: String = "relationship_type"
+ const val MODEL_DEFINITION_TYPE_DATA_TYPE: String = "data_type"
+
+ const val MODEL_TYPE_DATATYPES_ROOT: String = "tosca.datatypes.Root"
+ const val MODEL_TYPE_NODES_ROOT: String = "tosca.nodes.Root"
+ const val MODEL_TYPE_GROUPS_ROOT: String = "tosca.groups.Root"
+ const val MODEL_TYPE_RELATIONSHIPS_ROOT: String = "tosca.relationships.Root"
+ const val MODEL_TYPE_ARTIFACTS_ROOT: String = "tosca.artifacts.Root"
+ const val MODEL_TYPE_CAPABILITIES_ROOT: String = "tosca.capabilities.Root"
+ const val MODEL_TYPE_INTERFACES_ROOT: String = "tosca.interfaces.Root"
+
+ const val MODEL_TYPE_RELATIONSHIPS_DEPENDS_ON = "tosca.relationships.DependsOn"
+ const val MODEL_TYPE_RELATIONSHIPS_HOSTED_ON = "tosca.relationships.HostedOn"
+ const val MODEL_TYPE_RELATIONSHIPS_CONNECTS_TO = "tosca.relationships.ConnectsTo"
+ const val MODEL_TYPE_RELATIONSHIPS_ATTACH_TO = "tosca.relationships.AttachesTo"
+ const val MODEL_TYPE_RELATIONSHIPS_ROUTES_TO = "tosca.relationships.RoutesTo"
+
+ const val MODEL_TYPE_NODE_DG = "tosca.nodes.DG"
+ const val MODEL_TYPE_NODE_COMPONENT = "tosca.nodes.Component"
+ const val MODEL_TYPE_NODE_VNF = "tosca.nodes.Vnf"
+ @Deprecated("Artifacts will be attached to Node Template")
+ const val MODEL_TYPE_NODE_ARTIFACT = "tosca.nodes.Artifact"
+ const val MODEL_TYPE_NODE_RESOURCE_SOURCE = "tosca.nodes.ResourceSource"
+
+ const val MODEL_TYPE_NODES_COMPONENT_JAVA: String = "tosca.nodes.component.Java"
+ const val MODEL_TYPE_NODES_COMPONENT_BUNDLE: String = "tosca.nodes.component.Bundle"
+ 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_JAVA_SCRIPT: String = "tosca.nodes.component.JavaScript"
+
+ const val MODEL_TYPE_ARTIFACT_TYPE_IMPLEMENTATION = "tosca.artifacts.Implementation"
+
+ const val MODEL_TYPE_DATA_TYPE_DYNAMIC = "tosca.datatypes.Dynamic"
+
+ const val MODEL_TYPE_CAPABILITY_TYPE_NODE = "tosca.capabilities.Node"
+ const val MODEL_TYPE_CAPABILITY_TYPE_COMPUTE = "tosca.capabilities.Compute"
+ const val MODEL_TYPE_CAPABILITY_TYPE_NETWORK = "tosca.capabilities.Network"
+ const val MODEL_TYPE_CAPABILITY_TYPE_STORAGE = "tosca.capabilities.Storage"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT = "tosca.capabilities.Endpoint"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_PUBLIC = "tosca.capabilities.Endpoint.Public"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_ADMIN = "tosca.capabilities.Endpoint.Admin"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ENDPOINT_DATABASE = "tosca.capabilities.Endpoint.Database"
+ const val MODEL_TYPE_CAPABILITY_TYPE_ATTACHMENT = "tosca.capabilities.Attachment"
+ const val MODEL_TYPE_CAPABILITY_TYPE_OPERATION_SYSTEM = "tosca.capabilities.OperatingSystem"
+ const val MODEL_TYPE_CAPABILITY_TYPE_BINDABLE = "tosca.capabilities.network.Bindable"
+ // Custom capabilities
+ const val MODEL_TYPE_CAPABILITY_TYPE_CONTENT = "tosca.capabilities.Content"
+ const val MODEL_TYPE_CAPABILITY_TYPE_MAPPING = "tosca.capabilities.Mapping"
+ const val MODEL_TYPE_CAPABILITY_TYPE_NETCONF = "tosca.capabilities.Netconf"
+ const val MODEL_TYPE_CAPABILITY_TYPE_SSH = "tosca.capabilities.Ssh"
+ const val MODEL_TYPE_CAPABILITY_TYPE_SFTP = "tosca.capabilities.Sftp"
+
+ const val EXPRESSION_GET_INPUT: String = "get_input"
+ const val EXPRESSION_GET_ATTRIBUTE: String = "get_attribute"
+ const val EXPRESSION_GET_ARTIFACT: String = "get_artifact"
+ const val EXPRESSION_GET_PROPERTY: String = "get_property"
+ const val EXPRESSION_GET_OPERATION_OUTPUT: String = "get_operation_output"
+ const val EXPRESSION_GET_NODE_OF_TYPE: String = "get_nodes_of_type"
+
+ const val PROPERTY_BLUEPRINT_PROCESS_ID: String = "blueprint-process-id"
+ const val PROPERTY_BLUEPRINT_BASE_PATH: String = "blueprint-basePath"
+ const val PROPERTY_BLUEPRINT_RUNTIME: String = "blueprint-runtime"
+ const val PROPERTY_BLUEPRINT_INPUTS_DATA: String = "blueprint-inputs-data"
+ const val PROPERTY_BLUEPRINT_CONTEXT: String = "blueprint-context"
+ const val PROPERTY_BLUEPRINT_NAME: String = "template_name"
+ const val PROPERTY_BLUEPRINT_VERSION: String = "template_version"
+
+ const val TOSCA_METADATA_DIR: String = "TOSCA-Metadata"
+ const val TOSCA_METADATA_ENTRY_DEFINITION_FILE: String = "TOSCA-Metadata/TOSCA.meta"
+ const val TOSCA_DEFINITIONS_DIR: String = "Definitions"
+ const val TOSCA_PLANS_DIR: String = "Plans"
+ const val TOSCA_SCRIPTS_DIR: String = "Scripts"
+ const val TOSCA_MAPPINGS_DIR: String = "Mappings"
+ const val TOSCA_TEMPLATES_DIR: String = "Templates"
+
+ const val METADATA_USER_GROUPS = "user-groups"
+ const val METADATA_TEMPLATE_NAME = "template_name"
+ const val METADATA_TEMPLATE_VERSION = "template_version"
+ const val METADATA_TEMPLATE_AUTHOR = "template_author"
+ const val METADATA_TEMPLATE_TAGS = "template_tags"
+ const val METADATA_WORKFLOW_NAME = "workflow_name"
+
+ const val PAYLOAD_DATA = "payload-data"
+ const val PROPERTY_CURRENT_STEP = "current-step"
+ const val PROPERTY_CURRENT_NODE_TEMPLATE = "current-node-template"
+ const val PROPERTY_CURRENT_INTERFACE = "current-interface"
+ const val PROPERTY_CURRENT_OPERATION = "current-operation"
+ const val PROPERTY_CURRENT_IMPLEMENTATION = "current-implementation"
+ const val PROPERTY_EXECUTION_REQUEST = "execution-request"
+
+ const val OPERATION_PROCESS = "process"
+ const val OPERATION_PREPARE = "prepare"
+
+ const val BLUEPRINT_RETRIEVE_TYPE_DB = "db"
+ const val BLUEPRINT_RETRIEVE_TYPE_FILE = "file"
+ const val BLUEPRINT_RETRIEVE_TYPE_REPO = "repo"
+
}
\ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index 64797ed40..4c35b53a2 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -103,6 +103,7 @@ object BluePrintTypes { validTypes.add(BluePrintConstants.DATA_TYPE_STRING)
validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER)
validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT)
+ validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE)
validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN)
validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)
validTypes.add(BluePrintConstants.DATA_TYPE_NULL)
@@ -117,6 +118,7 @@ object BluePrintTypes { validTypes.add(BluePrintConstants.DATA_TYPE_STRING)
validTypes.add(BluePrintConstants.DATA_TYPE_INTEGER)
validTypes.add(BluePrintConstants.DATA_TYPE_FLOAT)
+ validTypes.add(BluePrintConstants.DATA_TYPE_DOUBLE)
validTypes.add(BluePrintConstants.DATA_TYPE_BOOLEAN)
validTypes.add(BluePrintConstants.DATA_TYPE_TIMESTAMP)
validTypes.add(BluePrintConstants.DATA_TYPE_NULL)
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt index 4d1d9b653..11f709c9a 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/CustomFunctions.kt @@ -112,25 +112,40 @@ fun MutableMap<String, JsonNode>.getAsDouble(key: String): Double { // Checks
fun checkNotEmpty(value: String?): Boolean {
- return value != null && value.isNotEmpty()
+ return value != null && value.isNotBlank()
}
-fun checkNotEmptyNThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean {
- val notEmpty = value != null && value.isNotEmpty()
+fun checkNotEmptyOrThrow(value: String?, message: String? = value.plus(" is null/empty ")): Boolean {
+ val notEmpty = checkNotEmpty(value)
if (!notEmpty) {
throw BluePrintException(message!!)
}
return notEmpty
}
+fun checkEqualsOrThrow(value1: String?, value2: String?, lazyMessage: () -> Any): Boolean {
+ if (value1.equals(value2, ignoreCase = true)) {
+ return true
+ } else {
+ throw BluePrintException(lazyMessage().toString())
+ }
+}
+
+fun nullToEmpty(value: String?): String {
+ return if (checkNotEmpty(value)) value!! else ""
+}
+
+fun returnNotEmptyOrThrow(value: String?, lazyMessage: () -> Any): String {
+ if (checkNotEmpty(value)) {
+ return value!!
+ } else {
+ throw IllegalStateException(lazyMessage().toString())
+ }
+}
+
fun InputStream.toFile(path: String): File {
val file = File(path)
file.outputStream().use { this.copyTo(it) }
return file
}
-
-
-
-
-
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt index 178373704..b33cc3f0c 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintValidatorService.kt @@ -523,7 +523,7 @@ open class BluePrintValidatorDefaultService : BluePrintValidatorService { @Throws(BluePrintException::class)
open fun validateImplementation(implementation: Implementation) {
- checkNotEmptyNThrow(implementation.primary)
+ checkNotEmptyOrThrow(implementation.primary)
}
@Throws(BluePrintException::class)
diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt index 6321a8385..2e5a040c5 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JacksonUtils.kt @@ -33,9 +33,11 @@ import kotlinx.coroutines.withContext import org.apache.commons.io.IOUtils
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintConstants
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException
+import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintProcessorException
import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes
import java.io.File
import java.nio.charset.Charset
+import kotlin.reflect.jvm.internal.impl.load.kotlin.JvmType
/**
*
@@ -174,8 +176,13 @@ class JacksonUtils { return getMapFromJson(content, valueType)
}
+ fun <T> getInstanceFromMap(properties: MutableMap<String, JsonNode>, classType: Class<T>): T {
+ return readValue(getJson(properties), classType)
+ ?: throw BluePrintProcessorException("failed to transform content ($properties) to type ($classType)")
+ }
+
fun checkJsonNodeValueOfType(type: String, jsonNode: JsonNode): Boolean {
- if (BluePrintTypes.validPrimitiveTypes().contains(type)) {
+ if (BluePrintTypes.validPrimitiveTypes().contains(type.toLowerCase())) {
return checkJsonNodeValueOfPrimitiveType(type, jsonNode)
} else if (BluePrintTypes.validCollectionTypes().contains(type)) {
return checkJsonNodeValueOfCollectionType(type, jsonNode)
@@ -183,59 +190,76 @@ class JacksonUtils { return false
}
+ fun checkIfPrimitiveType(primitiveType: String): Boolean {
+ return when (primitiveType.toLowerCase()) {
+ BluePrintConstants.DATA_TYPE_STRING -> true
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> true
+ BluePrintConstants.DATA_TYPE_INTEGER -> true
+ BluePrintConstants.DATA_TYPE_FLOAT -> true
+ BluePrintConstants.DATA_TYPE_DOUBLE -> true
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> true
+ else -> false
+ }
+ }
+
fun checkJsonNodeValueOfPrimitiveType(primitiveType: String, jsonNode: JsonNode): Boolean {
- when (primitiveType) {
- BluePrintConstants.DATA_TYPE_STRING -> return jsonNode.isTextual
- BluePrintConstants.DATA_TYPE_BOOLEAN -> return jsonNode.isBoolean
- BluePrintConstants.DATA_TYPE_INTEGER -> return jsonNode.isInt
- BluePrintConstants.DATA_TYPE_FLOAT -> return jsonNode.isDouble
- BluePrintConstants.DATA_TYPE_TIMESTAMP -> return jsonNode.isTextual
- else -> return false
+ return when (primitiveType.toLowerCase()) {
+ BluePrintConstants.DATA_TYPE_STRING -> jsonNode.isTextual
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNode.isBoolean
+ BluePrintConstants.DATA_TYPE_INTEGER -> jsonNode.isInt
+ BluePrintConstants.DATA_TYPE_FLOAT -> jsonNode.isDouble
+ BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNode.isDouble
+ BluePrintConstants.DATA_TYPE_TIMESTAMP -> jsonNode.isTextual
+ else -> false
}
}
fun checkJsonNodeValueOfCollectionType(type: String, jsonNode: JsonNode): Boolean {
- when (type) {
- BluePrintConstants.DATA_TYPE_LIST -> return jsonNode.isArray
- BluePrintConstants.DATA_TYPE_MAP -> return jsonNode.isContainerNode
- else -> return false
+ return when (type.toLowerCase()) {
+ BluePrintConstants.DATA_TYPE_LIST -> jsonNode.isArray
+ BluePrintConstants.DATA_TYPE_MAP -> jsonNode.isContainerNode
+ else -> false
}
}
fun populatePrimitiveValues(key: String, value: Any, primitiveType: String, objectNode: ObjectNode) {
- when (primitiveType) {
+ when (primitiveType.toLowerCase()) {
BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, value as Boolean)
BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, value as Int)
BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, value as Float)
+ BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, value as Double)
BluePrintConstants.DATA_TYPE_TIMESTAMP -> objectNode.put(key, value as String)
else -> objectNode.put(key, value as String)
}
}
fun populatePrimitiveValues(value: Any, primitiveType: String, arrayNode: ArrayNode) {
- when (primitiveType) {
+ when (primitiveType.toLowerCase()) {
BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(value as Boolean)
BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(value as Int)
BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(value as Float)
+ BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(value as Double)
BluePrintConstants.DATA_TYPE_TIMESTAMP -> arrayNode.add(value as String)
else -> arrayNode.add(value as String)
}
}
fun populatePrimitiveDefaultValues(key: String, primitiveType: String, objectNode: ObjectNode) {
- when (primitiveType) {
+ when (primitiveType.toLowerCase()) {
BluePrintConstants.DATA_TYPE_BOOLEAN -> objectNode.put(key, false)
BluePrintConstants.DATA_TYPE_INTEGER -> objectNode.put(key, 0)
BluePrintConstants.DATA_TYPE_FLOAT -> objectNode.put(key, 0.0)
+ BluePrintConstants.DATA_TYPE_DOUBLE -> objectNode.put(key, 0.0)
else -> objectNode.put(key, "")
}
}
fun populatePrimitiveDefaultValuesForArrayNode(primitiveType: String, arrayNode: ArrayNode) {
- when (primitiveType) {
+ when (primitiveType.toLowerCase()) {
BluePrintConstants.DATA_TYPE_BOOLEAN -> arrayNode.add(false)
BluePrintConstants.DATA_TYPE_INTEGER -> arrayNode.add(0)
BluePrintConstants.DATA_TYPE_FLOAT -> arrayNode.add(0.0)
+ BluePrintConstants.DATA_TYPE_DOUBLE -> arrayNode.add(0.0)
else -> arrayNode.add("")
}
}
@@ -250,13 +274,15 @@ class JacksonUtils { }
}
- fun convertPrimitiveResourceValue(type: String, value: String): JsonNode? {
- when (type) {
- BluePrintConstants.DATA_TYPE_BOOLEAN -> return JacksonUtils.getJsonNode(value as Boolean)
- BluePrintConstants.DATA_TYPE_INTEGER -> return JacksonUtils.getJsonNode(value as Int)
- BluePrintConstants.DATA_TYPE_FLOAT -> return JacksonUtils.getJsonNode(value as Float)
- else -> return JacksonUtils.getJsonNode(value)
+ fun convertPrimitiveResourceValue(type: String, value: String): JsonNode {
+ return when (type.toLowerCase()) {
+ BluePrintConstants.DATA_TYPE_BOOLEAN -> jsonNodeFromObject(java.lang.Boolean.valueOf(value))
+ BluePrintConstants.DATA_TYPE_INTEGER -> jsonNodeFromObject(Integer.valueOf(value))
+ BluePrintConstants.DATA_TYPE_FLOAT -> jsonNodeFromObject(java.lang.Float.valueOf(value))
+ BluePrintConstants.DATA_TYPE_DOUBLE -> jsonNodeFromObject(java.lang.Double.valueOf(value))
+ else -> getJsonNode(value)
}
}
+
}
}
\ No newline at end of file diff --git a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt index 2e4a733a8..1077f347e 100644 --- a/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt +++ b/components/core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/validation/BluePrintNodeTypeValidatorImpl.kt @@ -20,7 +20,7 @@ import com.att.eelf.configuration.EELFLogger import com.att.eelf.configuration.EELFManager import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintTypes -import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyNThrow +import org.onap.ccsdk.apps.controllerblueprints.core.checkNotEmptyOrThrow import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintNodeTypeValidator import org.onap.ccsdk.apps.controllerblueprints.core.interfaces.BluePrintTypeValidatorService @@ -149,7 +149,7 @@ open class BluePrintNodeTypeValidatorImpl(private val bluePrintTypeValidatorServ } open fun validateImplementation(implementation: Implementation) { - checkNotEmptyNThrow(implementation.primary) + checkNotEmptyOrThrow(implementation.primary) } }
\ No newline at end of file diff --git a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt b/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt deleted file mode 100644 index a234a89ee..000000000 --- a/components/resource-dict/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/resource/dict/utils/ResourceAssignmentUtils.kt +++ /dev/null @@ -1,156 +0,0 @@ -/* - * 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.resource.dict.utils - -import java.util.Date -import com.att.eelf.configuration.EELFLogger -import com.att.eelf.configuration.EELFManager -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.ObjectMapper -import com.fasterxml.jackson.databind.node.NullNode -import com.fasterxml.jackson.databind.node.ObjectNode -import org.onap.ccsdk.apps.controllerblueprints.core.* -import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils -import org.onap.ccsdk.apps.controllerblueprints.resource.dict.ResourceAssignment - -class ResourceAssignmentUtils { - companion object { - - private val logger: EELFLogger = EELFManager.getInstance().getLogger(ResourceAssignmentUtils::class.toString()) - - @Synchronized - @Throws(BluePrintProcessorException::class) - fun setResourceDataValue(resourceAssignment: ResourceAssignment, value: Any?) { - - val resourceProp = checkNotNull(resourceAssignment.property) { "Failed in setting resource value for resource mapping $resourceAssignment" } - checkNotEmptyNThrow(resourceAssignment.name, "Failed in setting resource value for resource mapping $resourceAssignment") - - if (checkNotEmpty(resourceAssignment.dictionaryName)) { - resourceAssignment.dictionaryName = resourceAssignment.name - logger.warn("Missing dictionary key, setting with template key (${resourceAssignment.name}) as dictionary key (${resourceAssignment.dictionaryName})") - } - - try { - if (checkNotEmpty(resourceProp.type)) { - val convertedValue = convertResourceValue(resourceProp.type, value) - logger.info("Setting Resource Value ($convertedValue) for Resource Name (${resourceAssignment.dictionaryName}) of type (${resourceProp.type})") - resourceProp.value = convertedValue - resourceAssignment.updatedDate = Date() - resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM - resourceAssignment.status = BluePrintConstants.STATUS_SUCCESS - } - } catch (e: Exception) { - throw BluePrintProcessorException("Failed in setting value for template key (%s) and " + - "dictionary key (${resourceAssignment.name}) of type (${resourceProp.type}) with error message (${e.message})", e) - } - } - - private fun convertResourceValue(type: String, value: Any?): JsonNode? { - var convertedValue: JsonNode? - - if (value == null || value is NullNode) { - logger.info("Returning {} value from convertResourceValue", value) - return null - } else if (BluePrintTypes.validPrimitiveTypes().contains(type) && value is String) { - convertedValue = JacksonUtils.convertPrimitiveResourceValue(type, value) - } else { - // Case where Resource is non-primitive type - if (value is String) { - convertedValue = JacksonUtils.jsonNode(value) - } else { - convertedValue = JacksonUtils.getJsonNode(value) - } - } - return convertedValue - } - - @Synchronized - fun setFailedResourceDataValue(resourceAssignment: ResourceAssignment, message: String?) { - if (checkNotEmpty(resourceAssignment.name)) { - resourceAssignment.updatedDate = Date() - resourceAssignment.updatedBy = BluePrintConstants.USER_SYSTEM - resourceAssignment.status = BluePrintConstants.STATUS_FAILURE - resourceAssignment.message = message - } - } - - @Synchronized - @Throws(BluePrintProcessorException::class) - fun assertTemplateKeyValueNotNull(resourceAssignment: ResourceAssignment) { - val resourceProp = checkNotNull(resourceAssignment.property) { "Failed to populate mandatory resource resource mapping $resourceAssignment" } - if (resourceProp.required != null && resourceProp.required!! && (resourceProp.value == null || resourceProp.value !is NullNode)) { - logger.error("failed to populate mandatory resource mapping ($resourceAssignment)") - throw BluePrintProcessorException("failed to populate mandatory resource mapping ($resourceAssignment)") - } - } - - @Synchronized - @Throws(BluePrintProcessorException::class) - fun generateResourceDataForAssignments(assignments: List<ResourceAssignment>): String { - var result = "{}" - try { - val mapper = ObjectMapper() - val root = mapper.readTree(result) - - assignments.forEach { - if (checkNotEmpty(it.name) && it.property != null) { - - val type = it.property?.type - val value = it.property?.value - logger.info("Generating Resource name ({}), type ({}), value ({})", it.name, type, - value) - if (value == null) { - (root as ObjectNode).set(it.name, null) - } else if (value is JsonNode) { - (root as ObjectNode).put(it.name, value as JsonNode) - } else if (BluePrintConstants.DATA_TYPE_STRING.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as String) - } else if (BluePrintConstants.DATA_TYPE_BOOLEAN.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as Boolean) - } else if (BluePrintConstants.DATA_TYPE_INTEGER.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as Int) - } else if (BluePrintConstants.DATA_TYPE_FLOAT.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as Float) - } else if (BluePrintConstants.DATA_TYPE_TIMESTAMP.equals(type, ignoreCase = true)) { - (root as ObjectNode).put(it.name, value as String) - } else { - val jsonNode = JacksonUtils.getJsonNode(value) - if (jsonNode != null) { - (root as ObjectNode).put(it.name, jsonNode) - } else { - (root as ObjectNode).set(it.name, null) - } - } - } - } - result = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root) - logger.info("Generated Resource Param Data ({})", result) - } catch (e: Exception) { - throw BluePrintProcessorException("kapil is failing with $e.message", e) - } - - return result - } - - fun <T> transformResourceSource(properties: MutableMap<String, JsonNode>, classType: Class<T>): T { - val content = JacksonUtils.getJson(properties) - return JacksonUtils.readValue(content, classType) - ?: throw BluePrintProcessorException("failed to transform content($content) to type($classType)") - } - - } -}
\ No newline at end of file |