diff options
Diffstat (limited to 'catalog-be/src/main/java')
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, |