aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-01-31 17:13:55 +0000
committerVasyl Razinkov <vasyl.razinkov@est.tech>2023-02-01 10:23:31 +0000
commit46a9238f48695d25066e2e351c275f0594f2eb9a (patch)
tree048447f601eea9b4c2ad6d1c38ae95a0f157890b
parent42d3f9feb3884301f839b55c6ed9244f051daa06 (diff)
Stop auto-generation of inputs from substitution mapping node
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: I0ecdfe1f22790b0fc23fa99b9a85cdaca3b23515 Issue-ID: SDC-4361
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java9
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java4
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java64
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java7
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/config/ContainerInstanceTypesData.java5
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java2
7 files changed, 51 insertions, 46 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
index e4b54c18b5..0df8555b47 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/CsarBusinessLogic.java
@@ -21,6 +21,8 @@
*/
package org.openecomp.sdc.be.components.csar;
+import static org.openecomp.sdc.common.api.Constants.DEFAULT_MODEL_NAME;
+
import fj.data.Either;
import java.util.Map;
import java.util.Optional;
@@ -133,13 +135,13 @@ public class CsarBusinessLogic extends BaseBusinessLogic {
if (resource.getModel() == null) {
if (!vendorSoftwareProduct.getModelList().isEmpty()) {
var modelStringList = String.join(", ", vendorSoftwareProduct.getModelList());
- throw new ByActionStatusComponentException(ActionStatus.VSP_MODEL_NOT_ALLOWED, "SDC AID", modelStringList);
+ throw new ByActionStatusComponentException(ActionStatus.VSP_MODEL_NOT_ALLOWED, DEFAULT_MODEL_NAME, modelStringList);
}
return;
}
if (!vendorSoftwareProduct.getModelList().contains(resource.getModel())) {
var modelStringList =
- vendorSoftwareProduct.getModelList().isEmpty() ? "SDC AID" : String.join(", ", vendorSoftwareProduct.getModelList());
+ vendorSoftwareProduct.getModelList().isEmpty() ? DEFAULT_MODEL_NAME : String.join(", ", vendorSoftwareProduct.getModelList());
throw new ByActionStatusComponentException(ActionStatus.VSP_MODEL_NOT_ALLOWED, resource.getModel(), modelStringList);
}
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
index af4d6e48e0..dc77c6044f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/csar/ServiceCsarInfo.java
@@ -83,14 +83,15 @@ public class ServiceCsarInfo extends CsarInfo {
importFilePaths.stream().filter(path -> !filesHandled.contains(path)).forEach(
importFilePath -> {
- byte[] importFile = csar.get(importFilePath.toString());
+ final String importFilePathString = importFilePath.toString();
+ final byte[] importFile = csar.get(importFilePathString);
if (importFile != null) {
filesHandled.add(importFilePath);
- Map<String, Object> mappedImportFile = new Yaml().load(new String(csar.get(importFilePath.toString())));
- templateImports.put(importFilePath.toString(), mappedImportFile);
+ final Map<String, Object> mappedImportFile = new Yaml().load(new String(importFile));
+ templateImports.put(importFilePathString, mappedImportFile);
templateImports.putAll(getTemplateImports(csar, mappedImportFile, importFilePath.getParent(), filesHandled));
} else {
- log.info("Import {} cannot be found in CSAR", importFilePath.toString());
+ log.warn("Import {} cannot be found in CSAR", importFilePathString);
}
});
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index f5db6be6bd..187d7b8491 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -707,7 +707,9 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (service.isSubstituteCandidate() || genericTypeBusinessLogic.hasMandatorySubstitutionType(service)) {
final Resource genericType = fetchAndSetDerivedFromGenericType(service);
generatePropertiesFromGenericType(service, genericType);
- generateAndAddInputsFromGenericTypeProperties(service, genericType);
+ if (Constants.DEFAULT_MODEL_NAME.equals(service.getModel()) || service.getModel() == null) {
+ generateAndAddInputsFromGenericTypeProperties(service, genericType);
+ }
}
beforeCreate(service);
Either<Service, StorageOperationStatus> dataModelResponse = toscaOperationFacade.createToscaComponent(service);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
index 7bdaaee9a6..828439e44b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportBusinessLogic.java
@@ -291,48 +291,47 @@ public class ServiceImportBusinessLogic {
protected Service createServiceFromCsar(Service service, User user, Map<String, byte[]> csarUIPayload, String csarUUID) {
log.trace("************* created successfully from YAML, resource TOSCA ");
try {
- ServiceCsarInfo csarInfo = csarBusinessLogic.getCsarInfo(service, null, user, csarUIPayload, csarUUID);
-
- final Map<String, Object> dataTypesToCreate = getDatatypesToCreate(service.getModel(), csarInfo);
+ final ServiceCsarInfo csarInfo = csarBusinessLogic.getCsarInfo(service, null, user, csarUIPayload, csarUUID);
+ final String serviceModel = service.getModel();
+ final Map<String, Object> dataTypesToCreate = getDatatypesToCreate(serviceModel, csarInfo);
if (MapUtils.isNotEmpty(dataTypesToCreate)) {
- dataTypeBusinessLogic.createDataTypeFromYaml(new Yaml().dump(dataTypesToCreate), service.getModel(), true);
+ dataTypeBusinessLogic.createDataTypeFromYaml(new Yaml().dump(dataTypesToCreate), serviceModel, true);
dataTypesToCreate.keySet().forEach(key ->
- applicationDataTypeCache.reload(service.getModel(), UniqueIdBuilder.buildDataTypeUid(service.getModel(), key))
+ applicationDataTypeCache.reload(serviceModel, UniqueIdBuilder.buildDataTypeUid(serviceModel, key))
);
}
- final Map<String, Object> artifactTypesToCreate = getArtifactTypesToCreate(service.getModel(), csarInfo);
+ final Map<String, Object> artifactTypesToCreate = getArtifactTypesToCreate(serviceModel, csarInfo);
if (MapUtils.isNotEmpty(artifactTypesToCreate)) {
- artifactTypeImportManager.createArtifactTypes(new Yaml().dump(artifactTypesToCreate), service.getModel(), true);
+ artifactTypeImportManager.createArtifactTypes(new Yaml().dump(artifactTypesToCreate), serviceModel, true);
}
- final List<NodeTypeDefinition> nodeTypesToCreate = getNodeTypesToCreate(service.getModel(), csarInfo);
+ final List<NodeTypeDefinition> nodeTypesToCreate = getNodeTypesToCreate(serviceModel, csarInfo);
if (CollectionUtils.isNotEmpty(nodeTypesToCreate)) {
- createNodeTypes(nodeTypesToCreate, service.getModel(), csarInfo.getModifier());
+ createNodeTypes(nodeTypesToCreate, serviceModel, csarInfo.getModifier());
}
- final Map<String, Object> groupTypesToCreate = getGroupTypesToCreate(service.getModel(), csarInfo);
+ final Map<String, Object> groupTypesToCreate = getGroupTypesToCreate(serviceModel, csarInfo);
if (MapUtils.isNotEmpty(groupTypesToCreate)) {
final Map<String, ToscaTypeMetadata> toscaTypeMetadata = fillToscaTypeMetadata(groupTypesToCreate);
final ToscaTypeImportData toscaTypeImportData = new ToscaTypeImportData(new Yaml().dump(groupTypesToCreate), toscaTypeMetadata);
- groupTypeImportManager.createGroupTypes(toscaTypeImportData, service.getModel(), true);
+ groupTypeImportManager.createGroupTypes(toscaTypeImportData, serviceModel, true);
}
- final Map<String, Object> interfaceTypesToCreate = getInterfaceTypesToCreate(service.getModel(), csarInfo);
+ final Map<String, Object> interfaceTypesToCreate = getInterfaceTypesToCreate(serviceModel, csarInfo);
if (MapUtils.isNotEmpty(interfaceTypesToCreate)) {
- interfaceLifecycleTypeImportManager
- .createLifecycleTypes(new Yaml().dump(interfaceTypesToCreate), service.getModel(), true);
+ interfaceLifecycleTypeImportManager.createLifecycleTypes(new Yaml().dump(interfaceTypesToCreate), serviceModel, true);
}
- final Map<String, Object> capabilityTypesToCreate = getCapabilityTypesToCreate(service.getModel(), csarInfo);
+ final Map<String, Object> capabilityTypesToCreate = getCapabilityTypesToCreate(serviceModel, csarInfo);
if (MapUtils.isNotEmpty(capabilityTypesToCreate)) {
- capabilityTypeImportManager.createCapabilityTypes(new Yaml().dump(capabilityTypesToCreate), service.getModel(), true);
+ capabilityTypeImportManager.createCapabilityTypes(new Yaml().dump(capabilityTypesToCreate), serviceModel, true);
}
Map<String, NodeTypeInfo> nodeTypesInfo = csarInfo.extractTypesInfo();
- Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = serviceImportParseLogic
- .findNodeTypesArtifactsToHandle(nodeTypesInfo, csarInfo, service);
+ Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes
+ = serviceImportParseLogic.findNodeTypesArtifactsToHandle(nodeTypesInfo, csarInfo, service);
if (findNodeTypesArtifactsToHandleRes.isRight()) {
log.debug("failed to find node types for update with artifacts during import csar {}. ", csarInfo.getCsarUUID());
throw new ComponentException(findNodeTypesArtifactsToHandleRes.right().value());
@@ -761,23 +760,22 @@ public class ServiceImportBusinessLogic {
private Service updateInputs(final Service component, final String userId) {
final List<InputDefinition> inputs = component.getInputs();
- final List<ComponentInstance> componentInstances = component.getComponentInstances();
- final String componentUniqueId = component.getUniqueId();
- final Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = component.getComponentInstancesProperties();
- for (final InputDefinition input : inputs) {
- if (isInputFromComponentInstanceProperty(input.getName(), componentInstances, componentInstancesProperties)) {
- associateInputToComponentInstanceProperty(userId, input, componentInstances, componentInstancesProperties,
- componentUniqueId);
- } else {
- associateInputToServiceProperty(userId, input, component);
+ if (CollectionUtils.isNotEmpty(inputs)) {
+ final List<ComponentInstance> componentInstances = component.getComponentInstances();
+ final String componentUniqueId = component.getUniqueId();
+ final Map<String, List<ComponentInstanceProperty>> componentInstancesProperties = component.getComponentInstancesProperties();
+ for (final InputDefinition input : inputs) {
+ if (isInputFromComponentInstanceProperty(input.getName(), componentInstances, componentInstancesProperties)) {
+ associateInputToComponentInstanceProperty(userId, input, componentInstances, componentInstancesProperties, componentUniqueId);
+ } else {
+ associateInputToServiceProperty(userId, input, component);
+ }
}
- }
-
- final Either<List<InputDefinition>, StorageOperationStatus> either
- = toscaOperationFacade.updateInputsToComponent(inputs, componentUniqueId);
- if (either.isRight()) {
- throw new ComponentException(ActionStatus.GENERAL_ERROR);
+ Either<List<InputDefinition>, StorageOperationStatus> either = toscaOperationFacade.updateInputsToComponent(inputs, componentUniqueId);
+ if (either.isRight()) {
+ throw new ComponentException(ActionStatus.GENERAL_ERROR);
+ }
}
return component;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java
index 13e2ba3259..2e67a9bb47 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/DataTypeServlet.java
@@ -45,6 +45,7 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
+import org.apache.commons.lang3.StringUtils;
import org.openecomp.sdc.be.components.impl.DataTypeBusinessLogic;
import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
@@ -152,11 +153,11 @@ public class DataTypeServlet extends BeGenericServlet {
String model = dataType.getModel();
Optional<DataTypeDataDefinition> propertyDataType = dataTypeOperation.getDataTypeByNameAndModel(propertyDefinitionDto.getType(), model);
if (propertyDataType.isEmpty()) {
- if (model == null || model.isEmpty()) {
- model = "SDC AID";
+ if (StringUtils.isEmpty(model)) {
+ model = Constants.DEFAULT_MODEL_NAME;
}
throw new OperationException(ActionStatus.INVALID_MODEL,
- String.format("Property model is not the same as the data type model. Must be be '%s'", model));
+ String.format("Property model is not the same as the data type model. Must be '%s'", model));
}
final PropertyDefinitionDto property = dataTypeOperation.createProperty(id, propertyDefinitionDto);
dataTypeOperation.addPropertyToAdditionalTypeDataType(dataType, property);
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/config/ContainerInstanceTypesData.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/config/ContainerInstanceTypesData.java
index 7bf528105c..75a0cd625e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/config/ContainerInstanceTypesData.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/config/ContainerInstanceTypesData.java
@@ -27,6 +27,7 @@ import org.apache.commons.collections4.MapUtils;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.common.api.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
@@ -74,12 +75,12 @@ public class ContainerInstanceTypesData {
/**
* Gets the list of allowed component instances for a service of the given model.
*
- * @param model the model
+ * @param modelName the model
* @return the list of allowed component instances
*/
public List<String> getServiceAllowedList(final String modelName) {
List<String> allowedInstanceResourceType = getComponentAllowedList(ComponentTypeEnum.SERVICE, null);
- if (modelName == null || modelName.isEmpty() || modelName.equals("SDC AID")){
+ if (modelName == null || modelName.isEmpty() || modelName.equals(Constants.DEFAULT_MODEL_NAME)){
allowedInstanceResourceType.remove("VFC");
}
return allowedInstanceResourceType;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
index ceb505ac3c..31aea03a8e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
@@ -1534,7 +1534,7 @@ public class ToscaOperationFacade {
if (StorageOperationStatus.OK == status) {
log.debug(COMPONENT_CREATED_SUCCESSFULLY);
List<InputDefinition> inputsResList = null;
- if (inputsAsDataDef != null && !inputsAsDataDef.isEmpty()) {
+ if (CollectionUtils.isNotEmpty(inputsAsDataDef)) {
inputsResList = inputsAsDataDef.stream().map(InputDefinition::new).collect(Collectors.toList());
}
return Either.left(inputsResList);