X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=catalog-be%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fsdc%2Fbe%2Fcomponents%2Fimpl%2FArtifactsBusinessLogic.java;h=71d55d362bb9ffc6caffeb797415a64a2dee1002;hb=5d7ca5c1e86d7633a1954ae89334df18d264f82b;hp=10c50566d4c5ccd282ee492393f674059b9e8a5b;hpb=de228cef5770b37861ac7211343086613b21d527;p=sdc.git diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java index 10c50566d4..71d55d362b 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java @@ -172,6 +172,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private static final String UPDATE_ARTIFACT = "Update Artifact"; private static final String FOUND_DEPLOYMENT_ARTIFACT = "Found deployment artifact {}"; private static final String VALID_ARTIFACT_LABEL_NAME = "'A-Z', 'a-z', '0-9', '-', '@', '+' and space."; + private final ArtifactTypeOperation artifactTypeOperation; private Gson gson = new GsonBuilder().setPrettyPrinting().create(); @javax.annotation.Resource private IInterfaceLifecycleOperation interfaceLifecycleOperation; @@ -181,7 +182,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { private IElementOperation elementOperation; @javax.annotation.Resource private IHeatParametersOperation heatParametersOperation; - private final ArtifactTypeOperation artifactTypeOperation; private ArtifactCassandraDao artifactCassandraDao; private ToscaExportHandler toscaExportUtils; private CsarUtils csarUtils; @@ -377,7 +377,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return new ByResponseFormatComponentException(error); }); } else { - return toscaExportUtils.exportComponent(parent).left().map(toscaRepresentation -> { + return toscaExportUtils.exportComponent(parent, checkIfSkipImports(parent.getModel())).left().map(toscaRepresentation -> { log.debug("Tosca yaml exported for component {} ", parent.getUniqueId()); return toscaRepresentation.getMainYaml(); }).right().map(toscaError -> { @@ -387,6 +387,11 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } } + private boolean checkIfSkipImports(final String model) { + return null != model && !model.equalsIgnoreCase("ETSI SOL001 v2.5.1") + && !model.equalsIgnoreCase("AUTOMATION COMPOSITION"); + } + private Either doAction(String componentId, ComponentTypeEnum componentType, ArtifactOperationInfo operation, String artifactId, ArtifactDefinition artifactInfo, String origMd5, String originData, String interfaceName, String operationName, AuditingActionEnum auditingAction, User user, @@ -704,11 +709,10 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { new ArtifactOperationInfo(false, false, ArtifactOperationEnum.DOWNLOAD), artifactId, null, null, null, null, null, parentId, containerComponentType); ArtifactDefinition artifactDefinition; - Either insideValue = result; - if (insideValue.isLeft()) { - artifactDefinition = insideValue.left().value(); + if (result.isLeft()) { + artifactDefinition = result.left().value(); } else { - artifactDefinition = insideValue.right().value().getImplementationArtifact(); + artifactDefinition = result.right().value().getImplementationArtifact(); } // for tosca artifacts and heat env on VF level generated on download without saving if (artifactDefinition.getPayloadData() != null) { @@ -2211,7 +2215,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } private Either validateAndServiceApiUrl(ArtifactDefinition artifactInfo) { - if (!ValidationUtils.validateStringNotEmpty(artifactInfo.getApiUrl())) { + if (StringUtils.isEmpty(artifactInfo.getApiUrl())) { log.debug("Artifact url cannot be empty."); return Either.right(componentsUtils.getResponseFormat(ActionStatus.MISSING_DATA, ARTIFACT_URL)); } @@ -2514,32 +2518,14 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } private Service validateServiceNameAndVersion(String serviceName, String serviceVersion) { - Either, StorageOperationStatus> serviceListBySystemName = toscaOperationFacade - .getBySystemName(ComponentTypeEnum.SERVICE, serviceName); - if (serviceListBySystemName.isRight()) { + final Either serviceBySystemNameAndVersion + = toscaOperationFacade.getBySystemNameAndVersion(ComponentTypeEnum.SERVICE, serviceName, serviceVersion); + if (serviceBySystemNameAndVersion.isRight()) { log.debug("Couldn't fetch any service with name {}", serviceName); throw new ByActionStatusComponentException( - componentsUtils.convertFromStorageResponse(serviceListBySystemName.right().value(), ComponentTypeEnum.SERVICE), serviceName); + componentsUtils.convertFromStorageResponse(serviceBySystemNameAndVersion.right().value(), ComponentTypeEnum.SERVICE), serviceName); } - List serviceList = serviceListBySystemName.left().value(); - if (serviceList == null || serviceList.isEmpty()) { - log.debug("Couldn't fetch any service with name {}", serviceName); - throw new ByActionStatusComponentException(ActionStatus.SERVICE_NOT_FOUND, serviceName); - } - Service foundService = null; - for (Service service : serviceList) { - if (service.getVersion().equals(serviceVersion)) { - log.trace("Found service with version {}", serviceVersion); - foundService = service; - break; - } - } - if (foundService == null) { - log.debug("Couldn't find version {} for service {}", serviceVersion, serviceName); - throw new ByActionStatusComponentException(ActionStatus.COMPONENT_VERSION_NOT_FOUND, ComponentTypeEnum.SERVICE.getValue(), - serviceVersion); - } - return foundService; + return serviceBySystemNameAndVersion.left().value(); } private Resource validateResourceNameAndVersion(String resourceName, String resourceVersion) { @@ -2898,9 +2884,9 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { List empltyHeatValues = new ArrayList<>(); for (HeatParameterDefinition heatParameterDefinition : heatParameters) { String heatValue = heatParameterDefinition.getCurrentValue(); - if (!ValidationUtils.validateStringNotEmpty(heatValue)) { + if (StringUtils.isEmpty(heatValue)) { heatValue = heatParameterDefinition.getDefaultValue(); - if (!ValidationUtils.validateStringNotEmpty(heatValue)) { + if (StringUtils.isEmpty(heatValue)) { empltyHeatValues.add(heatParameterDefinition); continue; } @@ -3131,7 +3117,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { json.put(Constants.ARTIFACT_GROUP_TYPE, artifactGroupType.getType()); json.put(Constants.REQUIRED_ARTIFACTS, (updatedRequiredArtifacts == null || updatedRequiredArtifacts.isEmpty()) ? new ArrayList<>() : updatedRequiredArtifacts.stream().filter( - e -> e.getType().equals(ArtifactTypeEnum.HEAT_ARTIFACT.getType()) || e.getType().equals(ArtifactTypeEnum.HEAT_NESTED.getType())) + e -> e.getType().equals(ArtifactTypeEnum.HEAT_ARTIFACT.getType()) || e.getType().equals(ArtifactTypeEnum.HEAT_NESTED.getType())) .map(ArtifactTemplateInfo::getFileName).collect(Collectors.toList())); json.put(Constants.ARTIFACT_HEAT_PARAMS, (heatParameters == null || heatParameters.isEmpty()) ? new ArrayList<>() : heatParameters); return json; @@ -3693,7 +3679,7 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { operation.setImplementation(implementationArtifact); gotInterface.setOperationsMap(operationsMap); Either, StorageOperationStatus> interfaceDefinitionStorageOperationStatusEither = interfaceOperation - .updateInterfaces(storedComponent.getUniqueId(), Collections.singletonList(gotInterface)); + .updateInterfaces(storedComponent, Collections.singletonList(gotInterface)); if (interfaceDefinitionStorageOperationStatusEither.isRight()) { StorageOperationStatus storageOperationStatus = interfaceDefinitionStorageOperationStatusEither.right().value(); ActionStatus actionStatus = componentsUtils.convertFromStorageResponseForDataType(storageOperationStatus); @@ -3758,7 +3744,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { errorWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status))); } if (errorWrapper.isEmpty()) { - NodeTypeEnum parentType = convertParentType(componentType); final List existingDeploymentArtifacts = getDeploymentArtifacts(toscaComponentEither.left().value(), null); for (ArtifactDefinition artifactDefinition : existingDeploymentArtifacts) { if (artifactInfo.getArtifactName().equalsIgnoreCase(artifactDefinition.getArtifactName())) { @@ -4046,7 +4031,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { String componentId = component.getUniqueId(); String artifactId = artifactDefinition.getUniqueId(); Either result; - Wrapper errorWrapper = new Wrapper<>(); //artifact validation artifactDefinition = validateArtifact(componentId, componentType, operation, artifactId, artifactDefinition, auditingAction, user, component, shouldLock, inTransaction); @@ -4238,7 +4222,6 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { } private Component checkoutParentComponent(ComponentTypeEnum componentType, String parentId, String userId) { - Component component = null; User modifier = userBusinessLogic.getUser(userId, false); LifecycleChangeInfoWithAction changeInfo = new LifecycleChangeInfoWithAction("External API checkout", LifecycleChanceActionEnum.UPDATE_FROM_EXTERNAL_API); @@ -4268,11 +4251,4 @@ public class ArtifactsBusinessLogic extends BaseBusinessLogic { return operation == CREATE || operation == LINK; } } - - public Map getAllToscaArtifacts(final String modelName) { - if (StringUtils.isNotEmpty(modelName)) { - artifactTypeOperation.validateModel(modelName); - } - return artifactTypeOperation.getAllArtifactTypes(modelName); - } }