aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be
diff options
context:
space:
mode:
Diffstat (limited to 'catalog-be')
-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
5 files changed, 47 insertions, 43 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);