X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-be%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Fcomponents%2Fimpl%2FServiceImportParseLogic.java;h=5bde56de8049c2d5288a9d95b830935357f9ff32;hb=7c61c7bb0369bc27d05c8801c8cb0cca41e494bf;hp=994092911f01f66c3b47b815cc8b5edc7ea7febe;hpb=df1e300dad94d65a88d2012df9096961619d8272;p=sdc.git diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java index 994092911f..5bde56de80 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java @@ -18,14 +18,12 @@ package org.openecomp.sdc.be.components.impl; import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; import static java.util.stream.Collectors.toMap; -import static java.util.stream.Collectors.toSet; import static org.apache.commons.collections.CollectionUtils.isNotEmpty; import fj.data.Either; import java.util.ArrayList; import java.util.EnumMap; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.ListIterator; @@ -34,13 +32,13 @@ import java.util.Optional; import java.util.Set; import java.util.function.Function; import lombok.Getter; -import lombok.Setter; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.components.csar.CsarInfo; import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo; +import org.openecomp.sdc.be.components.impl.exceptions.BusinessLogicException; import org.openecomp.sdc.be.components.impl.exceptions.ByResponseFormatComponentException; import org.openecomp.sdc.be.components.impl.exceptions.ComponentException; import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic; @@ -52,9 +50,12 @@ import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition; import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition; import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.ListDataDefinition; import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.MapInterfaceDataDefinition; import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition; import org.openecomp.sdc.be.datatypes.elements.RequirementDataDefinition; +import org.openecomp.sdc.be.datatypes.elements.SubstitutionFilterPropertyDataDefinition; import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum; import org.openecomp.sdc.be.datatypes.enums.CreatedFrom; import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum; @@ -77,6 +78,7 @@ import org.openecomp.sdc.be.model.LifeCycleTransitionEnum; import org.openecomp.sdc.be.model.LifecycleStateEnum; import org.openecomp.sdc.be.model.NodeTypeInfo; import org.openecomp.sdc.be.model.Operation; +import org.openecomp.sdc.be.model.OutputDefinition; import org.openecomp.sdc.be.model.PropertyDefinition; import org.openecomp.sdc.be.model.RelationshipImpl; import org.openecomp.sdc.be.model.RelationshipInfo; @@ -87,6 +89,7 @@ import org.openecomp.sdc.be.model.Service; import org.openecomp.sdc.be.model.UploadCapInfo; import org.openecomp.sdc.be.model.UploadComponentInstanceInfo; import org.openecomp.sdc.be.model.UploadInfo; +import org.openecomp.sdc.be.model.UploadNodeFilterInfo; import org.openecomp.sdc.be.model.UploadPropInfo; import org.openecomp.sdc.be.model.UploadReqInfo; import org.openecomp.sdc.be.model.UploadResourceInfo; @@ -111,12 +114,10 @@ import org.openecomp.sdc.common.log.wrappers.Logger; import org.openecomp.sdc.common.util.GeneralUtility; import org.openecomp.sdc.common.util.ValidationUtils; import org.openecomp.sdc.exception.ResponseFormat; -import org.springframework.beans.factory.annotation.Autowired; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; @Getter -@Setter @org.springframework.stereotype.Component public class ServiceImportParseLogic { @@ -131,22 +132,39 @@ public class ServiceImportParseLogic { private static final String CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES = "Create Resource - validateCapabilityTypesCreate"; private static final String CATEGORY_IS_EMPTY = "Resource category is empty"; private static final Logger log = Logger.getLogger(ServiceImportParseLogic.class); - @Autowired - private ServiceBusinessLogic serviceBusinessLogic; - @Autowired - private ComponentsUtils componentsUtils; - @Autowired - private ToscaOperationFacade toscaOperationFacade; - @Autowired - private LifecycleBusinessLogic lifecycleBusinessLogic; - @Autowired - private InputsBusinessLogic inputsBusinessLogic; - @Autowired - private ResourceImportManager resourceImportManager; - @Autowired - private IInterfaceLifecycleOperation interfaceTypeOperation = null; - @Autowired - private ICapabilityTypeOperation capabilityTypeOperation = null; + private final ServiceBusinessLogic serviceBusinessLogic; + private final ComponentsUtils componentsUtils; + private final ToscaOperationFacade toscaOperationFacade; + private final LifecycleBusinessLogic lifecycleBusinessLogic; + private final InputsBusinessLogic inputsBusinessLogic; + private final ResourceImportManager resourceImportManager; + private final ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic; + private final IInterfaceLifecycleOperation interfaceTypeOperation; + private final ICapabilityTypeOperation capabilityTypeOperation; + private final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic; + private final GroupBusinessLogic groupBusinessLogic; + private final OutputsBusinessLogic outputsBusinessLogic; + + public ServiceImportParseLogic(final ServiceBusinessLogic serviceBusinessLogic, final ComponentsUtils componentsUtils, + final ToscaOperationFacade toscaOperationFacade, final LifecycleBusinessLogic lifecycleBusinessLogic, + final InputsBusinessLogic inputsBusinessLogic, final ResourceImportManager resourceImportManager, + final ComponentSubstitutionFilterBusinessLogic substitutionFilterBusinessLogic, + final IInterfaceLifecycleOperation interfaceTypeOperation, final ICapabilityTypeOperation capabilityTypeOperation, + final ComponentNodeFilterBusinessLogic componentNodeFilterBusinessLogic, + final GroupBusinessLogic groupBusinessLogic, final OutputsBusinessLogic outputsBusinessLogic) { + this.serviceBusinessLogic = serviceBusinessLogic; + this.componentsUtils = componentsUtils; + this.toscaOperationFacade = toscaOperationFacade; + this.lifecycleBusinessLogic = lifecycleBusinessLogic; + this.inputsBusinessLogic = inputsBusinessLogic; + this.resourceImportManager = resourceImportManager; + this.substitutionFilterBusinessLogic = substitutionFilterBusinessLogic; + this.interfaceTypeOperation = interfaceTypeOperation; + this.capabilityTypeOperation = capabilityTypeOperation; + this.componentNodeFilterBusinessLogic = componentNodeFilterBusinessLogic; + this.groupBusinessLogic = groupBusinessLogic; + this.outputsBusinessLogic = outputsBusinessLogic; + } public Either>>, ResponseFormat> findNodeTypesArtifactsToHandle( Map nodeTypesInfo, CsarInfo csarInfo, Service oldResource) { @@ -441,31 +459,6 @@ public class ServiceImportParseLogic { return componentTypeForResponse; } - protected boolean isfillGroupMemebersRecursivlyStopCondition(String groupName, Map allGroups, - Set allGroupMembers) { - boolean stop = false; - // In Case Not Group Stop - if (!allGroups.containsKey(groupName)) { - stop = true; - } - // In Case Group Has no members stop - if (!stop) { - GroupDefinition groupDefinition = allGroups.get(groupName); - stop = MapUtils.isEmpty(groupDefinition.getMembers()); - } - // In Case all group members already contained stop - if (!stop) { - final Set allMembers = allGroups.get(groupName).getMembers().keySet(); - Set membersOfTypeGroup = allMembers.stream(). - // Filter In Only Group members - filter(allGroups::containsKey). - // Collect - collect(toSet()); - stop = allGroupMembers.containsAll(membersOfTypeGroup); - } - return stop; - } - public Resource buildValidComplexVfc(Resource resource, CsarInfo csarInfo, String nodeName, Map nodesInfo) { Resource complexVfc = buildComplexVfcMetadata(resource, csarInfo, nodeName, nodesInfo); log.debug("************* Going to validate complex VFC from yaml {}", complexVfc.getName()); @@ -521,7 +514,8 @@ public class ServiceImportParseLogic { while (intItr.hasNext() && eitherResult.isLeft()) { InterfaceDefinition interfaceDefinition = intItr.next(); String intType = interfaceDefinition.getUniqueId(); - Either eitherCapTypeFound = interfaceTypeOperation.getInterface(intType); + Either eitherCapTypeFound = interfaceTypeOperation.getInterface( + UniqueIdBuilder.buildInterfaceTypeUid(resource.getModel(), intType)); if (eitherCapTypeFound.isRight()) { if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) { BeEcompErrorManager.getInstance() @@ -571,7 +565,7 @@ public class ServiceImportParseLogic { Map.Entry> typeEntry, boolean inTransaction) { Either eitherCapTypeFound = capabilityTypeOperation - .getCapabilityType(typeEntry.getKey(), inTransaction); + .getCapabilityType(UniqueIdBuilder.buildCapabilityTypeUid(resource.getModel(), typeEntry.getKey()), inTransaction); if (eitherCapTypeFound.isRight()) { if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) { BeEcompErrorManager.getInstance() @@ -623,7 +617,7 @@ public class ServiceImportParseLogic { boolean inTransaction) { try { Either eitherCapTypeFound = capabilityTypeOperation - .getCapabilityType(type, inTransaction); + .getCapabilityType(UniqueIdBuilder.buildCapabilityTypeUid(resource.getModel(), type), inTransaction); if (eitherCapTypeFound.isRight()) { if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) { BeEcompErrorManager.getInstance() @@ -922,6 +916,7 @@ public class ServiceImportParseLogic { cvfc.setContactId(csarInfo.getModifier().getUserId()); cvfc.setCreatorUserId(csarInfo.getModifier().getUserId()); cvfc.setVendorName(resourceVf.getVendorName()); + cvfc.setTenant(resourceVf.getTenant()); cvfc.setVendorRelease(resourceVf.getVendorRelease()); cvfc.setResourceVendorModelNumber(resourceVf.getResourceVendorModelNumber()); cvfc.setToscaResourceName(buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(), nodeName).getLeft()); @@ -987,6 +982,7 @@ public class ServiceImportParseLogic { resourceMetaData.setIcon(ImportUtils.Constants.DEFAULT_ICON); resourceMetaData.setContactId(user.getUserId()); resourceMetaData.setVendorName(resourceVf.getVendorName()); + resourceMetaData.setTenant(resourceVf.getTenant()); resourceMetaData.setVendorRelease(resourceVf.getVendorRelease()); // Setting tag List tags = new ArrayList<>(); @@ -1018,9 +1014,9 @@ public class ServiceImportParseLogic { } } - public Either findAviableRequiremen(String regName, String yamlName, - UploadComponentInstanceInfo uploadComponentInstanceInfo, - ComponentInstance currentCompInstance, String capName) { + public Either findAvailableRequirement(String regName, String yamlName, + UploadComponentInstanceInfo uploadComponentInstanceInfo, + ComponentInstance currentCompInstance, String capName) { Map> comInstRegDefMap = currentCompInstance.getRequirements(); List list = comInstRegDefMap.get(capName); RequirementDefinition validRegDef = null; @@ -1039,8 +1035,6 @@ public class ServiceImportParseLogic { reqDef.setLeftOccurrences(String.valueOf(left)); validRegDef = reqDef; break; - } else { - continue; } } else { validRegDef = reqDef; @@ -1066,8 +1060,6 @@ public class ServiceImportParseLogic { reqDef.setLeftOccurrences(String.valueOf(left)); validRegDef = reqDef; break; - } else { - continue; } } else { validRegDef = reqDef; @@ -1222,7 +1214,7 @@ public class ServiceImportParseLogic { String propertyName = property.getName().toLowerCase(); String propertyType = property.getType(); ComponentInstanceProperty validProperty; - if (defaultProperties.containsKey(propertyName) && propertTypeEqualsTo(defaultProperties, propertyName, propertyType)) { + if (defaultProperties.containsKey(propertyName) && propertyTypeEqualsTo(defaultProperties, propertyName, propertyType)) { throw new ComponentException(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NAME_ALREADY_EXISTS, propertyName)); } validProperty = new ComponentInstanceProperty(); @@ -1237,7 +1229,7 @@ public class ServiceImportParseLogic { defaultCapability.setProperties(validProperties); } - private boolean propertTypeEqualsTo(Map defaultProperties, String propertyName, String propertyType) { + private boolean propertyTypeEqualsTo(Map defaultProperties, String propertyName, String propertyType) { return propertyType != null && !defaultProperties.get(propertyName).getType().equals(propertyType); } @@ -1315,6 +1307,7 @@ public class ServiceImportParseLogic { cvfc.setContactId(csarInfo.getModifier().getUserId()); cvfc.setCreatorUserId(csarInfo.getModifier().getUserId()); cvfc.setVendorName("cmri"); + cvfc.setTenant("tenant"); cvfc.setVendorRelease("1.0"); cvfc.setResourceVendorModelNumber(""); cvfc.setToscaResourceName(buildNestedToscaResourceName(ResourceTypeEnum.VF.name(), csarInfo.getVfResourceName(), nodeName).getLeft()); @@ -1371,32 +1364,75 @@ public class ServiceImportParseLogic { return updatedResource.left().value(); } - public Service createServiceTransaction(Service service, User user, boolean isNormative) { - // validate resource name uniqueness - log.debug("validate resource name"); - Either eitherValidation = toscaOperationFacade - .validateComponentNameExists(service.getName(), null, service.getComponentType()); - if (eitherValidation.isRight()) { - log.debug("Failed to validate component name {}. Status is {}. ", service.getName(), eitherValidation.right().value()); - ResponseFormat errorResponse = componentsUtils - .getResponseFormat(componentsUtils.convertFromStorageResponse(eitherValidation.right().value())); - throw new ComponentException(errorResponse); + public Service createOutputsOnService(final Service service, final Map outputs, final String userId) { + if (MapUtils.isNotEmpty(outputs) || isNotEmpty(service.getOutputs())) { + final Either, ResponseFormat> createOutputs = outputsBusinessLogic.createOutputsInGraph(outputs, service, userId); + if (createOutputs.isRight()) { + throw new ComponentException(createOutputs.right().value()); + } + } else { + return service; + } + final Either updatedResource = toscaOperationFacade.getToscaElement(service.getUniqueId()); + if (updatedResource.isRight()) { + throw new ComponentException( + componentsUtils.getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, + ComponentTypeEnum.SERVICE)); + } + return updatedResource.left().value(); + } + + public Service createSubstitutionFilterOnService(Service service, + ListDataDefinition substitutionFilterProperties) + throws BusinessLogicException { + if (substitutionFilterProperties == null || substitutionFilterProperties.isEmpty()) { + return service; } - if (eitherValidation.left().value()) { - log.debug("resource with name: {}, already exists", service.getName()); - ResponseFormat errorResponse = componentsUtils - .getResponseFormat(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), service.getName()); - throw new ComponentException(errorResponse); + substitutionFilterBusinessLogic.addSubstitutionFilterInGraph(service.getUniqueId(), substitutionFilterProperties); + Either updatedResource = toscaOperationFacade.getToscaElement(service.getUniqueId()); + if (updatedResource.isRight()) { + throw new ComponentException(componentsUtils + .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, + ComponentTypeEnum.SERVICE)); + } + return updatedResource.left().value(); + } + + + public Service createServiceTransaction(Service service, User user, boolean isNormative, AuditingActionEnum auditingAction) { + if (!AuditingActionEnum.UPDATE_SERVICE_TOSCA_TEMPLATE.equals(auditingAction) && + !AuditingActionEnum.UPDATE_SERVICE_TOSCA_MODEL.equals(auditingAction)) { + // validate resource name uniqueness + log.debug("validate resource name"); + Either eitherValidation = toscaOperationFacade + .validateComponentNameExists(service.getName(), null, service.getComponentType()); + if (eitherValidation.isRight()) { + log.debug("Failed to validate component name {}. Status is {}. ", service.getName(), eitherValidation.right().value()); + ResponseFormat errorResponse = componentsUtils + .getResponseFormat(componentsUtils.convertFromStorageResponse(eitherValidation.right().value())); + throw new ComponentException(errorResponse); + } + if (eitherValidation.left().value()) { + log.debug("resource with name: {}, already exists", service.getName()); + ResponseFormat errorResponse = componentsUtils + .getResponseFormat(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), service.getName()); + throw new ComponentException(errorResponse); + } } log.debug("send resource {} to dao for create", service.getName()); createArtifactsPlaceHolderData(service, user); // enrich object - if (!isNormative) { + if (!isNormative && !AuditingActionEnum.UPDATE_SERVICE_TOSCA_TEMPLATE.equals(auditingAction) && + !AuditingActionEnum.UPDATE_SERVICE_TOSCA_MODEL.equals(auditingAction)) { log.debug("enrich resource with creator, version and state"); service.setLifecycleState(LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT); service.setVersion(INITIAL_VERSION); service.setHighestVersion(true); } + if (AuditingActionEnum.UPDATE_SERVICE_TOSCA_TEMPLATE.equals(auditingAction) || + AuditingActionEnum.UPDATE_SERVICE_TOSCA_MODEL.equals(auditingAction)) { + toscaOperationFacade.deleteService(service.getInvariantUUID(), false); + } return toscaOperationFacade.createToscaComponent(service).left().on(r -> throwComponentExceptionByResource(r, service)); } @@ -1636,18 +1672,16 @@ public class ServiceImportParseLogic { if (isNotEmpty(groupsToCreate)) { fillGroupsFinalFields(groupsToCreate); if (isNotEmpty(groupsFromResource)) { - serviceBusinessLogic.groupBusinessLogic.addGroups(resource, groupsToCreate, true).left() - .on(serviceBusinessLogic::throwComponentException); + groupBusinessLogic.addGroups(resource, groupsToCreate, true).left().on(serviceBusinessLogic::throwComponentException); } else { - serviceBusinessLogic.groupBusinessLogic.createGroups(resource, groupsToCreate, true).left() - .on(serviceBusinessLogic::throwComponentException); + groupBusinessLogic.createGroups(resource, groupsToCreate, true).left().on(serviceBusinessLogic::throwComponentException); } } if (isNotEmpty(groupsToDelete)) { - serviceBusinessLogic.groupBusinessLogic.deleteGroups(resource, groupsToDelete).left().on(serviceBusinessLogic::throwComponentException); + groupBusinessLogic.deleteGroups(resource, groupsToDelete).left().on(serviceBusinessLogic::throwComponentException); } if (isNotEmpty(groupsToUpdate)) { - serviceBusinessLogic.groupBusinessLogic.updateGroups(resource, groupsToUpdate, true).left() + groupBusinessLogic.updateGroups(resource, groupsToUpdate, true).left() .on(serviceBusinessLogic::throwComponentException); } } @@ -1683,10 +1717,6 @@ public class ServiceImportParseLogic { List result = new ArrayList<>(); List componentInstances = component.getComponentInstances(); if (groups != null) { - Either validateCyclicGroupsDependencies = validateCyclicGroupsDependencies(groups); - if (validateCyclicGroupsDependencies.isRight()) { - throw new ComponentException(validateCyclicGroupsDependencies.right().value()); - } for (Map.Entry entry : groups.entrySet()) { String groupName = entry.getKey(); GroupDefinition groupDefinition = entry.getValue(); @@ -1733,55 +1763,6 @@ public class ServiceImportParseLogic { updatedGroupDefinition.setMembers(relevantInstances); } - public Either validateCyclicGroupsDependencies(Map allGroups) { - Either result = Either.left(true); - try { - Iterator> allGroupsItr = allGroups.entrySet().iterator(); - while (allGroupsItr.hasNext() && result.isLeft()) { - Map.Entry groupAEntry = allGroupsItr.next(); - // Fetches a group member A - String groupAName = groupAEntry.getKey(); - // Finds all group members in group A - Set allGroupAMembersNames = new HashSet<>(); - fillAllGroupMemebersRecursivly(groupAEntry.getKey(), allGroups, allGroupAMembersNames); - // If A is a group member of itself found cyclic dependency - if (allGroupAMembersNames.contains(groupAName)) { - ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GROUP_HAS_CYCLIC_DEPENDENCY, groupAName); - result = Either.right(responseFormat); - } - } - } catch (Exception e) { - ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR); - result = Either.right(responseFormat); - log.debug("Exception occured when validateCyclicGroupsDependencies, error is:{}", e.getMessage(), e); - } - return result; - } - - protected void fillAllGroupMemebersRecursivly(String groupName, Map allGroups, Set allGroupMembers) { - // Found Cyclic dependency - if (isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)) { - return; - } - GroupDefinition groupDefinition = allGroups.get(groupName); - // All Members Of Current Group Resource Instances & Other Groups - Set currGroupMembers = groupDefinition.getMembers().keySet(); - // Filtered Members Of Current Group containing only members which - - // are groups - List currGroupFilteredMembers = currGroupMembers.stream(). - // Keep Only Elements of type group and not Resource Instances - filter(allGroups::containsKey). - // Add Filtered Elements to main Set - peek(allGroupMembers::add). - // Collect results - collect(toList()); - // Recursively call the method for all the filtered group members - for (String innerGroupName : currGroupFilteredMembers) { - fillAllGroupMemebersRecursivly(innerGroupName, allGroups, allGroupMembers); - } - } - public ImmutablePair createResourceFromNodeType(String nodeTypeYaml, UploadResourceInfo resourceMetaData, User creator, boolean isInTransaction, boolean needLock, Map> nodeTypeArtifactsToHandle, @@ -1793,7 +1774,7 @@ public class ServiceImportParseLogic { Function validator = resource -> validateResourceCreationFromNodeType(resource, creator); return resourceImportManager .importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, true, needLock, - nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested); + nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested, null); } public ImmutablePair createNodeTypeResourceFromYaml(String yamlName, Map.Entry nodeNameValue, User user, @@ -2035,6 +2016,33 @@ public class ServiceImportParseLogic { } } + public void associateComponentInstanceInterfacesToComponent( + String yamlName, + Service service, + Map> instInterfaces + ) { + if (MapUtils.isNotEmpty(instInterfaces)) { + Either, StorageOperationStatus> addInterfaceToInst = + toscaOperationFacade + .associateComponentInstanceInterfacesToComponent( + instInterfaces, + service.getUniqueId() + ); + if (addInterfaceToInst.isRight()) { + log.error("failed to associate interfaces value of service {}, status is {}", service.getUniqueId(), + addInterfaceToInst.right().value()); + throw new ComponentException( + componentsUtils.getResponseFormat( + componentsUtils.convertFromStorageResponse( + addInterfaceToInst.right().value() + ), + yamlName + ) + ); + } + } + } + public void associateDeploymentArtifactsToInstances(User user, String yamlName, Resource resource, Map> instDeploymentArtifacts) { StorageOperationStatus addArtToInst = toscaOperationFacade.associateDeploymentArtifactsToInstances(instDeploymentArtifacts, resource, user); @@ -2127,6 +2135,18 @@ public class ServiceImportParseLogic { } } + public void associateCINodeFilterToComponent(String yamlName, Service service, Map nodeFilter) { + log.trace("************* Going to associate all resource node filters {}", yamlName); + if (MapUtils.isNotEmpty(nodeFilter)) { + StorageOperationStatus status = componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(service.getUniqueId(), + nodeFilter); + if (status != StorageOperationStatus.OK) { + throw new ComponentException( + componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName)); + } + } + } + public void associateComponentInstancePropertiesToComponent(String yamlName, Service service, Map> instProperties) { Either>, StorageOperationStatus> addPropToInst = toscaOperationFacade @@ -2304,7 +2324,7 @@ public class ServiceImportParseLogic { RequirementCapabilityRelDef regCapRelDef = new RequirementCapabilityRelDef(); regCapRelDef.setFromNode(resourceInstanceId); log.debug("try to find available requirement {} ", regName); - Either eitherReqStatus = findAviableRequiremen(regName, yamlName, nodesInfoValue, + Either eitherReqStatus = findAvailableRequirement(regName, yamlName, nodesInfoValue, currentCompInstance, uploadRegInfo.getCapabilityName()); if (eitherReqStatus.isRight()) { return eitherReqStatus.right().value();