import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
-import static java.util.stream.Collectors.toSet;
import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
import static org.apache.commons.collections.MapUtils.isEmpty;
import static org.apache.commons.collections.MapUtils.isNotEmpty;
import static org.openecomp.sdc.be.components.impl.ImportUtils.getPropertyJsonStringValue;
import static org.openecomp.sdc.be.tosca.CsarUtils.VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN;
import static org.openecomp.sdc.common.api.Constants.DEFAULT_GROUP_VF_MODULE;
+
+import com.google.common.annotations.VisibleForTesting;
+import fj.data.Either;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import org.openecomp.sdc.be.components.csar.CsarArtifactsAndGroupsBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarBusinessLogic;
import org.openecomp.sdc.be.components.csar.CsarInfo;
+import org.openecomp.sdc.be.components.csar.OnboardedCsarInfo;
import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum;
import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
import org.openecomp.sdc.be.components.impl.artifact.ArtifactOperationInfo;
import org.openecomp.sdc.be.components.merge.TopologyComparator;
import org.openecomp.sdc.be.components.merge.property.PropertyDataValueMergeBusinessLogic;
import org.openecomp.sdc.be.components.merge.resource.ResourceDataMergeBusinessLogic;
-import org.openecomp.sdc.be.components.merge.utils.MergeInstanceUtils;
import org.openecomp.sdc.be.components.property.PropertyConstraintsUtils;
import org.openecomp.sdc.be.components.validation.component.ComponentContactIdValidator;
import org.openecomp.sdc.be.components.validation.component.ComponentDescriptionValidator;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.jsongraph.JanusGraphDao;
+import org.openecomp.sdc.be.dao.janusgraph.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.enums.ComponentFieldsEnum;
import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.CreatedFrom;
+import org.openecomp.sdc.be.datatypes.enums.ModelTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DataTypeDefinition;
import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.GroupProperty;
import org.openecomp.sdc.be.model.InputDefinition;
import org.openecomp.sdc.be.model.InterfaceDefinition;
import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
import org.openecomp.sdc.be.model.Operation;
import org.openecomp.sdc.be.model.ParsedToscaYamlInfo;
import org.openecomp.sdc.be.model.PolicyDefinition;
+import org.openecomp.sdc.be.model.PolicyTypeDefinition;
import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.RelationshipImpl;
import org.openecomp.sdc.be.model.RelationshipInfo;
import org.openecomp.sdc.be.model.operations.api.IInterfaceLifecycleOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.operations.impl.InterfaceLifecycleOperation;
+import org.openecomp.sdc.be.model.operations.impl.ModelOperation;
import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
import org.openecomp.sdc.be.model.operations.utils.ComponentValidationUtils;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.be.user.UserBusinessLogic;
import org.openecomp.sdc.be.utils.CommonBeUtils;
import org.openecomp.sdc.be.utils.TypeUtils;
+import org.openecomp.sdc.be.utils.TypeUtils.ToscaTagNamesEnum;
import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
import org.openecomp.sdc.common.api.ArtifactTypeEnum;
import org.openecomp.sdc.common.api.Constants;
import org.springframework.context.annotation.Lazy;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
-import com.google.common.annotations.VisibleForTesting;
-import fj.data.Either;
@org.springframework.stereotype.Component("resourceBusinessLogic")
public class ResourceBusinessLogic extends ComponentBusinessLogic {
private final CompositionBusinessLogic compositionBusinessLogic;
private final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic;
private final CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic;
- private final MergeInstanceUtils mergeInstanceUtils;
private final UiComponentDataConverter uiComponentDataConverter;
private final CsarBusinessLogic csarBusinessLogic;
private final PropertyBusinessLogic propertyBusinessLogic;
private final PolicyBusinessLogic policyBusinessLogic;
private final ModelBusinessLogic modelBusinessLogic;
+ private final DataTypeBusinessLogic dataTypeBusinessLogic;
+ private final PolicyTypeBusinessLogic policyTypeBusinessLogic;
+ private final ModelOperation modelOperation;
private IInterfaceLifecycleOperation interfaceTypeOperation;
private LifecycleBusinessLogic lifecycleBusinessLogic;
@Autowired
final OutputsBusinessLogic outputsBusinessLogic, final CompositionBusinessLogic compositionBusinessLogic,
final ResourceDataMergeBusinessLogic resourceDataMergeBusinessLogic,
final CsarArtifactsAndGroupsBusinessLogic csarArtifactsAndGroupsBusinessLogic,
- final MergeInstanceUtils mergeInstanceUtils, final UiComponentDataConverter uiComponentDataConverter,
- final CsarBusinessLogic csarBusinessLogic, final ArtifactsOperations artifactToscaOperation,
- final PropertyBusinessLogic propertyBusinessLogic, final ComponentContactIdValidator componentContactIdValidator,
- final ComponentNameValidator componentNameValidator, final ComponentTagsValidator componentTagsValidator,
- final ComponentValidator componentValidator, final ComponentIconValidator componentIconValidator,
+ final UiComponentDataConverter uiComponentDataConverter, final CsarBusinessLogic csarBusinessLogic,
+ final ArtifactsOperations artifactToscaOperation, final PropertyBusinessLogic propertyBusinessLogic,
+ final ComponentContactIdValidator componentContactIdValidator, final ComponentNameValidator componentNameValidator,
+ final ComponentTagsValidator componentTagsValidator, final ComponentValidator componentValidator,
+ final ComponentIconValidator componentIconValidator,
final ComponentProjectCodeValidator componentProjectCodeValidator,
final ComponentDescriptionValidator componentDescriptionValidator, final PolicyBusinessLogic policyBusinessLogic,
- final ModelBusinessLogic modelBusinessLogic) {
+ final ModelBusinessLogic modelBusinessLogic, final DataTypeBusinessLogic dataTypeBusinessLogic,
+ final PolicyTypeBusinessLogic policyTypeBusinessLogic, final ModelOperation modelOperation) {
super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, interfaceOperation,
interfaceLifecycleTypeOperation, artifactsBusinessLogic, artifactToscaOperation, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator);
this.compositionBusinessLogic = compositionBusinessLogic;
this.resourceDataMergeBusinessLogic = resourceDataMergeBusinessLogic;
this.csarArtifactsAndGroupsBusinessLogic = csarArtifactsAndGroupsBusinessLogic;
- this.mergeInstanceUtils = mergeInstanceUtils;
this.uiComponentDataConverter = uiComponentDataConverter;
this.csarBusinessLogic = csarBusinessLogic;
this.propertyBusinessLogic = propertyBusinessLogic;
this.policyBusinessLogic = policyBusinessLogic;
this.modelBusinessLogic = modelBusinessLogic;
+ this.dataTypeBusinessLogic = dataTypeBusinessLogic;
+ this.policyTypeBusinessLogic = policyTypeBusinessLogic;
+ this.modelOperation = modelOperation;
}
static <T> Either<T, RuntimeException> rollbackWithEither(final JanusGraphDao janusGraphDao, final ActionStatus actionStatus,
this.artifactsBusinessLogic = artifactsManager;
}
- public ApplicationDataTypeCache getApplicationDataTypeCache() {
- return applicationDataTypeCache;
- }
-
@Autowired
@Override
public void setApplicationDataTypeCache(ApplicationDataTypeCache applicationDataTypeCache) {
validateLifecycleState(oldResource, user);
String lockedResourceId = oldResource.getUniqueId();
List<ArtifactDefinition> createdArtifacts = new ArrayList<>();
- CsarInfo csarInfo = csarBusinessLogic.getCsarInfo(newResource, oldResource, user, csarUIPayload, csarUUID);
+ CsarInfo csarInfo = csarBusinessLogic.getCsarInfo(newResource, oldResource, user, csarUIPayload, csarUUID, null);
lockComponent(lockedResourceId, oldResource, "update Resource From Csar");
Map<String, NodeTypeInfo> nodeTypesInfo = csarInfo.extractTypesInfo();
Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = findNodeTypesArtifactsToHandle(
preparedResource = updateExistingResourceByImport(newResource, oldResource, csarInfo.getModifier(), inTransaction, shouldLock,
isNested).left;
log.trace("YAML topology file found in CSAR, file name: {}, contents: {}", yamlFileName, yamlFileContent);
- handleResourceGenericType(preparedResource, yamlFileContent, uploadComponentInstanceInfoMap, uploadComponentInstanceInfoMap.getSubstitutionMappingNodeType());
+ handleResourceGenericType(preparedResource, yamlFileContent, uploadComponentInstanceInfoMap,
+ uploadComponentInstanceInfoMap.getSubstitutionMappingNodeType());
handleNodeTypes(yamlFileName, preparedResource, yamlFileContent, shouldLock, nodeTypesArtifactsToHandle, createdArtifacts, nodeTypesInfo,
csarInfo, nodeName, newResource.getModel());
preparedResource = createInputsOnResource(preparedResource, uploadComponentInstanceInfoMap.getInputs());
Map<String, Resource> existingNodeTypesByResourceNames = new HashMap<>();
- final Map<String, UploadComponentInstanceInfo> instancesToCreate = getInstancesToCreate(uploadComponentInstanceInfoMap, newResource.getModel());
+ final Map<String, UploadComponentInstanceInfo> instancesToCreate = getInstancesToCreate(uploadComponentInstanceInfoMap,
+ newResource.getModel());
preparedResource = createResourceInstances(yamlFileName, preparedResource, oldResource, instancesToCreate, csarInfo.getCreatedNodes(),
existingNodeTypesByResourceNames);
- preparedResource = createResourceInstancesRelations(csarInfo.getModifier(), yamlFileName, preparedResource, oldResource, instancesToCreate,
+ preparedResource = createResourceInstancesRelations(csarInfo.getModifier(), yamlFileName, preparedResource, oldResource,
+ instancesToCreate,
existingNodeTypesByResourceNames);
} catch (ComponentException e) {
ResponseFormat responseFormat =
}
return Either.left(resource);
}
-
+
private Resource handleResourceGenericType(Resource resource) {
Resource genericResource = fetchAndSetDerivedFromGenericType(resource);
-
+
if (resource.shouldGenerateInputs()) {
generateAndAddInputsFromGenericTypeProperties(resource, genericResource);
}
return genericResource;
}
- private Resource handleResourceGenericType(final Resource resource, final String topologyTemplateYaml, final ParsedToscaYamlInfo parsedToscaYamlInfo, final String substitutionMappingNodeType) {
+ private Resource handleResourceGenericType(final Resource resource, final String topologyTemplateYaml,
+ final ParsedToscaYamlInfo parsedToscaYamlInfo, final String substitutionMappingNodeType) {
if (processSubstitutableAsNodeType(resource, parsedToscaYamlInfo)) {
- final Map<String, Object> substitutableAsNodeType = getSubstitutableAsNodeTypeFromTemplate((Map<String, Object>) new Yaml().load(topologyTemplateYaml), substitutionMappingNodeType);
- final Resource genericResource = fetchAndSetDerivedFromGenericType(resource, (String)substitutableAsNodeType.get(TypeUtils.ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
-
+ final Map<String, Object> substitutableAsNodeType = getSubstitutableAsNodeTypeFromTemplate(
+ (Map<String, Object>) new Yaml().load(topologyTemplateYaml), substitutionMappingNodeType);
+ final Resource genericResource = fetchAndSetDerivedFromGenericType(resource,
+ (String) substitutableAsNodeType.get(TypeUtils.ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
+
generatePropertiesFromGenericType(resource, genericResource);
generatePropertiesFromNodeType(resource, substitutableAsNodeType);
final String resourceId = resource.getUniqueId();
- resource.getProperties().forEach(propertyDefinition -> propertyDefinition.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(resourceId, propertyDefinition.getName())));
+ resource.getProperties().forEach(propertyDefinition -> propertyDefinition.setUniqueId(
+ UniqueIdBuilder.buildPropertyUniqueId(resourceId, propertyDefinition.getName())));
createResourcePropertiesOnGraph(resource);
return genericResource;
- }
+ }
return handleResourceGenericType(resource);
}
if (!nodes.isEmpty()) {
for (Entry<String, Object> nodeType : nodes.entrySet()) {
final ImmutablePair<String, String> toscaResourceName = buildNestedToscaResourceName(ResourceTypeEnum.VFC.name(), vfResourceName,
- nodeType.getKey());
+ nodeType.getKey());
vfcToscaNames.put(nodeType.getKey(), toscaResourceName);
}
}
loggerSupportability
.log(LoggerSupportabilityActions.CREATE_RESOURCE_FROM_YAML, StatusCode.STARTED, "Starting to create Resource From Csar by user {}",
user.getUserId());
- CsarInfo csarInfo = csarBusinessLogic.getCsarInfo(resource, null, user, csarUIPayload, csarUUID);
+ OnboardedCsarInfo csarInfo = csarBusinessLogic.getCsarInfo(resource, null, user, csarUIPayload, csarUUID, null);
+
Map<String, NodeTypeInfo> nodeTypesInfo = csarInfo.extractTypesInfo();
- if (StringUtils.isNotEmpty(resource.getModel())) {
- final Map<String, Object> dataTypesToCreate = new HashMap<>();
- for (final String dataType: csarInfo.getDataTypes().keySet()) {
- final Either<DataTypeDefinition, StorageOperationStatus> result = propertyOperation.getDataTypeByName(dataType, resource.getModel());
- if (result.isRight() && result.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
- dataTypesToCreate.put(dataType, csarInfo.getDataTypes().get(dataType));
- }
+ final String model = resource.getModel();
+ if (StringUtils.isNotEmpty(model)) {
+ final Map<String, Object> dataTypesToCreate = getDatatypesToCreate(model, csarInfo.getDataTypes());
+ final Map<String, Object> policyTypesToCreate = getPolicytypesToCreate(model, csarInfo.getPolicyTypes());
+ if (MapUtils.isNotEmpty(dataTypesToCreate) || MapUtils.isNotEmpty(policyTypesToCreate)) {
+ createModel(resource, csarInfo.getVfResourceName());
}
if (MapUtils.isNotEmpty(dataTypesToCreate)) {
- final String nameForGeneratedModel = resource.getModel() + "_" + csarInfo.getVfResourceName() + resource.getCsarVersion();
- final Model model = new Model(nameForGeneratedModel, resource.getModel());
- modelBusinessLogic.createModel(model, new Yaml().dump(dataTypesToCreate));
- resource.setModel(nameForGeneratedModel);
+ dataTypeBusinessLogic.createDataTypeFromYaml(new Yaml().dump(dataTypesToCreate), model, true);
+ }
+ if (MapUtils.isNotEmpty(policyTypesToCreate)) {
+ policyTypeBusinessLogic.createPolicyTypeFromYaml(new Yaml().dump(policyTypesToCreate), model, true);
}
}
-
Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = findNodeTypesArtifactsToHandle(
nodeTypesInfo, csarInfo, resource);
if (findNodeTypesArtifactsToHandleRes.isRight()) {
boolean needLock,
Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
- Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo, final String substitutableAsNodeType) {
+ Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
+ final String substitutableAsNodeType) {
Either<String, ResultStatusEnum> toscaVersion = findFirstToscaStringElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.TOSCA_VERSION);
if (toscaVersion.isRight()) {
throw new ByActionStatusComponentException(ActionStatus.INVALID_TOSCA_TEMPLATE);
private Map<String, Object> getNodeTypesFromTemplate(final Map<String, Object> mappedToscaTemplate, final String substitutableAsNodeType) {
final Map<String, Object> nodeTypes = getAllNodeTypesInTemplate(mappedToscaTemplate);
- if (StringUtils.isNotEmpty(substitutableAsNodeType)){
- nodeTypes.remove(substitutableAsNodeType);
+ if (StringUtils.isNotEmpty(substitutableAsNodeType)) {
+ nodeTypes.remove(substitutableAsNodeType);
}
return nodeTypes;
}
-
+
@SuppressWarnings("unchecked")
- private Map<String, Object> getSubstitutableAsNodeTypeFromTemplate(final Map<String, Object> mappedToscaTemplate, final String substitutableAsNodeType) {
- return (Map<String, Object>)getAllNodeTypesInTemplate(mappedToscaTemplate).get(substitutableAsNodeType);
+ private Map<String, Object> getSubstitutableAsNodeTypeFromTemplate(final Map<String, Object> mappedToscaTemplate,
+ final String substitutableAsNodeType) {
+ return (Map<String, Object>) getAllNodeTypesInTemplate(mappedToscaTemplate).get(substitutableAsNodeType);
}
-
+
private Map<String, Object> getAllNodeTypesInTemplate(final Map<String, Object> mappedToscaTemplate) {
return ImportUtils.findFirstToscaMapElement(mappedToscaTemplate, TypeUtils.ToscaTagNamesEnum.NODE_TYPES).left().orValue(HashMap::new);
}
+ private void createModel(final Resource resource, final String vfResourcename) {
+ final String nameForGeneratedModel = resource.getModel() + "_" + vfResourcename + resource.getCsarVersion();
+ Model model = new Model(nameForGeneratedModel, resource.getModel(), ModelTypeEnum.NORMATIVE_EXTENSION);
+ modelBusinessLogic.createModel(model);
+ resource.setModel(nameForGeneratedModel);
+ }
+
+ private Map<String, Object> getDatatypesToCreate(final String model, final Map<String, Object> dataTypes) {
+ final Map<String, Object> dataTypesToCreate = new HashMap<>();
+ for (final String dataType : dataTypes.keySet()) {
+ final Either<DataTypeDefinition, StorageOperationStatus> result =
+ propertyOperation.getDataTypeByName(dataType, model);
+ if (result.isRight() && result.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
+ dataTypesToCreate.put(dataType, dataTypes.get(dataType));
+ }
+ }
+ return dataTypesToCreate;
+ }
+
+ private Map<String, Object> getPolicytypesToCreate(final String model, final Map<String, Object> policyTypes) {
+ final Map<String, Object> policyTypesToCreate = new HashMap<>();
+ for (final String policyType : policyTypes.keySet()) {
+ final Either<PolicyTypeDefinition, StorageOperationStatus> result =
+ policyTypeOperation.getLatestPolicyTypeByType(policyType, model);
+ if (result.isRight() && result.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
+ policyTypesToCreate.put(policyType, policyTypes.get(policyType));
+ }
+ }
+ return policyTypesToCreate;
+ }
+
private void createNodeTypes(String yamlName, Resource resource, boolean needLock,
Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle,
List<ArtifactDefinition> nodeTypesNewCreatedArtifacts, Map<String, NodeTypeInfo> nodeTypesInfo, CsarInfo csarInfo,
Function<Resource, Boolean> validator = resource -> validateResourceCreationFromNodeType(resource, creator);
return resourceImportManager
.importCertifiedResource(nodeTypeYaml, resourceMetaData, creator, validator, lifecycleChangeInfo, isInTransaction, true, needLock,
- nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested);
+ nodeTypeArtifactsToHandle, nodeTypesNewCreatedArtifacts, forceCertificationAllowed, csarInfo, nodeName, isNested, null);
}
/**
resourceMetaData.setIcon(ImportUtils.Constants.DEFAULT_ICON);
resourceMetaData.setContactId(user.getUserId());
resourceMetaData.setVendorName(resourceVf.getVendorName());
+ resourceMetaData.setTenant(resourceVf.getTenant());
resourceMetaData.setVendorRelease(resourceVf.getVendorRelease());
resourceMetaData.setModel(resourceVf.getModel());
// Setting tag
cvfc.setContactId(csarInfo.getModifier().getUserId());
cvfc.setCreatorUserId(csarInfo.getModifier().getUserId());
cvfc.setVendorName(resourceVf.getVendorName());
+ cvfc.setTenant(resourceVf.getTenant());
cvfc.setVendorRelease(resourceVf.getVendorRelease());
cvfc.setModel(resourceVf.getModel());
cvfc.setResourceVendorModelNumber(resourceVf.getResourceVendorModelNumber());
loggerSupportability.log(LoggerSupportabilityActions.CREATE_INPUTS, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
"Starting to add inputs from yaml: {}", yamlName);
if (processSubstitutableAsNodeType(resource, parsedToscaYamlInfo)) {
- final Map<String, Object> substitutableAsNodeType = getSubstitutableAsNodeTypeFromTemplate((Map<String, Object>) new Yaml().load(topologyTemplateYaml), parsedToscaYamlInfo.getSubstitutionMappingNodeType());
+ final Map<String, Object> substitutableAsNodeType = getSubstitutableAsNodeTypeFromTemplate(
+ (Map<String, Object>) new Yaml().load(topologyTemplateYaml), parsedToscaYamlInfo.getSubstitutionMappingNodeType());
resource.setToscaResourceName(parsedToscaYamlInfo.getSubstitutionMappingNodeType());
- final Resource genericResource = fetchAndSetDerivedFromGenericType(resource, (String)substitutableAsNodeType.get(TypeUtils.ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
+ final Resource genericResource = fetchAndSetDerivedFromGenericType(resource,
+ (String) substitutableAsNodeType.get(TypeUtils.ToscaTagNamesEnum.DERIVED_FROM.getElementName()));
resource = createResourceTransaction(resource, csarInfo.getModifier(), isNormative);
generatePropertiesFromGenericType(resource, genericResource);
generatePropertiesFromNodeType(resource, substitutableAsNodeType);
final String resourceId = resource.getUniqueId();
- resource.getProperties().forEach(propertyDefinition -> propertyDefinition.setUniqueId(UniqueIdBuilder.buildPropertyUniqueId(resourceId, propertyDefinition.getName())));
+ resource.getProperties().forEach(propertyDefinition -> propertyDefinition.setUniqueId(
+ UniqueIdBuilder.buildPropertyUniqueId(resourceId, propertyDefinition.getName())));
createResourcePropertiesOnGraph(resource);
final Map<String, UploadComponentInstanceInfo> instancesToCreate = getInstancesToCreate(parsedToscaYamlInfo, resource.getModel());
-
- log.trace("************* Going to create nodes, RI's and Relations from yaml {}", yamlName);
- loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RESOURCE_FROM_YAML, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
- "Start create nodes, RI and Relations from yaml: {}", yamlName);
- resource = createRIAndRelationsFromYaml(yamlName, resource, instancesToCreate, topologyTemplateYaml,
- nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, nodeName, parsedToscaYamlInfo.getSubstitutionMappingNodeType());
+
+ if (MapUtils.isNotEmpty(instancesToCreate)) {
+ log.trace("************* Going to create nodes, RI's and Relations from yaml {}", yamlName);
+ loggerSupportability
+ .log(LoggerSupportabilityActions.CREATE_RESOURCE_FROM_YAML, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
+ "Start create nodes, RI and Relations from yaml: {}", yamlName);
+ resource = createRIAndRelationsFromYaml(yamlName, resource, instancesToCreate, topologyTemplateYaml,
+ nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, nodeName,
+ parsedToscaYamlInfo.getSubstitutionMappingNodeType());
+ }
} else {
final Resource genericResource = fetchAndSetDerivedFromGenericType(resource, null);
resource = createResourceTransaction(resource, csarInfo.getModifier(), isNormative);
}
final Map<String, InputDefinition> inputs = parsedToscaYamlInfo.getInputs();
resource = createInputsOnResource(resource, inputs);
-
+
log.trace("************* Finish to add inputs from yaml {}", yamlName);
loggerSupportability.log(LoggerSupportabilityActions.CREATE_INPUTS, resource.getComponentMetadataForSupportLog(), StatusCode.COMPLETE,
"Finish to add inputs from yaml: {}", yamlName);
log.trace("************* Adding software information to PNF");
softwareInformationBusinessLogic.setSoftwareInformation(resource, csarInfo);
log.trace("************* Removing non-mano software information file from PNF");
- if (csarInfo.getSoftwareInformationPath().isPresent() && !softwareInformationBusinessLogic.removeSoftwareInformationFile(csarInfo)) {
+ if (csarInfo.getSoftwareInformationPath().isPresent() && !softwareInformationBusinessLogic.removeSoftwareInformationFile(
+ csarInfo)) {
log.warn(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, ResourceBusinessLogic.class.getName(), "catalog-be",
"Could not remove the software information file.");
}
}
final Map<String, UploadComponentInstanceInfo> instancesToCreate = getInstancesToCreate(parsedToscaYamlInfo);
-
+
log.trace("************* Going to create nodes, RI's and Relations from yaml {}", yamlName);
loggerSupportability
.log(LoggerSupportabilityActions.CREATE_RESOURCE_FROM_YAML, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
"Start create nodes, RI and Relations from yaml: {}", yamlName);
resource = createRIAndRelationsFromYaml(yamlName, resource, instancesToCreate, topologyTemplateYaml,
nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo, nodeTypesArtifactsToCreate, nodeName, null);
- }
-
+ }
log.trace("************* Finished to create nodes, RI and Relation from yaml {}", yamlName);
loggerSupportability.log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.COMPLETE,
"Finished to create nodes, RI and Relation from yaml: {}", yamlName);
// validate update vf module group names
+ Optional<Map<String, GroupDefinition>> asdGroups = checkAndCreateAsdTypeVfModules(parsedToscaYamlInfo.getInstances());
+ Map<String, GroupDefinition> parsedGroups = parsedToscaYamlInfo.getGroups();
+ if (asdGroups.isPresent()) {
+ parsedGroups.putAll(asdGroups.get());
+ }
final Either<Map<String, GroupDefinition>, ResponseFormat> validateUpdateVfGroupNamesRes = groupBusinessLogic
- .validateUpdateVfGroupNames(parsedToscaYamlInfo.getGroups(), resource.getSystemName());
+ .validateUpdateVfGroupNames(parsedGroups, resource.getSystemName());
if (validateUpdateVfGroupNamesRes.isRight()) {
rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ByResponseFormatComponentException(validateUpdateVfGroupNamesRes.right().value());
if (!validateUpdateVfGroupNamesRes.left().value().isEmpty()) {
groups = validateUpdateVfGroupNamesRes.left().value();
} else {
- groups = parsedToscaYamlInfo.getGroups();
+ groups = parsedGroups;
}
final Either<Resource, ResponseFormat> createGroupsOnResource = createGroupsOnResource(resource, groups);
if (createGroupsOnResource.isRight()) {
rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
throw new ByResponseFormatComponentException(e.getResponseFormat());
} catch (final ComponentException e) {
- log.error(EcompLoggerErrorCode.SCHEMA_ERROR, ResourceBusinessLogic.class.getName(),
- "An error has occurred during resource and resource instance creation", e);
- rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
- throw new ByResponseFormatComponentException(e.getResponseFormat());
- } catch (final Exception e) {
+ log.error(EcompLoggerErrorCode.SCHEMA_ERROR, ResourceBusinessLogic.class.getName(),
+ "An error has occurred during resource and resource instance creation", e);
+ rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
+ throw new ByResponseFormatComponentException(e.getResponseFormat());
+ } catch (final Exception e) {
log.error(EcompLoggerErrorCode.BUSINESS_PROCESS_ERROR, ResourceBusinessLogic.class.getName(),
"An error has occurred during resource and resource instance creation", e);
rollback(inTransaction, resource, createdArtifacts, nodeTypesNewCreatedArtifacts);
}
}
}
-
+
+ private Optional<Map<String, GroupDefinition>> checkAndCreateAsdTypeVfModules(Map<String, UploadComponentInstanceInfo> instances) {
+ Map<String, GroupDefinition> addAsdGroups = new HashMap<>();
+ if (isNotEmpty(instances) || instances != null) {
+ for (Map.Entry<String, UploadComponentInstanceInfo> instance : instances.entrySet()) {
+ if (isNotEmpty(instance.getValue().getArtifacts()) || instance.getValue().getArtifacts() != null) {
+ Map<String, UploadArtifactInfo> artifactsMap = instance.getValue().getArtifacts()
+ .get(ToscaTagNamesEnum.ARTIFACTS.getElementName());
+ if (isNotEmpty(artifactsMap) || artifactsMap != null) {
+ for (Map.Entry<String, UploadArtifactInfo> artifact : artifactsMap.entrySet()) {
+ if (artifact.getValue().getType().equals(Constants.ASD_DEPLOYMENT_ITEM)) {
+ GroupDefinition groupDefinition = new GroupDefinition();
+ groupDefinition.setName(artifact.getKey());
+ groupDefinition.setType(Constants.DEFAULT_GROUP_VF_MODULE);
+ addAsdTypeProperties(groupDefinition);
+ addAsdGroups.put(groupDefinition.getName(), groupDefinition);
+ }
+ }
+ }
+ }
+ }
+ }
+ return Optional.of(addAsdGroups);
+ }
+
+ private void addAsdTypeProperties(GroupDefinition groupDefinition) {
+ List<GroupProperty> properties = new ArrayList<>();
+ GroupProperty propIsBase = new GroupProperty();
+ propIsBase.setName(Constants.IS_BASE);
+ propIsBase.setValue("true");
+ properties.add(propIsBase);
+ GroupProperty propVfModuleLabel = new GroupProperty();
+ propVfModuleLabel.setName(Constants.VF_MODULE_LABEL);
+ propVfModuleLabel.setValue(groupDefinition.getName());
+ properties.add(propVfModuleLabel);
+ GroupProperty propVfModuleDescription = new GroupProperty();
+ propVfModuleDescription.setName(Constants.VF_MODULE_DESCRIPTION);
+ propVfModuleDescription.setValue("VF Module representing deployment item " + groupDefinition.getName());
+ properties.add(propVfModuleDescription);
+ GroupProperty propMinVfModuleInstances = new GroupProperty();
+ propMinVfModuleInstances.setName(Constants.MIN_VF_MODULE_INSTANCES);
+ propMinVfModuleInstances.setValue("1");
+ properties.add(propMinVfModuleInstances);
+ GroupProperty propMaxVfModuleInstances = new GroupProperty();
+ propMaxVfModuleInstances.setName(Constants.MAX_VF_MODULE_INSTANCES);
+ propMaxVfModuleInstances.setValue("1");
+ properties.add(propMaxVfModuleInstances);
+ GroupProperty propInitialCount = new GroupProperty();
+ propInitialCount.setName(Constants.INITIAL_COUNT);
+ propInitialCount.setValue("1");
+ properties.add(propInitialCount);
+ GroupProperty propVfModuleType = new GroupProperty();
+ propVfModuleType.setName(Constants.VF_MODULE_TYPE);
+ propVfModuleType.setValue("Base");
+ properties.add(propVfModuleType);
+ GroupProperty propVolumeGroup = new GroupProperty();
+ propVolumeGroup.setName(Constants.VOLUME_GROUP);
+ propVolumeGroup.setValue("false");
+ properties.add(propVolumeGroup);
+ groupDefinition.convertFromGroupProperties(properties);
+ }
+
private boolean processSubstitutableAsNodeType(final Resource resource, final ParsedToscaYamlInfo parsedToscaYamlInfo) {
- return !resource.getResourceType().isAtomicType() && StringUtils.isNotEmpty(resource.getModel()) && parsedToscaYamlInfo.getSubstitutionMappingNodeType() != null;
+ return !resource.getResourceType().isAtomicType() && StringUtils.isNotEmpty(resource.getModel())
+ && parsedToscaYamlInfo.getSubstitutionMappingNodeType() != null;
}
-
+
private Map<String, UploadComponentInstanceInfo> getInstancesToCreate(final ParsedToscaYamlInfo parsedToscaYamlInfo) {
return getInstancesToCreate(parsedToscaYamlInfo, null);
}
-
+
private Map<String, UploadComponentInstanceInfo> getInstancesToCreate(final ParsedToscaYamlInfo parsedToscaYamlInfo, final String model) {
if (StringUtils.isEmpty(model) || StringUtils.isEmpty(parsedToscaYamlInfo.getSubstitutionMappingNodeType())) {
return parsedToscaYamlInfo.getInstances();
}
- return parsedToscaYamlInfo.getInstances().entrySet().stream().filter(entry -> !parsedToscaYamlInfo.getSubstitutionMappingNodeType().equals(entry.getValue().getType()))
+ return parsedToscaYamlInfo.getInstances().entrySet().stream()
+ .filter(entry -> !parsedToscaYamlInfo.getSubstitutionMappingNodeType().equals(entry.getValue().getType()))
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
}
}
private Resource createPoliciesOnResource(Resource resource, Map<String, PolicyDefinition> policies) {
- policyBusinessLogic.createPoliciesFromParsedCsar(resource, policies);
+ policyBusinessLogic.createPolicies(resource, policies);
return resource;
}
}
return resource;
}
-
+
private Resource generatePropertiesFromNodeType(final Resource resource, final Map<String, Object> nodeType) {
final Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils.getProperties(nodeType);
if (properties.isLeft()) {
}
}
resource.getProperties().addAll(propertiesList);
- }
+ }
return resource;
}
-
+
private Resource createResourcePropertiesOnGraph(final Resource resource) {
final List<PropertyDefinition> resourceProperties = resource.getProperties();
- for (PropertyDefinition propertyDefinition: resourceProperties) {
+ for (PropertyDefinition propertyDefinition : resourceProperties) {
final Either<PropertyDefinition, StorageOperationStatus> addPropertyEither = toscaOperationFacade
- .addPropertyToComponent(propertyDefinition.getName(), propertyDefinition, resource);
-
+ .addPropertyToComponent(propertyDefinition, resource);
+
if (addPropertyEither.isRight()) {
- final String error = String.format("failed to add properties from yaml: {}", addPropertyEither.right().value());
- loggerSupportability.log(LoggerSupportabilityActions.CREATE_PROPERTIES, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- error);
+ final String error = String.format("failed to add properties from yaml: %s", addPropertyEither.right().value());
+ loggerSupportability.log(LoggerSupportabilityActions.CREATE_PROPERTIES, resource.getComponentMetadataForSupportLog(),
+ StatusCode.ERROR,
+ error);
throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(addPropertyEither.right().value()), error);
}
}
List<GroupDefinition> result = new ArrayList<>();
List<ComponentInstance> componentInstances = component.getComponentInstances();
if (groups != null) {
- Either<Boolean, ResponseFormat> validateCyclicGroupsDependencies = validateCyclicGroupsDependencies(groups);
- if (validateCyclicGroupsDependencies.isRight()) {
- throw new ByResponseFormatComponentException(validateCyclicGroupsDependencies.right().value());
- }
for (Entry<String, GroupDefinition> entry : groups.entrySet()) {
String groupName = entry.getKey();
GroupDefinition groupDefinition = entry.getValue();
GroupDefinition updatedGroupDefinition = new GroupDefinition(groupDefinition);
+
updatedGroupDefinition.setMembers(null);
Map<String, String> members = groupDefinition.getMembers();
if (members != null) {
updatedGroupDefinition.setMembers(relevantInstances);
}
- /**
- * This Method validates that there is no cyclic group dependencies. meaning group A as member in group B which is member in group A
- *
- * @param allGroups
- * @return
- */
- private Either<Boolean, ResponseFormat> validateCyclicGroupsDependencies(Map<String, GroupDefinition> allGroups) {
- Either<Boolean, ResponseFormat> result = Either.left(true);
- try {
- Iterator<Entry<String, GroupDefinition>> allGroupsItr = allGroups.entrySet().iterator();
- while (allGroupsItr.hasNext() && result.isLeft()) {
- Entry<String, GroupDefinition> groupAEntry = allGroupsItr.next();
- // Fetches a group member A
- String groupAName = groupAEntry.getKey();
- // Finds all group members in group A
- Set<String> allGroupAMembersNames = new HashSet<>();
- fillAllGroupMemebersRecursivly(groupAEntry.getKey(), allGroups, allGroupAMembersNames);
- // If A is a group member of itself found cyclic dependency
- if (allGroupAMembersNames.contains(groupAName)) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GROUP_HAS_CYCLIC_DEPENDENCY, groupAName);
- result = Either.right(responseFormat);
- }
- }
- } catch (Exception e) {
- ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
- result = Either.right(responseFormat);
- log.debug("Exception occurred when validateCyclicGroupsDependencies, error is:{}", e.getMessage(), e);
- }
- return result;
- }
-
- /**
- * This Method fills recursively the set groupMembers with all the members of the given group which are also of type group.
- *
- * @param groupName
- * @param allGroups
- * @param allGroupMembers
- * @return
- */
- private void fillAllGroupMemebersRecursivly(String groupName, Map<String, GroupDefinition> allGroups, Set<String> allGroupMembers) {
- // Found Cyclic dependency
- if (isfillGroupMemebersRecursivlyStopCondition(groupName, allGroups, allGroupMembers)) {
- return;
- }
- GroupDefinition groupDefinition = allGroups.get(groupName);
- // All Members Of Current Group Resource Instances & Other Groups
- Set<String> currGroupMembers = groupDefinition.getMembers().keySet();
- // Filtered Members Of Current Group containing only members which
-
- // are groups
- List<String> currGroupFilteredMembers = currGroupMembers.stream().
- // Keep Only Elements of type group and not Resource Instances
- filter(allGroups::containsKey).
- // Add Filtered Elements to main Set
- peek(allGroupMembers::add).
- // Collect results
- collect(toList());
- // Recursively call the method for all the filtered group members
- for (String innerGroupName : currGroupFilteredMembers) {
- fillAllGroupMemebersRecursivly(innerGroupName, allGroups, allGroupMembers);
- }
- }
-
- private boolean isfillGroupMemebersRecursivlyStopCondition(String groupName, Map<String, GroupDefinition> allGroups,
- Set<String> allGroupMembers) {
- boolean stop = !allGroups.containsKey(groupName);
- // In Case Not Group Stop
- // In Case Group Has no members stop
- if (!stop) {
- GroupDefinition groupDefinition = allGroups.get(groupName);
- stop = isEmpty(groupDefinition.getMembers());
- }
- // In Case all group members already contained stop
- if (!stop) {
- final Set<String> allMembers = allGroups.get(groupName).getMembers().keySet();
- Set<String> membersOfTypeGroup = allMembers.stream().
- // Filter In Only Group members
- filter(allGroups::containsKey).
- // Collect
- collect(toSet());
- stop = allGroupMembers.containsAll(membersOfTypeGroup);
- }
- return stop;
- }
-
private Resource createRIAndRelationsFromYaml(String yamlName, Resource resource,
Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap,
String topologyTemplateYaml, List<ArtifactDefinition> nodeTypesNewCreatedArtifacts,
Constants.VENDOR_LICENSE_MODEL, ArtifactTypeEnum.VENDOR_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
Constants.VENDOR_LICENSE_LABEL, Constants.VENDOR_LICENSE_DISPLAY_NAME, Constants.VENDOR_LICENSE_DESCRIPTION, vendorLicenseModelId,
artifactOperation, null, true, shouldLock, inTransaction);
- createOrUpdateSingleNonMetaArtifact(resource, csarInfo, CsarUtils.ARTIFACTS_PATH + Constants.VF_LICENSE_MODEL, Constants.VF_LICENSE_MODEL,
- ArtifactTypeEnum.VF_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT, Constants.VF_LICENSE_LABEL,
- Constants.VF_LICENSE_DISPLAY_NAME, Constants.VF_LICENSE_DESCRIPTION, vfLicenseModelId, artifactOperation, null, true, shouldLock,
- inTransaction);
- Either<Resource, ResponseFormat> eitherCreateResult = createOrUpdateNonMetaArtifacts(csarInfo, resource, createdArtifacts, shouldLock,
- inTransaction, artifactOperation);
+ createOrUpdateSingleNonMetaArtifact(resource, csarInfo, CsarUtils.ARTIFACTS_PATH + Constants.VF_LICENSE_MODEL,
+ Constants.VF_LICENSE_MODEL, ArtifactTypeEnum.VF_LICENSE.getType(), ArtifactGroupTypeEnum.DEPLOYMENT,
+ Constants.VF_LICENSE_LABEL, Constants.VF_LICENSE_DISPLAY_NAME, Constants.VF_LICENSE_DESCRIPTION, vfLicenseModelId,
+ artifactOperation, null, true, shouldLock, inTransaction);
+ Either<Resource, ResponseFormat> eitherCreateResult
+ = createOrUpdateNonMetaArtifacts(csarInfo, resource, createdArtifacts, shouldLock, inTransaction, artifactOperation);
if (eitherCreateResult.isRight()) {
return Either.right(eitherCreateResult.right().value());
}
return Either.right(createArtifactsFromCsar.right().value());
}
return Either.left(createArtifactsFromCsar.left().value());
- } else {
- return csarArtifactsAndGroupsBusinessLogic.deleteVFModules(resource, csarInfo, shouldLock, inTransaction);
}
}
return Either.left(resource);
private boolean isValidArtifactType(ArtifactDefinition artifact) {
return artifact.getArtifactType() != null && ArtifactTypeEnum.parse(artifact.getArtifactType()) != ArtifactTypeEnum.VENDOR_LICENSE
- && ArtifactTypeEnum.parse(artifact.getArtifactType()) != ArtifactTypeEnum.VF_LICENSE;
+ && ArtifactTypeEnum.parse(artifact.getArtifactType()) != ArtifactTypeEnum.VF_LICENSE;
}
private Resource createResourceInstancesRelations(User user, String yamlName, Resource resource, Resource oldResource,
.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(getResourceRes.right().value()), resource);
throw new ByResponseFormatComponentException(responseFormat);
}
-
+
}
private void addRelationsToRI(String yamlName, Resource resource, Map<String, UploadComponentInstanceInfo> uploadResInstancesMap,
Either<Resource, StorageOperationStatus> updateRes = null;
Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilities = new HashMap<>();
Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements = new HashMap<>();
-
+
StorageOperationStatus status = toscaOperationFacade.deleteAllCalculatedCapabilitiesRequirements(resource.getUniqueId());
if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
log.debug("Failed to delete all calculated capabilities and requirements of resource {} upon update. Status is {}",
}
return updateRes;
}
-
+
private Either<Resource, StorageOperationStatus> updateCalculatedCapReqWithSubstitutionMappingsForVf(final Resource resource,
- final Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
+ final Map<String, UploadComponentInstanceInfo> uploadResInstancesMap) {
Either<Resource, StorageOperationStatus> updateRes = null;
final Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilities = new HashMap<>();
final Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements = new HashMap<>();
-
+
resource.getComponentInstances().forEach(i -> {
setExternalCapabilities(updatedInstCapabilities, i, uploadResInstancesMap.get(i.getName()).getCapabilitiesNamesToUpdate());
setExternalRequirements(updatedInstRequirements, i, uploadResInstancesMap.get(i.getName()).getRequirementsNamesToUpdate());
});
- final StorageOperationStatus status = toscaOperationFacade.updateCalculatedCapabilitiesRequirements(updatedInstCapabilities, updatedInstRequirements, resource);
+ final StorageOperationStatus status = toscaOperationFacade.updateCalculatedCapabilitiesRequirements(updatedInstCapabilities,
+ updatedInstRequirements, resource);
if (status != StorageOperationStatus.OK) {
log.debug(
- "Failed to update capabilities and requirements of resource {}. Status is {}",
- resource.getUniqueId(), status);
+ "Failed to update capabilities and requirements of resource {}. Status is {}",
+ resource.getUniqueId(), status);
updateRes = Either.right(status);
}
if (isNotEmpty(requirementsNamesToUpdate)) {
for (Map.Entry<String, List<RequirementDefinition>> requirements : instance.getRequirements().entrySet()) {
updatedRequirements.put(requirements.getKey(), requirements.getValue().stream().filter(
- r -> requirementsNamesToUpdate.containsKey(r.getName()) && !updatedReqNames.contains(requirementsNamesToUpdate.get(r.getName())))
+ r -> requirementsNamesToUpdate.containsKey(r.getName()) && !updatedReqNames.contains(requirementsNamesToUpdate.get(r.getName())))
.map(r -> {
r.setParentName(r.getName());
r.setName(requirementsNamesToUpdate.get(r.getName()));
updatedInstRequirements.put(instance, updatedRequirements);
}
}
-
+
private void setExternalRequirements(
- final Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements,
- final ComponentInstance instance, final Map<String, String> requirementsNamesToUpdate) {
+ final Map<ComponentInstance, Map<String, List<RequirementDefinition>>> updatedInstRequirements,
+ final ComponentInstance instance, final Map<String, String> requirementsNamesToUpdate) {
final Map<String, List<RequirementDefinition>> updatedRequirements = new HashMap<>();
final Set<String> updatedReqNames = new HashSet<>();
if (isNotEmpty(requirementsNamesToUpdate)) {
for (Map.Entry<String, List<RequirementDefinition>> requirements : instance.getRequirements().entrySet()) {
updatedRequirements.put(requirements.getKey(),
- requirements.getValue().stream()
- .filter(r -> requirementsNamesToUpdate.containsKey(r.getName())
- && !updatedReqNames.contains(requirementsNamesToUpdate.get(r.getName())))
- .map(r -> {
- r.setExternal(true);
- r.setExternalName(requirementsNamesToUpdate.get(r.getName()));
- updatedReqNames.add(r.getName());
- return r;
- }).collect(toList()));
+ requirements.getValue().stream()
+ .filter(r -> requirementsNamesToUpdate.containsKey(r.getName())
+ && !updatedReqNames.contains(requirementsNamesToUpdate.get(r.getName())))
+ .map(r -> {
+ r.setExternal(true);
+ r.setExternalName(requirementsNamesToUpdate.get(r.getName()));
+ updatedReqNames.add(r.getName());
+ return r;
+ }).collect(toList()));
}
}
if (isNotEmpty(updatedRequirements)) {
updatedInstRequirements.put(instance, updatedRequirements);
}
}
-
+
private void setExternalCapabilities(
- final Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilties,
- final ComponentInstance instance, Map<String, String> capabilitiesNamesToUpdate) {
+ final Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> updatedInstCapabilties,
+ final ComponentInstance instance, Map<String, String> capabilitiesNamesToUpdate) {
final Map<String, List<CapabilityDefinition>> updatedCapabilities = new HashMap<>();
final Set<String> updatedCapNames = new HashSet<>();
if (isNotEmpty(capabilitiesNamesToUpdate)) {
for (Map.Entry<String, List<CapabilityDefinition>> requirements : instance.getCapabilities().entrySet()) {
updatedCapabilities.put(requirements.getKey(),
- requirements.getValue().stream()
- .filter(c -> capabilitiesNamesToUpdate.containsKey(c.getName())
- && !updatedCapNames.contains(capabilitiesNamesToUpdate.get(c.getName())))
- .map(c -> {
- c.setExternal(true);
- c.setExternalName(capabilitiesNamesToUpdate.get(c.getName()));
- updatedCapNames.add(c.getName());
- return c;
- }).collect(toList()));
+ requirements.getValue().stream()
+ .filter(c -> capabilitiesNamesToUpdate.containsKey(c.getName())
+ && !updatedCapNames.contains(capabilitiesNamesToUpdate.get(c.getName())))
+ .map(c -> {
+ c.setExternal(true);
+ c.setExternalName(capabilitiesNamesToUpdate.get(c.getName()));
+ updatedCapNames.add(c.getName());
+ return c;
+ }).collect(toList()));
}
}
if (isNotEmpty(updatedCapabilities)) {
if (isNotEmpty(capabilitiesNamesToUpdate)) {
for (Map.Entry<String, List<CapabilityDefinition>> requirements : instance.getCapabilities().entrySet()) {
updatedCapabilities.put(requirements.getKey(), requirements.getValue().stream().filter(
- c -> capabilitiesNamesToUpdate.containsKey(c.getName()) && !updatedCapNames.contains(capabilitiesNamesToUpdate.get(c.getName())))
+ c -> capabilitiesNamesToUpdate.containsKey(c.getName()) && !updatedCapNames.contains(capabilitiesNamesToUpdate.get(c.getName())))
.map(c -> {
c.setParentName(c.getName());
c.setName(capabilitiesNamesToUpdate.get(c.getName()));
for (UploadReqInfo uploadRegInfo : uploadRegInfoList) {
log.debug("Going to create relation {}", uploadRegInfo.getName());
loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
- "Started to create relations on instance: {}", uploadRegInfo.getName());
+ .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.STARTED,
+ "Started to create relations on instance: {}", uploadRegInfo.getName());
String regName = uploadRegInfo.getName();
RequirementCapabilityRelDef regCapRelDef = new RequirementCapabilityRelDef();
regCapRelDef.setFromNode(resourceInstanceId);
log.debug("try to find available requirement {} ", regName);
Either<RequirementDefinition, ResponseFormat> eitherReqStatus = findAviableRequiremen(regName, yamlName, nodesInfoValue,
- currentCompInstance, uploadRegInfo.getCapabilityName());
+ currentCompInstance, uploadRegInfo.getCapabilityName());
if (eitherReqStatus.isRight()) {
log.debug("failed to find available requirement {} status is {}", regName, eitherReqStatus.right().value());
loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- "ERROR while search available requirement {} status is: {}", regName, eitherReqStatus.right().value());
+ .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
+ "ERROR while search available requirement {} status is: {}", regName, eitherReqStatus.right().value());
return eitherReqStatus.right().value();
}
RequirementDefinition validReq = eitherReqStatus.left().value();
if (currentCapCompInstance == null) {
log.debug("The component instance with name {} not found on resource {} ", uploadRegInfo.getNode(), resource.getUniqueId());
loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- "ERROR component instance with name: {} not found on resource: {}", uploadRegInfo.getNode(), resource.getUniqueId());
+ .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
+ "ERROR component instance with name: {} not found on resource: {}", uploadRegInfo.getNode(), resource.getUniqueId());
BeEcompErrorManager.getInstance()
- .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE, resource.getUniqueId(),
- ErrorSeverity.ERROR);
+ .logInternalDataError(COMPONENT_INSTANCE_WITH_NAME + uploadRegInfo.getNode() + IN_RESOURCE, resource.getUniqueId(),
+ ErrorSeverity.ERROR);
return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
regCapRelDef.setToNode(currentCapCompInstance.getUniqueId());
CapabilityDefinition aviableCapForRel = findAvailableCapabilityByTypeOrName(validReq, currentCapCompInstance, uploadRegInfo);
if (aviableCapForRel == null) {
log.debug("aviable capability was not found. req name is {} component instance is {}", validReq.getName(),
- currentCapCompInstance.getUniqueId());
+ currentCapCompInstance.getUniqueId());
loggerSupportability
- .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
- "ERROR available capability was not found. req name is: {} component instance is: {}", validReq.getName(),
- currentCapCompInstance.getUniqueId());
+ .log(LoggerSupportabilityActions.CREATE_RELATIONS, resource.getComponentMetadataForSupportLog(), StatusCode.ERROR,
+ "ERROR available capability was not found. req name is: {} component instance is: {}", validReq.getName(),
+ currentCapCompInstance.getUniqueId());
BeEcompErrorManager.getInstance().logInternalDataError(
- "aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance
- .getUniqueId(), resource.getUniqueId(), ErrorSeverity.ERROR);
+ "aviable capability was not found. req name is " + validReq.getName() + " component instance is " + currentCapCompInstance
+ .getUniqueId(), resource.getUniqueId(), ErrorSeverity.ERROR);
return componentsUtils.getResponseFormat(ActionStatus.NOT_TOPOLOGY_TOSCA_TEMPLATE, yamlName);
}
reqAndRelationshipPair.setCapability(aviableCapForRel.getName());
ToscaArtifactDataDefinition to = new ToscaArtifactDataDefinition();
to.setFile(entry.getValue().getFile());
to.setType(entry.getValue().getType());
+ if (isNotEmpty(entry.getValue().getProperties())) {
+ Map<String, Object> newPropertiesMap = new HashMap<>();
+ List<UploadPropInfo> artifactPropsInfo = entry.getValue().getProperties();
+ for (UploadPropInfo propInfo : artifactPropsInfo) {
+ newPropertiesMap.put(propInfo.getName(), propInfo.getValue());
+ }
+ to.setProperties(newPropertiesMap);
+ }
toscaArtifacts.put(entry.getKey(), to);
}
componentInstance.setToscaArtifacts(toscaArtifacts);
} else {
Either<Resource, StorageOperationStatus> findResourceEither = StringUtils.isEmpty(resource.getModel()) ?
toscaOperationFacade.getByToscaResourceNameMatchingVendorRelease(uploadComponentInstanceInfo.getType(),
- ((ResourceMetadataDataDefinition) resource.getComponentMetadataDefinition().getMetadataDataDefinition()).getVendorRelease()):
+ ((ResourceMetadataDataDefinition) resource.getComponentMetadataDefinition().getMetadataDataDefinition()).getVendorRelease()) :
toscaOperationFacade.getLatestByToscaResourceNameAndModel(uploadComponentInstanceInfo.getType(), resource.getModel());
if (findResourceEither.isRight()) {
log.debug("validateResourceInstanceBeforeCreate - not found latest version for resource instance with name {} and type {}",
nodeForceCertification(resource, user, lifecycleChangeInfo, inTransaction, needLock);
}
if (resource.getLifecycleState() == LifecycleStateEnum.CERTIFIED) {
- Either<ArtifactDefinition, Operation> eitherPopulated = populateToscaArtifacts(resource, user, false, inTransaction, needLock, false);
+ populateToscaArtifacts(resource, user, false, inTransaction, needLock, false);
return resource;
}
return nodeFullCertification(resource.getUniqueId(), user, lifecycleChangeInfo, inTransaction, needLock);
if (MapUtils.isEmpty(newResource.getToscaArtifacts())) {
setToscaArtifactsPlaceHolders(newResource, user);
}
- if (MapUtils.isEmpty(newResource.getInterfaces())) {
- newResource.setInterfaces(oldResource.getInterfaces());
- }
+
if (CollectionUtils.isEmpty(newResource.getAttributes())) {
newResource.setAttributes(oldResource.getAttributes());
}
if (newResource.getContactId() == null) {
newResource.setContactId(oldResource.getContactId());
}
+ newResource.setIcon(oldResource.getIcon());
newResource.setCategories(oldResource.getCategories());
if (newResource.getVendorName() == null) {
newResource.setVendorName(oldResource.getVendorName());
if (newResource.getResourceType().isAtomicType() && !newResource.getName().equals("Root")
&& newResource.getResourceType() != ResourceTypeEnum.CVFC) {
ResourceTypeEnum updatedResourceType = newResource.getResourceType();
- Component derivedFromResource = getParentComponent(newResource);
- if (derivedFromResource.getComponentType() == ComponentTypeEnum.RESOURCE) {
- Resource parentResource = (Resource) derivedFromResource;
+ Optional<Component> derivedFromResourceOptional = getParentComponent(newResource);
+ if (derivedFromResourceOptional.isPresent() && derivedFromResourceOptional.get().getComponentType() == ComponentTypeEnum.RESOURCE) {
+ Resource parentResource = (Resource) derivedFromResourceOptional.get();
if (!(parentResource.isAbstract() && (ResourceTypeEnum.VFC == parentResource.getResourceType()
|| ResourceTypeEnum.ABSTRACT == parentResource.getResourceType())) && parentResource.getResourceType() != updatedResourceType
&& oldResource.getResourceType() != updatedResourceType) {
}
}
- private Component getParentComponent(Resource newResource) {
+ private Optional<Component> getParentComponent(Resource newResource) {
+ if (newResource.getDerivedFrom() == null) {
+ return Optional.empty();
+ }
String toscaResourceNameDerivedFrom = newResource.getDerivedFrom().get(0);
Either<Component, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade
.getLatestByToscaResourceName(toscaResourceNameDerivedFrom, newResource.getModel());
log.debug("#mergeOldResourceMetadataWithNew - derived from resource {} not found", toscaResourceNameDerivedFrom);
throw new ByActionStatusComponentException(ActionStatus.RESOURCE_NOT_FOUND, toscaResourceNameDerivedFrom);
}
- return latestByToscaResourceName.left().value();
+ return Optional.of(latestByToscaResourceName.left().value());
}
private Resource prepareResourceForUpdate(Resource oldResource, Resource newResource, User user, boolean inTransaction, boolean needLock) {
while (intItr.hasNext() && eitherResult.isLeft()) {
InterfaceDefinition interfaceDefinition = intItr.next();
String intType = interfaceDefinition.getUniqueId();
- Either<InterfaceDefinition, StorageOperationStatus> eitherCapTypeFound = interfaceTypeOperation.getInterface(intType);
+ Either<InterfaceDefinition, StorageOperationStatus> eitherCapTypeFound = interfaceTypeOperation.getInterface(UniqueIdBuilder.buildInterfaceTypeUid(resource.getModel(), intType));
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
BeEcompErrorManager.getInstance()
Resource resource, List<?> validationObjects, AuditingActionEnum actionEnum,
Either<Boolean, ResponseFormat> eitherResult, String type,
boolean inTransaction) {
- Either<CapabilityTypeDefinition, StorageOperationStatus> eitherCapTypeFound = capabilityTypeOperation.getCapabilityType(type, inTransaction);
+ Either<CapabilityTypeDefinition, StorageOperationStatus> eitherCapTypeFound = capabilityTypeOperation.getCapabilityType(
+ UniqueIdBuilder.buildCapabilityTypeUid(resource.getModel(), type), inTransaction);
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
BeEcompErrorManager.getInstance().logBeGraphObjectMissingError(CREATE_RESOURCE_VALIDATE_CAPABILITY_TYPES, "Capability Type", type);
Either<Boolean, ResponseFormat> eitherResult,
Entry<String, List<CapabilityDefinition>> typeEntry, boolean inTransaction) {
Either<CapabilityTypeDefinition, StorageOperationStatus> eitherCapTypeFound = capabilityTypeOperation
- .getCapabilityType(typeEntry.getKey(), inTransaction);
+ .getCapabilityType(UniqueIdBuilder.buildCapabilityTypeUid(resource.getModel(), typeEntry.getKey()), inTransaction);
if (eitherCapTypeFound.isRight()) {
if (eitherCapTypeFound.right().value() == StorageOperationStatus.NOT_FOUND) {
BeEcompErrorManager.getInstance()
componentsUtils.auditResource(componentsUtils.getResponseFormat(ActionStatus.CREATED), user, createdResource, actionEnum);
ASDCKpiApi.countCreatedResourcesKPI();
} catch (ComponentException e) {
+ janusGraphDao.rollback();
ResponseFormat responseFormat =
e.getResponseFormat() == null ? componentsUtils.getResponseFormat(e.getActionStatus(), e.getParams()) : e.getResponseFormat();
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw e;
} catch (StorageException e) {
+ janusGraphDao.rollback();
ResponseFormat responseFormat = componentsUtils
.getResponseFormat(componentsUtils.convertFromStorageResponse(e.getStorageOperationStatus()));
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
}
}
+ private boolean isComponentSystemDeployed(Resource resource) {
+ return resource.getComponentMetadataDefinition().getMetadataDataDefinition().isNormative();
+ }
+
+ /**
+ * Deletes every version of the provided resource
+ *
+ * @param resourceId the resource identifier
+ * @param user the user that performs the deletion
+ * @return
+ * @throws ComponentException if there is any error in the deletion of the resource operation
+ */
+ public void deleteResourceAllVersions(String resourceId, User user) {
+ validateUserExists(user);
+ Either<Resource, StorageOperationStatus> resourceStatus = toscaOperationFacade.getToscaElement(resourceId);
+ if (resourceStatus.isRight()) {
+ log.debug("Failed to get resource {}", resourceId);
+ componentException(resourceStatus.right().value());
+ }
+ Resource resource = resourceStatus.left().value();
+ if (isComponentSystemDeployed(resource)) {
+ throw new ByActionStatusComponentException(ActionStatus.CANNOT_DELETE_SYSTEM_DEPLOYED_RESOURCES, ComponentTypeEnum.RESOURCE.getValue(),
+ resource.getName());
+ }
+ if (Boolean.FALSE.equals(resource.isArchived())) {
+ log.debug("The resource, {}, requested for delete has not been archived.", resourceId);
+ throw new ComponentException(ActionStatus.COMPONENT_NOT_ARCHIVED, resourceId);
+ }
+ try {
+ String model = resource.getModel();
+ final Optional<Model> modelOptional = modelOperation.findModelByName(model);
+ List<String> deletedResourceList = toscaOperationFacade.deleteComponent(resource.getInvariantUUID(), NodeTypeEnum.Resource, true);
+ if (log.isDebugEnabled()) {
+ deletedResourceList.forEach(deletedR -> log.debug("Component {} was deleted.", deletedR));
+ }
+ if (modelOptional.isPresent() && modelOptional.get().getModelType() == ModelTypeEnum.NORMATIVE_EXTENSION) {
+ modelOperation.deleteModel(modelOptional.get(), true);
+ }
+ toscaOperationFacade.commitAndCheck(resource.getUniqueId());
+ updateCatalog(resource, ChangeTypeEnum.DELETE);
+ } catch (ComponentException exception) {
+ log.debug("Failed to delete resource, {} ", resourceId);
+ janusGraphDao.rollback();
+ throw exception;
+ }
+ }
+
public ResponseFormat deleteResourceByNameAndVersion(String resourceName, String version, User user) {
ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.NO_CONTENT);
validateUserExists(user);
} else {
newResource.setDerivedFrom(null);
}
- Either<Resource, ResponseFormat> dataModelResponse = updateResourceMetadata(resourceIdToUpdate, newResource, user, currentResource, false,
+ Either<Resource, ResponseFormat> dataModelResponse = updateResourceMetadata(resourceIdToUpdate, newResource, user, currentResource,
true);
if (dataModelResponse.isRight()) {
log.debug("failed to update resource metadata!!!");
}
private Either<Resource, ResponseFormat> updateResourceMetadata(String resourceIdToUpdate, Resource newResource, User user,
- Resource currentResource, boolean shouldLock, boolean inTransaction) {
+ Resource currentResource, boolean inTransaction) {
updateVfModuleGroupsNames(currentResource, newResource);
validateResourceFieldsBeforeUpdate(currentResource, newResource, inTransaction, false);
// Setting last updater and uniqueId
throw new ByActionStatusComponentException(ActionStatus.RESOURCE_TOO_MUCH_SUBCATEGORIES);
}
SubCategoryDefinition subcategory = subcategories.get(0);
- if (!ValidationUtils.validateStringNotEmpty(category.getName())) {
+ if (StringUtils.isEmpty(category.getName())) {
log.debug(CATEGORY_IS_EMPTY);
ResponseFormat responseFormat = componentsUtils
.getResponseFormat(ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
componentsUtils.auditResource(responseFormat, user, resource, actionEnum);
throw new ByActionStatusComponentException(ActionStatus.COMPONENT_MISSING_CATEGORY, ComponentTypeEnum.RESOURCE.getValue());
}
- if (!ValidationUtils.validateStringNotEmpty(subcategory.getName())) {
+ if (StringUtils.isEmpty(subcategory.getName())) {
log.debug(CATEGORY_IS_EMPTY);
ResponseFormat responseFormat = componentsUtils
.getResponseFormat(ActionStatus.COMPONENT_MISSING_SUBCATEGORY, ComponentTypeEnum.RESOURCE.getValue());
public void validateVendorReleaseName(User user, Resource resource, AuditingActionEnum actionEnum) {
String vendorRelease = resource.getVendorRelease();
log.debug("validate vendor relese name");
- if (!ValidationUtils.validateStringNotEmpty(vendorRelease)) {
+ if (StringUtils.isEmpty(vendorRelease)) {
log.info("vendor relese name is missing.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_VENDOR_RELEASE);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
private void validateVendorName(User user, Resource resource, AuditingActionEnum actionEnum) {
String vendorName = resource.getVendorName();
- if (!ValidationUtils.validateStringNotEmpty(vendorName)) {
+ if (StringUtils.isEmpty(vendorName)) {
log.info("vendor name is missing.");
ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.MISSING_VENDOR_NAME);
componentsUtils.auditResource(errorResponse, user, resource, actionEnum);
}
public void iterateOverProperties(List<PropertyDefinition> properties, String model) {
- String type = null;
- String innerType = null;
for (PropertyDefinition property : properties) {
if (!propertyOperation.isPropertyTypeValid(property, model)) {
log.info("Invalid type for property {}", property);
throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_TYPE, property.getType(), property.getName());
}
Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, model);
- type = property.getType();
+ String type = property.getType();
if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
- ResponseFormat responseFormat = validateMapOrListPropertyType(property, innerType, allDataTypes);
+ ResponseFormat responseFormat = validateMapOrListPropertyType(property, allDataTypes);
if (responseFormat != null) {
break;
}
}
- validateDefaultPropertyValue(property, allDataTypes, type, innerType);
+ validateDefaultPropertyValue(property, allDataTypes, type);
}
}
- private void validateDefaultPropertyValue(PropertyDefinition property, Map<String, DataTypeDefinition> allDataTypes, String type,
- String innerType) {
+ private void validateDefaultPropertyValue(PropertyDefinition property, Map<String, DataTypeDefinition> allDataTypes, String type) {
if (!propertyOperation.isPropertyDefaultValueValid(property, allDataTypes)) {
log.info("Invalid default value for property {}", property);
ResponseFormat responseFormat;
if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
- throw new ByActionStatusComponentException(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE, property.getName(), type, innerType,
+ throw new ByActionStatusComponentException(ActionStatus.INVALID_COMPLEX_DEFAULT_VALUE, property.getName(), type,
property.getDefaultValue());
}
throw new ByActionStatusComponentException(ActionStatus.INVALID_DEFAULT_VALUE, property.getName(), type, property.getDefaultValue());
}
}
- private ResponseFormat validateMapOrListPropertyType(PropertyDefinition property, String innerType,
+ private ResponseFormat validateMapOrListPropertyType(PropertyDefinition property,
Map<String, DataTypeDefinition> allDataTypes) {
ResponseFormat responseFormat = null;
ImmutablePair<String, Boolean> propertyInnerTypeValid = propertyOperation.isPropertyInnerTypeValid(property, allDataTypes);
- innerType = propertyInnerTypeValid.getLeft();
- if (!propertyInnerTypeValid.getRight()) {
+ String innerType = propertyInnerTypeValid.getLeft();
+ if (Boolean.FALSE.equals(propertyInnerTypeValid.getRight())) {
log.info("Invalid inner type for property {}", property);
responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY_INNER_TYPE, innerType, property.getName());
}