diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp')
12 files changed, 42 insertions, 131 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java index d1e1250edd..88e96037f5 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/HeatToToscaUtil.java @@ -43,10 +43,6 @@ import org.openecomp.sdc.heat.services.tree.HeatTreeManager; import org.openecomp.sdc.heat.services.tree.HeatTreeManagerUtil; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; import org.openecomp.sdc.tosca.datatypes.ToscaElementTypes; import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; @@ -800,10 +796,7 @@ public class HeatToToscaUtil { return Optional.empty(); } Optional<AttachedPropertyVal> extractedProperty = extractProperty(property); - if (extractedProperty.isPresent()) { - return getParameterName(extractedProperty.get()); - } - return Optional.empty(); + return extractedProperty.flatMap(HeatToToscaUtil::getParameterName); } private static Optional<String> getParameterName(AttachedPropertyVal extractedProperty) { diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java index c084a6b876..d403fcbedc 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/TranslationService.java @@ -25,7 +25,6 @@ import org.apache.commons.collections4.MapUtils; import org.openecomp.core.translator.datatypes.TranslatorOutput; import org.openecomp.core.utilities.file.FileUtils; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.manifest.FileData; import org.openecomp.sdc.heat.datatypes.model.Environment; import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; @@ -33,10 +32,6 @@ import org.openecomp.sdc.heat.datatypes.model.Output; import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaGroupType; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; import org.openecomp.sdc.tosca.datatypes.model.GroupDefinition; @@ -68,7 +63,7 @@ import java.util.Set; public class TranslationService { - protected static Logger logger = (Logger) LoggerFactory.getLogger(TranslationService.class); + protected static Logger logger = LoggerFactory.getLogger(TranslationService.class); /** * Gets types to process by translator. * @@ -232,9 +227,7 @@ public class TranslationService { Optional<String> substitutableGroupMemberId = ToscaUtil.getSubstitutableGroupMemberId(heatFileName, serviceTemplate); - if (substitutableGroupMemberId.isPresent()) { - updatedMembersIds.add(substitutableGroupMemberId.get()); - } + substitutableGroupMemberId.ifPresent(updatedMembersIds::add); } private void translateInputParameters(ServiceTemplate serviceTemplate, diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java index dbf6bb1975..587b731a3e 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/BaseResourceConnection.java @@ -24,16 +24,11 @@ import org.apache.commons.collections4.MapUtils; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.manifest.FileData; import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.datatypes.model.NodeType; import org.openecomp.sdc.tosca.datatypes.model.RequirementAssignment; @@ -57,7 +52,7 @@ import java.util.Optional; import java.util.function.Predicate; abstract class BaseResourceConnection<T> { - protected static Logger logger = (Logger) LoggerFactory.getLogger(BaseResourceConnection.class); + protected static Logger logger = LoggerFactory.getLogger(BaseResourceConnection.class); protected TranslateTo translateTo; FileData nestedFileData; NodeTemplate substitutionNodeTemplate; diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/NovaToVolResourceConnection.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/NovaToVolResourceConnection.java index 02389d0b51..78021f3ba5 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/NovaToVolResourceConnection.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/NovaToVolResourceConnection.java @@ -22,15 +22,10 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslati import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.manifest.FileData; import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; import org.openecomp.sdc.heat.datatypes.model.Resource; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType; diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java index 6ba166ea47..8cccbb8894 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationBase.java @@ -22,13 +22,8 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslati import org.apache.commons.collections4.CollectionUtils; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.model.HeatOrchestrationTemplate; import org.openecomp.sdc.heat.datatypes.model.Resource; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType; import org.openecomp.sdc.tosca.datatypes.ToscaTopologyTemplateElements; @@ -60,7 +55,7 @@ import java.util.stream.Collectors; public abstract class ResourceTranslationBase { - protected static Logger logger = (Logger) LoggerFactory.getLogger(ResourceTranslationBase.class); + protected static Logger logger = LoggerFactory.getLogger(ResourceTranslationBase.class); protected abstract void translate(TranslateTo translateTo); /** @@ -92,8 +87,8 @@ public abstract class ResourceTranslationBase { if (!translatedId.isPresent()) { return Optional.empty(); } - logger.debug("Translate- file:" + heatFileName + " resource Id:" + resourceId - + " translated resource id:" + translatedId.get()); + logger.debug("Translate- file: {} resource Id: {} translated resource id: {}", + heatFileName, resourceId, translatedId.get()); TranslateTo translateTo = new TranslateTo(heatFileName, serviceTemplate, heatOrchestrationTemplate, resource, resourceId, translatedId.get(), context); translate(translateTo); @@ -200,10 +195,8 @@ public abstract class ResourceTranslationBase { generateTranslationTo(heatFileName, null, heatOrchestrationTemplate, resource, resourceId, null, context); - Optional<ToscaTopologyTemplateElements> translatedElementTemplate = - ResourceTranslationFactory.getInstance(resource) - .getTranslatedToscaTopologyElement(translateTo); - return translatedElementTemplate; + return ResourceTranslationFactory.getInstance(resource) + .getTranslatedToscaTopologyElement(translateTo); } protected String generateTranslatedId(TranslateTo translateTo) { @@ -248,13 +241,7 @@ public abstract class ResourceTranslationBase { private void updateResourceDependency(TranslateTo translateTo) { - String heatFileName = translateTo.getHeatFileName(); Resource resource = translateTo.getResource(); - HeatOrchestrationTemplate heatOrchestrationTemplate = translateTo - .getHeatOrchestrationTemplate(); - String translatedId = translateTo.getTranslatedId(); - ServiceTemplate serviceTemplate = translateTo.getServiceTemplate(); - TranslationContext context = translateTo.getContext(); if (resource.getDepends_on() == null) { return; } @@ -302,9 +289,8 @@ public abstract class ResourceTranslationBase { DataModelUtil.addRequirementAssignment( serviceTemplate.getTopology_template().getNode_templates().get(nodeTemplateId), ToscaConstants.DEPENDS_ON_REQUIREMENT_ID, requirementAssignment); - Resource dependsOnResource = targetResource; ConsolidationDataUtil - .updateNodesConnectedData(translateTo, dependsOnResourceId, dependsOnResource, + .updateNodesConnectedData(translateTo, dependsOnResourceId, targetResource, sourceResource, nodeTemplateId, ToscaConstants.DEPENDS_ON_REQUIREMENT_ID, requirementAssignment); } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImpl.java index 623eeca66b..72f96c744b 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationCinderVolumeAttachmentImpl.java @@ -22,17 +22,12 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslati import org.apache.commons.lang3.StringUtils; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.manifest.FileData; import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.heat.services.HeatConstants; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType; import org.openecomp.sdc.tosca.datatypes.ToscaTopologyTemplateElements; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; @@ -56,10 +51,12 @@ import java.util.Optional; import static org.openecomp.sdc.translator.services.heattotosca.HeatToToscaUtil.getResource; public class ResourceTranslationCinderVolumeAttachmentImpl extends ResourceTranslationBase { - protected static Logger logger = - (Logger) LoggerFactory.getLogger(ResourceTranslationCinderVolumeAttachmentImpl.class); - private String volumeIdPropertyName = "volume_id"; - private String toscaCapabilityAttachment = "tosca.capabilities.Attachment"; + + private static final String UNSUPPORTED_VOLUME_ATTACHMENT_MSG = + "Volume attachment with id '{}' is pointing to unsupported resource type({}) through the property " + + "'volume_id'. The connection to the volume is ignored. Supported types are: {}"; + + protected static Logger logger = LoggerFactory.getLogger(ResourceTranslationCinderVolumeAttachmentImpl.class); @Override protected void translate(TranslateTo translateTo) { @@ -74,6 +71,7 @@ public class ResourceTranslationCinderVolumeAttachmentImpl extends ResourceTrans translateTo.getHeatOrchestrationTemplate(), translateTo.getResource().getType(), relationTemplate, translateTo.getContext())); + String volumeIdPropertyName = "volume_id"; AttachedResourceId attachedVolumeId = getAttachedResourceId(translateTo, volumeIdPropertyName); String instanceUuid = HeatConstants.INSTANCE_UUID_PROPERTY_NAME; AttachedResourceId attachedNovaServerId = getAttachedResourceId(translateTo, instanceUuid); @@ -112,18 +110,15 @@ public class ResourceTranslationCinderVolumeAttachmentImpl extends ResourceTrans String relationshipTemplateId, String heatFileName, AttachedResourceId volResourceId, String novaResourceId) { RequirementAssignment requirement = new RequirementAssignment(); + String toscaCapabilityAttachment = "tosca.capabilities.Attachment"; requirement.setCapability(toscaCapabilityAttachment); if (volResourceId.isGetResource()) { Resource volServerResource = getResource(translateTo.getHeatOrchestrationTemplate(), (String) volResourceId.getTranslatedId(), heatFileName); if (!StringUtils.equals(HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE.getHeatResource(), volServerResource.getType())) { - logger.warn("Volume attachment with id '" + translateTo.getResourceId() - + "' is pointing to unsupported resource type(" + volServerResource.getType() - + ") through the property 'volume_id'." - + " The connection to the volume is ignored. " - + "Supported types are: " - + HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE.getHeatResource()); + logger.warn(UNSUPPORTED_VOLUME_ATTACHMENT_MSG, translateTo.getResourceId(), volServerResource.getType(), + HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE.getHeatResource()); return; } requirement.setNode((String) volResourceId.getTranslatedId()); @@ -140,12 +135,8 @@ public class ResourceTranslationCinderVolumeAttachmentImpl extends ResourceTrans .getHeatResource(); if (!StringUtils.equals(HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE.getHeatResource(), volServerResource.getType())) { - logger.warn("Volume attachment with id '" + translateTo.getResourceId() - + "' is pointing to unsupported resource type(" + volServerResource.getType() - + ") through the property 'volume_id'." - + " The connection to the volume is ignored. " - + "Supported types are: " - + HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE.getHeatResource()); + logger.warn(UNSUPPORTED_VOLUME_ATTACHMENT_MSG, translateTo.getResourceId(), volServerResource.getType(), + HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE.getHeatResource()); return; } requirement.setNode( @@ -164,12 +155,8 @@ public class ResourceTranslationCinderVolumeAttachmentImpl extends ResourceTrans getResource(translateTo.getHeatOrchestrationTemplate(), novaResourceId, heatFileName); if (!StringUtils.equals(HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), novaServerResource.getType())) { - logger.warn("Volume attachment with id '" + translateTo.getResourceId() - + "' is pointing to unsupported resource type(" + novaServerResource.getType() - + ") through the property 'instance_uuid'." - + " The connection to the nova server is ignored. " - + "Supported types are: " - + HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource()); + logger.warn(UNSUPPORTED_VOLUME_ATTACHMENT_MSG,translateTo.getResourceId(), + novaServerResource.getType(), HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource()); return; } Optional<String> translatedNovaServerId = diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailAttachPolicyImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailAttachPolicyImpl.java index b225061bc2..c6719afa92 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailAttachPolicyImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailAttachPolicyImpl.java @@ -21,14 +21,9 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; import org.openecomp.sdc.tosca.datatypes.ToscaRelationshipType; import org.openecomp.sdc.tosca.datatypes.ToscaTopologyTemplateElements; @@ -45,8 +40,8 @@ import org.openecomp.sdc.translator.services.heattotosca.errors.MissingMandatory import java.util.Optional; public class ResourceTranslationContrailAttachPolicyImpl extends ResourceTranslationBase { - protected static Logger logger = - (Logger) LoggerFactory.getLogger(ResourceTranslationContrailAttachPolicyImpl.class); + + protected static Logger logger = LoggerFactory.getLogger(ResourceTranslationContrailAttachPolicyImpl.class); @Override protected void translate(TranslateTo translateTo) { @@ -86,10 +81,9 @@ public class ResourceTranslationContrailAttachPolicyImpl extends ResourceTransla if (policyResourceId.isPresent()) { policyNodeTemplate = getPolicyNodeTemplate(translateTo, heatFileName, policyResourceId.get()); } else { - logger.warn("Heat resource: '" + translateTo.getResourceId() + "' with type: '" - + translateTo.getResource().getType() - + "' include 'policy' property without 'get_attr' of 'fq_name'/'get_resource' function," - + " therefore this resource will be ignored in TOSCA translation."); + logger.warn("Heat resource: '{}' with type: '{}' include 'policy' property without 'get_attr' of " + + "'fq_name'/'get_resource' function, therefore this resource will be ignored in TOSCA translation.", + translateTo.getResourceId(), translateTo.getResource().getType()); } return policyNodeTemplate; } @@ -104,10 +98,9 @@ public class ResourceTranslationContrailAttachPolicyImpl extends ResourceTransla translateTo.getHeatOrchestrationTemplate(), policyResource, policyResourceId, translateTo.getContext()); if (!translatedPolicyResourceId.isPresent()) { - logger.warn("Heat resource: '" + translateTo.getResourceId() + "' with type: '" - + translateTo.getResource().getType() - + "' include unsupported policy resource, therefore this resource will be ignored in " - + "TOSCA translation. "); + logger.warn("Heat resource: '{}' with type: '{}' include unsupported policy resource, " + + "therefore this resource will be ignored in TOSCA translation.", + translateTo.getResourceId(), translateTo.getResource().getType()); return null; } return DataModelUtil @@ -122,10 +115,9 @@ public class ResourceTranslationContrailAttachPolicyImpl extends ResourceTransla if (attachedNetworkResourceId.isGetResource()) { translatedNetworkResourceId = (String) attachedNetworkResourceId.getTranslatedId(); } else { - logger.warn("Heat resource: '" + translateTo.getResourceId() + "' with type: '" - + translateTo.getResource().getType() - + "' include 'network' property without 'get_resource' function, therefore this " - + "resource will be ignored in TOSCA translation."); + logger.warn("Heat resource: '{}' with type: '{}' include 'network' property without 'get_resource' " + + "function, therefore this resource will be ignored in TOSCA translation.", + translateTo.getResourceId(), translateTo.getResource().getType()); } return translatedNetworkResourceId; } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java index 4661a792db..72251fa85c 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceInstanceImpl.java @@ -21,17 +21,12 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.HeatBoolean; import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.heat.services.HeatConstants; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaCapabilityType; import org.openecomp.sdc.tosca.datatypes.ToscaFunctions; import org.openecomp.sdc.tosca.datatypes.ToscaGroupType; @@ -75,8 +70,8 @@ import java.util.Objects; import java.util.Optional; public class ResourceTranslationContrailServiceInstanceImpl extends ResourceTranslationBase { - protected static Logger logger = - (Logger) LoggerFactory.getLogger(ResourceTranslationContrailServiceInstanceImpl.class); + + protected static Logger logger = LoggerFactory.getLogger(ResourceTranslationContrailServiceInstanceImpl.class); @Override public void translate(TranslateTo translateTo) { @@ -113,10 +108,6 @@ public class ResourceTranslationContrailServiceInstanceImpl extends ResourceTran + "' in property 'service_template'" + ", therefore this resource will be ignored in TOSCA translation."); return; - /*throw new CoreException(new ReferenceToUnsupportedResourceErrorBuilder - (translateTo.getResourceId(), translateTo.getResource().getType(), - contrailServiceTemplateResourceId, contrailServiceTemplateResource - .getType(), "service_template").build());*/ } ServiceTemplate globalSubstitutionServiceTemplate = @@ -210,7 +201,7 @@ public class ResourceTranslationContrailServiceInstanceImpl extends ResourceTran Resource contrailServiceTemplateResource) { Object serviceScalingPropertyValue = contrailServiceTemplateResource.getProperties() .get(HeatConstants.SERVICE_SCALING_PROPERTY_NAME); - Object serviceScalingValue = null; + Object serviceScalingValue; if (serviceScalingPropertyValue != null) { serviceScalingValue = TranslatorHeatToToscaPropertyConverter .getToscaPropertyValue(translateTo.getServiceTemplate(), translateTo.getTranslatedId(), @@ -326,7 +317,7 @@ public class ResourceTranslationContrailServiceInstanceImpl extends ResourceTran String heatStackGroupKey, NodeTemplate substitutedNodeTemplate, boolean orderedInterfaces, String computeNodeTemplateId) { if (index == null) { - index = new Integer(0); + index = 0; } NodeTemplate portNodeTemplate = createPortNodeTemplate(index, orderedInterfaces, computeNodeTemplateId); @@ -405,8 +396,6 @@ public class ResourceTranslationContrailServiceInstanceImpl extends ResourceTran + translateTo.getResource().getType() + "' missing 'virtual_network' property in 'interface_list' entry, therefore, no " + "network connection is define for this entry."); - //throw new CoreException(new - // MissingMandatoryPropertyErrorBuilder("virtual_network").build()); } } } diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceTemplateImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceTemplateImpl.java index 7e2871043c..b4e0d839d7 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceTemplateImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationContrailServiceTemplateImpl.java @@ -21,11 +21,6 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaNodeType; import org.openecomp.sdc.tosca.datatypes.ToscaTopologyTemplateElements; import org.openecomp.sdc.tosca.datatypes.model.NodeType; diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronSubnetImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronSubnetImpl.java index 83df81046a..264232b770 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronSubnetImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationNeutronSubnetImpl.java @@ -21,15 +21,10 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.HeatBoolean; import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.logging.api.Logger; import org.openecomp.sdc.logging.api.LoggerFactory; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaFunctions; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.datatypes.model.ParameterDefinition; @@ -48,8 +43,8 @@ import java.util.Map; import java.util.Optional; public class ResourceTranslationNeutronSubnetImpl extends ResourceTranslationBase { - protected static Logger logger = - (Logger) LoggerFactory.getLogger(ResourceTranslationNeutronSubnetImpl.class); + + protected static Logger logger = LoggerFactory.getLogger(ResourceTranslationNeutronSubnetImpl.class); @Override public void translate(TranslateTo translateTo) { @@ -155,7 +150,7 @@ public class ResourceTranslationNeutronSubnetImpl extends ResourceTranslationBas } private Optional<AttachedResourceId> getAttachedNetworkResource(TranslateTo translateTo) { - Optional<AttachedResourceId> subnetNetwork = Optional.empty(); + Optional<AttachedResourceId> subnetNetwork; Optional<AttachedResourceId> attachedNetworkId = HeatToToscaUtil.extractAttachedResourceId(translateTo, "network_id"); if (!attachedNetworkId.isPresent()) { diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationResourceGroupImpl.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationResourceGroupImpl.java index 31956fb35b..6afaf79cb9 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationResourceGroupImpl.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/services/heattotosca/impl/resourcetranslation/ResourceTranslationResourceGroupImpl.java @@ -21,14 +21,9 @@ package org.openecomp.sdc.translator.services.heattotosca.impl.resourcetranslation; import org.openecomp.sdc.common.errors.CoreException; -import org.openecomp.sdc.datatypes.error.ErrorLevel; import org.openecomp.sdc.heat.datatypes.model.HeatResourcesTypes; import org.openecomp.sdc.heat.datatypes.model.Resource; import org.openecomp.sdc.heat.services.HeatConstants; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; -import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import org.openecomp.sdc.tosca.datatypes.ToscaFunctions; import org.openecomp.sdc.tosca.datatypes.model.NodeTemplate; import org.openecomp.sdc.tosca.services.DataModelUtil; diff --git a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java index 7ad2cf9c60..dfeea57163 100644 --- a/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java +++ b/openecomp-be/lib/openecomp-sdc-translator-lib/openecomp-sdc-translator-core/src/main/java/org/openecomp/sdc/translator/utils/ResourceWalker.java @@ -20,11 +20,7 @@ import org.apache.commons.io.IOUtils; import org.openecomp.sdc.common.errors.CoreException; import org.openecomp.sdc.common.errors.ErrorCategory; import org.openecomp.sdc.common.errors.ErrorCode; -import org.openecomp.sdc.datatypes.error.ErrorLevel; -import org.openecomp.sdc.logging.types.LoggerConstants; -import org.openecomp.sdc.logging.types.LoggerErrorCode; import org.openecomp.sdc.logging.types.LoggerErrorDescription; -import org.openecomp.sdc.logging.types.LoggerTragetServiceName; import java.io.BufferedReader; import java.io.File; |