summaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main/java
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2021-02-05 16:18:52 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-02-21 07:55:36 +0000
commit8cc03e2c78639be5500ab50f3ebaaf7d64404775 (patch)
tree1c4d82ba477c4de058f8817b717deaa2f3f4e877 /catalog-be/src/main/java
parent751ac4b93e575c56e29cdbbcf95e0aa899d914a2 (diff)
Update node and data types for SOL001 3.3.1 + CNF enhancements
Types in 2.7.1 folder are types valid for v3.3.1 that have not changed from v2.7.1 Types in 4.1.1 folder are the CNF enhancements which it is assumed will be in v4.1.1 Includes some changes in functionality to support: 1. Deployment of both existing (2.5.1) versions of types and new versions of types through sdc-BE-init 2. Selection of the correct node type definition version at onboarding of an ETSI SOL004 VNF/CNF csar, based on the declared version supported in the csar (i.e. when a 3.3.1 csar is imported, the node type definitions valid for 3.3.1 are used (rather than current logic which always selects the latest version) Signed-off-by: MichaelMorris <michael.morris@est.tech> Issue-ID: SDC-3470 Change-Id: Iff835d230b173b9d44349caa6b0b11d783e8f8d3
Diffstat (limited to 'catalog-be/src/main/java')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java34
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java9
3 files changed, 28 insertions, 23 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java
index 5ba9cfbe87..2e8344fc0a 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java
@@ -86,14 +86,10 @@ public class DataTypeImportManager {
return Either.right(responseFormat);
}
} else {
- // if it is not a scalar data type and it derives from abstract
- // data type, we should reject the request.
if (!ToscaPropertyType.isScalarType(dataTypeName) && isAbstract(derivedDataType)) {
- log.debug("Data type {} which derived from abstract data type must have at least one property", dataType.getName());
- ResponseFormat responseFormat = componentsUtils.getResponseFormatByDataType(ActionStatus.DATA_TYPE_NOR_PROPERTIES_NEITHER_DERIVED_FROM, dataType, null);
- return Either.right(responseFormat);
+ log.warn("Creating data type {} which derived from abstract data type with no properties", dataType.getName());
}
- }
+ }
} else {
// properties tag cannot be empty
if (properties.isEmpty()) {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index 80093bcf0a..01b7451a53 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -93,6 +93,7 @@ import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
import org.openecomp.sdc.be.datamodel.utils.ArtifactUtils;
import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
+import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ArtifactDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.GetInputValueDataDefinition;
@@ -3427,24 +3428,24 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
PropertyDefinition curPropertyDef = currPropertiesMap.get(propName);
ComponentInstanceProperty property = null;
-
+
String value = null;
List<GetInputValueDataDefinition> getInputs = null;
boolean isValidate = true;
if (propertyInfo.getValue() != null) {
- getInputs = propertyInfo.getGet_input();
- isValidate = getInputs == null || getInputs.isEmpty();
- if (isValidate) {
- value = getPropertyJsonStringValue(propertyInfo.getValue(), curPropertyDef.getType());
- } else {
- value = getPropertyJsonStringValue(propertyInfo.getValue(),
- TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
- }
- }
+ getInputs = propertyInfo.getGet_input();
+ isValidate = getInputs == null || getInputs.isEmpty();
+ if (isValidate) {
+ value = getPropertyJsonStringValue(propertyInfo.getValue(), curPropertyDef.getType());
+ } else {
+ value = getPropertyJsonStringValue(propertyInfo.getValue(),
+ TypeUtils.ToscaTagNamesEnum.GET_INPUT.getElementName());
+ }
+ }
property = new ComponentInstanceProperty(curPropertyDef, value, null);
String validatePropValue = validatePropValueBeforeCreate(property, value, isValidate, allDataTypes);
- property.setValue(validatePropValue);
+ property.setValue(validatePropValue);
if (getInputs != null && !getInputs.isEmpty()) {
List<GetInputValueDataDefinition> getInputValues = new ArrayList<>();
@@ -3706,7 +3707,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
.getToscaResourceName());
}
Resource refResource = validateResourceInstanceBeforeCreate(yamlName, uploadComponentInstanceInfo,
- existingnodeTypeMap);
+ existingnodeTypeMap, resource);
ComponentInstance componentInstance = new ComponentInstance();
componentInstance.setComponentUid(refResource.getUniqueId());
@@ -3796,7 +3797,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
}
private Resource validateResourceInstanceBeforeCreate(String yamlName,
- UploadComponentInstanceInfo uploadComponentInstanceInfo, Map<String, Resource> nodeNamespaceMap) {
+ UploadComponentInstanceInfo uploadComponentInstanceInfo, Map<String, Resource> nodeNamespaceMap, Resource resource) {
log.debug(
"validateResourceInstanceBeforeCreate - going to validate resource instance with name {} and type {} before create",
@@ -3806,10 +3807,11 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
refResource = nodeNamespaceMap.get(uploadComponentInstanceInfo.getType());
} else {
Either<Resource, StorageOperationStatus> findResourceEither = toscaOperationFacade
- .getLatestCertifiedNodeTypeByToscaResourceName(uploadComponentInstanceInfo.getType());
+ .getByToscaResourceNameMatchingVendorRelease(uploadComponentInstanceInfo.getType(),
+ ((ResourceMetadataDataDefinition)resource.getComponentMetadataDefinition().getMetadataDataDefinition()).getVendorRelease());
if (findResourceEither.isRight()) {
log.debug(
- "validateResourceInstanceBeforeCreate - not found lates version for resource instance with name {} and type {}",
+ "validateResourceInstanceBeforeCreate - not found latest version for resource instance with name {} and type {}",
uploadComponentInstanceInfo.getName(), uploadComponentInstanceInfo.getType());
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(findResourceEither.right().value()));
}
@@ -4139,7 +4141,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
if (derivedFromResource.getComponentType() == ComponentTypeEnum.RESOURCE) {
Resource parentResource = (Resource) derivedFromResource;
if (!(parentResource.isAbstract() && (ResourceTypeEnum.VFC == parentResource.getResourceType() || ResourceTypeEnum.ABSTRACT == parentResource.getResourceType())) &&
- parentResource.getResourceType() != updatedResourceType) {
+ parentResource.getResourceType() != updatedResourceType && oldResource.getResourceType() != updatedResourceType) {
BeEcompErrorManager.getInstance()
.logInternalDataError("mergeOldResourceMetadataWithNew", "resource type of the resource does not match to derived from resource type",
ErrorSeverity.ERROR);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index b2e4ef298f..7e5e1b9568 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -60,6 +60,7 @@ import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -196,7 +197,7 @@ public class ResourceImportManager {
populateResourceFromYaml(resourceYml, resource);
- Boolean isValidResource = validationFunction.apply(resource);
+ validationFunction.apply(resource);
if (!createNewVersion) {
Either<Resource, StorageOperationStatus> latestByName = toscaOperationFacade
.getLatestByName(resource.getName());
@@ -204,6 +205,12 @@ public class ResourceImportManager {
throw new ByActionStatusComponentException(ActionStatus.COMPONENT_NAME_ALREADY_EXIST,
resource.getName());
}
+ } else {
+ final Either<Resource, StorageOperationStatus> component = toscaOperationFacade.getComponentByNameAndVendorRelease(resource.getComponentType(), resource.getName(), resource.getVendorRelease(), JsonParseFlagEnum.ParseAll);
+ if (component.isLeft()) {
+ throw new ByActionStatusComponentException(ActionStatus.COMPONENT_VERSION_ALREADY_EXIST,
+ resource.getName());
+ }
}
resource = resourceBusinessLogic
.createOrUpdateResourceByImport(resource, creator, true, isInTransaction, needLock, csarInfo, nodeName,