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=b88661740f20c4f9f74e9bf6094fefa3a308b7ba;hb=c469756a1092194adedd590d35f0f1f8feac3a36;hp=3c82df4a50f9a731253dc0dfe864d9478593750b;hpb=216ea4998de9ae4ee603d7f8f5f6725b218ca710;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 3c82df4a50..b88661740f 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 @@ -35,6 +35,7 @@ import lombok.Getter; import org.apache.commons.codec.binary.Base64; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; import org.openecomp.sdc.be.components.csar.CsarInfo; import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo; @@ -167,18 +168,18 @@ public class ServiceImportParseLogic { } public Either>>, ResponseFormat> findNodeTypesArtifactsToHandle( - Map nodeTypesInfo, CsarInfo csarInfo, Service oldResource) { + Map nodeTypesInfo, CsarInfo csarInfo, Service oldResource) { Map>> nodeTypesArtifactsToHandle = new HashMap<>(); Either>>, ResponseFormat> nodeTypesArtifactsToHandleRes = Either - .left(nodeTypesArtifactsToHandle); + .left(nodeTypesArtifactsToHandle); try { Map> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csarInfo.getCsar()); Map> extractedVfcToscaNames = extractVfcToscaNames(nodeTypesInfo, oldResource.getName(), csarInfo); log.debug("Going to fetch node types for resource with name {} during import csar with UUID {}. ", oldResource.getName(), - csarInfo.getCsarUUID()); + csarInfo.getCsarUUID()); extractedVfcToscaNames.forEach( - (namespace, vfcToscaNames) -> findAddNodeTypeArtifactsToHandle(csarInfo, nodeTypesArtifactsToHandle, oldResource, - extractedVfcsArtifacts, namespace, vfcToscaNames)); + (namespace, vfcToscaNames) -> findAddNodeTypeArtifactsToHandle(csarInfo, nodeTypesArtifactsToHandle, oldResource, + extractedVfcsArtifacts, namespace, vfcToscaNames)); } catch (Exception e) { ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR); nodeTypesArtifactsToHandleRes = Either.right(responseFormat); @@ -196,7 +197,7 @@ public class ServiceImportParseLogic { while (nodesNameEntry.hasNext()) { Map.Entry nodeType = nodesNameEntry.next(); ImmutablePair toscaResourceName = buildNestedToscaResourceName(ResourceTypeEnum.VFC.name(), vfResourceName, - nodeType.getKey()); + nodeType.getKey()); vfcToscaNames.put(nodeType.getKey(), toscaResourceName); } } @@ -216,7 +217,7 @@ public class ServiceImportParseLogic { Yaml yaml = new Yaml(options); Map node = new HashMap<>(); node.put(buildNestedToscaResourceName(nodeResourceType, csarInfo.getVfResourceName(), nodeNameValue.getKey()).getLeft(), - nodeNameValue.getValue()); + nodeNameValue.getValue()); mapToConvert.put(TypeUtils.ToscaTagNamesEnum.NODE_TYPES.getElementName(), node); return yaml.dumpAsMap(mapToConvert); } @@ -249,7 +250,7 @@ public class ServiceImportParseLogic { } StringBuilder previousToscaResourceName = new StringBuilder(toscaResourceName); return new ImmutablePair<>(toscaResourceName.append(actualName.toLowerCase()).toString(), - previousToscaResourceName.append(actualName.substring(actualName.split("\\.")[1].length() + 1).toLowerCase()).toString()); + previousToscaResourceName.append(actualName.substring(actualName.split("\\.")[1].length() + 1).toLowerCase()).toString()); } catch (Exception e) { componentsUtils.getResponseFormat(ActionStatus.INVALID_TOSCA_TEMPLATE); log.debug("Exception occured when buildNestedToscaResourceName, error is:{}", e.getMessage(), e); @@ -268,7 +269,7 @@ public class ServiceImportParseLogic { private void extractNodeTypes(Map nodes, Map mappedToscaTemplate) { Either, ImportUtils.ResultStatusEnum> eitherNodeTypes = ImportUtils - .findFirstToscaMapElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES); + .findFirstToscaMapElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES); if (eitherNodeTypes.isLeft()) { nodes.putAll(eitherNodeTypes.left().value()); } @@ -296,8 +297,8 @@ public class ServiceImportParseLogic { List artifactsToDelete = new ArrayList<>(); // delete all informational artifacts artifactsToDelete.addAll( - curNodeType.getArtifacts().values().stream().filter(a -> a.getArtifactGroupType() == ArtifactGroupTypeEnum.INFORMATIONAL) - .collect(toList())); + curNodeType.getArtifacts().values().stream().filter(a -> a.getArtifactGroupType() == ArtifactGroupTypeEnum.INFORMATIONAL) + .collect(toList())); // delete all deployment artifacts artifactsToDelete.addAll(curNodeType.getDeploymentArtifacts().values()); if (!artifactsToDelete.isEmpty()) { @@ -332,7 +333,7 @@ public class ServiceImportParseLogic { throw new ComponentException(componentsUtils.convertFromStorageResponse(status), csarInfo.getCsarUUID()); } else if (org.apache.commons.lang.StringUtils.isNotEmpty(currVfcToscaName)) { return (Resource) toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName, resource.getModel()).left() - .on(st -> findVfcResource(csarInfo, resource, previousVfcToscaName, null, st)); + .on(st -> findVfcResource(csarInfo, resource, previousVfcToscaName, null, st)); } return null; } @@ -345,7 +346,7 @@ public class ServiceImportParseLogic { List artifactsToUpdate = new ArrayList<>(); List artifactsToDelete = new ArrayList<>(); processExistingNodeTypeArtifacts(extractedArtifacts, artifactsToUpload, artifactsToUpdate, artifactsToDelete, - collectExistingArtifacts(curNodeType)); + collectExistingArtifacts(curNodeType)); nodeTypeArtifactsToHandle = putFoundArtifacts(artifactsToUpload, artifactsToUpdate, artifactsToDelete); } catch (Exception e) { log.debug("Exception occured when findNodeTypeArtifactsToHandle, error is:{}", e.getMessage(), e); @@ -364,14 +365,14 @@ public class ServiceImportParseLogic { } if (MapUtils.isNotEmpty(curNodeType.getArtifacts())) { existingArtifacts.putAll( - curNodeType.getArtifacts().entrySet().stream().filter(e -> e.getValue().getArtifactGroupType() == ArtifactGroupTypeEnum.INFORMATIONAL) - .collect(toMap(Map.Entry::getKey, Map.Entry::getValue))); + curNodeType.getArtifacts().entrySet().stream().filter(e -> e.getValue().getArtifactGroupType() == ArtifactGroupTypeEnum.INFORMATIONAL) + .collect(toMap(Map.Entry::getKey, Map.Entry::getValue))); } return existingArtifacts; } protected EnumMap> putFoundArtifacts( - List artifactsToUpload, List artifactsToUpdate, List artifactsToDelete) { + List artifactsToUpload, List artifactsToUpdate, List artifactsToDelete) { EnumMap> nodeTypeArtifactsToHandle = null; if (!artifactsToUpload.isEmpty() || !artifactsToUpdate.isEmpty() || !artifactsToDelete.isEmpty()) { nodeTypeArtifactsToHandle = new EnumMap<>(ArtifactsBusinessLogic.ArtifactOperationEnum.class); @@ -405,7 +406,7 @@ public class ServiceImportParseLogic { protected void processNodeTypeArtifact(List artifactsToUpload, List artifactsToUpdate, Map existingArtifacts, ArtifactDefinition currNewArtifact) { Optional foundArtifact = existingArtifacts.values().stream() - .filter(a -> a.getArtifactName().equals(currNewArtifact.getArtifactName())).findFirst(); + .filter(a -> a.getArtifactName().equals(currNewArtifact.getArtifactName())).findFirst(); if (foundArtifact.isPresent()) { if (foundArtifact.get().getArtifactType().equals(currNewArtifact.getArtifactType())) { updateFoundArtifact(artifactsToUpdate, currNewArtifact, foundArtifact.get()); @@ -414,7 +415,7 @@ public class ServiceImportParseLogic { } else { log.debug("Can't upload two artifact with the same name {}.", currNewArtifact.getArtifactName()); throw new ComponentException(ActionStatus.ARTIFACT_ALREADY_EXIST_IN_DIFFERENT_TYPE_IN_CSAR, currNewArtifact.getArtifactName(), - currNewArtifact.getArtifactType(), foundArtifact.get().getArtifactType()); + currNewArtifact.getArtifactType(), foundArtifact.get().getArtifactType()); } } } @@ -432,7 +433,7 @@ public class ServiceImportParseLogic { public void addNonMetaCreatedArtifactsToSupportRollback(ArtifactOperationInfo operation, List createdArtifacts, Either, ResponseFormat> eitherNonMetaArtifacts) { if (ArtifactsBusinessLogic.ArtifactOperationEnum.isCreateOrLink(operation.getArtifactOperationEnum()) && createdArtifacts != null - && eitherNonMetaArtifacts.isLeft()) { + && eitherNonMetaArtifacts.isLeft()) { Either eitherResult = eitherNonMetaArtifacts.left().value(); if (eitherResult.isLeft()) { createdArtifacts.add(eitherResult.left().value()); @@ -483,7 +484,7 @@ public class ServiceImportParseLogic { resourceSystemName = resource.getSystemName(); } resource - .setToscaResourceName(CommonBeUtils.generateToscaResourceName(resource.getResourceType().name().toLowerCase(), resourceSystemName)); + .setToscaResourceName(CommonBeUtils.generateToscaResourceName(resource.getResourceType().name().toLowerCase(), resourceSystemName)); } // Generate invariant UUID - must be here and not in operation since it @@ -515,11 +516,11 @@ public class ServiceImportParseLogic { InterfaceDefinition interfaceDefinition = intItr.next(); String intType = interfaceDefinition.getUniqueId(); Either eitherCapTypeFound = interfaceTypeOperation.getInterface( - UniqueIdBuilder.buildInterfaceTypeUid(resource.getModel(), intType)); + UniqueIdBuilder.buildInterfaceTypeUid(resource.getModel(), intType)); if (eitherCapTypeFound.isRight()) { if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) { BeEcompErrorManager.getInstance() - .logBeGraphObjectMissingError("Create Resource - validateLifecycleTypesCreate", "Interface", intType); + .logBeGraphObjectMissingError("Create Resource - validateLifecycleTypesCreate", "Interface", intType); log.debug("Lifecycle Type: {} is required by resource: {} but does not exist in the DB", intType, resource.getName()); BeEcompErrorManager.getInstance().logBeDaoSystemError("Create Resource - validateLifecycleTypesCreate"); log.debug("request to data model failed with error: {}", eitherCapTypeFound.right().value().name()); @@ -540,7 +541,7 @@ public class ServiceImportParseLogic { log.debug("validate capability Types Exist - capabilities section"); for (Map.Entry> typeEntry : resource.getCapabilities().entrySet()) { eitherResult = validateCapabilityTypeExists(user, capabilityTypeOperation, resource, actionEnum, eitherResult, typeEntry, - inTransaction); + inTransaction); if (eitherResult.isRight()) { return Either.right(eitherResult.right().value()); } @@ -550,7 +551,7 @@ public class ServiceImportParseLogic { log.debug("validate capability Types Exist - requirements section"); for (String type : resource.getRequirements().keySet()) { eitherResult = validateCapabilityTypeExists(user, capabilityTypeOperation, resource, resource.getRequirements().get(type), actionEnum, - eitherResult, type, inTransaction); + eitherResult, type, inTransaction); if (eitherResult.isRight()) { return Either.right(eitherResult.right().value()); } @@ -565,11 +566,11 @@ public class ServiceImportParseLogic { Map.Entry> typeEntry, boolean inTransaction) { Either eitherCapTypeFound = capabilityTypeOperation - .getCapabilityType(UniqueIdBuilder.buildCapabilityTypeUid(resource.getModel(), typeEntry.getKey()), inTransaction); + .getCapabilityType(UniqueIdBuilder.buildCapabilityTypeUid(resource.getModel(), typeEntry.getKey()), inTransaction); if (eitherCapTypeFound.isRight()) { if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) { BeEcompErrorManager.getInstance() - .logBeGraphObjectMissingError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES, "Capability Type", typeEntry.getKey()); + .logBeGraphObjectMissingError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES, "Capability Type", typeEntry.getKey()); log.debug("Capability Type: {} is required by resource: {} but does not exist in the DB", typeEntry.getKey(), resource.getName()); BeEcompErrorManager.getInstance().logBeDaoSystemError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES); } @@ -617,11 +618,11 @@ public class ServiceImportParseLogic { boolean inTransaction) { try { Either eitherCapTypeFound = capabilityTypeOperation - .getCapabilityType(UniqueIdBuilder.buildCapabilityTypeUid(resource.getModel(), type), inTransaction); + .getCapabilityType(UniqueIdBuilder.buildCapabilityTypeUid(resource.getModel(), type), inTransaction); if (eitherCapTypeFound.isRight()) { if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) { BeEcompErrorManager.getInstance() - .logBeGraphObjectMissingError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES, "Capability Type", type); + .logBeGraphObjectMissingError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES, "Capability Type", type); log.debug("Capability Type: {} is required by resource: {} but does not exist in the DB", type, resource.getName()); BeEcompErrorManager.getInstance().logBeDaoSystemError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES); } @@ -698,7 +699,7 @@ public class ServiceImportParseLogic { BeEcompErrorManager.getInstance().logBeDaoSystemError("Create Resource - validateDerivedFromExist"); log.debug("request to data model failed with error: {}", storageStatus); ResponseFormat responseFormat = componentsUtils - .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus), resource); + .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus), resource); log.trace("audit before sending response"); componentsUtils.auditResource(responseFormat, user, resource, actionEnum); throw new ComponentException(componentsUtils.convertFromStorageResponse(storageStatus)); @@ -743,10 +744,10 @@ public class ServiceImportParseLogic { if (!ValidationUtils.validateResourceVendorModelNumberLength(resourceVendorModelNumber)) { log.info("resource vendor model number exceeds limit."); ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, - "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH); + "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH); componentsUtils.auditResource(errorResponse, user, resource, actionEnum); throw new ComponentException(ActionStatus.RESOURCE_VENDOR_MODEL_NUMBER_EXCEEDS_LIMIT, - "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH); + "" + ValidationUtils.RESOURCE_VENDOR_MODEL_NUMBER_MAX_LENGTH); } // resource vendor model number is currently validated as vendor @@ -763,7 +764,7 @@ public class ServiceImportParseLogic { public void validateVendorReleaseName(User user, Resource resource, AuditingActionEnum actionEnum) { String vendorRelease = resource.getVendorRelease(); log.debug("validate vendor relese name"); - if (!ValidationUtils.validateStringNotEmpty(vendorRelease)) { + if (StringUtils.isEmpty(vendorRelease)) { log.info("vendor relese name is missing."); ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_VENDOR_RELEASE); componentsUtils.auditResource(errorResponse, user, resource, actionEnum); @@ -777,7 +778,7 @@ public class ServiceImportParseLogic { if (!ValidationUtils.validateVendorReleaseLength(vendorRelease)) { log.info("vendor release exceds limit."); ResponseFormat errorResponse = componentsUtils - .getResponseFormat(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH); + .getResponseFormat(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH); componentsUtils.auditResource(errorResponse, user, resource, actionEnum); throw new ComponentException(ActionStatus.VENDOR_RELEASE_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_RELEASE_MAX_LENGTH); } @@ -795,7 +796,7 @@ public class ServiceImportParseLogic { if (CollectionUtils.isEmpty(categories)) { log.debug(CATEGORY_IS_EMPTY); ResponseFormat responseFormat = componentsUtils - .getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()); + .getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()); componentsUtils.auditResource(responseFormat, user, resource, actionEnum); throw new ComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()); } @@ -814,17 +815,17 @@ public class ServiceImportParseLogic { throw new ComponentException(ActionStatus.RESOURCE_TOO_MUCH_SUBCATEGORIES); } SubCategoryDefinition subcategory = subcategories.get(0); - if (!ValidationUtils.validateStringNotEmpty(category.getName())) { + if (StringUtils.isEmpty(category.getName())) { log.debug(CATEGORY_IS_EMPTY); ResponseFormat responseFormat = componentsUtils - .getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()); + .getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()); componentsUtils.auditResource(responseFormat, user, resource, actionEnum); throw new ComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue()); } - if (!ValidationUtils.validateStringNotEmpty(subcategory.getName())) { + if (StringUtils.isEmpty(subcategory.getName())) { log.debug(CATEGORY_IS_EMPTY); ResponseFormat responseFormat = componentsUtils - .getResponseFormat(ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue()); + .getResponseFormat(ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue()); componentsUtils.auditResource(responseFormat, user, resource, actionEnum); throw new ComponentException(ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue()); } @@ -838,7 +839,7 @@ public class ServiceImportParseLogic { try { log.debug("validating resource category {} against valid categories list", category); Either, ActionStatus> categories = serviceBusinessLogic.elementDao - .getAllCategories(NodeTypeEnum.ResourceNewCategory, inTransaction); + .getAllCategories(NodeTypeEnum.ResourceNewCategory, inTransaction); if (categories.isRight()) { log.debug("failed to retrieve resource categories from Titan"); responseFormat = componentsUtils.getResponseFormat(categories.right().value()); @@ -847,16 +848,16 @@ public class ServiceImportParseLogic { } List categoryList = categories.left().value(); Optional foundCategory = categoryList.stream().filter(cat -> cat.getName().equals(category.getName())) - .findFirst(); + .findFirst(); if (!foundCategory.isPresent()) { log.debug("Category {} is not part of resource category group. Resource category valid values are {}", category, categoryList); failOnInvalidCategory(user, resource, actionEnum); } Optional foundSubcategory = foundCategory.get().getSubcategories().stream() - .filter(subcat -> subcat.getName().equals(subcategory.getName())).findFirst(); + .filter(subcat -> subcat.getName().equals(subcategory.getName())).findFirst(); if (!foundSubcategory.isPresent()) { log.debug("SubCategory {} is not part of resource category group. Resource subcategory valid values are {}", subcategory, - foundCategory.get().getSubcategories()); + foundCategory.get().getSubcategories()); failOnInvalidCategory(user, resource, actionEnum); } } catch (Exception e) { @@ -875,7 +876,7 @@ public class ServiceImportParseLogic { protected void validateVendorName(User user, Resource resource, AuditingActionEnum actionEnum) { String vendorName = resource.getVendorName(); - if (!ValidationUtils.validateStringNotEmpty(vendorName)) { + if (StringUtils.isEmpty(vendorName)) { log.info("vendor name is missing."); ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_VENDOR_NAME); componentsUtils.auditResource(errorResponse, user, resource, actionEnum); @@ -889,7 +890,7 @@ public class ServiceImportParseLogic { if (!ValidationUtils.validateVendorNameLength(vendorName)) { log.info("vendor name exceds limit."); ResponseFormat errorResponse = componentsUtils - .getResponseFormat(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH); + .getResponseFormat(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH); componentsUtils.auditResource(errorResponse, user, resource, actionEnum); throw new ComponentException(ActionStatus.VENDOR_NAME_EXCEEDS_LIMIT, "" + ValidationUtils.VENDOR_NAME_MAX_LENGTH); } @@ -1070,8 +1071,8 @@ public class ServiceImportParseLogic { } if (validRegDef == null) { ResponseFormat responseFormat = componentsUtils - .getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE, yamlName, uploadComponentInstanceInfo.getName(), - uploadComponentInstanceInfo.getType()); + .getResponseFormat(ActionStatus.INVALID_NODE_TEMPLATE, yamlName, uploadComponentInstanceInfo.getName(), + uploadComponentInstanceInfo.getType()); return Either.right(responseFormat); } return Either.left(validRegDef); @@ -1120,7 +1121,7 @@ public class ServiceImportParseLogic { return null; } Optional capByName = capMap.get(validReq.getCapability()).stream() - .filter(p -> p.getName().equals(uploadReqInfo.getCapabilityName())).findAny(); + .filter(p -> p.getName().equals(uploadReqInfo.getCapabilityName())).findAny(); if (!capByName.isPresent()) { return null; } @@ -1208,7 +1209,7 @@ public class ServiceImportParseLogic { UploadCapInfo uploadedCapability) { List validProperties = new ArrayList<>(); Map defaultProperties = defaultCapability.getProperties().stream() - .collect(toMap(PropertyDefinition::getName, Function.identity())); + .collect(toMap(PropertyDefinition::getName, Function.identity())); List uploadedProperties = uploadedCapability.getProperties(); for (UploadPropInfo property : uploadedProperties) { String propertyName = property.getName().toLowerCase(); @@ -1248,7 +1249,7 @@ public class ServiceImportParseLogic { artifactMap = new HashMap<>(); } Map deploymentResourceArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration() - .getDeploymentResourceArtifacts(); + .getDeploymentResourceArtifacts(); if (deploymentResourceArtifacts != null) { Map finalArtifactMap = artifactMap; deploymentResourceArtifacts.forEach((k, v) -> processDeploymentResourceArtifacts(user, resource, finalArtifactMap, k, v)); @@ -1272,7 +1273,7 @@ public class ServiceImportParseLogic { if (shouldCreateArtifact) { if (serviceBusinessLogic.artifactsBusinessLogic != null) { ArtifactDefinition artifactDefinition = serviceBusinessLogic.artifactsBusinessLogic - .createArtifactPlaceHolderInfo(resource.getUniqueId(), k, (Map) v, user, ArtifactGroupTypeEnum.DEPLOYMENT); + .createArtifactPlaceHolderInfo(resource.getUniqueId(), k, (Map) v, user, ArtifactGroupTypeEnum.DEPLOYMENT); if (artifactDefinition != null && !artifactMap.containsKey(artifactDefinition.getArtifactLabel())) { artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition); } @@ -1337,7 +1338,7 @@ public class ServiceImportParseLogic { private void validateDerivedFromNotEmpty(User user, Resource resource, AuditingActionEnum actionEnum) { log.debug("validate resource derivedFrom field"); if ((resource.getDerivedFrom() == null) || (resource.getDerivedFrom().isEmpty()) || (resource.getDerivedFrom().get(0)) == null || (resource - .getDerivedFrom().get(0).trim().isEmpty())) { + .getDerivedFrom().get(0).trim().isEmpty())) { log.info("derived from (template) field is missing for the resource"); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.MISSING_DERIVED_FROM_TEMPLATE); componentsUtils.auditResource(responseFormat, user, resource, actionEnum); @@ -1358,8 +1359,8 @@ public class ServiceImportParseLogic { Either updatedResource = toscaOperationFacade.getToscaElement(service.getUniqueId()); if (updatedResource.isRight()) { throw new ComponentException(componentsUtils - .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, - ComponentTypeEnum.SERVICE)); + .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, + ComponentTypeEnum.SERVICE)); } return updatedResource.left().value(); } @@ -1376,15 +1377,15 @@ public class ServiceImportParseLogic { final Either updatedResource = toscaOperationFacade.getToscaElement(service.getUniqueId()); if (updatedResource.isRight()) { throw new ComponentException( - componentsUtils.getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, - ComponentTypeEnum.SERVICE)); + componentsUtils.getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, + ComponentTypeEnum.SERVICE)); } return updatedResource.left().value(); } public Service createSubstitutionFilterOnService(Service service, ListDataDefinition substitutionFilterProperties) - throws BusinessLogicException { + throws BusinessLogicException { if (substitutionFilterProperties == null || substitutionFilterProperties.isEmpty()) { return service; } @@ -1392,8 +1393,8 @@ public class ServiceImportParseLogic { Either updatedResource = toscaOperationFacade.getToscaElement(service.getUniqueId()); if (updatedResource.isRight()) { throw new ComponentException(componentsUtils - .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, - ComponentTypeEnum.SERVICE)); + .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), service, + ComponentTypeEnum.SERVICE)); } return updatedResource.left().value(); } @@ -1401,21 +1402,21 @@ public class ServiceImportParseLogic { 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)) { + !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()); + .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())); + .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()); + .getResponseFormat(ActionStatus.COMPONENT_NAME_ALREADY_EXIST, ComponentTypeEnum.RESOURCE.getValue(), service.getName()); throw new ComponentException(errorResponse); } } @@ -1423,22 +1424,22 @@ public class ServiceImportParseLogic { createArtifactsPlaceHolderData(service, user); // enrich object if (!isNormative && !AuditingActionEnum.UPDATE_SERVICE_TOSCA_TEMPLATE.equals(auditingAction) && - !AuditingActionEnum.UPDATE_SERVICE_TOSCA_MODEL.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); + AuditingActionEnum.UPDATE_SERVICE_TOSCA_MODEL.equals(auditingAction)) { + toscaOperationFacade.deleteService(service.getInvariantUUID(), true); } return toscaOperationFacade.createToscaComponent(service).left().on(r -> throwComponentExceptionByResource(r, service)); } public Service throwComponentExceptionByResource(StorageOperationStatus status, Service service) { ResponseFormat responseFormat = componentsUtils - .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(status), service, ComponentTypeEnum.SERVICE); + .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(status), service, ComponentTypeEnum.SERVICE); throw new ComponentException(responseFormat); } @@ -1458,7 +1459,7 @@ public class ServiceImportParseLogic { List exludeResourceCategory = ConfigurationManager.getConfigurationManager().getConfiguration().getExcludeResourceCategory(); List exludeResourceType = ConfigurationManager.getConfigurationManager().getConfiguration().getExcludeResourceType(); Map informationalResourceArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration() - .getInformationalResourceArtifacts(); + .getInformationalResourceArtifacts(); List categories = service.getCategories(); boolean isCreateArtifact = true; if (exludeResourceCategory != null) { @@ -1471,8 +1472,8 @@ public class ServiceImportParseLogic { Map artifactInfoMap = (Map) informationalResourceArtifacts.get(informationalResourceArtifactName); if (serviceBusinessLogic.artifactsBusinessLogic != null) { ArtifactDefinition artifactDefinition = serviceBusinessLogic.artifactsBusinessLogic - .createArtifactPlaceHolderInfo(resourceUniqueId, informationalResourceArtifactName, artifactInfoMap, user, - ArtifactGroupTypeEnum.INFORMATIONAL); + .createArtifactPlaceHolderInfo(resourceUniqueId, informationalResourceArtifactName, artifactInfoMap, user, + ArtifactGroupTypeEnum.INFORMATIONAL); artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition); } } @@ -1503,7 +1504,7 @@ public class ServiceImportParseLogic { private Resource nodeFullCertification(String uniqueId, User user, LifecycleChangeInfoWithAction lifecycleChangeInfo, boolean inTransaction, boolean needLock) { Either resourceResponse = lifecycleBusinessLogic - .changeState(uniqueId, user, LifeCycleTransitionEnum.CERTIFY, lifecycleChangeInfo, inTransaction, needLock); + .changeState(uniqueId, user, LifeCycleTransitionEnum.CERTIFY, lifecycleChangeInfo, inTransaction, needLock); if (resourceResponse.isRight()) { throw new ByResponseFormatComponentException(resourceResponse.right().value()); } @@ -1525,7 +1526,7 @@ public class ServiceImportParseLogic { validateDerivedFromExist(null, updateInfoResource, null); } else { Either validateDerivedFromExtending = validateDerivedFromExtending(null, currentResource, updateInfoResource, - null); + null); if (validateDerivedFromExtending.isRight() || !validateDerivedFromExtending.left().value()) { log.debug("Derived from cannot be updated if it doesnt inherits directly or extends inheritance"); return validateDerivedFromExtending; @@ -1540,12 +1541,12 @@ public class ServiceImportParseLogic { String currentTemplateName = currentResource.getDerivedFrom().get(0); String updatedTemplateName = updateInfoResource.getDerivedFrom().get(0); Either dataModelResponse = toscaOperationFacade - .validateToscaResourceNameExtends(currentTemplateName, updatedTemplateName, currentResource.getModel()); + .validateToscaResourceNameExtends(currentTemplateName, updatedTemplateName, currentResource.getModel()); if (dataModelResponse.isRight()) { StorageOperationStatus storageStatus = dataModelResponse.right().value(); BeEcompErrorManager.getInstance().logBeDaoSystemError("Create/Update Resource - validateDerivingFromExtendingType"); ResponseFormat responseFormat = componentsUtils - .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus), currentResource); + .getResponseFormatByResource(componentsUtils.convertFromStorageResponse(storageStatus), currentResource); log.trace("audit before sending response"); componentsUtils.auditResource(responseFormat, user, currentResource, actionEnum); return Either.right(responseFormat); @@ -1609,15 +1610,15 @@ public class ServiceImportParseLogic { return true; } return currentResource.getResourceType().equals(ResourceTypeEnum.VF) && resourceNameUpdated - .equals(addCvfcSuffixToResourceName(resourceNameCurrent)); + .equals(addCvfcSuffixToResourceName(resourceNameCurrent)); } public Resource prepareResourceForUpdate(Resource oldResource, Resource newResource, User user, boolean inTransaction, boolean needLock) { if (!ComponentValidationUtils.canWorkOnResource(oldResource, user.getUserId())) { // checkout return lifecycleBusinessLogic - .changeState(oldResource.getUniqueId(), user, LifeCycleTransitionEnum.CHECKOUT, new LifecycleChangeInfoWithAction("update by import"), - inTransaction, needLock).left().on(response -> failOnChangeState(response, user, oldResource, newResource)); + .changeState(oldResource.getUniqueId(), user, LifeCycleTransitionEnum.CHECKOUT, new LifecycleChangeInfoWithAction("update by import"), + inTransaction, needLock).left().on(response -> failOnChangeState(response, user, oldResource, newResource)); } return oldResource; } @@ -1626,7 +1627,7 @@ public class ServiceImportParseLogic { if (response.getRequestError() != null) { log.info("resource {} cannot be updated. reason={}", oldResource.getUniqueId(), response.getFormattedMessage()); componentsUtils.auditResource(response, user, newResource, AuditingActionEnum.IMPORT_RESOURCE, - ResourceVersionInfo.newBuilder().state(oldResource.getLifecycleState().name()).version(oldResource.getVersion()).build()); + ResourceVersionInfo.newBuilder().state(oldResource.getLifecycleState().name()).version(oldResource.getVersion()).build()); } throw new ComponentException(response); } @@ -1652,7 +1653,7 @@ public class ServiceImportParseLogic { Either updatedResource = toscaOperationFacade.getToscaElement(resource.getUniqueId()); if (updatedResource.isRight()) { throw new ComponentException( - componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource)); + componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource)); } return updatedResource.left().value(); } @@ -1682,7 +1683,7 @@ public class ServiceImportParseLogic { } if (isNotEmpty(groupsToUpdate)) { groupBusinessLogic.updateGroups(resource, groupsToUpdate, true).left() - .on(serviceBusinessLogic::throwComponentException); + .on(serviceBusinessLogic::throwComponentException); } } @@ -1690,7 +1691,7 @@ public class ServiceImportParseLogic { List groupsToUpdate, List groupsToCreate) { for (GroupDefinition group : groupsAsList) { Optional op = groupsFromResource.stream().filter(p -> p.getInvariantName().equalsIgnoreCase(group.getInvariantName())) - .findAny(); + .findAny(); if (op.isPresent()) { GroupDefinition groupToUpdate = op.get(); groupToUpdate.setMembers(group.getMembers()); @@ -1738,16 +1739,16 @@ public class ServiceImportParseLogic { if (CollectionUtils.isEmpty(componentInstances)) { String membersAstString = compInstancesNames.stream().collect(joining(",")); log.debug("The members: {}, in group: {}, cannot be found in component {}. There are no component instances.", membersAstString, - groupName, component.getNormalizedName()); + groupName, component.getNormalizedName()); throw new ComponentException(componentsUtils - .getResponseFormat(ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName, component.getNormalizedName(), - getComponentTypeForResponse(component))); + .getResponseFormat(ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName, component.getNormalizedName(), + getComponentTypeForResponse(component))); } // Find all component instances with the member names Map memberNames = componentInstances.stream().collect(toMap(ComponentInstance::getName, ComponentInstance::getUniqueId)); memberNames.putAll(groups.keySet().stream().collect(toMap(g -> g, g -> ""))); Map relevantInstances = memberNames.entrySet().stream().filter(n -> compInstancesNames.contains(n.getKey())) - .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); + .collect(toMap(Map.Entry::getKey, Map.Entry::getValue)); if (relevantInstances == null || relevantInstances.size() != compInstancesNames.size()) { List foundMembers = new ArrayList<>(); if (relevantInstances != null) { @@ -1757,8 +1758,8 @@ public class ServiceImportParseLogic { String membersAstString = compInstancesNames.stream().collect(joining(",")); log.debug("The members: {}, in group: {}, cannot be found in component: {}", membersAstString, groupName, component.getNormalizedName()); throw new ComponentException(componentsUtils - .getResponseFormat(ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName, component.getNormalizedName(), - getComponentTypeForResponse(component))); + .getResponseFormat(ActionStatus.GROUP_INVALID_COMPONENT_INSTANCE, membersAstString, groupName, component.getNormalizedName(), + getComponentTypeForResponse(component))); } updatedGroupDefinition.setMembers(relevantInstances); } @@ -1770,11 +1771,11 @@ public class ServiceImportParseLogic { boolean forceCertificationAllowed, CsarInfo csarInfo, String nodeName, boolean isNested) { LifecycleChangeInfoWithAction lifecycleChangeInfo = new LifecycleChangeInfoWithAction(CERTIFICATION_ON_IMPORT, - LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR); + LifecycleChangeInfoWithAction.LifecycleChanceActionEnum.CREATE_FROM_CSAR); Function validator = resource -> validateResourceCreationFromNodeType(resource, creator); return resourceImportManager - .importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, true, needLock, - nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested); + .importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, true, needLock, + nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested, null); } public ImmutablePair createNodeTypeResourceFromYaml(String yamlName, Map.Entry nodeNameValue, User user, @@ -1788,7 +1789,7 @@ public class ServiceImportParseLogic { String singleVfcYaml = buildNodeTypeYaml(nodeNameValue, mapToConvert, resourceMetaData.getResourceType(), csarInfo); user = serviceBusinessLogic.validateUser(user, "CheckIn Resource", resourceVf, AuditingActionEnum.CHECKIN_RESOURCE, true); return createResourceFromNodeType(singleVfcYaml, resourceMetaData, user, true, needLock, nodeTypeArtifactsToHandle, - nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeNameValue.getKey(), isNested); + nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeNameValue.getKey(), isNested); } protected UploadResourceInfo fillResourceMetadata(String yamlName, Service resourceVf, String nodeName, User user) { @@ -1843,12 +1844,12 @@ public class ServiceImportParseLogic { Either result = null; try { if (resource.getLifecycleState() != LifecycleStateEnum.CERTIFIED && forceCertificationAllowed && lifecycleBusinessLogic - .isFirstCertification(resource.getVersion())) { + .isFirstCertification(resource.getVersion())) { nodeForceCertification(resource, user, lifecycleChangeInfo, inTransaction, needLock); } if (resource.getLifecycleState() == LifecycleStateEnum.CERTIFIED) { Either eitherPopulated = serviceBusinessLogic - .populateToscaArtifacts(resource, user, false, inTransaction, needLock); + .populateToscaArtifacts(resource, user, false, inTransaction, needLock); return resource; } return nodeFullCertification(resource.getUniqueId(), user, lifecycleChangeInfo, inTransaction, needLock); @@ -1883,7 +1884,7 @@ public class ServiceImportParseLogic { Either updatedResource = toscaOperationFacade.getToscaElement(resource.getUniqueId()); if (updatedResource.isRight()) { throw new ComponentException( - componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource)); + componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(updatedResource.right().value()), resource)); } return updatedResource.left().value(); } @@ -1897,7 +1898,7 @@ public class ServiceImportParseLogic { List exludeResourceCategory = ConfigurationManager.getConfigurationManager().getConfiguration().getExcludeResourceCategory(); List exludeResourceType = ConfigurationManager.getConfigurationManager().getConfiguration().getExcludeResourceType(); Map informationalResourceArtifacts = ConfigurationManager.getConfigurationManager().getConfiguration() - .getInformationalResourceArtifacts(); + .getInformationalResourceArtifacts(); List categories = resource.getCategories(); boolean isCreateArtifact = true; if (exludeResourceCategory != null) { @@ -1914,8 +1915,8 @@ public class ServiceImportParseLogic { Map artifactInfoMap = (Map) informationalResourceArtifacts.get(informationalResourceArtifactName); if (serviceBusinessLogic.artifactsBusinessLogic != null) { ArtifactDefinition artifactDefinition = serviceBusinessLogic.artifactsBusinessLogic - .createArtifactPlaceHolderInfo(resourceUniqueId, informationalResourceArtifactName, artifactInfoMap, user, - ArtifactGroupTypeEnum.INFORMATIONAL); + .createArtifactPlaceHolderInfo(resourceUniqueId, informationalResourceArtifactName, artifactInfoMap, user, + ArtifactGroupTypeEnum.INFORMATIONAL); artifactMap.put(artifactDefinition.getArtifactLabel(), artifactDefinition); } } @@ -1944,7 +1945,7 @@ public class ServiceImportParseLogic { List inputs = service.getInputs(); if (MapUtils.isNotEmpty(groups)) { groups.values().stream().filter(g -> isNotEmpty(g.getProperties())).flatMap(g -> g.getProperties().stream()) - .forEach(p -> handleGetInputs(p, inputs)); + .forEach(p -> handleGetInputs(p, inputs)); } } @@ -1952,7 +1953,7 @@ public class ServiceImportParseLogic { List inputs = resource.getInputs(); if (MapUtils.isNotEmpty(groups)) { groups.values().stream().filter(g -> isNotEmpty(g.getProperties())).flatMap(g -> g.getProperties().stream()) - .forEach(p -> handleGetInputs(p, inputs)); + .forEach(p -> handleGetInputs(p, inputs)); } } @@ -1961,7 +1962,7 @@ public class ServiceImportParseLogic { if (inputs == null || inputs.isEmpty()) { log.debug("Failed to add property {} to group. Inputs list is empty ", property); serviceBusinessLogic.rollbackWithException(ActionStatus.INPUTS_NOT_FOUND, - property.getGetInputValues().stream().map(GetInputValueDataDefinition::getInputName).collect(toList()).toString()); + property.getGetInputValues().stream().map(GetInputValueDataDefinition::getInputName).collect(toList()).toString()); } ListIterator getInputValuesIter = property.getGetInputValues().listIterator(); while (getInputValuesIter.hasNext()) { @@ -1991,11 +1992,11 @@ public class ServiceImportParseLogic { Map> instProperties) { try { Either>, StorageOperationStatus> addPropToInst = toscaOperationFacade - .associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId()); + .associateComponentInstancePropertiesToComponent(instProperties, resource.getUniqueId()); if (addPropToInst.isRight()) { log.debug("failed to associate properties of resource {} status is {}", resource.getUniqueId(), addPropToInst.right().value()); throw new ComponentException( - componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName)); + componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName)); } } catch (Exception e) { log.debug("Exception occured when findNodeTypeArtifactsToHandle, error is:{}", e.getMessage()); @@ -2007,37 +2008,37 @@ public class ServiceImportParseLogic { Map> instInputs) { if (MapUtils.isNotEmpty(instInputs)) { Either>, StorageOperationStatus> addInputToInst = toscaOperationFacade - .associateComponentInstanceInputsToComponent(instInputs, resource.getUniqueId()); + .associateComponentInstanceInputsToComponent(instInputs, resource.getUniqueId()); if (addInputToInst.isRight()) { log.debug("failed to associate inputs value of resource {} status is {}", resource.getUniqueId(), addInputToInst.right().value()); throw new ComponentException( - componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName)); + componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName)); } } } public void associateComponentInstanceInterfacesToComponent( - String yamlName, - Service service, - Map> instInterfaces + String yamlName, + Service service, + Map> instInterfaces ) { if (MapUtils.isNotEmpty(instInterfaces)) { Either, StorageOperationStatus> addInterfaceToInst = - toscaOperationFacade - .associateComponentInstanceInterfacesToComponent( - instInterfaces, - service.getUniqueId() - ); + toscaOperationFacade + .associateComponentInstanceInterfacesToComponent( + instInterfaces, + service.getUniqueId() + ); if (addInterfaceToInst.isRight()) { log.error("failed to associate interfaces value of service {}, status is {}", service.getUniqueId(), - addInterfaceToInst.right().value()); + addInterfaceToInst.right().value()); throw new ComponentException( - componentsUtils.getResponseFormat( - componentsUtils.convertFromStorageResponse( - addInterfaceToInst.right().value() - ), - yamlName - ) + componentsUtils.getResponseFormat( + componentsUtils.convertFromStorageResponse( + addInterfaceToInst.right().value() + ), + yamlName + ) ); } } @@ -2126,11 +2127,11 @@ public class ServiceImportParseLogic { public void associateComponentInstanceInputsToComponent(String yamlName, Service service, Map> instInputs) { if (MapUtils.isNotEmpty(instInputs)) { Either>, StorageOperationStatus> addInputToInst = toscaOperationFacade - .associateComponentInstanceInputsToComponent(instInputs, service.getUniqueId()); + .associateComponentInstanceInputsToComponent(instInputs, service.getUniqueId()); if (addInputToInst.isRight()) { log.debug("failed to associate inputs value of resource {} status is {}", service.getUniqueId(), addInputToInst.right().value()); throw new ComponentException( - componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName)); + componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addInputToInst.right().value()), yamlName)); } } } @@ -2139,10 +2140,10 @@ public class ServiceImportParseLogic { log.trace("************* Going to associate all resource node filters {}", yamlName); if (MapUtils.isNotEmpty(nodeFilter)) { StorageOperationStatus status = componentNodeFilterBusinessLogic.associateNodeFilterToComponentInstance(service.getUniqueId(), - nodeFilter); + nodeFilter); if (status != StorageOperationStatus.OK) { throw new ComponentException( - componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName)); + componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), yamlName)); } } } @@ -2150,10 +2151,10 @@ public class ServiceImportParseLogic { public void associateComponentInstancePropertiesToComponent(String yamlName, Service service, Map> instProperties) { Either>, StorageOperationStatus> addPropToInst = toscaOperationFacade - .associateComponentInstancePropertiesToComponent(instProperties, service.getUniqueId()); + .associateComponentInstancePropertiesToComponent(instProperties, service.getUniqueId()); if (addPropToInst.isRight()) { throw new ComponentException( - componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName)); + componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(addPropToInst.right().value()), yamlName)); } } @@ -2217,7 +2218,7 @@ public class ServiceImportParseLogic { public void associateResourceInstances(String yamlName, Service service, List relations) { Either, StorageOperationStatus> relationsEither = toscaOperationFacade - .associateResourceInstances(service, service.getUniqueId(), relations); + .associateResourceInstances(service, service.getUniqueId(), relations); if (relationsEither.isRight() && relationsEither.right().value() != StorageOperationStatus.NOT_FOUND) { StorageOperationStatus status = relationsEither.right().value(); log.debug("failed to associate instances of service {} status is {}", service.getUniqueId(), status); @@ -2260,7 +2261,7 @@ public class ServiceImportParseLogic { public void associateResourceInstances(String yamlName, Resource resource, List relations) { Either, StorageOperationStatus> relationsEither = toscaOperationFacade - .associateResourceInstances(resource, resource.getUniqueId(), relations); + .associateResourceInstances(resource, resource.getUniqueId(), relations); if (relationsEither.isRight() && relationsEither.right().value() != StorageOperationStatus.NOT_FOUND) { StorageOperationStatus status = relationsEither.right().value(); log.debug("failed to associate instances of resource {} status is {}", resource.getUniqueId(), status); @@ -2282,8 +2283,8 @@ public class ServiceImportParseLogic { if (currentCompInstance == null) { log.debug(COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE, uploadComponentInstanceInfo.getName(), resource.getUniqueId()); BeEcompErrorManager.getInstance() - .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE, resource.getUniqueId(), - BeEcompErrorManager.ErrorSeverity.ERROR); + .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadComponentInstanceInfo.getName() + IN_RESOURCE, resource.getUniqueId(), + BeEcompErrorManager.ErrorSeverity.ERROR); ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName); throw new ComponentException(responseFormat); } @@ -2307,8 +2308,8 @@ public class ServiceImportParseLogic { if (currentCompInstance == null) { log.debug(COMPONENT_INSTANCE_WITH_NAME_IN_RESOURCE, nodesInfoValue.getName(), resource.getUniqueId()); BeEcompErrorManager.getInstance() - .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + nodesInfoValue.getName() + IN_RESOURCE, resource.getUniqueId(), - BeEcompErrorManager.ErrorSeverity.ERROR); + .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + nodesInfoValue.getName() + IN_RESOURCE, resource.getUniqueId(), + BeEcompErrorManager.ErrorSeverity.ERROR); return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName); } String resourceInstanceId = currentCompInstance.getUniqueId(); @@ -2325,7 +2326,7 @@ public class ServiceImportParseLogic { regCapRelDef.setFromNode(resourceInstanceId); log.debug("try to find available requirement {} ", regName); Either eitherReqStatus = findAvailableRequirement(regName, yamlName, nodesInfoValue, - currentCompInstance, uploadRegInfo.getCapabilityName()); + currentCompInstance, uploadRegInfo.getCapabilityName()); if (eitherReqStatus.isRight()) { return eitherReqStatus.right().value(); } @@ -2351,8 +2352,8 @@ public class ServiceImportParseLogic { if (currentCapCompInstance == null) { log.debug("The component instance with name {} not found on resource {} ", uploadRegInfo.getNode(), resource.getUniqueId()); BeEcompErrorManager.getInstance() - .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE, resource.getUniqueId(), - BeEcompErrorManager.ErrorSeverity.ERROR); + .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE, resource.getUniqueId(), + BeEcompErrorManager.ErrorSeverity.ERROR); return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName); } regCapRelDef.setToNode(currentCapCompInstance.getUniqueId()); @@ -2363,8 +2364,8 @@ public class ServiceImportParseLogic { reqAndRelationshipPair.setCapabilityOwnerId(aviableCapForRel.getOwnerId()); if (aviableCapForRel == null) { BeEcompErrorManager.getInstance().logInternalDataError( - "aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance - .getUniqueId(), resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR); + "aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance + .getUniqueId(), resource.getUniqueId(), BeEcompErrorManager.ErrorSeverity.ERROR); return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName); } CapabilityRequirementRelationship capReqRel = new CapabilityRequirementRelationship();