From f5f13c4f6b6fe3b4d98e349dfd7db59339803436 Mon Sep 17 00:00:00 2001 From: Michael Lando Date: Sun, 19 Feb 2017 12:35:04 +0200 Subject: push addional code Change-Id: Ia427bb3460cda3a896f8faced2de69eaf3807b74 Signed-off-by: Michael Lando --- .../sdc/tosca/datatypes/ToscaArtifactType.java | 39 ++ .../sdc/tosca/datatypes/ToscaCapabilityType.java | 52 ++ .../sdc/tosca/datatypes/ToscaDataType.java | 84 +++ .../sdc/tosca/datatypes/ToscaElementTypes.java | 25 + .../sdc/tosca/datatypes/ToscaFunctions.java | 43 ++ .../sdc/tosca/datatypes/ToscaGroupType.java | 40 ++ .../sdc/tosca/datatypes/ToscaNodeType.java | 162 ++++++ .../sdc/tosca/datatypes/ToscaPolicyType.java | 43 ++ .../sdc/tosca/datatypes/ToscaRelationshipType.java | 44 ++ .../sdc/tosca/datatypes/ToscaServiceModel.java | 72 +++ .../tosca/datatypes/model/ArtifactDefinition.java | 69 +++ .../sdc/tosca/datatypes/model/ArtifactType.java | 83 +++ .../tosca/datatypes/model/AttributeDefinition.java | 85 +++ .../datatypes/model/CapabilityAssignment.java | 45 ++ .../datatypes/model/CapabilityDefinition.java | 113 ++++ .../model/CapabilityFilterDefinition.java | 35 ++ .../sdc/tosca/datatypes/model/CapabilityType.java | 82 +++ .../sdc/tosca/datatypes/model/Constraint.java | 181 +++++++ .../sdc/tosca/datatypes/model/DataType.java | 73 +++ .../sdc/tosca/datatypes/model/Directive.java | 40 ++ .../sdc/tosca/datatypes/model/EntrySchema.java | 65 +++ .../sdc/tosca/datatypes/model/GroupDefinition.java | 64 +++ .../sdc/tosca/datatypes/model/GroupType.java | 82 +++ .../sdc/tosca/datatypes/model/Import.java | 61 +++ .../tosca/datatypes/model/InterfaceDefinition.java | 24 + .../sdc/tosca/datatypes/model/InterfaceType.java | 24 + .../sdc/tosca/datatypes/model/Metadata.java | 55 ++ .../sdc/tosca/datatypes/model/NodeFilter.java | 47 ++ .../sdc/tosca/datatypes/model/NodeTemplate.java | 127 +++++ .../sdc/tosca/datatypes/model/NodeType.java | 125 +++++ .../tosca/datatypes/model/ParameterDefinition.java | 99 ++++ .../tosca/datatypes/model/PolicyDefinition.java | 63 +++ .../sdc/tosca/datatypes/model/PolicyType.java | 73 +++ .../tosca/datatypes/model/PropertyDefinition.java | 112 ++++ .../sdc/tosca/datatypes/model/PropertyType.java | 117 ++++ .../datatypes/model/RelationshipTemplate.java | 99 ++++ .../tosca/datatypes/model/RelationshipType.java | 93 ++++ .../datatypes/model/RequirementAssignment.java | 70 +++ .../datatypes/model/RequirementDefinition.java | 82 +++ .../sdc/tosca/datatypes/model/Scalar.java | 34 ++ .../sdc/tosca/datatypes/model/ServiceTemplate.java | 144 +++++ .../sdc/tosca/datatypes/model/Status.java | 42 ++ .../tosca/datatypes/model/SubstitutionMapping.java | 54 ++ .../sdc/tosca/datatypes/model/Template.java | 24 + .../tosca/datatypes/model/TopologyTemplate.java | 114 ++++ .../model/heatextend/ParameterDefinitionExt.java | 55 ++ .../model/heatextend/PropertyTypeExt.java | 85 +++ .../InvalidAddActionNullEntityErrorBuilder.java | 58 ++ .../InvalidRequirementAssignmentErrorBuilder.java | 57 ++ .../sdc/tosca/errors/ToscaErrorCodes.java | 36 ++ .../ToscaInvalidEntryNotFoundErrorBuilder.java | 55 ++ ...aInvalidSubstituteNodeTemplateErrorBuilder.java | 55 ++ ...bstituteNodeTemplatePropertiesErrorBuilder.java | 59 +++ ...lidSubstitutionServiceTemplateErrorBuilder.java | 57 ++ ...ngSubstitutionMappingForReqCapErrorBuilder.java | 88 +++ .../errors/ToscaNodeTypeNotFoundErrorBuilder.java | 46 ++ .../tosca/exceptions/CsarCreationErrorBuilder.java | 43 ++ .../CsarMissingEntryPointErrorBuilder.java | 44 ++ .../sdc/tosca/services/DataModelUtil.java | 588 +++++++++++++++++++++ .../sdc/tosca/services/ToscaAnalyzerService.java | 66 +++ .../sdc/tosca/services/ToscaConstants.java | 65 +++ .../sdc/tosca/services/ToscaFileOutputService.java | 34 ++ .../services/ToscaNativeTypesServiceTemplate.java | 309 +++++++++++ .../openecomp/sdc/tosca/services/ToscaUtil.java | 151 ++++++ .../services/impl/ToscaAnalyzerServiceImpl.java | 467 ++++++++++++++++ .../impl/ToscaFileOutputServiceCsarImpl.java | 158 ++++++ .../services/yamlutil/ToscaExtensionYamlUtil.java | 93 ++++ 67 files changed, 5973 insertions(+) create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaArtifactType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaCapabilityType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaDataType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaElementTypes.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaFunctions.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaGroupType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaNodeType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaPolicyType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaRelationshipType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/AttributeDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityAssignment.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityFilterDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Constraint.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Directive.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EntrySchema.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Import.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Metadata.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeFilter.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ParameterDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementAssignment.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinition.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Scalar.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Status.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/SubstitutionMapping.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Template.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/ParameterDefinitionExt.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidAddActionNullEntityErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidRequirementAssignmentErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidEntryNotFoundErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplateErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstitutionServiceTemplateErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaMissingSubstitutionMappingForReqCapErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaNodeTypeNotFoundErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarCreationErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarMissingEntryPointErrorBuilder.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaNativeTypesServiceTemplate.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaUtil.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java create mode 100644 openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/yamlutil/ToscaExtensionYamlUtil.java (limited to 'openecomp-be/lib/openecomp-tosca-lib/src/main') diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaArtifactType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaArtifactType.java new file mode 100644 index 0000000000..2da60c0b79 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaArtifactType.java @@ -0,0 +1,39 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + + +public enum ToscaArtifactType { + + DEPLOYMENT("tosca.artifacts.Deployment"),; + + private String displayName; + + ToscaArtifactType(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaCapabilityType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaCapabilityType.java new file mode 100644 index 0000000000..d26eb3a83a --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaCapabilityType.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + + +public enum ToscaCapabilityType { + + ROOT("tosca.capabilities.Root"), + NODE("tosca.capabilities.Node"), + CONTAINER("tosca.capabilities.Container"), + NETWORK_BINDABLE("tosca.capabilities.network.Bindable"), + SCALABLE("tosca.capabilities.Scalable"), + OPERATING_SYSTEM("tosca.capabilities.OperatingSystem"), + ENDPOINT_ADMIN("tosca.capabilities.Endpoint.Admin"), + ATTACHMENT("tosca.capabilities.Attachment"), + NETWORK_LINKABLE("tosca.capabilities.network.Linkable"), + METRIC("org.openecomp.capabilities.Metric"), + NFV_METRIC("tosca.capabilities.nfv.Metric"), + METRIC_CEILOMETER("org.openecomp.capabilities.metric.Ceilometer"), + METRIC_SNMP_TRAP("org.openecomp.capabilities.metric.SnmpTrap"), + METRIC_SNMP_POLLING("org.openecomp.capabilities.metric.SnmpPolling"),; + + private String displayName; + + ToscaCapabilityType(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaDataType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaDataType.java new file mode 100644 index 0000000000..2a9df65b17 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaDataType.java @@ -0,0 +1,84 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + + +public enum ToscaDataType { + + ROOT("tosca.datatypes.Root"), + NETWORK_NETWORK_INFO("tosca.datatypes.network.NetworkInfo"), + NETWORK_PORT_INFO("tosca.datatypes.network.PortInfo"), + NOVA_SERVER_PORT_EXTRA_PROPERTIES( + "org.openecomp.datatypes.heat.novaServer.network.PortExtraProperties"), + NETWORK_ADDRESS_PAIR("org.openecomp.datatypes.heat.network.AddressPair"), + NEUTRON_PORT_FIXED_IPS("org.openecomp.datatypes.heat.neutron.port.FixedIps"), + CONTRAIL_NETWORK_RULE("org.openecomp.datatypes.heat.contrail.network.rule.Rule"), + CONTRAIL_NETWORK_RULE_LIST("org.openecomp.datatypes.heat.contrail.network.rule.RuleList"), + CONTRAIL_NETWORK_RULE_PORT_PAIRS("org.openecomp.datatypes.heat.contrail.network.rule.PortPairs"), + CONTRAIL_NETWORK_RULE_VIRTUAL_NETWORK( + "org.openecomp.datatypes.heat.contrail.network.rule.VirtualNetwork"), + CONTRAILV2_NETWORK_RULE("org.openecomp.datatypes.heat.contrailV2.network.rule.Rule"), + CONTRAILV2_NETWORK_RULE_LIST("org.openecomp.datatypes.heat.contrailV2.network.rule.RuleList"), + CONTRAILV2_NETWORK_RULE_SRC_PORT_PAIRS( + "org.openecomp.datatypes.heat.contrailV2.network.rule.SrcPortPairs"), + CONTRAILV2_NETWORK_RULE_DST_PORT_PAIRS( + "org.openecomp.datatypes.heat.contrailV2.network.rule.DstPortPairs"), + CONTRAILV2_NETWORK_RULE_DST_VIRTUAL_NETWORK( + "org.openecomp.datatypes.heat.contrailV2.network.rule.DstVirtualNetwork"), + CONTRAILV2_NETWORK_RULE_SRC_VIRTUAL_NETWORK( + "org.openecomp.datatypes.heat.contrailV2.network.rule.SrcVirtualNetwork"), + CONTRAILV2_VIRTUAL_MACHINE_INTERFACE_PROPERTIES( + "org.openecomp.datatypes.heat.contrailV2.virtual.machine.interface.Properties"), + CONTRAILV2_NETWORK_RULE_ACTION_LIST( + "org.openecomp.datatypes.heat.contrailV2.network.rule.ActionList"), + CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA( + "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.IpamRefData"), + CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET_LIST( + "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.ref.data.IpamSubnetList"), + CONTRAILV2_VIRTUAL_NETWORK_IPAM_REF_DATA_IPAM_SUBNET( + "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.ref.data.IpamSubnet"), + CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA( + "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.RefData"), + CONTRAILV2_VIRTUAL_NETWORK_POLICY_REF_DATA_SEQUENCE( + "org.openecomp.datatypes.heat.contrailV2.virtual.network.rule.RefDataSequence"), + NOVA_SERVER_NETWORK_ADDRESS_INFO("org.openecomp.datatypes.heat.novaServer.network.AddressInfo"), + NEUTRON_SUBNET("org.openecomp.datatypes.heat.network.neutron.Subnet"), + NETWORK_ALLOCATION_POOL("org.openecomp.datatypes.heat.network.AllocationPool"), + NETWORK_HOST_ROUTE("org.openecomp.datatypes.heat.network.subnet.HostRoute"), + SUBSTITUTION_FILTER("org.openecomp.datatypes.heat.substitution.SubstitutionFilter"), + SUBSTITUTION_FILTERING("org.openecomp.datatypes.heat.substitution.SubstitutionFiltering"), + NEUTRON_SECURITY_RULES_RULE("org.openecomp.datatypes.heat.network.neutron.SecurityRules.Rule"), + CONTRAIL_STATIC_ROUTE("org.openecomp.datatypes.heat.network.contrail.port.StaticRoute"), + CONTRAIL_ADDRESS_PAIR("org.openecomp.datatypes.heat.network.contrail.AddressPair"), + CONTRAIL_INTERFACE_DATA("org.openecomp.datatypes.heat.network.contrail.InterfaceData"); + + private String displayName; + + ToscaDataType(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaElementTypes.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaElementTypes.java new file mode 100644 index 0000000000..97fec7ae7d --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaElementTypes.java @@ -0,0 +1,25 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + +public enum ToscaElementTypes { + CAPABILITY_TYPE +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaFunctions.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaFunctions.java new file mode 100644 index 0000000000..989a1c6178 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaFunctions.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + +public enum ToscaFunctions { + + TOKEN("token"), + GET_PROPERTY("get_property"), + GET_ATTRIBUTE("get_attribute"), + GET_ARTIFACT("get_artifact"), + GET_INPUT("get_input"), + CONCAT("concat"); + + private String displayName; + + ToscaFunctions(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaGroupType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaGroupType.java new file mode 100644 index 0000000000..5422fa6dc9 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaGroupType.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + + +public enum ToscaGroupType { + + ROOT("tosca.groups.Root"), + HEAT_STACK("org.openecomp.groups.heat.HeatStack"),; + + private String displayName; + + ToscaGroupType(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaNodeType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaNodeType.java new file mode 100644 index 0000000000..c7c5a6e64e --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaNodeType.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + +import org.openecomp.sdc.tosca.services.ToscaConstants; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + + +/** + * The enum Tosca node type. + */ +public enum ToscaNodeType { + + /** + * Compute tosca node type. + */ + COMPUTE("tosca.nodes.Compute"), + /** + * Root tosca node type. + */ + ROOT("tosca.nodes.Root"), + /** + * Block storage tosca node type. + */ + BLOCK_STORAGE("tosca.nodes.BlockStorage"), + /** + * Network tosca node type. + */ + NETWORK("tosca.nodes.network.Network"), + /** + * Network port tosca node type. + */ + NETWORK_PORT("tosca.nodes.network.Port"), + /** + * Nova server tosca node type. + */ + NOVA_SERVER(ToscaConstants.NODES_PREFIX + "nova.Server"), + /** + * Cinder volume tosca node type. + */ + CINDER_VOLUME(ToscaConstants.NODES_PREFIX + "cinder.Volume"), + /** + * Neutron net tosca node type. + */ + NEUTRON_NET("org.openecomp.resource.vl.nodes.heat.network.neutron.Net"), + /** + * Neutron port tosca node type. + */ + NEUTRON_PORT("org.openecomp.resource.cp.nodes.heat.network.neutron.Port"), + /** + * Neutron security rules tosca node type. + */ + NEUTRON_SECURITY_RULES("org.openecomp.resource.vfc.rules.nodes" + + ".heat.network.neutron.SecurityRules"), + /** + * Contrail virtual network tosca node type. + */ + CONTRAIL_VIRTUAL_NETWORK("org.openecomp.resource.vl.nodes.heat.network.contrail.VirtualNetwork"), + /** + * Contrail network rule tosca node type. + */ + CONTRAIL_NETWORK_RULE("org.openecomp.resource.vfc." + + "rules.nodes.heat.network.contrail.NetworkRules"), + /** + * Contrailv 2 virtual network tosca node type. + */ + CONTRAILV2_VIRTUAL_NETWORK("org.openecomp.resource.vl.nodes." + + "heat.network.contrailV2.VirtualNetwork"), + /** + * Contrailv 2 network rule tosca node type. + */ + CONTRAILV2_NETWORK_RULE( + "org.openecomp.resource.vfc.rules.nodes.heat.network.contrailV2.NetworkRules"), + /** + * Contrailv 2 virtual machine interface tosca node type. + */ + CONTRAILV2_VIRTUAL_MACHINE_INTERFACE( + "org.openecomp.resource.cp.nodes.heat.contrailV2.VirtualMachineInterface"), + /** + * Abstract substitute tosca node type. + */ + ABSTRACT_SUBSTITUTE("org.openecomp.resource.abstract.nodes.AbstractSubstitute"), + /** + * Contrail compute tosca node type. + */ + CONTRAIL_COMPUTE(ToscaConstants.NODES_PREFIX + "contrail.Compute"), + /** + * Contrail port tosca node type. + */ + CONTRAIL_PORT("org.openecomp.resource.cp.nodes.heat.network.contrail.Port"), + /** + * Contrail abstract substitute tosca node type. + */ + CONTRAIL_ABSTRACT_SUBSTITUTE("org.openecomp.resource.abstract." + + "nodes.contrail.AbstractSubstitute"),; + + private static final Map mMap = + Collections.unmodifiableMap(initializeMapping()); + private String displayName; + + ToscaNodeType(String displayName) { + this.displayName = displayName; + } + + /** + * Initialize mapping map. + * + * @return the map + */ + public static Map initializeMapping() { + Map toscaMap = new HashMap<>(); + for (ToscaNodeType v : ToscaNodeType.values()) { + toscaMap.put(v.displayName, v); + } + return toscaMap; + } + + /** + * Gets tosca node type by display name. + * + * @param displayName the display name + * @return the tosca node type by display name + */ + public static ToscaNodeType getToscaNodeTypeByDisplayName(String displayName) { + if (mMap.containsKey(displayName)) { + return mMap.get(displayName); + } + return null; + } + + /** + * Gets display name. + * + * @return the display name + */ + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaPolicyType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaPolicyType.java new file mode 100644 index 0000000000..38195782d2 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaPolicyType.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + +public enum ToscaPolicyType { + + PLACEMENT("tosca.policy.placement"), + PLACEMENT_ANTILOCATE("org.openecomp.policies.placement.Antilocate"), + PLACEMENT_COLOCATE("org.openecomp.policies.placement.Colocate"), + PLACEMENT_VALET_AFFINITY("org.openecomp.policies.placement.valet.Affinity"), + PLACEMENT_VALET_EXCLUSIVITY("org.openecomp.policies.placement.valet.Exclusivity"), + PLACEMENT_VALET_DIVERSITY("org.openecomp.policies.placement.valet.Diversity"); + + private String displayName; + + ToscaPolicyType(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaRelationshipType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaRelationshipType.java new file mode 100644 index 0000000000..03a35bd4d0 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaRelationshipType.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + +public enum ToscaRelationshipType { + + ROOT("tosca.relationships.Root"), + NATIVE_ATTACHES_TO("tosca.relationships.AttachesTo"), + DEPENDS_ON("tosca.relationships.DependsOn"), + NETWORK_LINK_TO("tosca.relationships.network.LinksTo"), + NETWORK_BINDS_TO("tosca.relationships.network.BindsTo"), + CINDER_VOLUME_ATTACHES_TO("org.openecomp.relationships.heat.cinder.VolumeAttachesTo"), + ATTACHES_TO("org.openecomp.relationships.AttachesTo"),; + + private String displayName; + + ToscaRelationshipType(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java new file mode 100644 index 0000000000..70b23ae3f6 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/ToscaServiceModel.java @@ -0,0 +1,72 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes; + +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.datatypes.model.AsdcModel; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; + +import java.util.Collections; +import java.util.Map; + +public class ToscaServiceModel implements AsdcModel { + private FileContentHandler artifactFiles; + private Map serviceTemplates; + private String entryDefinitionServiceTemplate; + + /** + * Instantiates a new Tosca service model. + * + * @param artifactFiles the artifact files + * @param serviceTemplates the service templates + * @param entryDefinitionServiceTemplate the entry definition service template + */ + public ToscaServiceModel(FileContentHandler artifactFiles, + Map serviceTemplates, + String entryDefinitionServiceTemplate) { + this.artifactFiles = artifactFiles; + this.serviceTemplates = serviceTemplates; + this.entryDefinitionServiceTemplate = entryDefinitionServiceTemplate; + } + + + public FileContentHandler getArtifactFiles() { + return artifactFiles;//MapUtils.isEmpty(artifactFiles) ? Collections.EMPTY_MAP + // : Collections.unmodifiableMap(artifactFiles); + } + + + public Map getServiceTemplates() { + return Collections.unmodifiableMap(serviceTemplates); + } + + public void setServiceTemplates(Map serviceTemplates) { + this.serviceTemplates = serviceTemplates; + } + + public String getEntryDefinitionServiceTemplate() { + return entryDefinitionServiceTemplate; + } + + public void setEntryDefinitionServiceTemplate(String entryDefinitionServiceTemplate) { + this.entryDefinitionServiceTemplate = entryDefinitionServiceTemplate; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactDefinition.java new file mode 100644 index 0000000000..8461fef85f --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactDefinition.java @@ -0,0 +1,69 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public class ArtifactDefinition { + private String type; + private String file; + private String repository; + private String description; + private String deploy_path; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getFile() { + return file; + } + + public void setFile(String file) { + this.file = file; + } + + public String getRepository() { + return repository; + } + + public void setRepository(String repository) { + this.repository = repository; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getDeploy_path() { + return deploy_path; + } + + public void setDeploy_path(String deployPath) { + this.deploy_path = deployPath; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java new file mode 100644 index 0000000000..80580e97f3 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ArtifactType.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class ArtifactType { + + private String derived_from; + private String version; + private String description; + private String mime_type; + private List file_ext; + private Map properties; + + + public String getDerived_from() { + return derived_from; + } + + public void setDerived_from(String derivedFrom) { + this.derived_from = derivedFrom; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getMime_type() { + return mime_type; + } + + public void setMime_type(String mimeType) { + this.mime_type = mimeType; + } + + public List getFile_ext() { + return file_ext; + } + + public void setFile_ext(List fileExt) { + this.file_ext = fileExt; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/AttributeDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/AttributeDefinition.java new file mode 100644 index 0000000000..13c93a283d --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/AttributeDefinition.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public class AttributeDefinition { + + private String type; + private String description; + private Object _default; + private Status status; + private EntrySchema entry_schema; + + public AttributeDefinition() { + status = Status.SUPPORTED; + } + + public EntrySchema getEntry_schema() { + return entry_schema; + } + + public void setEntry_schema(EntrySchema entrySchema) { + this.entry_schema = entrySchema; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public Object get_default() { + return _default; + } + + public void set_default(Object defaultValue) { + this._default = defaultValue; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public AttributeDefinition clone() { + AttributeDefinition attributeDefinition = new AttributeDefinition(); + attributeDefinition.setType(this.getType()); + attributeDefinition.setDescription(this.getDescription()); + attributeDefinition.set_default(this.get_default()); + attributeDefinition.setStatus(this.getStatus()); + attributeDefinition.setEntry_schema(this.getEntry_schema().clone()); + return attributeDefinition; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityAssignment.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityAssignment.java new file mode 100644 index 0000000000..b548f7855c --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityAssignment.java @@ -0,0 +1,45 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; + +public class CapabilityAssignment { + + private Map properties; + private Map attributes; + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinition.java new file mode 100644 index 0000000000..36dccad6eb --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityDefinition.java @@ -0,0 +1,113 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import org.openecomp.sdc.tosca.services.DataModelUtil; +import org.openecomp.sdc.tosca.services.ToscaConstants; + +import java.util.List; +import java.util.Map; + +public class CapabilityDefinition { + + private String type; + private String description; + private Map properties; + private Map attributes; + private List valid_source_types; + private Object[] occurrences; + + + /** + * Instantiates a new Capability definition. + */ + public CapabilityDefinition() { + occurrences = new Object[2]; + occurrences[0] = 1; + occurrences[1] = ToscaConstants.UNBOUNDED; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + public List getValid_source_types() { + return valid_source_types; + } + + public void setValid_source_types(List validSourceTypes) { + this.valid_source_types = validSourceTypes; + } + + public Object[] getOccurrences() { + return occurrences; + } + + public void setOccurrences(Object[] occurrences) { + this.occurrences = occurrences; + } + + @Override + public CapabilityDefinition clone() { + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + capabilityDefinition + .setOccurrences(new Object[]{this.getOccurrences()[0], this.getOccurrences()[1]}); + capabilityDefinition + .setProperties(DataModelUtil.clonePropertyDefinitions(this.getProperties())); + capabilityDefinition.setType(this.getType()); + capabilityDefinition + .setAttributes(DataModelUtil.cloneAttributeDefinitions(this.getAttributes())); + capabilityDefinition.setDescription(this.getDescription()); + capabilityDefinition + .setValid_source_types(DataModelUtil.cloneValidSourceTypes(this.getValid_source_types())); + return capabilityDefinition; + + } + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityFilterDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityFilterDefinition.java new file mode 100644 index 0000000000..3678583384 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityFilterDefinition.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; + +public class CapabilityFilterDefinition { + List properties; + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityType.java new file mode 100644 index 0000000000..b0281b4ca0 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/CapabilityType.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class CapabilityType { + + private String derived_from; + private String version; + private String description; + private Map properties; + private Map attributes; + private List valid_source_types; + + public String getDerived_from() { + return derived_from; + } + + public void setDerived_from(String derivedFrom) { + this.derived_from = derivedFrom; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + public List getValid_source_types() { + return valid_source_types; + } + + public void setValid_source_types(List validSourceTypes) { + this.valid_source_types = validSourceTypes; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Constraint.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Constraint.java new file mode 100644 index 0000000000..2c39ce3902 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Constraint.java @@ -0,0 +1,181 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.ArrayList; +import java.util.List; + +public class Constraint { + private Object equal; + private Object greater_or_equal; + private Object greater_than; + private Object less_than; + private Object less_or_equal; + private Object[] in_range; + private List valid_values; + private Integer length; + private Integer min_length; + private Integer max_length; + private Object pattern; + + public Constraint() { + } + + public Object getGreater_or_equal() { + return greater_or_equal; + } + + public void setGreater_or_equal(Object greaterOrEqual) { + this.greater_or_equal = greaterOrEqual; + } + + public Object getEqual() { + return equal; + } + + public void setEqual(Object equal) { + this.equal = equal; + } + + public Object getGreater_than() { + return greater_than; + } + + public void setGreater_than(Object greaterThan) { + this.greater_than = greaterThan; + } + + public Object getLess_than() { + return less_than; + } + + public void setLess_than(Object lessThan) { + this.less_than = lessThan; + } + + public Object getLess_or_equal() { + return less_or_equal; + } + + public void setLess_or_equal(Object lessOrEqual) { + this.less_or_equal = lessOrEqual; + } + + public Object[] getIn_range() { + return in_range; + } + + /** + * Sets in range. + * + * @param inRange the in range + */ + public void setIn_range(Object[] inRange) { + this.in_range = new Object[2]; + this.in_range[0] = inRange[0]; + this.in_range[1] = inRange[1]; + } + + public List getValid_values() { + return valid_values; + } + + public void setValid_values(List validValues) { + this.valid_values = validValues; + } + + /** + * Add valid value. + * + * @param validValue the valid value + */ + public void addValidValue(Object validValue) { + if (this.valid_values == null) { + this.valid_values = new ArrayList<>(); + } + valid_values.add(validValue); + } + + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public Integer getMin_length() { + return min_length; + } + + public void setMin_length(Integer minLength) { + this.min_length = minLength; + } + + public Integer getMax_length() { + return max_length; + } + + public void setMax_length(Integer maxLength) { + this.max_length = maxLength; + } + + public Object getPattern() { + return pattern; + } + + public void setPattern(Object pattern) { + this.pattern = pattern; + } + + @Override + public Constraint clone() { + Constraint constraint = new Constraint(); + constraint.setEqual(this.getEqual()); + constraint.setGreater_or_equal(this.getGreater_or_equal()); + constraint.setGreater_than(this.getGreater_than()); + cloneInRange(constraint); + constraint.setLength(this.getLength()); + constraint.setLess_or_equal(this.getLess_or_equal()); + constraint.setLess_than(this.getLess_than()); + constraint.setMax_length(this.getMax_length()); + constraint.setMin_length(this.getMin_length()); + constraint.setPattern(this.getPattern()); + cloneValidValues(constraint); + + return constraint; + } + + private void cloneInRange(Constraint constraint) { + if (this.getIn_range() != null) { + constraint.setIn_range(new Object[]{this.getIn_range()[0], this.getIn_range()[1]}); + } + } + + private void cloneValidValues(Constraint constraint) { + if (this.getValid_values() != null) { + constraint.setValid_values(new ArrayList<>()); + for (Object entry : this.getValid_values()) { + constraint.getValid_values().add(entry); + } + } + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java new file mode 100644 index 0000000000..866c5774d8 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/DataType.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class DataType { + + private String derived_from; + private String version; + private String description; + private List constraints; + private Map properties; + + public String getDerived_from() { + return derived_from; + } + + public void setDerived_from(String derivedFrom) { + this.derived_from = derivedFrom; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getConstraints() { + return constraints; + } + + public void setConstraints(List constraints) { + this.constraints = constraints; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Directive.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Directive.java new file mode 100644 index 0000000000..078a6449ea --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Directive.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public enum Directive { + + + SELECTABLE("selectable"), + SUBSTITUTABLE("substitutable"); + + private String displayName; + + Directive(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EntrySchema.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EntrySchema.java new file mode 100644 index 0000000000..8b08e54c01 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/EntrySchema.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import org.openecomp.sdc.tosca.services.DataModelUtil; + +import java.util.List; + +public class EntrySchema { + + private String description; + private String type; + private List constraints; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public List getConstraints() { + return constraints; + } + + public void setConstraints(List constraints) { + this.constraints = constraints; + } + + @Override + public EntrySchema clone() { + EntrySchema entrySchema = new EntrySchema(); + entrySchema.setDescription(this.getDescription()); + entrySchema.setType(this.getType()); + entrySchema.setConstraints(DataModelUtil.cloneConstraints(this.getConstraints())); + return entrySchema; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java new file mode 100644 index 0000000000..807bf260c3 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupDefinition.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class GroupDefinition { + + private String type; + private String description; + private Map properties; + private List members; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java new file mode 100644 index 0000000000..4bbb861286 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/GroupType.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class GroupType { + + private String derived_from; + private String version; + private String description; + private Map properties; + private List members; + private Map interfaces; + + public String getDerived_from() { + return derived_from; + } + + public void setDerived_from(String derivedFrom) { + this.derived_from = derivedFrom; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public List getMembers() { + return members; + } + + public void setMembers(List members) { + this.members = members; + } + + public Map getInterfaces() { + return interfaces; + } + + public void setInterfaces(Map interfaces) { + this.interfaces = interfaces; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Import.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Import.java new file mode 100644 index 0000000000..207a1b520a --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Import.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public class Import { + + private String file; + private String repository; + private String namespace_uri; + private String namespace_prefix; + + public String getFile() { + return file; + } + + public void setFile(String file) { + this.file = file; + } + + public String getRepository() { + return repository; + } + + public void setRepository(String repository) { + this.repository = repository; + } + + public String getNamespace_uri() { + return namespace_uri; + } + + public void setNamespace_uri(String namespaceUri) { + this.namespace_uri = namespaceUri; + } + + public String getNamespace_prefix() { + return namespace_prefix; + } + + public void setNamespace_prefix(String namespacePrefix) { + this.namespace_prefix = namespacePrefix; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java new file mode 100644 index 0000000000..cf09510083 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceDefinition.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public class InterfaceDefinition { +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java new file mode 100644 index 0000000000..b177b0660a --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/InterfaceType.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public class InterfaceType { +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Metadata.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Metadata.java new file mode 100644 index 0000000000..162e693dba --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Metadata.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; + +public class Metadata { + + private String template_name; + private String template_author; + private String template_version; + + + public String getTemplate_name() { + return template_name; + } + + public void setTemplate_name(String templateName) { + this.template_name = templateName; + } + + public String getTemplate_author() { + return template_author; + } + + public void setTemplate_author(String templateAuthor) { + this.template_author = templateAuthor; + } + + public String getTemplate_version() { + return template_version; + } + + public void setTemplate_version(String templateVersion) { + this.template_version = templateVersion; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeFilter.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeFilter.java new file mode 100644 index 0000000000..d87dcd7b1d --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeFilter.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class NodeFilter { + + Map> properties; + Map capabilities; + + public Map> getProperties() { + + return properties; + } + + public void setProperties(Map> properties) { + this.properties = properties; + } + + public Map getCapabilities() { + return capabilities; + } + + public void setCapabilities(Map capabilities) { + this.capabilities = capabilities; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java new file mode 100644 index 0000000000..41ac232605 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeTemplate.java @@ -0,0 +1,127 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class NodeTemplate implements Template { + + private String type; + private String description; + private List directives; + private Map properties; + private Map attributes; + private List> requirements; + private List> capabilities; + private Map interfaces; + private Map artifacts; + private NodeFilter node_filter; + private String copy; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getDirectives() { + return directives; + } + + public void setDirectives(List directives) { + this.directives = directives; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + public List> getRequirements() { + return requirements; + } + + public void setRequirements(List> requirements) { + this.requirements = requirements; + } + + public List> getCapabilities() { + return capabilities; + } + + public void setCapabilities(List> capabilities) { + this.capabilities = capabilities; + } + + public Map getInterfaces() { + return interfaces; + } + + public void setInterfaces(Map interfaces) { + this.interfaces = interfaces; + } + + public Map getArtifacts() { + return artifacts; + } + + public void setArtifacts(Map artifacts) { + this.artifacts = artifacts; + } + + public NodeFilter getNode_filter() { + return node_filter; + } + + public void setNode_filter(NodeFilter nodeFilter) { + this.node_filter = nodeFilter; + } + + public String getCopy() { + return copy; + } + + public void setCopy(String copy) { + this.copy = copy; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java new file mode 100644 index 0000000000..d477f286ee --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/NodeType.java @@ -0,0 +1,125 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class NodeType { + + private String derived_from; + private String version; + private String description; + private Map properties; + private Map attributes; + private List> requirements; + private Map capabilities; + private Map interfaces; + private Map artifacts; + + + public String getDerived_from() { + return derived_from; + } + + public void setDerived_from(String derivedFrom) { + this.derived_from = derivedFrom; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + public List> getRequirements() { + return requirements; + } + + public void setRequirements(List> requirements) { + this.requirements = requirements; + } + + public Map getCapabilities() { + return capabilities; + } + + public void setCapabilities(Map capabilities) { + this.capabilities = capabilities; + } + + public Map getInterfaces() { + return interfaces; + } + + public void setInterfaces(Map interfaces) { + this.interfaces = interfaces; + } + + public Map getArtifacts() { + return artifacts; + } + + public void setArtifacts(Map artifacts) { + this.artifacts = artifacts; + } + + @Override + public NodeType clone() { + NodeType clone = new NodeType(); + clone.setCapabilities(this.getCapabilities()); + clone.setDerived_from(this.getDerived_from()); + clone.setProperties(this.getProperties()); + clone.setRequirements(this.getRequirements()); + clone.setDescription(this.getDescription()); + clone.setAttributes(this.getAttributes()); + clone.setInterfaces(this.getInterfaces()); + clone.setVersion(this.getVersion()); + clone.setArtifacts(this.getArtifacts()); + return clone; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ParameterDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ParameterDefinition.java new file mode 100644 index 0000000000..6ef4c782f5 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ParameterDefinition.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; + +public class ParameterDefinition { + + private String type; + private String description; + private Object value; + private Boolean required; + private Object _default; + private Status status; + private List constraints; + private EntrySchema entry_schema; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public Boolean getRequired() { + return required; + } + + public void setRequired(Boolean required) { + this.required = required; + } + + public Object get_default() { + return _default; + } + + public void set_default(Object defaultValue) { + this._default = defaultValue; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public List getConstraints() { + return constraints; + } + + public void setConstraints(List constraints) { + this.constraints = constraints; + } + + public EntrySchema getEntry_schema() { + return entry_schema; + } + + public void setEntry_schema(EntrySchema entrySchema) { + this.entry_schema = entrySchema; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java new file mode 100644 index 0000000000..90f44ae36a --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyDefinition.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class PolicyDefinition implements Template { + private String type; + private String description; + private Map properties; + private List targets; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java new file mode 100644 index 0000000000..07412cda59 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PolicyType.java @@ -0,0 +1,73 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class PolicyType { + + private String derived_from; + private String version; + private String description; + private Map properties; + private List targets; + + public String getDerived_from() { + return derived_from; + } + + public void setDerived_from(String derivedFrom) { + this.derived_from = derivedFrom; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public List getTargets() { + return targets; + } + + public void setTargets(List targets) { + this.targets = targets; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyDefinition.java new file mode 100644 index 0000000000..cf47d0b113 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyDefinition.java @@ -0,0 +1,112 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import org.openecomp.sdc.tosca.services.DataModelUtil; + +import java.util.List; + +public class PropertyDefinition { + + private String type; + private String description; + private Boolean required; + private Object _default; + private Status status; + private List constraints; + private EntrySchema entry_schema; + + public PropertyDefinition() { + status = Status.SUPPORTED; + required = true; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Boolean getRequired() { + return required; + } + + public void setRequired(Boolean required) { + this.required = required; + } + + public Object get_default() { + return _default; + } + + public void set_default(Object defaultValue) { + this._default = defaultValue; + } + + public Status getStatus() { + return status; + } + + public void setStatus(Status status) { + this.status = status; + } + + public List getConstraints() { + return constraints; + } + + public void setConstraints(List constraints) { + this.constraints = constraints; + } + + public EntrySchema getEntry_schema() { + return entry_schema; + } + + public void setEntry_schema(EntrySchema entrySchema) { + this.entry_schema = entrySchema; + } + + @Override + public PropertyDefinition clone() { + PropertyDefinition propertyDefinition = new PropertyDefinition(); + propertyDefinition.setType(this.getType()); + propertyDefinition.setDescription(this.getDescription()); + propertyDefinition.setRequired(this.getRequired()); + propertyDefinition.set_default(this.get_default()); + propertyDefinition.setStatus(this.getStatus()); + propertyDefinition.setEntry_schema(this.getEntry_schema().clone()); + propertyDefinition.setConstraints(DataModelUtil.cloneConstraints(this.getConstraints())); + return propertyDefinition; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyType.java new file mode 100644 index 0000000000..3fdd9bba0e --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/PropertyType.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * The enum Property type. + */ +public enum PropertyType { + + /** + * String property type. + */ + STRING("string"), + /** + * Integer property type. + */ + INTEGER("integer"), + /** + * Float property type. + */ + FLOAT("float"), + /** + * Boolean property type. + */ + BOOLEAN("boolean"), + /** + * Timestamp property type. + */ + TIMESTAMP("timestamp"), + /** + * Null property type. + */ + NULL("null"), + /** + * Map property type. + */ + MAP("map"), + /** + * List property type. + */ + LIST("list"), + /** + * Scalar unit size property type. + */ + SCALAR_UNIT_SIZE("scalar-unit.size"); + + private static final Map mMap = + Collections.unmodifiableMap(initializeMapping()); + private String displayName; + + PropertyType(String displayName) { + + this.displayName = displayName; + } + + /** + * Initialize mapping map. + * + * @return the map + */ + public static Map initializeMapping() { + Map typeMap = new HashMap(); + for (PropertyType v : PropertyType.values()) { + typeMap.put(v.displayName, v); + } + return typeMap; + } + + /** + * Gets property type by display name. + * + * @param displayName the display name + * @return the property type by display name + */ + public static PropertyType getPropertyTypeByDisplayName(String displayName) { + if (mMap == null) { + initializeMapping(); + } + if (mMap.containsKey(displayName)) { + return mMap.get(displayName); + } + return null; + } + + /** + * Gets display name. + * + * @return the display name + */ + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java new file mode 100644 index 0000000000..c3a1195565 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipTemplate.java @@ -0,0 +1,99 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; + +public class RelationshipTemplate implements Template { + + private String type; + private String description; + private Map properties; + private Map attributes; + private Map requirements; + private Map capabilities; + private Map interfaces; + private String copy; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + public Map getRequirements() { + return requirements; + } + + public void setRequirements(Map requirements) { + this.requirements = requirements; + } + + public Map getCapabilities() { + return capabilities; + } + + public void setCapabilities(Map capabilities) { + this.capabilities = capabilities; + } + + public Map getInterfaces() { + return interfaces; + } + + public void setInterfaces(Map interfaces) { + this.interfaces = interfaces; + } + + public String getCopy() { + return copy; + } + + public void setCopy(String copy) { + this.copy = copy; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java new file mode 100644 index 0000000000..173a8a0f64 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RelationshipType.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class RelationshipType { + + private String derived_from; + private String version; + private String description; + private Map properties; + private Map attributes; + private Map interfaces; + private List valid_target_types; + //An optional list of one or more names of Capability Types that are valid targets + //for this relationship + + public String getDerived_from() { + return derived_from; + } + + public void setDerived_from(String derivedFrom) { + this.derived_from = derivedFrom; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getProperties() { + return properties; + } + + public void setProperties(Map properties) { + this.properties = properties; + } + + public Map getAttributes() { + return attributes; + } + + public void setAttributes(Map attributes) { + this.attributes = attributes; + } + + public Map getInterfaces() { + return interfaces; + } + + public void setInterfaces(Map interfaces) { + this.interfaces = interfaces; + } + + public List getValid_target_types() { + return valid_target_types; + } + + public void setValid_target_types(List validTargetTypes) { + this.valid_target_types = validTargetTypes; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementAssignment.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementAssignment.java new file mode 100644 index 0000000000..445063a3ed --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementAssignment.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public class RequirementAssignment { + + private String capability; + private String node; + private String relationship; + private NodeFilter node_filter; + private Object[] occurrences; + + public String getCapability() { + return capability; + } + + public void setCapability(String capability) { + this.capability = capability; + } + + public String getNode() { + return node; + } + + public void setNode(String node) { + this.node = node; + } + + public String getRelationship() { + return relationship; + } + + public void setRelationship(String relationship) { + this.relationship = relationship; + } + + public NodeFilter getNode_filter() { + return node_filter; + } + + public void setNode_filter(NodeFilter nodeFilter) { + this.node_filter = nodeFilter; + } + + public Object[] getOccurrences() { + return occurrences; + } + + public void setOccurrences(Object[] occurrences) { + this.occurrences = occurrences; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinition.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinition.java new file mode 100644 index 0000000000..fe3238f1b5 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/RequirementDefinition.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public class RequirementDefinition { + + private String capability; + private String node; + private String relationship; + private Object[] occurrences; + + /** + * Instantiates a new Requirement definition. + */ + public RequirementDefinition() { + occurrences = new Object[2]; + occurrences[0] = 1; + occurrences[1] = 1; + } + + public String getCapability() { + return capability; + } + + public void setCapability(String capability) { + this.capability = capability; + } + + public String getNode() { + return node; + } + + public void setNode(String node) { + this.node = node; + } + + public String getRelationship() { + return relationship; + } + + public void setRelationship(String relationship) { + this.relationship = relationship; + } + + public Object[] getOccurrences() { + return occurrences; + } + + public void setOccurrences(Object[] occurrences) { + this.occurrences = occurrences; + } + + @Override + public RequirementDefinition clone() { + RequirementDefinition requirementDefinition = new RequirementDefinition(); + requirementDefinition.setNode(this.getNode()); + requirementDefinition.setRelationship(this.getRelationship()); + requirementDefinition.setCapability(this.getCapability()); + requirementDefinition + .setOccurrences(new Object[]{this.getOccurrences()[0], this.getOccurrences()[1]}); + return requirementDefinition; + } + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Scalar.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Scalar.java new file mode 100644 index 0000000000..619ac510b0 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Scalar.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public class Scalar { + + private Float value; + + public Float getValue() { + return value; + } + + public void setValue(Float value) { + this.value = value; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java new file mode 100644 index 0000000000..98da0104b8 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/ServiceTemplate.java @@ -0,0 +1,144 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; + +public class ServiceTemplate implements Template { + + private String tosca_definitions_version; + private Metadata metadata; + private String description; + private Map imports; + private Map artifact_types; + private Map data_types; + private Map capability_types; + private Map interface_types; + private Map relationship_types; + private Map node_types; + private Map group_types; + private Map policy_types; + private TopologyTemplate topology_template; + + public String getTosca_definitions_version() { + return tosca_definitions_version; + } + + public void setTosca_definitions_version(String toscaDefinitionsVersion) { + this.tosca_definitions_version = toscaDefinitionsVersion; + } + + public Metadata getMetadata() { + return metadata; + } + + public void setMetadata(Metadata metadata) { + this.metadata = metadata; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getImports() { + return imports; + } + + public void setImports(Map imports) { + this.imports = imports; + } + + public Map getArtifact_types() { + return artifact_types; + } + + public void setArtifact_types(Map artifactTypes) { + this.artifact_types = artifactTypes; + } + + public Map getData_types() { + return data_types; + } + + public void setData_types(Map dataTypes) { + this.data_types = dataTypes; + } + + public Map getCapability_types() { + return capability_types; + } + + public void setCapability_types(Map capabilityTypes) { + this.capability_types = capabilityTypes; + } + + public Map getRelationship_types() { + return relationship_types; + } + + public void setRelationship_types(Map relationshipTypes) { + this.relationship_types = relationshipTypes; + } + + public Map getNode_types() { + return node_types; + } + + public void setNode_types(Map nodeTypes) { + this.node_types = nodeTypes; + } + + public Map getGroup_types() { + return group_types; + } + + public void setGroup_types(Map groupTypes) { + this.group_types = groupTypes; + } + + public Map getInterface_types() { + return interface_types; + } + + public void setInterface_types(Map interfaceTypes) { + this.interface_types = interfaceTypes; + } + + public Map getPolicy_types() { + return policy_types; + } + + public void setPolicy_types(Map policyTypes) { + this.policy_types = policyTypes; + } + + public TopologyTemplate getTopology_template() { + return topology_template; + } + + public void setTopology_template(TopologyTemplate topologyTemplate) { + this.topology_template = topologyTemplate; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Status.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Status.java new file mode 100644 index 0000000000..0805982a54 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Status.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.Map; + +public enum Status { + + SUPPORTED("supported"), + UNSUPPORTED("unsupported"), + EXPERIMENTAL("experimental"), + DEPRECATED("deprecated"),; + private String displayName; + + Status(String displayName) { + this.displayName = displayName; + } + + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/SubstitutionMapping.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/SubstitutionMapping.java new file mode 100644 index 0000000000..50c262dc42 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/SubstitutionMapping.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.List; +import java.util.Map; + +public class SubstitutionMapping { + private String node_type; + private Map> capabilities; + private Map> requirements; + + public String getNode_type() { + return node_type; + } + + public void setNode_type(String nodeType) { + this.node_type = nodeType; + } + + public Map> getRequirements() { + return requirements; + } + + public void setRequirements(Map> requirements) { + this.requirements = requirements; + } + + public Map> getCapabilities() { + return capabilities; + } + + public void setCapabilities(Map> capabilities) { + this.capabilities = capabilities; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Template.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Template.java new file mode 100644 index 0000000000..128bb3c0a9 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/Template.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +public interface Template { +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java new file mode 100644 index 0000000000..288242946a --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/TopologyTemplate.java @@ -0,0 +1,114 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +public class TopologyTemplate { + + private String description; + private Map inputs; + private Map node_templates; + private Map relationship_templates; + private Map groups; + private Map outputs; + private SubstitutionMapping substitution_mappings; + private Map policies; + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Map getInputs() { + return inputs; + } + + public void setInputs(Map inputs) { + this.inputs = inputs; + } + + public Map getNode_templates() { + return node_templates; + } + + public void setNode_templates(Map nodeTemplates) { + this.node_templates = nodeTemplates; + } + + public Map getRelationship_templates() { + return relationship_templates; + } + + public void setRelationship_templates(Map relationshipTemplates) { + this.relationship_templates = relationshipTemplates; + } + + public Map getGroups() { + return groups; + } + + public void setGroups(Map groups) { + this.groups = groups; + } + + /** + * Add group. + * + * @param groupKey the group key + * @param groupDefinition the group definition + */ + public void addGroup(String groupKey, GroupDefinition groupDefinition) { + if (Objects.isNull(this.groups)) { + this.groups = new HashMap<>(); + } + this.groups.put(groupKey, groupDefinition); + } + + public Map getOutputs() { + return outputs; + } + + public void setOutputs(Map outputs) { + this.outputs = outputs; + } + + public SubstitutionMapping getSubstitution_mappings() { + return substitution_mappings; + } + + public void setSubstitution_mappings(SubstitutionMapping substitutionMapping) { + this.substitution_mappings = substitutionMapping; + } + + public Map getPolicies() { + return policies; + } + + public void setPolicies(Map policies) { + this.policies = policies; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/ParameterDefinitionExt.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/ParameterDefinitionExt.java new file mode 100644 index 0000000000..bde81108de --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/ParameterDefinitionExt.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model.heatextend; + + +import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition; + +public class ParameterDefinitionExt extends ParameterDefinition { + + String label; + Boolean hidden; + Boolean immutable; + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public Boolean getHidden() { + return hidden; + } + + public void setHidden(Boolean hidden) { + this.hidden = hidden; + } + + public Boolean getImmutable() { + return immutable; + } + + public void setImmutable(Boolean immutable) { + this.immutable = immutable; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java new file mode 100644 index 0000000000..f92d674070 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/datatypes/model/heatextend/PropertyTypeExt.java @@ -0,0 +1,85 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.datatypes.model.heatextend; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +/** + * The enum Property type ext. + */ +public enum PropertyTypeExt { + + /** + * Json property type ext. + */ + JSON("json"); + + private static final Map mMap = + Collections.unmodifiableMap(initializeMapping()); + private String displayName; + + PropertyTypeExt(String displayName) { + + this.displayName = displayName; + } + + /** + * Initialize mapping map. + * + * @return the map + */ + public static Map initializeMapping() { + Map typeMap = new HashMap(); + for (PropertyTypeExt v : PropertyTypeExt.values()) { + typeMap.put(v.displayName, v); + } + return typeMap; + } + + /** + * Gets property type by display name. + * + * @param displayName the display name + * @return the property type by display name + */ + public static PropertyTypeExt getPropertyTypeByDisplayName(String displayName) { + if (mMap == null) { + initializeMapping(); + } + if (mMap.containsKey(displayName)) { + return mMap.get(displayName); + } + return null; + } + + /** + * Gets display name. + * + * @return the display name + */ + public String getDisplayName() { + return displayName; + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidAddActionNullEntityErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidAddActionNullEntityErrorBuilder.java new file mode 100644 index 0000000000..02bee69251 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidAddActionNullEntityErrorBuilder.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +/** + * The type Invalid add action null entity error builder. + */ +public class InvalidAddActionNullEntityErrorBuilder { + + private static final String INVALID_ACTION_NULL_ENTITY_ERR_MSG = + "Invalid action, can't add '%s' to '%s', '%s' entity is NULL."; + + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Invalid add action null entity error builder. + * + * @param addedData the added data + * @param updatedEntity the updated entity + */ + public InvalidAddActionNullEntityErrorBuilder(String addedData, String updatedEntity) { + builder.withId(ToscaErrorCodes.TOSCA_INVALID_ADD_ACTION_NULL_ENTITY); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage( + String.format(INVALID_ACTION_NULL_ENTITY_ERR_MSG, addedData, updatedEntity, updatedEntity)); + } + + /** + * Build error code. + * + * @return the error code + */ + public ErrorCode build() { + return builder.build(); + } + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidRequirementAssignmentErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidRequirementAssignmentErrorBuilder.java new file mode 100644 index 0000000000..cc0b821748 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/InvalidRequirementAssignmentErrorBuilder.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +/** + * The type Invalid requirement assignment error builder. + */ +public class InvalidRequirementAssignmentErrorBuilder { + + private static final String INVALID_REQ_ASSIGNMENT_ERR_ID = "INVALID_REQ_ASSIGNMENT_ERR_ID"; + private static final String INVALID_REQ_ASSIGNMENT_ERR_MSG = + "Invalid Requirement Assignment, Node value is NULL, Requirement ID '%s'."; + + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Invalid requirement assignment error builder. + * + * @param requirementId the requirement id + */ + public InvalidRequirementAssignmentErrorBuilder(String requirementId) { + builder.withId(INVALID_REQ_ASSIGNMENT_ERR_ID); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(INVALID_REQ_ASSIGNMENT_ERR_MSG, requirementId)); + } + + /** + * Build error code. + * + * @return the error code + */ + public ErrorCode build() { + return builder.build(); + } + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java new file mode 100644 index 0000000000..099f0771f2 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaErrorCodes.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +public class ToscaErrorCodes { + + static final String INVALID_SUBSTITUTE_NODE_TEMPLATE = "INVALID_SUBSTITUTE_NODE_TEMPLATE"; + static final String INVALID_SUBSTITUTION_SERVICE_TEMPLATE = + "INVALID_SUBSTITUTION_SERVICE_TEMPLATE"; + static final String TOSCA_ENTRY_NOT_FOUND = "TOSCA_ENTRY_NOT_FOUND"; + static final String MISSING_SUBSTITUTION_MAPPING_FOR_REQ_CAP = + "MISSING_SUBSTITUTION_MAPPING_FOR_REQ_CAP"; + static final String TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE = + "TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE"; + static final String TOSCA_INVALID_ADD_ACTION_NULL_ENTITY = "TOSCA_INVALID_ADD_ACTION_NULL_ENTITY"; + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidEntryNotFoundErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidEntryNotFoundErrorBuilder.java new file mode 100644 index 0000000000..7e05d18755 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidEntryNotFoundErrorBuilder.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +/** + * The type Tosca invalid entry not found error builder. + */ +public class ToscaInvalidEntryNotFoundErrorBuilder { + // + private static final String ENTRY_NOT_FOUND_MSG = + "Invalid Tosca model data, missing '%s' entry for '%s' id %s"; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Tosca invalid entry not found error builder. + * + * @param entryName the entry name + * @param entryId the entry id + */ + public ToscaInvalidEntryNotFoundErrorBuilder(String entryName, String entryId) { + builder.withId(ToscaErrorCodes.TOSCA_ENTRY_NOT_FOUND); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(ENTRY_NOT_FOUND_MSG, entryName, entryName, entryId)); + } + + /** + * Build error code. + * + * @return the error code + */ + public ErrorCode build() { + return builder.build(); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplateErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplateErrorBuilder.java new file mode 100644 index 0000000000..5913e5ffba --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplateErrorBuilder.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + + +/** + * The type Tosca invalid substitute node template error builder. + */ +public class ToscaInvalidSubstituteNodeTemplateErrorBuilder { + private static final String INVALID_SUBSTITUTE_NODE_TEMPLATE_MSG = + "Invalid substitute node template, directives with substitutable value must be defined. " + + "node template id %s"; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Tosca invalid substitute node template error builder. + * + * @param nodeTemplateId the node template id + */ + public ToscaInvalidSubstituteNodeTemplateErrorBuilder(String nodeTemplateId) { + builder.withId(ToscaErrorCodes.TOSCA_INVALID_SUBSTITUTE_NODE_TEMPLATE); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(INVALID_SUBSTITUTE_NODE_TEMPLATE_MSG, nodeTemplateId)); + } + + /** + * Build error code. + * + * @return the error code + */ + public ErrorCode build() { + return builder.build(); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder.java new file mode 100644 index 0000000000..90c681efc9 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder.java @@ -0,0 +1,59 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; +import org.openecomp.sdc.tosca.services.ToscaConstants; + + +/** + * The type Tosca invalid substitute node template properties error builder. + */ +public class ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder { + + private static final String INVALID_SUBSTITUTE_NODE_TEMPLATE_MSG = + "Invalid Substitute Node Template %s, mandatory map property %s with mandatory " + + "key %s must be defined."; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Tosca invalid substitute node template properties error builder. + * + * @param nodeTemplateId the node template id + */ + public ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(String nodeTemplateId) { + builder.withId(ToscaErrorCodes.INVALID_SUBSTITUTE_NODE_TEMPLATE); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(INVALID_SUBSTITUTE_NODE_TEMPLATE_MSG, nodeTemplateId, + ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME, + ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME)); + } + + /** + * Build error code. + * + * @return the error code + */ + public ErrorCode build() { + return builder.build(); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstitutionServiceTemplateErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstitutionServiceTemplateErrorBuilder.java new file mode 100644 index 0000000000..c240992597 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaInvalidSubstitutionServiceTemplateErrorBuilder.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + + +/** + * The type Tosca invalid substitution service template error builder. + */ +public class ToscaInvalidSubstitutionServiceTemplateErrorBuilder { + + private static final String INVALID_SUBSTITUTION_SERVICE_TEMPLATE_MSG = + "Invalid Substitution Service Template %s, missing mandatory file 'Node type' " + + "in substitution mapping."; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Tosca invalid substitution service template error builder. + * + * @param serviceTemplateFileName the service template file name + */ + public ToscaInvalidSubstitutionServiceTemplateErrorBuilder(String serviceTemplateFileName) { + builder.withId(ToscaErrorCodes.INVALID_SUBSTITUTION_SERVICE_TEMPLATE); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage( + String.format(INVALID_SUBSTITUTION_SERVICE_TEMPLATE_MSG, serviceTemplateFileName)); + } + + /** + * Build error code. + * + * @return the error code + */ + public ErrorCode build() { + return builder.build(); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaMissingSubstitutionMappingForReqCapErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaMissingSubstitutionMappingForReqCapErrorBuilder.java new file mode 100644 index 0000000000..74392cdcdb --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaMissingSubstitutionMappingForReqCapErrorBuilder.java @@ -0,0 +1,88 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +/** + * The type Tosca missing substitution mapping for req cap error builder. + */ +public class ToscaMissingSubstitutionMappingForReqCapErrorBuilder { + + private static final String MISSING_SUBSTITUTION_MAPPING_FOR_REQ_CAP_MSG = + "Invalid Substitution, Missing Substitution Mapping for %s with Id %s."; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Tosca missing substitution mapping for req cap error builder. + * + * @param exposedEntry the exposed entry + * @param id the id + */ + public ToscaMissingSubstitutionMappingForReqCapErrorBuilder(MappingExposedEntry exposedEntry, + String id) { + builder.withId(ToscaErrorCodes.MISSING_SUBSTITUTION_MAPPING_FOR_REQ_CAP); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String + .format(MISSING_SUBSTITUTION_MAPPING_FOR_REQ_CAP_MSG, exposedEntry.getDisplayName(), id)); + } + + /** + * Build error code. + * + * @return the error code + */ + public ErrorCode build() { + return builder.build(); + } + + /** + * The enum Mapping exposed entry. + */ + public enum MappingExposedEntry { + + /** + * Capability mapping exposed entry. + */ + CAPABILITY("Capability"), + /** + * Requirement mapping exposed entry. + */ + REQUIREMENT("Requirement"),; + + private String displayName; + + MappingExposedEntry(String displayName) { + this.displayName = displayName; + } + + /** + * Gets display name. + * + * @return the display name + */ + public String getDisplayName() { + return displayName; + } + + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaNodeTypeNotFoundErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaNodeTypeNotFoundErrorBuilder.java new file mode 100644 index 0000000000..3d51970d50 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/errors/ToscaNodeTypeNotFoundErrorBuilder.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.errors; + +import org.openecomp.sdc.common.errors.ErrorCategory; +import org.openecomp.sdc.common.errors.ErrorCode; + +public class ToscaNodeTypeNotFoundErrorBuilder { + private static final String ENTRY_NOT_FOUND_MSG = + "NodeType '%s' or one of its derivedFrom node type hierarchy, " + + "is not defined in tosca service model"; + private final ErrorCode.ErrorCodeBuilder builder = new ErrorCode.ErrorCodeBuilder(); + + /** + * Instantiates a new Tosca node type not found error builder. + * + * @param nodeType the node type + */ + public ToscaNodeTypeNotFoundErrorBuilder(String nodeType) { + builder.withId(ToscaErrorCodes.TOSCA_ENTRY_NOT_FOUND); + builder.withCategory(ErrorCategory.APPLICATION); + builder.withMessage(String.format(ENTRY_NOT_FOUND_MSG, nodeType)); + } + + public ErrorCode build() { + return builder.build(); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarCreationErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarCreationErrorBuilder.java new file mode 100644 index 0000000000..c7b9bc2da4 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarCreationErrorBuilder.java @@ -0,0 +1,43 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.exceptions; + +import org.openecomp.sdc.common.errors.BaseErrorBuilder; +import org.openecomp.sdc.common.errors.ErrorCategory; + +/** + * The type Csar creation error builder. + */ +public class CsarCreationErrorBuilder extends BaseErrorBuilder { + + private static final String MANDATORY_PROPERTY_IS_MISSING_MSG = + "Failed to create CSAR file from ToscaServiceModel"; + private static final String ZIP_FILE_CREATION = "ZIP_FILE_CREATION"; + + /** + * Instantiates a new Csar creation error builder. + */ + public CsarCreationErrorBuilder() { + getErrorCodeBuilder().withId(ZIP_FILE_CREATION); + getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION); + getErrorCodeBuilder().withMessage(MANDATORY_PROPERTY_IS_MISSING_MSG); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarMissingEntryPointErrorBuilder.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarMissingEntryPointErrorBuilder.java new file mode 100644 index 0000000000..9b9257ad33 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/exceptions/CsarMissingEntryPointErrorBuilder.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.exceptions; + +import org.openecomp.sdc.common.errors.BaseErrorBuilder; +import org.openecomp.sdc.common.errors.ErrorCategory; + +/** + * The type Csar missing entry point error builder. + */ +public class CsarMissingEntryPointErrorBuilder extends BaseErrorBuilder { + + private static final String MANDATORY_PROPERTY_IS_MISSING_MSG = + "Failed to create CSAR file from ToscaServiceModel,missing mandatory " + + "EntryDefinitionServiceTemplate "; + private static final String ZIP_FILE_CREATION = "ZIP_FILE_CREATION__MISSING_ENTRY_DEFINITION"; + + /** + * Instantiates a new Csar missing entry point error builder. + */ + public CsarMissingEntryPointErrorBuilder() { + getErrorCodeBuilder().withId(ZIP_FILE_CREATION); + getErrorCodeBuilder().withCategory(ErrorCategory.APPLICATION); + getErrorCodeBuilder().withMessage(MANDATORY_PROPERTY_IS_MISSING_MSG); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java new file mode 100644 index 0000000000..d0d7ccf621 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/DataModelUtil.java @@ -0,0 +1,588 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services; + +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.tosca.datatypes.ToscaFunctions; +import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition; +import org.openecomp.sdc.tosca.datatypes.model.Constraint; +import org.openecomp.sdc.tosca.datatypes.model.EntrySchema; +import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition; +import org.openecomp.sdc.tosca.datatypes.model.Metadata; +import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.datatypes.model.PolicyDefinition; +import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition; +import org.openecomp.sdc.tosca.datatypes.model.RelationshipTemplate; +import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; +import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import org.openecomp.sdc.tosca.datatypes.model.Status; +import org.openecomp.sdc.tosca.datatypes.model.SubstitutionMapping; +import org.openecomp.sdc.tosca.datatypes.model.TopologyTemplate; +import org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt; +import org.openecomp.sdc.tosca.errors.InvalidAddActionNullEntityErrorBuilder; +import org.openecomp.sdc.tosca.errors.InvalidRequirementAssignmentErrorBuilder; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * The type Data model util. + */ +public class DataModelUtil { + + /** + * Add substitution mapping. + * + * @param serviceTemplate the service template + * @param substitutionMapping the substitution mapping + */ + public static void addSubstitutionMapping(ServiceTemplate serviceTemplate, + SubstitutionMapping substitutionMapping) { + if (serviceTemplate == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping", "Service Template") + .build()); + } + + if (serviceTemplate.getTopology_template() == null) { + serviceTemplate.setTopology_template(new TopologyTemplate()); + } + serviceTemplate.getTopology_template().setSubstitution_mappings(substitutionMapping); + } + + /** + * Add substitution mapping req. + * + * @param serviceTemplate the service template + * @param substitutionMappingRequirementId the substitution mapping requirement id + * @param substitutionMappingRequirementList the substitution mapping requirement list + */ + public static void addSubstitutionMappingReq(ServiceTemplate serviceTemplate, + String substitutionMappingRequirementId, + List substitutionMappingRequirementList) { + if (serviceTemplate == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Substitution Mapping Requirements", + "Service Template").build()); + } + + if (serviceTemplate.getTopology_template() == null) { + serviceTemplate.setTopology_template(new TopologyTemplate()); + } + if (serviceTemplate.getTopology_template().getSubstitution_mappings() == null) { + serviceTemplate.getTopology_template().setSubstitution_mappings(new SubstitutionMapping()); + } + if (serviceTemplate.getTopology_template().getSubstitution_mappings().getRequirements() + == null) { + serviceTemplate.getTopology_template().getSubstitution_mappings() + .setRequirements(new HashMap<>()); + } + + serviceTemplate.getTopology_template().getSubstitution_mappings().getRequirements() + .put(substitutionMappingRequirementId, substitutionMappingRequirementList); + } + + /** + * Add node template. + * + * @param serviceTemplate the service template + * @param nodeTemplateId the node template id + * @param nodeTemplate the node template + */ + public static void addNodeTemplate(ServiceTemplate serviceTemplate, String nodeTemplateId, + NodeTemplate nodeTemplate) { + if (serviceTemplate == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Node Template", "Service Template").build()); + } + TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template(); + if (Objects.isNull(topologyTemplate)) { + topologyTemplate = new TopologyTemplate(); + serviceTemplate.setTopology_template(topologyTemplate); + } + if (topologyTemplate.getNode_templates() == null) { + topologyTemplate.setNode_templates(new HashMap<>()); + } + topologyTemplate.getNode_templates().put(nodeTemplateId, nodeTemplate); + } + + /** + * Add policy definition. + * + * @param serviceTemplate the service template + * @param policyId the policy id + * @param policyDefinition the policy definition + */ + public static void addPolicyDefinition(ServiceTemplate serviceTemplate, String policyId, + PolicyDefinition policyDefinition) { + if (serviceTemplate == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Policy Definition", "Service Template") + .build()); + } + TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template(); + if (Objects.isNull(topologyTemplate)) { + topologyTemplate = new TopologyTemplate(); + serviceTemplate.setTopology_template(topologyTemplate); + } + if (topologyTemplate.getPolicies() == null) { + topologyTemplate.setPolicies(new HashMap<>()); + } + topologyTemplate.getPolicies().put(policyId, policyDefinition); + } + + /** + * Add node type. + * + * @param serviceTemplate the service template + * @param nodeTypeId the node type id + * @param nodeType the node type + */ + public static void addNodeType(ServiceTemplate serviceTemplate, String nodeTypeId, + NodeType nodeType) { + if (serviceTemplate == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Node Type", "Service Template").build()); + } + if (serviceTemplate.getNode_types() == null) { + serviceTemplate.setNode_types(new HashMap<>()); + } + serviceTemplate.getNode_types().put(nodeTypeId, nodeType); + } + + /** + * Add relationship template. + * + * @param serviceTemplate the service template + * @param relationshipTemplateId the relationship template id + * @param relationshipTemplate the relationship template + */ + public static void addRelationshipTemplate(ServiceTemplate serviceTemplate, + String relationshipTemplateId, + RelationshipTemplate relationshipTemplate) { + if (serviceTemplate == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Relationship Template", "Service Template") + .build()); + } + if (serviceTemplate.getTopology_template() == null) { + serviceTemplate.setTopology_template(new TopologyTemplate()); + } + if (serviceTemplate.getTopology_template().getRelationship_templates() == null) { + serviceTemplate.getTopology_template().setRelationship_templates(new HashMap<>()); + } + serviceTemplate.getTopology_template().getRelationship_templates() + .put(relationshipTemplateId, relationshipTemplate); + } + + /** + * Add requirement assignment. + * + * @param nodeTemplate the node template + * @param requirementId the requirement id + * @param requirementAssignment the requirement assignment + */ + public static void addRequirementAssignment(NodeTemplate nodeTemplate, String requirementId, + RequirementAssignment requirementAssignment) { + if (nodeTemplate == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Requirement Assignment", "Node Template") + .build()); + } + if (requirementAssignment.getNode() == null) { + throw new CoreException(new InvalidRequirementAssignmentErrorBuilder(requirementId).build()); + } + + if (nodeTemplate.getRequirements() == null) { + nodeTemplate.setRequirements(new ArrayList<>()); + } + Map requirement = new HashMap<>(); + requirement.put(requirementId, requirementAssignment); + nodeTemplate.getRequirements().add(requirement); + } + + /** + * Gets node template. + * + * @param serviceTemplate the service template + * @param nodeTemplateId the node template id + * @return the node template + */ + public static NodeTemplate getNodeTemplate(ServiceTemplate serviceTemplate, + String nodeTemplateId) { + if (serviceTemplate == null + || serviceTemplate.getTopology_template() == null + || serviceTemplate.getTopology_template().getNode_templates() == null) { + return null; + } + return serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId); + } + + /** + * Gets node type. + * + * @param serviceTemplate the service template + * @param nodeTypeId the node type id + * @return the node type + */ + public static NodeType getNodeType(ServiceTemplate serviceTemplate, String nodeTypeId) { + if (serviceTemplate == null || serviceTemplate.getNode_types() == null) { + return null; + } + return serviceTemplate.getNode_types().get(nodeTypeId); + } + + /** + * Add group definition to topology template. + * + * @param serviceTemplate the service template + * @param groupName the group name + * @param group the group + */ + public static void addGroupDefinitionToTopologyTemplate(ServiceTemplate serviceTemplate, + String groupName, GroupDefinition group) { + if (serviceTemplate == null) { + throw new CoreException( + new InvalidAddActionNullEntityErrorBuilder("Group Definition", "Service Template") + .build()); + } + + TopologyTemplate topologyTemplate = serviceTemplate.getTopology_template(); + if (Objects.isNull(topologyTemplate)) { + topologyTemplate = new TopologyTemplate(); + serviceTemplate.setTopology_template(topologyTemplate); + } + if (topologyTemplate.getGroups() == null) { + topologyTemplate.setGroups(new HashMap<>()); + } + if (serviceTemplate.getTopology_template().getGroups() == null) { + Map groups = new HashMap<>(); + serviceTemplate.getTopology_template().setGroups(groups); + } + serviceTemplate.getTopology_template().getGroups().put(groupName, group); + } + + /** + * Create property definition property definition. + * + * @param type the type + * @param description the description + * @param required the required + * @param constraints the constraints + * @param status the status + * @param entrySchema the entry schema + * @param defaultVal the default val + * @return the property definition + */ + public static PropertyDefinition createPropertyDefinition(String type, String description, + boolean required, + List constraints, + Status status, + EntrySchema entrySchema, + Object defaultVal) { + PropertyDefinition propDef = new PropertyDefinition(); + propDef.setType(type); + propDef.setDescription(description); + propDef.setRequired(required); + propDef.setConstraints(constraints); + if (status != null) { + propDef.setStatus(status); + } + propDef.setEntry_schema(entrySchema); + propDef.set_default(defaultVal); + + return propDef; + } + + /** + * Create requirement requirement definition. + * + * @param capability the capability + * @param node the node + * @param relationship the relationship + * @param occurrences the occurrences + * @return the requirement definition + */ + public static RequirementDefinition createRequirement(String capability, String node, + String relationship, Object[] occurrences) { + RequirementDefinition requirementDefinition = new RequirementDefinition(); + requirementDefinition.setCapability(capability); + requirementDefinition.setNode(node); + requirementDefinition.setRelationship(relationship); + if (occurrences != null) { + requirementDefinition.setOccurrences(occurrences); + } + return requirementDefinition; + } + + /** + * Create attribute definition attribute definition. + * + * @param type the type + * @param description the description + * @param status the status + * @param entrySchema the entry schema + * @param defaultVal the default val + * @return the attribute definition + */ + public static AttributeDefinition createAttributeDefinition(String type, String description, + Status status, + EntrySchema entrySchema, + Object defaultVal) { + AttributeDefinition attributeDef = new AttributeDefinition(); + attributeDef.setType(type); + + if (description != null) { + attributeDef.setDescription(description); + } + if (status != null) { + attributeDef.setStatus(status); + } + attributeDef.setEntry_schema(entrySchema); + attributeDef.set_default(defaultVal); + + return attributeDef; + } + + /** + * Create valid values constraint constraint. + * + * @param values the values + * @return the constraint + */ + public static Constraint createValidValuesConstraint(Object... values) { + Constraint validValues = new Constraint(); + for (Object value : values) { + validValues.addValidValue(value); + } + return validValues; + } + + /** + * Create metadata metadata. + * + * @param templateName the template name + * @param templateVersion the template version + * @param templateAuthor the template author + * @return the metadata + */ + public static Metadata createMetadata(String templateName, String templateVersion, + String templateAuthor) { + Metadata metadata = new Metadata(); + metadata.setTemplate_name(templateName); + metadata.setTemplate_version(templateVersion); + metadata.setTemplate_author(templateAuthor); + + return metadata; + } + + /** + * Create entry schema entry schema. + * + * @param type the type + * @param description the description + * @param constraints the constraints + * @return the entry schema + */ + public static EntrySchema createEntrySchema(String type, String description, + List constraints) { + EntrySchema entrySchema = new EntrySchema(); + entrySchema.setType(type); + entrySchema.setDescription(description); + entrySchema.setConstraints(constraints); + return entrySchema; + } + + /** + * Create valid values constraints list list. + * + * @param values the values + * @return the list + */ + public static List createValidValuesConstraintsList(String... values) { + List constraints; + Constraint validValues; + constraints = new ArrayList<>(); + validValues = DataModelUtil.createValidValuesConstraint(values); + constraints.add(validValues); + return constraints; + } + + /** + * Create greater or equal constrain constraint. + * + * @param value the value + * @return the constraint + */ + public static Constraint createGreaterOrEqualConstrain(Object value) { + + Constraint constraint = new Constraint(); + constraint.setGreater_or_equal(value); + return constraint; + } + + /** + * Gets constrain list. + * + * @param constrains the constrains + * @return the constrain list + */ + public static List getConstrainList(Constraint... constrains) { + return Arrays.asList(constrains); + + } + + /** + * Create get input property value from list parameter map. + * + * @param inputPropertyListName the input property list name + * @param indexInTheList the index in the list + * @param nestedPropertyName the nested property name + * @return the map + */ + public static Map createGetInputPropertyValueFromListParameter(String inputPropertyListName, + int indexInTheList, + String... nestedPropertyName) { + List propertyList = new ArrayList<>(); + propertyList.add(inputPropertyListName); + propertyList.add(indexInTheList); + if (nestedPropertyName != null) { + Collections.addAll(propertyList, nestedPropertyName); + } + Map getInputProperty = new HashMap<>(); + getInputProperty.put(ToscaFunctions.GET_INPUT.getDisplayName(), propertyList); + return getInputProperty; + } + + /** + * Convert property def to parameter def parameter definition ext. + * + * @param propertyDefinition the property definition + * @return the parameter definition ext + */ + public static ParameterDefinitionExt convertPropertyDefToParameterDef( + PropertyDefinition propertyDefinition) { + if (propertyDefinition == null) { + return null; + } + + ParameterDefinitionExt parameterDefinition = new ParameterDefinitionExt(); + parameterDefinition.setType(propertyDefinition.getType()); + parameterDefinition.setDescription(propertyDefinition.getDescription()); + parameterDefinition.setRequired(propertyDefinition.getRequired()); + parameterDefinition.set_default(propertyDefinition.get_default()); + parameterDefinition.setStatus(propertyDefinition.getStatus()); + parameterDefinition.setConstraints(propertyDefinition.getConstraints()); + parameterDefinition.setEntry_schema(propertyDefinition.getEntry_schema()); + parameterDefinition.setHidden(false); + parameterDefinition.setImmutable(false); + + return parameterDefinition; + } + + /** + * Convert attribute def to parameter def parameter definition ext. + * + * @param attributeDefinition the attribute definition + * @param outputValue the output value + * @return the parameter definition ext + */ + public static ParameterDefinitionExt convertAttributeDefToParameterDef( + AttributeDefinition attributeDefinition, Map outputValue) { + if (attributeDefinition == null) { + return null; + } + ParameterDefinitionExt parameterDefinition = new ParameterDefinitionExt(); + parameterDefinition.setDescription(attributeDefinition.getDescription()); + parameterDefinition.setValue(outputValue); + return parameterDefinition; + } + + /** + * Clone constraints list. + * + * @param constraints the constraints + * @return the list + */ + public static List cloneConstraints(List constraints) { + if (constraints == null) { + return null; + } + return constraints.stream().map(Constraint::clone).collect(Collectors.toList()); + } + + /** + * Clone valid source types list. + * + * @param validSourceTypes the valid source types + * @return the list + */ + public static List cloneValidSourceTypes(List validSourceTypes) { + if (validSourceTypes == null) { + return null; + } + return validSourceTypes.stream().collect(Collectors.toList()); + } + + /** + * Clone property definitions map. + * + * @param propertyDefinitions the property definitions + * @return the map + */ + public static Map clonePropertyDefinitions( + Map propertyDefinitions) { + if (propertyDefinitions == null) { + return null; + } + Map clonedProperties = new HashMap<>(); + for (String propertyKey : propertyDefinitions.keySet()) { + clonedProperties.put(propertyKey, propertyDefinitions.get(propertyKey).clone()); + } + return clonedProperties; + } + + /** + * Clone attribute definitions map. + * + * @param attributeDefinitions the attribute definitions + * @return the map + */ + public static Map cloneAttributeDefinitions( + Map attributeDefinitions) { + if (attributeDefinitions == null) { + return null; + } + Map clonedAttributeDefinitions = new HashMap<>(); + for (String attributeKey : attributeDefinitions.keySet()) { + clonedAttributeDefinitions.put(attributeKey, attributeDefinitions.get(attributeKey).clone()); + } + return clonedAttributeDefinitions; + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java new file mode 100644 index 0000000000..271c471922 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaAnalyzerService.java @@ -0,0 +1,66 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services; + +import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; +import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; + +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public interface ToscaAnalyzerService { + + /* + node template with type equal to node type or derived from node type + */ + Map getNodeTemplatesByType(ServiceTemplate serviceTemplate, String nodeType, + ToscaServiceModel toscaServiceModel); + + boolean isTypeOf(NodeTemplate nodeTemplate, String nodeType, ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel); + + List getRequirements(NodeTemplate nodeTemplate, String requirementId); + + Optional getNodeTemplateById(ServiceTemplate serviceTemplate, + String nodeTemplateId); + + Optional getSubstituteServiceTemplateName(String substituteNodeTemplateId, + NodeTemplate substitutableNodeTemplate); + + Map getSubstitutableNodeTemplates(ServiceTemplate serviceTemplate); + + Optional> getSubstitutionMappedNodeTemplateByExposedReq( + String substituteServiceTemplateFileName, ServiceTemplate substituteServiceTemplate, + String requirementId); + + /* + match only for the input which is not null + */ + boolean isDesiredRequirementAssignment(RequirementAssignment requirementAssignment, + String capability, String node, String relationship); + + Object getFlatEntity(ToscaElementTypes elementType, String type, ServiceTemplate serviceTemplate, + ToscaServiceModel toscaModel); +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java new file mode 100644 index 0000000000..27cf07e166 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaConstants.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services; + + +public class ToscaConstants { + + //TOSCA Node Types prefix + public static final String NODES_PREFIX = "org.openecomp.resource.vfc.nodes.heat."; + public static final String NODES_SUBSTITUTION_PREFIX + = "org.openecomp.resource.abstract.nodes.heat."; + + //TOSCA Requirement Ids + public static final String DEPENDS_ON_REQUIREMENT_ID = "dependency"; + public static final String BINDING_REQUIREMENT_ID = "binding"; + public static final String LINK_REQUIREMENT_ID = "link"; + public static final String LOCAL_STORAGE_REQUIREMENT_ID = "local_storage"; + public static final String NETWORK_REQUIREMENT_ID = "network"; + public static final String PORT_REQUIREMENT_ID = "port"; + + //TOSCA Capability Ids + public static final String BINDING_CAPABILITY_ID = "binding"; + public static final String LINK_CAPABILITY_ID = "link"; + public static final String HOST_CAPABILITY_ID = "host"; + public static final String ENDPOINT_CAPABILITY_ID = "endpoint"; + public static final String OS_CAPABILITY_ID = "os"; + public static final String SCALABLE_CAPABILITY_ID = "scalable"; + + //General + public static final String TOSCA_DEFINITIONS_VERSION = "tosca_simple_yaml_1_0_0"; + public static final String MODELABLE_ENTITY_NAME_SELF = "SELF"; + public static final String NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE = "substitutable"; + public static final String NATIVE_TYPES_SERVICE_TEMPLATE_NAME = "NativeTypesServiceTemplate"; + public static final String UNBOUNDED = "UNBOUNDED"; + + //properties + public static final String SERVICE_TEMPLATE_FILTER_PROPERTY_NAME = "service_template_filter"; + public static final String SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME = + "substitute_service_template"; + public static final String COUNT_PROPERTY_NAME = "count"; + public static final String INDEX_VALUE_PROPERTY_NAME = "index_value"; + public static final String SCALING_ENABLED_PROPERTY_NAME = "scaling_enabled"; + + public static final String DHCP_ENABLED_PROPERTY_NAME = "dhcp_enabled"; + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java new file mode 100644 index 0000000000..7ec2fffa2b --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaFileOutputService.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services; + +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; + +public interface ToscaFileOutputService { + byte[] createOutputFile(ToscaServiceModel toscaServiceModel, + FileContentHandler externalArtifacts); + + String createMetaFile(String entryDefinitionsFileName); + + String getArtifactsFolderName(); + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaNativeTypesServiceTemplate.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaNativeTypesServiceTemplate.java new file mode 100644 index 0000000000..013d761168 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaNativeTypesServiceTemplate.java @@ -0,0 +1,309 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services; + +import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; +import org.openecomp.sdc.tosca.datatypes.ToscaDataType; +import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; +import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType; + +import org.openecomp.sdc.tosca.datatypes.model.AttributeDefinition; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; +import org.openecomp.sdc.tosca.datatypes.model.InterfaceDefinition; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.datatypes.model.PropertyDefinition; +import org.openecomp.sdc.tosca.datatypes.model.PropertyType; +import org.openecomp.sdc.tosca.datatypes.model.RequirementDefinition; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * The type Tosca native types service template. + */ +public class ToscaNativeTypesServiceTemplate { + /** + * Create service template service template. + * + * @return the service template + */ + public static ServiceTemplate createServiceTemplate() { + ServiceTemplate nativeNodeTypesServiceTemplate = new ServiceTemplate(); + nativeNodeTypesServiceTemplate + .setTosca_definitions_version(ToscaConstants.TOSCA_DEFINITIONS_VERSION); + nativeNodeTypesServiceTemplate.setMetadata(DataModelUtil + .createMetadata(ToscaConstants.NATIVE_TYPES_SERVICE_TEMPLATE_NAME, "1.0.0", null)); + nativeNodeTypesServiceTemplate.setDescription("TOSCA Native Node Types"); + nativeNodeTypesServiceTemplate.setNode_types(createNativeNodeTypes()); + return nativeNodeTypesServiceTemplate; + } + + private static Map createNativeNodeTypes() { + Map nativeNodeTypes = new HashMap<>(); + nativeNodeTypes.put(ToscaNodeType.COMPUTE.getDisplayName(), createToscaNodesComputeNodeType()); + nativeNodeTypes.put(ToscaNodeType.ROOT.getDisplayName(), createToscaNodesRootNodeType()); + nativeNodeTypes + .put(ToscaNodeType.NETWORK_PORT.getDisplayName(), createToscaNodesPortsNodeType()); + nativeNodeTypes + .put(ToscaNodeType.BLOCK_STORAGE.getDisplayName(), createToscaNodesBlockStorageNodeType()); + nativeNodeTypes.put(ToscaNodeType.NETWORK.getDisplayName(), createToscaNodesNetworkNodeType()); + return nativeNodeTypes; + } + + private static NodeType createToscaNodesComputeNodeType() { + NodeType computeNodeType = new NodeType(); + computeNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName()); + computeNodeType.setAttributes(createComputeAttributes()); + computeNodeType.setRequirements(createComputeRequirements()); + computeNodeType.setCapabilities(createComputeCapabilities()); + return computeNodeType; + } + + private static NodeType createToscaNodesRootNodeType() { + NodeType computeNodeType = new NodeType(); + computeNodeType.setAttributes(createRootAttributes()); + computeNodeType.setInterfaces(createRootInterfaces()); + return computeNodeType; + } + + private static NodeType createToscaNodesPortsNodeType() { + NodeType computeNodeType = new NodeType(); + computeNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName()); + computeNodeType.setProperties(createToscaNodesPortProperties()); + computeNodeType.setRequirements(createToscaNodesPortRequirements()); + return computeNodeType; + } + + private static NodeType createToscaNodesBlockStorageNodeType() { + NodeType computeNodeType = new NodeType(); + computeNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName()); + computeNodeType.setProperties(createToscaNodesBlockStorageProperties()); + computeNodeType.setCapabilities(createToscaNodesBlockStorageCapabilities()); + return computeNodeType; + } + + private static NodeType createToscaNodesNetworkNodeType() { + NodeType computeNodeType = new NodeType(); + computeNodeType.setDerived_from(ToscaNodeType.ROOT.getDisplayName()); + computeNodeType.setProperties(createToscaNodesNetworkProperties()); + computeNodeType.setCapabilities(createToscaNodesNetworkCapabilities()); + return computeNodeType; + } + + private static Map createToscaNodesPortProperties() { + Map propertyDefinitionMap = new HashMap<>(); + propertyDefinitionMap.put("ip_address", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("order", DataModelUtil + .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(), null, true, + DataModelUtil.getConstrainList(DataModelUtil.createGreaterOrEqualConstrain(0)), null, + null, 0)); + propertyDefinitionMap.put("is_default", DataModelUtil + .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(), null, false, null, null, + null, false)); + propertyDefinitionMap.put("ip_range_start", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("ip_range_end", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + return propertyDefinitionMap; + } + + private static Map createToscaNodesBlockStorageProperties() { + Map propertyDefinitionMap = new HashMap<>(); + propertyDefinitionMap.put("size", DataModelUtil + .createPropertyDefinition(PropertyType.SCALAR_UNIT_SIZE.getDisplayName(), null, false, + DataModelUtil.getConstrainList(DataModelUtil.createGreaterOrEqualConstrain("1 MB")), + null, null, null)); + propertyDefinitionMap.put("volume_id", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("snapshot_id", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + return propertyDefinitionMap; + } + + private static Map createToscaNodesNetworkProperties() { + Map propertyDefinitionMap = new HashMap<>(); + propertyDefinitionMap.put("ip_version", DataModelUtil + .createPropertyDefinition(PropertyType.INTEGER.getDisplayName(), null, false, + DataModelUtil.getConstrainList(DataModelUtil.createValidValuesConstraint(4, 6)), null, + null, 4)); + propertyDefinitionMap.put("cidr", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("start_ip", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("end_ip", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("gateway_ip", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("network_name", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("network_id", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("segmentation_id", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("network_type", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("physical_network", DataModelUtil + .createPropertyDefinition(PropertyType.STRING.getDisplayName(), null, false, null, null, + null, null)); + propertyDefinitionMap.put("dhcp_enabled", DataModelUtil + .createPropertyDefinition(PropertyType.BOOLEAN.getDisplayName(), null, false, null, null, + null, true)); + + return propertyDefinitionMap; + } + + private static Map createRootInterfaces() { + return new HashMap<>(); + } + + private static Map createComputeCapabilities() { + Map computeCapabilities = new HashMap<>(); + computeCapabilities.put(ToscaConstants.HOST_CAPABILITY_ID, + createCapabilityDefinition(ToscaCapabilityType.CONTAINER.getDisplayName(), + createValidSourceTypes("tosca.nodes.SoftwareComponent"))); + computeCapabilities.put(ToscaConstants.ENDPOINT_CAPABILITY_ID, + createCapabilityDefinition(ToscaCapabilityType.ENDPOINT_ADMIN.getDisplayName(), null)); + computeCapabilities.put(ToscaConstants.OS_CAPABILITY_ID, + createCapabilityDefinition(ToscaCapabilityType.OPERATING_SYSTEM.getDisplayName(), null)); + computeCapabilities.put(ToscaConstants.SCALABLE_CAPABILITY_ID, + createCapabilityDefinition(ToscaCapabilityType.SCALABLE.getDisplayName(), null)); + computeCapabilities.put(ToscaConstants.BINDING_CAPABILITY_ID, + createCapabilityDefinition(ToscaCapabilityType.NETWORK_BINDABLE.getDisplayName(), null)); + return computeCapabilities; + } + + private static Map createToscaNodesBlockStorageCapabilities() { + Map computeCapabilities = new HashMap<>(); + computeCapabilities.put("attachment", + createCapabilityDefinition(ToscaCapabilityType.ATTACHMENT.getDisplayName(), null)); + return computeCapabilities; + } + + private static Map createToscaNodesNetworkCapabilities() { + Map computeCapabilities = new HashMap<>(); + computeCapabilities.put(ToscaConstants.LINK_CAPABILITY_ID, + createCapabilityDefinition(ToscaCapabilityType.NETWORK_LINKABLE.getDisplayName(), null)); + return computeCapabilities; + } + + private static List createValidSourceTypes(String... validSourceTypes) { + return Arrays.asList(validSourceTypes); + } + + private static CapabilityDefinition createCapabilityDefinition(String type, + List validSourceTypes) { + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + capabilityDefinition.setType(type); + capabilityDefinition.setValid_source_types(validSourceTypes); + return capabilityDefinition; + } + + private static List> createComputeRequirements() { + List> computeRequirementList = new ArrayList<>(); + Map localStorageRequirement = new HashMap<>(); + localStorageRequirement.put("local_storage", DataModelUtil + .createRequirement(ToscaCapabilityType.ATTACHMENT.getDisplayName(), + ToscaNodeType.BLOCK_STORAGE.getDisplayName(), + ToscaRelationshipType.NATIVE_ATTACHES_TO.getDisplayName(), + createOccurrences(0, ToscaConstants.UNBOUNDED))); + computeRequirementList.add(localStorageRequirement); + return computeRequirementList; + } + + private static List> createToscaNodesPortRequirements() { + List> requirements = new ArrayList<>(); + + Map linkRequirement = new HashMap<>(); + linkRequirement.put(ToscaConstants.LINK_REQUIREMENT_ID, DataModelUtil + .createRequirement(ToscaCapabilityType.NETWORK_LINKABLE.getDisplayName(), + ToscaNodeType.ROOT.getDisplayName(), + ToscaRelationshipType.NETWORK_LINK_TO.getDisplayName(), null)); + requirements.add(linkRequirement); + + Map bindingRequirement = new HashMap<>(); + bindingRequirement.put(ToscaConstants.BINDING_REQUIREMENT_ID, DataModelUtil + .createRequirement(ToscaCapabilityType.NETWORK_BINDABLE.getDisplayName(), + ToscaNodeType.ROOT.getDisplayName(), + ToscaRelationshipType.NETWORK_BINDS_TO.getDisplayName(), null)); + requirements.add(bindingRequirement); + + return requirements; + } + + + private static Object[] createOccurrences(Object min, Object max) { + return new Object[]{min, max}; + + } + + private static Map createComputeAttributes() { + Map computeAttributesDefMap = new HashMap<>(); + computeAttributesDefMap.put("private_address", DataModelUtil + .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "private address", null, + null, null)); + computeAttributesDefMap.put("public_address", DataModelUtil + .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "public_address", null, + null, null)); + computeAttributesDefMap.put("networks", DataModelUtil + .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "networks", null, + DataModelUtil + .createEntrySchema(ToscaDataType.NETWORK_NETWORK_INFO.getDisplayName(), null, null), + null)); + computeAttributesDefMap.put("ports", DataModelUtil + .createAttributeDefinition(PropertyType.MAP.getDisplayName(), "ports", null, DataModelUtil + .createEntrySchema(ToscaDataType.NETWORK_PORT_INFO.getDisplayName(), null, null), + null)); + return computeAttributesDefMap; + } + + private static Map createRootAttributes() { + Map attributesDefMap = new HashMap<>(); + attributesDefMap.put("tosca_id", DataModelUtil + .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "tosca id", null, null, + null)); + attributesDefMap.put("tosca_name", DataModelUtil + .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "tosca name", null, null, + null)); + attributesDefMap.put("state", DataModelUtil + .createAttributeDefinition(PropertyType.STRING.getDisplayName(), "state", null, null, + null)); + return attributesDefMap; + } + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaUtil.java new file mode 100644 index 0000000000..4f9c70267d --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/ToscaUtil.java @@ -0,0 +1,151 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services; + +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityDefinition; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityType; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; + +/** + * The type Tosca util. + */ +public class ToscaUtil { + + /** + * Gets service template file name. + * + * @param serviceTemplate the service template + * @return the service template file name + */ + public static String getServiceTemplateFileName(ServiceTemplate serviceTemplate) { + if (serviceTemplate == null) { + return null; + } + if (serviceTemplate.getMetadata() == null) { + return UUID.randomUUID().toString() + "ServiceTemplate.yaml"; + } + return getServiceTemplateFileName(serviceTemplate.getMetadata().getTemplate_name()); + } + + /** + * Gets service template file name. + * + * @param templateName the template name + * @return the service template file name + */ + public static String getServiceTemplateFileName(String templateName) { + return (Objects.isNull(templateName) ? UUID.randomUUID().toString() : templateName) + + "ServiceTemplate.yaml"; + } + + /** + * Add service template to map with key file name. + * + * @param serviceTemplates the service templates + * @param commonServiceTemplate the common service template + */ + public static void addServiceTemplateToMapWithKeyFileName( + Map serviceTemplates, ServiceTemplate commonServiceTemplate) { + serviceTemplates + .put(ToscaUtil.getServiceTemplateFileName(commonServiceTemplate), commonServiceTemplate); + } + + /** + * Convert type to definition capability definition. + * + * @param type the type + * @param capabilityType the capability type + * @param properties the properties + * @param description the description + * @return the capability definition + */ + public static CapabilityDefinition convertTypeToDefinition(String type, + CapabilityType capabilityType, + Map properties, + String description) { + CapabilityDefinition capabilityDefinition = new CapabilityDefinition(); + capabilityDefinition.setAttributes(capabilityType.getAttributes()); + capabilityDefinition.setProperties(capabilityType.getProperties()); + if (description == null) { + capabilityDefinition.setDescription(capabilityType.getDescription()); + } else { + capabilityDefinition.setDescription(description); + } + capabilityDefinition.setType(type); + + capabilityDefinition.getProperties() + .entrySet() + .stream() + .filter(entry -> properties.containsKey(entry.getKey())) + .forEach(entry -> entry.getValue() + .set_default(properties.get(entry.getKey()))); + + + return capabilityDefinition; + + } + + /** + * Normalize component name node type map. + * + * @param toscaModel the tosca model + * @param components the components + * @return the map + */ + public static Map> normalizeComponentNameNodeType( + ToscaServiceModel toscaModel, Set components) { + + Map> normalizedData = new HashMap<>(); + toscaModel + .getServiceTemplates() + .entrySet().stream().filter(entry -> entry + .getValue() + .getNode_types() != null) + .forEach(entry -> entry + .getValue() + .getNode_types() + .entrySet().stream() + .filter(nodeTypeEntry -> components + .contains(nodeTypeEntry + .getKey())) + .forEach(nodeTypeEntry -> addNodeType(nodeTypeEntry.getKey(), nodeTypeEntry.getValue(), + normalizedData))); + return normalizedData; + } + + private static void addNodeType(String key, NodeType value, + Map> normalizedData) { + if (!normalizedData.containsKey(key)) { + normalizedData.put(key, new ArrayList<>()); + } + normalizedData.get(key).add(value); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java new file mode 100644 index 0000000000..a11bff4b6a --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaAnalyzerServiceImpl.java @@ -0,0 +1,467 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services.impl; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.MapUtils; +import org.openecomp.core.utilities.CommonMethods; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; +import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes; +import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.CapabilityType; +import org.openecomp.sdc.tosca.datatypes.model.Import; +import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; +import org.openecomp.sdc.tosca.datatypes.model.NodeType; +import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import org.openecomp.sdc.tosca.errors.ToscaInvalidEntryNotFoundErrorBuilder; +import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder; +import org.openecomp.sdc.tosca.errors.ToscaInvalidSubstitutionServiceTemplateErrorBuilder; +import org.openecomp.sdc.tosca.errors.ToscaNodeTypeNotFoundErrorBuilder; +import org.openecomp.sdc.tosca.services.ToscaAnalyzerService; +import org.openecomp.sdc.tosca.services.ToscaConstants; +import org.openecomp.sdc.tosca.services.yamlutil.ToscaExtensionYamlUtil; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; +import java.util.Set; + +public class ToscaAnalyzerServiceImpl implements ToscaAnalyzerService { + /* + node template with type equal to node type or derived from node type. + */ + @Override + public Map getNodeTemplatesByType(ServiceTemplate serviceTemplate, + String nodeType, + ToscaServiceModel toscaServiceModel) { + Map nodeTemplates = new HashMap<>(); + + if (Objects.nonNull(serviceTemplate.getTopology_template()) + && MapUtils.isNotEmpty(serviceTemplate.getTopology_template().getNode_templates())) { + for (Map.Entry nodeTemplateEntry : serviceTemplate + .getTopology_template().getNode_templates().entrySet()) { + if (isTypeOf(nodeTemplateEntry.getValue(), nodeType, serviceTemplate, toscaServiceModel)) { + nodeTemplates.put(nodeTemplateEntry.getKey(), nodeTemplateEntry.getValue()); + } + + } + } + return nodeTemplates; + } + + @Override + public boolean isTypeOf(NodeTemplate nodeTemplate, String nodeType, + ServiceTemplate serviceTemplate, ToscaServiceModel toscaServiceModel) { + if (nodeTemplate == null) { + return false; + } + + if (isNodeTemplateOfTypeNodeType(nodeTemplate, nodeType)) { + return true; + } + + Optional nodeTypeExistInServiceTemplateHierarchy = + isNodeTypeExistInServiceTemplateHierarchy(nodeType, nodeTemplate.getType(), serviceTemplate, + toscaServiceModel, null); + return nodeTypeExistInServiceTemplateHierarchy.orElseThrow(() -> new CoreException( + new ToscaNodeTypeNotFoundErrorBuilder(nodeTemplate.getType()).build())); + } + + + private Optional isNodeTypeExistInServiceTemplateHierarchy(String nodeTypeToMatch, + String nodeTypeToSearch, + ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel, + Set analyzedImportFiles) { + Map searchableNodeTypes = serviceTemplate.getNode_types(); + if (!MapUtils.isEmpty(searchableNodeTypes)) { + NodeType nodeType = searchableNodeTypes.get(nodeTypeToSearch); + if (Objects.nonNull(nodeType)) { + if (Objects.equals(nodeType.getDerived_from(), nodeTypeToMatch)) { + return Optional.of(true); + } else if (isNodeTypeIsToscaRoot(nodeType)) { + return Optional.of(false); + } else { + return isNodeTypeExistInServiceTemplateHierarchy(nodeTypeToMatch, + nodeType.getDerived_from(), serviceTemplate, toscaServiceModel, null); + } + } else { + return isNodeTypeExistInImports(nodeTypeToMatch, nodeTypeToSearch, serviceTemplate, + toscaServiceModel, analyzedImportFiles); + } + } + return isNodeTypeExistInImports(nodeTypeToMatch, nodeTypeToSearch, serviceTemplate, + toscaServiceModel, analyzedImportFiles); + + } + + private Optional isNodeTypeExistInImports(String nodeTypeToMatch, + String nodeTypeToSearch, + ServiceTemplate serviceTemplate, + ToscaServiceModel toscaServiceModel, + Set analyzedImportFiles) { + Map imports = serviceTemplate.getImports(); + if (imports == null) { + return Optional.empty(); + } + + analyzedImportFiles = createAnalyzedImportFilesSet(analyzedImportFiles); + for (Import anImport : imports.values()) { + if (Objects.isNull(anImport) || Objects.isNull(anImport.getFile())) { + throw new RuntimeException("import without file entry"); + } + String importFile = anImport.getFile(); + if (analyzedImportFiles.contains(importFile)) { + continue; + } + addImportFileToAnalyzedImportFilesSet(analyzedImportFiles, importFile); + ServiceTemplate template = toscaServiceModel.getServiceTemplates().get(importFile); + Optional nodeTypeExistInServiceTemplateHierarchy = + isNodeTypeExistInServiceTemplateHierarchy(nodeTypeToMatch, nodeTypeToSearch, template, + toscaServiceModel, analyzedImportFiles); + if (nodeTypeExistInServiceTemplateHierarchy.isPresent()) { + if (nodeTypeExistInServiceTemplateHierarchy.get()) { + return Optional.of(true); + } + } + } + return Optional.of(false); + } + + private Set addImportFileToAnalyzedImportFilesSet(Set analyzedImportFiles, + String importFile) { + analyzedImportFiles.add(importFile); + return analyzedImportFiles; + } + + private Set createAnalyzedImportFilesSet(Set analyzedImportFiles) { + if (Objects.isNull(analyzedImportFiles)) { + analyzedImportFiles = new HashSet<>(); + } + return analyzedImportFiles; + } + + private boolean isNodeTypeIsToscaRoot(NodeType stNodeType) { + return Objects.equals(stNodeType.getDerived_from(), ToscaNodeType.ROOT.getDisplayName()); + } + + private boolean isNodeTemplateOfTypeNodeType(NodeTemplate nodeTemplate, String nodeType) { + return Objects.equals(nodeTemplate.getType(), nodeType); + } + + @Override + public List getRequirements(NodeTemplate nodeTemplate, + String requirementId) { + List requirements = new ArrayList<>(); + List> requirementList = nodeTemplate.getRequirements(); + if (requirementList != null) { + requirementList.stream().filter(reqMap -> reqMap.get(requirementId) != null) + .forEach(reqMap -> { + ToscaExtensionYamlUtil toscaExtensionYamlUtil = new ToscaExtensionYamlUtil(); + RequirementAssignment reqAssignment = toscaExtensionYamlUtil + .yamlToObject(toscaExtensionYamlUtil.objectToYaml(reqMap.get(requirementId)), + RequirementAssignment.class); + requirements.add(reqAssignment); + }); + } + return requirements; + } + + @Override + public Optional getNodeTemplateById(ServiceTemplate serviceTemplate, + String nodeTemplateId) { + if ((serviceTemplate.getTopology_template() != null) + && (serviceTemplate.getTopology_template().getNode_templates() != null) + && (serviceTemplate.getTopology_template().getNode_templates() + .get(nodeTemplateId) != null)) { + return Optional + .of(serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId)); + } + return Optional.empty(); + } + + @Override + public Optional getSubstituteServiceTemplateName(String substituteNodeTemplateId, + NodeTemplate substitutableNodeTemplate) { + if (!isSubstitutableNodeTemplate(substitutableNodeTemplate)) { + return Optional.empty(); + } + + if (substitutableNodeTemplate.getProperties() != null + && substitutableNodeTemplate.getProperties() + .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME) != null) { + Object serviceTemplateFilter = substitutableNodeTemplate.getProperties() + .get(ToscaConstants.SERVICE_TEMPLATE_FILTER_PROPERTY_NAME); + if (serviceTemplateFilter != null && serviceTemplateFilter instanceof Map) { + Object substituteServiceTemplate = ((Map) serviceTemplateFilter) + .get(ToscaConstants.SUBSTITUTE_SERVICE_TEMPLATE_PROPERTY_NAME); + if (substituteServiceTemplate == null) { + throw new CoreException( + new ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(substituteNodeTemplateId) + .build()); + } + return Optional.of(substituteServiceTemplate.toString()); + } + } + throw new CoreException( + new ToscaInvalidSubstituteNodeTemplatePropertiesErrorBuilder(substituteNodeTemplateId) + .build()); + } + + @Override + public Map getSubstitutableNodeTemplates(ServiceTemplate serviceTemplate) { + Map substitutableNodeTemplates = new HashMap<>(); + + if (serviceTemplate == null + || serviceTemplate.getTopology_template() == null + || serviceTemplate.getTopology_template().getNode_templates() == null) { + return substitutableNodeTemplates; + } + + Map nodeTemplates = + serviceTemplate.getTopology_template().getNode_templates(); + for (String nodeTemplateId : nodeTemplates.keySet()) { + NodeTemplate nodeTemplate = nodeTemplates.get(nodeTemplateId); + if (isSubstitutableNodeTemplate(nodeTemplate)) { + substitutableNodeTemplates.put(nodeTemplateId, nodeTemplate); + } + } + + return substitutableNodeTemplates; + } + + private boolean isSubstitutableNodeTemplate(NodeTemplate nodeTemplate) { + return nodeTemplate.getDirectives() != null + && nodeTemplate.getDirectives().contains(ToscaConstants + .NODE_TEMPLATE_DIRECTIVE_SUBSTITUTABLE); + } + + private boolean isSubstitutionServiceTemplate(String substituteServiceTemplateFileName, + ServiceTemplate substituteServiceTemplate) { + if (substituteServiceTemplate != null + && substituteServiceTemplate.getTopology_template() != null + && substituteServiceTemplate.getTopology_template().getSubstitution_mappings() != null) { + if (substituteServiceTemplate.getTopology_template().getSubstitution_mappings() + .getNode_type() == null) { + throw new CoreException(new ToscaInvalidSubstitutionServiceTemplateErrorBuilder( + substituteServiceTemplateFileName).build()); + } + return true; + } + return false; + + } + + @Override + public Optional> getSubstitutionMappedNodeTemplateByExposedReq( + String substituteServiceTemplateFileName, ServiceTemplate substituteServiceTemplate, + String requirementId) { + if (isSubstitutionServiceTemplate(substituteServiceTemplateFileName, + substituteServiceTemplate)) { + Map> substitutionMappingRequirements = + substituteServiceTemplate.getTopology_template().getSubstitution_mappings() + .getRequirements(); + if (substitutionMappingRequirements != null) { + List requirementMapping = substitutionMappingRequirements.get(requirementId); + if (requirementMapping != null && !requirementMapping.isEmpty()) { + String mappedNodeTemplateId = requirementMapping.get(0); + Optional mappedNodeTemplate = + getNodeTemplateById(substituteServiceTemplate, mappedNodeTemplateId); + mappedNodeTemplate.orElseThrow(() -> new CoreException( + new ToscaInvalidEntryNotFoundErrorBuilder("Node Template", mappedNodeTemplateId) + .build())); + Map.Entry mappedNodeTemplateEntry = + new Map.Entry() { + @Override + public String getKey() { + return mappedNodeTemplateId; + } + + @Override + public NodeTemplate getValue() { + return mappedNodeTemplate.get(); + } + + @Override + public NodeTemplate setValue(NodeTemplate value) { + return null; + } + }; + return Optional.of(mappedNodeTemplateEntry); + } + } + } + return Optional.empty(); + } + + + /* + match only for the input which is not null + */ + @Override + public boolean isDesiredRequirementAssignment(RequirementAssignment requirementAssignment, + String capability, String node, + String relationship) { + if (capability != null) { + if (requirementAssignment.getCapability() == null + || !requirementAssignment.getCapability().equals(capability)) { + return false; + } + } + + if (node != null) { + if (requirementAssignment.getNode() == null + || !requirementAssignment.getNode().equals(node)) { + return false; + } + } + + if (relationship != null) { + if (requirementAssignment.getRelationship() == null + || !requirementAssignment.getRelationship().equals(relationship)) { + return false; + } + } + + return !(capability == null && node == null && relationship == null); + + } + + @Override + public Object getFlatEntity(ToscaElementTypes elementType, String typeId, + ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel) { + Object returnEntity; + + switch (elementType) { + case CAPABILITY_TYPE: + returnEntity = new CapabilityType(); + break; + default: + throw new RuntimeException( + "Entity[" + elementType + "] id[" + typeId + "] flat not supported"); + } + + scanAnFlatEntity(elementType, typeId, returnEntity, serviceTemplate, toscaModel); + + + return returnEntity; + } + + private void scanAnFlatEntity(ToscaElementTypes elementType, String typeId, Object entity, + ServiceTemplate serviceTemplate, ToscaServiceModel toscaModel) { + + + boolean entityFound = + enrichEntityFromCurrentServiceTemplate(elementType, typeId, entity, serviceTemplate, + toscaModel); + if (!entityFound) { + Map imports = serviceTemplate.getImports(); + if (MapUtils.isEmpty(imports)) { + return; + } + for (Import importServiceTemplate : imports.values()) { + ServiceTemplate template = + toscaModel.getServiceTemplates().get(importServiceTemplate.getFile()); + scanAnFlatEntity(elementType, typeId, entity, template, toscaModel); + } + } + + + } + + private boolean enrichEntityFromCurrentServiceTemplate(ToscaElementTypes elementType, + String typeId, Object entity, + ServiceTemplate serviceTemplate, + ToscaServiceModel toscaModel) { + String derivedFrom; + switch (elementType) { + case CAPABILITY_TYPE: + if (serviceTemplate.getCapability_types() != null + && serviceTemplate.getCapability_types().containsKey(typeId)) { + + CapabilityType targetCapabilityType = ((CapabilityType) entity); + CapabilityType sourceCapabilityType = serviceTemplate.getCapability_types().get(typeId); + derivedFrom = sourceCapabilityType.getDerived_from(); + if (derivedFrom != null + && !ToscaCapabilityType.NFV_METRIC.getDisplayName().equals(derivedFrom)) { + scanAnFlatEntity(elementType, derivedFrom, entity, serviceTemplate, toscaModel); + } + combineCapabilityTypeInfo(sourceCapabilityType, targetCapabilityType); + } else { + return false; + } + break; + default: + throw new RuntimeException( + "Entity[" + elementType + "] id[" + typeId + "] flat not supported"); + } + + return true; + + + } + + private void combineCapabilityTypeInfo(CapabilityType sourceCapabilityType, + CapabilityType targetCapabilityType) { + if (MapUtils.isNotEmpty(sourceCapabilityType.getAttributes())) { + if (targetCapabilityType.getAttributes() == null) { + targetCapabilityType.setAttributes(new HashMap<>()); + } + targetCapabilityType.getAttributes().putAll(sourceCapabilityType.getAttributes()); + } + + if (MapUtils.isNotEmpty(sourceCapabilityType.getProperties())) { + if (targetCapabilityType.getProperties() == null) { + targetCapabilityType.setProperties(new HashMap<>()); + } + targetCapabilityType.getProperties().putAll(sourceCapabilityType.getProperties()); + } + + if (CollectionUtils.isNotEmpty(sourceCapabilityType.getValid_source_types())) { + if (targetCapabilityType.getValid_source_types() == null) { + targetCapabilityType.setValid_source_types(new ArrayList<>()); + } + targetCapabilityType.getValid_source_types() + .addAll(sourceCapabilityType.getValid_source_types()); + } + + if (CommonMethods.isEmpty(sourceCapabilityType.getDerived_from())) { + targetCapabilityType.setDerived_from(sourceCapabilityType.getDerived_from()); + } + if (CommonMethods.isEmpty(sourceCapabilityType.getDescription())) { + targetCapabilityType.setDescription(sourceCapabilityType.getDescription()); + } + if (CommonMethods.isEmpty(sourceCapabilityType.getVersion())) { + targetCapabilityType.setVersion(sourceCapabilityType.getVersion()); + } + + + } + + +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java new file mode 100644 index 0000000000..d4c22f105f --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/impl/ToscaFileOutputServiceCsarImpl.java @@ -0,0 +1,158 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services.impl; + +import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.core.utilities.file.FileUtils; +import org.openecomp.sdc.common.errors.CoreException; +import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; +import org.openecomp.sdc.tosca.datatypes.model.ServiceTemplate; +import org.openecomp.sdc.tosca.exceptions.CsarCreationErrorBuilder; +import org.openecomp.sdc.tosca.exceptions.CsarMissingEntryPointErrorBuilder; +import org.openecomp.sdc.tosca.services.ToscaFileOutputService; + +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.Map; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; + +public class ToscaFileOutputServiceCsarImpl implements ToscaFileOutputService { + static final String EXTERNAL_ARTIFACTS_FOLDER_NAME = "Artifacts"; + private static final String DEFINITIONS_FOLDER_NAME = "Definitions"; + private static final String ARTIFACTS_FOLDER_NAME = "Artifacts"; + //todo currently duplicated, to be changed when external artifacts are separated from internal + private static final String TOSCA_META_FOLDER_NAME = "TOSCA-Metadata"; + private static final String TOSCA_META_FILE_VERSION = "TOSCA-Meta-File-Version"; + private static final String TOSCA_META_FILE_VERSION_VALUE = "1.0"; + private static final String TOSCA_META_FILE_NAME = "TOSCA.meta"; + private static final String CSAR_VERSION = "CSAR-Version"; + private static final String CSAR_VERSION_VALUE = "1.1"; + private static final String CREATED_BY = "Created-By"; + private static final String CREATED_BY_VALUE = "ASDC Onboarding portal"; + private static final String ENTRY_DEFINITIONS = "Entry-Definitions"; + private static final String META_FILE_DELIMITER = ":"; + private static final String SPACE = " "; + private static final String FILE_SEPARATOR = File.separator; + + @Override + public byte[] createOutputFile(ToscaServiceModel toscaServiceModel, + FileContentHandler externalArtifacts) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (ZipOutputStream zos = new ZipOutputStream(new BufferedOutputStream(baos))) { + packDefinitions(zos, toscaServiceModel.getServiceTemplates()); + FileContentHandler artifactFiles = toscaServiceModel.getArtifactFiles(); + if (artifactFiles != null && !artifactFiles.isEmpty()) { + packArtifacts(zos, artifactFiles); + } + if (toscaServiceModel.getEntryDefinitionServiceTemplate() == null) { + throw new CoreException(new CsarMissingEntryPointErrorBuilder().build()); + } + createAndPackToscaMetaFile(zos, toscaServiceModel.getEntryDefinitionServiceTemplate()); + if (externalArtifacts != null) { + packExternalArtifacts(zos, externalArtifacts); + } + } catch (IOException exc) { + throw new CoreException(new CsarCreationErrorBuilder().build(), exc); + } + return baos.toByteArray(); + } + + @Override + public String createMetaFile(String entryDefinitionsFileName) { + return TOSCA_META_FILE_VERSION + META_FILE_DELIMITER + SPACE + TOSCA_META_FILE_VERSION_VALUE + + System.lineSeparator() + + CSAR_VERSION + META_FILE_DELIMITER + SPACE + CSAR_VERSION_VALUE + System.lineSeparator() + + CREATED_BY + META_FILE_DELIMITER + SPACE + CREATED_BY_VALUE + System.lineSeparator() + + ENTRY_DEFINITIONS + META_FILE_DELIMITER + SPACE + DEFINITIONS_FOLDER_NAME + + FILE_SEPARATOR + entryDefinitionsFileName; + } + + @Override + public String getArtifactsFolderName() { + return ARTIFACTS_FOLDER_NAME; + } + + private void createAndPackToscaMetaFile(ZipOutputStream zos, String entryDefinitionsFileName) + throws IOException { + String metaFile = createMetaFile(entryDefinitionsFileName); + zos.putNextEntry( + new ZipEntry((TOSCA_META_FOLDER_NAME + FILE_SEPARATOR + TOSCA_META_FILE_NAME))); + writeBytesToZip(zos, new ByteArrayInputStream(metaFile.getBytes())); + } + + private void packDefinitions(ZipOutputStream zos, Map serviceTemplates) + throws IOException { + for (Map.Entry serviceTemplate : serviceTemplates.entrySet()) { + String fileName = serviceTemplate.getKey(); + zos.putNextEntry(new ZipEntry(DEFINITIONS_FOLDER_NAME + FILE_SEPARATOR + fileName)); + writeBytesToZip(zos, + FileUtils.convertToInputStream(serviceTemplate.getValue(), FileUtils.FileExtension.YAML)); + } + } + + private void packExternalArtifacts(ZipOutputStream zos, FileContentHandler externalArtifacts) { + + for (String filenameIncludingPath : externalArtifacts.getFileList()) { + try { + zos.putNextEntry(new ZipEntry(filenameIncludingPath)); + writeBytesToZip(zos, externalArtifacts.getFileContent(filenameIncludingPath)); + + } catch (IOException exc) { + throw new RuntimeException(exc); + } finally { + try { + zos.closeEntry(); + } catch (IOException ignore) { + //do nothing + } + } + } + + } + + private void packArtifacts(ZipOutputStream zos, FileContentHandler artifacts) { + + for (String fileName : artifacts.getFileList()) { + try { + zos.putNextEntry(new ZipEntry((ARTIFACTS_FOLDER_NAME + FILE_SEPARATOR + fileName))); + writeBytesToZip(zos, artifacts.getFileContent(fileName)); + + } catch (IOException exc) { + throw new RuntimeException(exc); + } finally { + try { + zos.closeEntry(); + } catch (IOException ignore) { + //do nothing + } + } + } + } + + private void writeBytesToZip(ZipOutputStream zos, InputStream is) throws IOException { + FileUtils.copy(is, zos); + } +} diff --git a/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/yamlutil/ToscaExtensionYamlUtil.java b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/yamlutil/ToscaExtensionYamlUtil.java new file mode 100644 index 0000000000..a1c11c2483 --- /dev/null +++ b/openecomp-be/lib/openecomp-tosca-lib/src/main/java/org/openecomp/sdc/tosca/services/yamlutil/ToscaExtensionYamlUtil.java @@ -0,0 +1,93 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdc.tosca.services.yamlutil; + +import org.openecomp.core.utilities.yaml.YamlUtil; +import org.yaml.snakeyaml.constructor.Constructor; +import org.yaml.snakeyaml.introspector.Property; +import org.yaml.snakeyaml.introspector.PropertyUtils; +import org.yaml.snakeyaml.nodes.MappingNode; +import org.yaml.snakeyaml.nodes.NodeId; + +import java.beans.IntrospectionException; + +public class ToscaExtensionYamlUtil extends YamlUtil { + + @Override + public Constructor getConstructor(Class typClass) { + return new ToscaWithHeatExtensionConstructor(typClass); + } + + @Override + protected PropertyUtils getPropertyUtils() { + return new ToscaPropertyUtilsWithHeatExtension(); + } + + public class ToscaPropertyUtilsWithHeatExtension extends MyPropertyUtils { + @Override + public Property getProperty(Class type, String name) + throws IntrospectionException { + try { + if (type.equals( + Class.forName("org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition"))) { + type = Class.forName( + "org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt"); + } + } catch (ClassNotFoundException exception) { + throw new RuntimeException(exception); + } + return super.getProperty(type, name); + } + } + + protected class ToscaWithHeatExtensionConstructor extends StrictMapAppenderConstructor { + public ToscaWithHeatExtensionConstructor(Class theRoot) { + super(theRoot); + yamlClassConstructors.put(NodeId.mapping, new MyPersistentObjectConstruct()); + } + + class MyPersistentObjectConstruct extends ConstructMapping { + @Override + protected Object constructJavaBean2ndStep(MappingNode node, Object object) { + Class type = node.getType(); + try { + if (type.equals( + Class.forName("org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition"))) { + Class extendHeatClass = Class.forName( + "org.openecomp.sdc.tosca.datatypes.model.heatextend.ParameterDefinitionExt"); + Object extendHeatObject = extendHeatClass.newInstance(); + // create JavaBean + return super.constructJavaBean2ndStep(node, extendHeatObject); + } else { + // create JavaBean + return super.constructJavaBean2ndStep(node, object); + } + } catch (ClassNotFoundException | InstantiationException + | IllegalAccessException exception) { + throw new RuntimeException(exception); + } + } + } + } +} + + + -- cgit 1.2.3-korg