aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-be/src/main
diff options
context:
space:
mode:
authorVasyl Razinkov <vasyl.razinkov@est.tech>2022-09-20 15:18:27 +0000
committerMichael Morris <michael.morris@est.tech>2022-09-23 09:16:04 +0000
commit0323aadb6038a630798ad133f8b86a9b9d50feea (patch)
tree36a192bd0d819cfa51d0f64886aabcd362c346d5 /catalog-be/src/main
parent9a2c547065bc7ff4a23c680dfbafe4008a09290c (diff)
Revert "Fix 'Wrong Inputs creation on (Add Service)'"
This reverts commit ae24e28cda8247fdce38330356b63db1377be58f. Reason for revert: problem reported with 'default' values Issue-ID: SDC-4097 Change-Id: I8966470070329cc8aafcb45255f2febb9b00ab4e Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech>
Diffstat (limited to 'catalog-be/src/main')
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java8
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java110
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java48
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java20
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java2
5 files changed, 77 insertions, 111 deletions
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index 763552fcf3..bca901ee8b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -213,7 +213,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
component = getComponentEither.left().value();
Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
- if (op.isEmpty()) {
+ if (!op.isPresent()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, parentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
@@ -369,7 +369,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
component = getComponentEither.left().value();
Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
- if (op.isEmpty()) {
+ if (!op.isPresent()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, componentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
@@ -664,7 +664,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
filter(input -> input.getUniqueId().equals(inputId)).
// Get the input
findAny();
- if (optionalInput.isEmpty()) {
+ if (!optionalInput.isPresent()) {
throw new ByActionStatusComponentException(ActionStatus.INPUT_IS_NOT_CHILD_OF_COMPONENT, inputId, componentId);
}
InputDefinition inputForDelete = optionalInput.get();
@@ -770,7 +770,7 @@ public class InputsBusinessLogic extends BaseBusinessLogic {
}
Component component = getComponentEither.left().value();
Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
- if (op.isEmpty()) {
+ if (!op.isPresent()) {
ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, componentId, actionStatus);
return Either.right(componentsUtils.getResponseFormat(actionStatus));
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 577d1f5e32..2cccc31ded 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
@@ -109,10 +109,8 @@ import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.ArtifactDefinition;
import org.openecomp.sdc.be.model.CapabilityDefinition;
import org.openecomp.sdc.be.model.Component;
-import org.openecomp.sdc.be.model.ComponentInstInputsMap;
import org.openecomp.sdc.be.model.ComponentInstance;
import org.openecomp.sdc.be.model.ComponentInstanceInterface;
-import org.openecomp.sdc.be.model.ComponentInstancePropInput;
import org.openecomp.sdc.be.model.ComponentInstanceProperty;
import org.openecomp.sdc.be.model.ComponentParametersView;
import org.openecomp.sdc.be.model.DistributionStatusEnum;
@@ -191,12 +189,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
private final ServiceInstantiationTypeValidator serviceInstantiationTypeValidator;
private final ServiceCategoryValidator serviceCategoryValidator;
private final ServiceValidator serviceValidator;
+ private final PolicyBusinessLogic policyBusinessLogic;
+ private final GroupBusinessLogic groupBusinessLogic;
private ForwardingPathOperation forwardingPathOperation;
private AuditCassandraDao auditCassandraDao;
private ServiceTypeValidator serviceTypeValidator;
private List<ServiceCreationPlugin> serviceCreationPluginList;
private ServiceFunctionValidator serviceFunctionValidator;
- private final InputsBusinessLogic inputsBusinessLogic;
public ServiceBusinessLogic(IElementOperation elementDao, IGroupOperation groupOperation, IGroupInstanceOperation groupInstanceOperation,
IGroupTypeOperation groupTypeOperation, GroupBusinessLogic groupBusinessLogic, InterfaceOperation interfaceOperation,
@@ -211,7 +210,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
final ServiceRoleValidator serviceRoleValidator,
final ServiceInstantiationTypeValidator serviceInstantiationTypeValidator,
final ServiceCategoryValidator serviceCategoryValidator, final ServiceValidator serviceValidator,
- final InputsBusinessLogic inputsBusinessLogic) {
+ final PolicyBusinessLogic policyBusinessLogic) {
super(elementDao, groupOperation, groupInstanceOperation, groupTypeOperation, groupBusinessLogic, interfaceOperation,
interfaceLifecycleTypeOperation, artifactsBusinessLogic, artifactToscaOperation, componentContactIdValidator, componentNameValidator,
componentTagsValidator, componentValidator, componentIconValidator, componentProjectCodeValidator, componentDescriptionValidator);
@@ -225,7 +224,8 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
this.serviceInstantiationTypeValidator = serviceInstantiationTypeValidator;
this.serviceCategoryValidator = serviceCategoryValidator;
this.serviceValidator = serviceValidator;
- this.inputsBusinessLogic = inputsBusinessLogic;
+ this.policyBusinessLogic = policyBusinessLogic;
+ this.groupBusinessLogic = groupBusinessLogic;
}
@Autowired
@@ -311,7 +311,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
Optional<ComponentInstance> serviceInstanceCandidate = componentInstances.stream()
.filter(instance -> instance.getUniqueId().equals(serviceInstanceId)).findAny();
- if (serviceInstanceCandidate.isEmpty()) {
+ if (!serviceInstanceCandidate.isPresent()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_OPERATION_NOT_FOUND, serviceInstanceId));
}
Map<String, List<ComponentInstanceInterface>> componentInstancesInterfaces = parentService.getComponentInstancesInterfaces();
@@ -324,7 +324,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
}
ComponentInstance serviceInstance = serviceInstanceCandidate.get();
Optional<InterfaceDefinition> interfaceCandidate = InterfaceOperationUtils.getInterfaceDefinitionFromOperationId(interfaces, operationId);
- if (interfaceCandidate.isEmpty()) {
+ if (!interfaceCandidate.isPresent()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.INTERFACE_OPERATION_NOT_FOUND, serviceInstanceId));
}
InterfaceDefinition interfaceDefinition = interfaceCandidate.get();
@@ -336,7 +336,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
Either<Operation, ResponseFormat> operationEither = Either.left(operation);
ListDataDefinition<OperationInputDefinition> inputs = operation.getInputs();
Optional<OperationInputDefinition> inputCandidate = getOperationInputByInputId(serviceConsumptionData, inputs);
- if (inputCandidate.isEmpty()) {
+ if (!inputCandidate.isPresent()) {
return Either.right(new ResponseFormat(HttpStatus.NOT_FOUND.value()));
}
OperationInputDefinition operationInputDefinition = inputCandidate.get();
@@ -419,7 +419,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
.getListToscaDataDefinition();
} else {
Optional<ComponentInstance> getComponentInstance = containerService.getComponentInstanceById(source);
- if (getComponentInstance.isEmpty()) {
+ if (!getComponentInstance.isPresent()) {
return Either.right(componentsUtils.getResponseFormat(ActionStatus.COMPONENT_INSTANCE_NOT_FOUND_ON_CONTAINER, source));
}
ComponentInstance componentInstance = getComponentInstance.get();
@@ -692,7 +692,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
private Either<Service, ResponseFormat> createServiceByDao(final Service service, final User user) {
log.debug("send service {} to dao for create", service.getComponentMetadataDefinition().getMetadataDataDefinition().getName());
- final Either<Boolean, ResponseFormat> lockResult = lockComponentByName(service.getSystemName(), service, "Create Service");
+ Either<Boolean, ResponseFormat> lockResult = lockComponentByName(service.getSystemName(), service, "Create Service");
if (lockResult.isRight()) {
ResponseFormat responseFormat = lockResult.right().value();
componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
@@ -710,64 +710,25 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
generateAndAddInputsFromGenericTypeProperties(service, genericType);
}
beforeCreate(service);
- final Either<Service, StorageOperationStatus> dataModelResponse = toscaOperationFacade.createToscaComponent(service);
- if (dataModelResponse.isRight()) {
- ResponseFormat responseFormat = componentsUtils
- .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(dataModelResponse.right().value()), service,
- ComponentTypeEnum.SERVICE);
- log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
+ Either<Service, StorageOperationStatus> dataModelResponse = toscaOperationFacade.createToscaComponent(service);
+ if (dataModelResponse.isLeft()) {
+ log.debug("Service '{}' created successfully", service.getName());
+ ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
- return Either.right(responseFormat);
+ ASDCKpiApi.countCreatedServicesKPI();
+ return Either.left(dataModelResponse.left().value());
}
- final Service createdService = dataModelResponse.left().value();
- if (createdService.isSubstituteCandidate() || genericTypeBusinessLogic.hasMandatorySubstitutionType(createdService)) {
- updateInputs(createdService);
- }
- log.debug("Service '{}' created successfully", createdService.getName());
- final ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.CREATED);
- componentsUtils.auditComponentAdmin(responseFormat, user, createdService, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
- ASDCKpiApi.countCreatedServicesKPI();
- return Either.left(createdService);
+ ResponseFormat responseFormat = componentsUtils
+ .getResponseFormatByComponent(componentsUtils.convertFromStorageResponse(dataModelResponse.right().value()), service,
+ ComponentTypeEnum.SERVICE);
+ log.debug(AUDIT_BEFORE_SENDING_RESPONSE);
+ componentsUtils.auditComponentAdmin(responseFormat, user, service, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
+ return Either.right(responseFormat);
} finally {
graphLockOperation.unlockComponentByName(service.getSystemName(), service.getUniqueId(), NodeTypeEnum.Service);
}
}
- private void updateInputs(final Service service) {
- final List<InputDefinition> genericTypeInputs = service.getInputs();
- final Either<List<InputDefinition>, ResponseFormat> inputs = inputsBusinessLogic.getInputs(service.getCreatorUserId(), service.getUniqueId());
- if (inputs.isRight() || CollectionUtils.isEmpty(inputs.left().value())) {
- log.warn("Failed to declare Generic Type Properties as Inputs");
- service.setInputs(null);
- return;
- }
- inputs.left().value().forEach(
- inputDefinition -> inputsBusinessLogic.deleteInput(service.getUniqueId(), service.getCreatorUserId(), inputDefinition.getUniqueId()));
-
- service.setInputs(null);
- if (CollectionUtils.isNotEmpty(genericTypeInputs)) {
- // From SELF
- final ComponentInstInputsMap componentInstInputsMap = new ComponentInstInputsMap();
- final List<ComponentInstancePropInput> componentInstancePropInputs = genericTypeInputs.stream()
- .map(prop -> {
- prop.setInstanceUniqueId(service.getUniqueId());
- prop.setParentUniqueId(service.getUniqueId());
- return new ComponentInstancePropInput(new ComponentInstanceProperty(prop));
- }
- ).collect(Collectors.toList());
- componentInstInputsMap.setServiceProperties(Collections.singletonMap(service.getUniqueId(), componentInstancePropInputs));
-
- final Either<List<InputDefinition>, ResponseFormat> listResponseFormatEither = inputsBusinessLogic.declareProperties(
- service.getCreatorUserId(), service.getUniqueId(), ComponentTypeEnum.SERVICE, componentInstInputsMap);
- if (listResponseFormatEither.isRight()) {
- log.warn("Failed to declare Generic Type Properties as Inputs");
- service.setInputs(null);
- return;
- }
- service.setInputs(listResponseFormatEither.left().value());
- }
- }
-
private void beforeCreate(final Service service) {
if (CollectionUtils.isEmpty(serviceCreationPluginList)) {
return;
@@ -784,7 +745,10 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
@SuppressWarnings("unchecked")
private void createServiceApiArtifactsData(Service service, User user) {
// create mandatory artifacts
- // TODO it must be removed after that artifact uniqueId creation will be moved to ArtifactOperation
+
+ // TODO it must be removed after that artifact uniqueId creation will be
+
+ // moved to ArtifactOperation
String serviceUniqueId = service.getUniqueId();
Map<String, ArtifactDefinition> artifactMap = service.getServiceApiArtifacts();
if (artifactMap == null) {
@@ -1666,13 +1630,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
BeEcompErrorManager.getInstance()
.logBeComponentMissingError("markDistributionAsDeployed", ComponentTypeEnum.SERVICE.getValue(), serviceId);
log.debug("service {} not found", serviceId);
- ResponseFormat responseFormat = auditDeployError(did, user, null,
+ ResponseFormat responseFormat = auditDeployError(did, user, auditAction, null,
componentsUtils.convertFromStorageResponse(getServiceResponse.right().value(), ComponentTypeEnum.SERVICE), "");
return Either.right(responseFormat);
}
Service service = getServiceResponse.left().value();
user = validateRoleForDeploy(did, user, auditAction, service);
- return checkDistributionAndDeploy(did, user, service);
+ return checkDistributionAndDeploy(did, user, auditAction, service);
}
public Either<Service, ResponseFormat> generateVfModuleArtifacts(Service service, User modifier, boolean shouldLock, boolean inTransaction) {
@@ -1746,13 +1710,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return null;
}
- private synchronized Either<Service, ResponseFormat> checkDistributionAndDeploy(String distributionId, User user,
+ private synchronized Either<Service, ResponseFormat> checkDistributionAndDeploy(String distributionId, User user, AuditingActionEnum auditAction,
Service service) {
boolean isDeployed = isDistributionDeployed(distributionId);
if (isDeployed) {
return Either.left(service);
}
- Either<Boolean, ResponseFormat> distributionSuccess = checkDistributionSuccess(distributionId, user, service);
+ Either<Boolean, ResponseFormat> distributionSuccess = checkDistributionSuccess(distributionId, user, auditAction, service);
if (distributionSuccess.isRight()) {
return Either.right(distributionSuccess.right().value());
}
@@ -1775,20 +1739,20 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
return isDeployed;
}
- protected Either<Boolean, ResponseFormat> checkDistributionSuccess(String did, User user, Service service) {
+ protected Either<Boolean, ResponseFormat> checkDistributionSuccess(String did, User user, AuditingActionEnum auditAction, Service service) {
log.trace("checkDistributionSuccess");
// get all "DRequest" records for this distribution
Either<List<ResourceAdminEvent>, ActionStatus> distRequestsResponse = auditCassandraDao
.getDistributionRequest(did, AuditingActionEnum.DISTRIBUTION_STATE_CHANGE_REQUEST.getName());
if (distRequestsResponse.isRight()) {
- ResponseFormat error = auditDeployError(did, user, service, distRequestsResponse.right().value());
+ ResponseFormat error = auditDeployError(did, user, auditAction, service, distRequestsResponse.right().value());
return Either.right(error);
}
List<ResourceAdminEvent> distributionRequests = distRequestsResponse.left().value();
if (distributionRequests.isEmpty()) {
BeEcompErrorManager.getInstance().logBeDistributionMissingError("markDistributionAsDeployed", did);
log.info("distribution {} is not found", did);
- ResponseFormat error = auditDeployError(did, user, service, ActionStatus.DISTRIBUTION_REQUESTED_NOT_FOUND);
+ ResponseFormat error = auditDeployError(did, user, auditAction, service, ActionStatus.DISTRIBUTION_REQUESTED_NOT_FOUND);
return Either.right(error);
}
boolean isRequestSucceeded = false;
@@ -1803,7 +1767,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
Either<List<DistributionNotificationEvent>, ActionStatus> distNotificationsResponse = auditCassandraDao
.getDistributionNotify(did, AuditingActionEnum.DISTRIBUTION_NOTIFY.getName());
if (distNotificationsResponse.isRight()) {
- ResponseFormat error = auditDeployError(did, user, service, distNotificationsResponse.right().value());
+ ResponseFormat error = auditDeployError(did, user, auditAction, service, distNotificationsResponse.right().value());
return Either.right(error);
}
List<DistributionNotificationEvent> distributionNotifications = distNotificationsResponse.left().value();
@@ -1819,13 +1783,13 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
if (!(isRequestSucceeded && isNotificationsSucceeded)) {
log.info("distribution {} has failed", did);
ResponseFormat error = componentsUtils.getResponseFormat(ActionStatus.DISTRIBUTION_REQUESTED_FAILED, did);
- auditDeployError(did, user, service, ActionStatus.DISTRIBUTION_REQUESTED_FAILED, did);
+ auditDeployError(did, user, auditAction, service, ActionStatus.DISTRIBUTION_REQUESTED_FAILED, did);
return Either.right(error);
}
return Either.left(true);
}
- private ResponseFormat auditDeployError(String did, User user, Service service, ActionStatus status,
+ private ResponseFormat auditDeployError(String did, User user, AuditingActionEnum auditAction, Service service, ActionStatus status,
String... params) {
ResponseFormat error = componentsUtils.getResponseFormat(status, params);
String message = "";
@@ -1853,7 +1817,7 @@ public class ServiceBusinessLogic extends ComponentBusinessLogic {
validateUserRole(user, service, roles, auditAction, null);
} catch (ByActionStatusComponentException e) {
log.info("role {} is not allowed to perform this action", user.getRole());
- auditDeployError(did, user, service, e.getActionStatus());
+ auditDeployError(did, user, auditAction, service, e.getActionStatus());
throw e;
}
return user;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
index 07d5ba0f24..0412516390 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/property/DefaultPropertyDeclarator.java
@@ -126,7 +126,7 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
private Either<List<PolicyDefinition>, StorageOperationStatus> declarePropertiesAsPolicies(Component component, PROPERTYOWNER propertiesOwner,
List<ComponentInstancePropInput> propsToDeclare) {
- PropertiesDeclarationData policyProperties = createPoliciesAndOverridePropertiesValues(propertiesOwner.getUniqueId(),
+ PropertiesDeclarationData policyProperties = createPoliciesAndOverridePropertiesValues(propertiesOwner.getUniqueId(), propertiesOwner,
propsToDeclare);
return updatePropertiesValues(component, propertiesOwner.getUniqueId(), policyProperties.getPropertiesToUpdate()).left()
.map(updatePropsRes -> policyProperties.getPoliciesToCreate());
@@ -144,7 +144,8 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
.map(updatePropsRes -> inputsProperties.getInputsToCreate());
}
- private PropertiesDeclarationData createPoliciesAndOverridePropertiesValues(String componentId, List<ComponentInstancePropInput> propsToDeclare) {
+ private PropertiesDeclarationData createPoliciesAndOverridePropertiesValues(String componentId, PROPERTYOWNER propertiesOwner,
+ List<ComponentInstancePropInput> propsToDeclare) {
List<PROPERTYTYPE> declaredProperties = new ArrayList<>();
List<PolicyDefinition> policies = new ArrayList<>();
propsToDeclare.forEach(property -> policies.add(declarePropertyPolicy(componentId, declaredProperties, property)));
@@ -249,7 +250,7 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
if (propertyCapability.isPresent()) {
String capName = propertyCapability.get().getName();
if (capName.contains(".")) {
- capName = capName.replace(".", UNDERSCORE);
+ capName = capName.replaceAll("\\.", UNDERSCORE);
}
generatedInputPrefix =
generatedInputPrefix == null || generatedInputPrefix.isEmpty() ? capName : generatedInputPrefix + UNDERSCORE + capName;
@@ -314,12 +315,12 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
input.setInputPath(propertiesName);
input.setInstanceUniqueId(propertiesOwner.getUniqueId());
input.setPropertyId(propInput.getUniqueId());
- if (Objects.isNull(input.getSubPropertyInputPath()) || (StringUtils.isNotEmpty(propertiesName) && input.getSubPropertyInputPath()
+ if (Objects.isNull(input.getSubPropertyInputPath()) || (Objects.nonNull(propertiesName) && input.getSubPropertyInputPath()
.substring(input.getSubPropertyInputPath().lastIndexOf('#')).equals(propertiesName.substring(propertiesName.lastIndexOf('#'))))) {
input.setParentPropertyType(propInput.getType());
input.setSubPropertyInputPath(propertiesName);
}
- changePropertyValueToGetInputValue(parsedPropNames, input, prop, complexProperty);
+ changePropertyValueToGetInputValue(inputName, parsedPropNames, input, prop, complexProperty);
if (prop instanceof IComponentInstanceConnectedElement) {
((IComponentInstanceConnectedElement) prop).setComponentInstanceId(propertiesOwner.getUniqueId());
((IComponentInstanceConnectedElement) prop).setComponentInstanceName(propertiesOwner.getName());
@@ -327,43 +328,42 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
return input;
}
- private void changePropertyValueToGetInputValue(String[] parsedPropNames, InputDefinition input, PropertyDataDefinition prop,
+ private void changePropertyValueToGetInputValue(String inputName, String[] parsedPropNames, InputDefinition input, PropertyDataDefinition prop,
boolean complexProperty) {
JSONObject jsonObject = new JSONObject();
- final String value = prop.getValue();
- final String inputName = input.getName();
+ String value = prop.getValue();
if (value == null || value.isEmpty()) {
if (complexProperty) {
jsonObject = createJSONValueForProperty(parsedPropNames.length - 1, parsedPropNames, jsonObject, inputName);
prop.setValue(jsonObject.toJSONString());
} else {
- jsonObject.put(GET_INPUT, inputName);
+ jsonObject.put(GET_INPUT, input.getName());
prop.setValue(jsonObject.toJSONString());
}
} else {
- final Object objValue = new Yaml().load(value);
+ Object objValue = new Yaml().load(value);
if (objValue instanceof Map || objValue instanceof List) {
if (!complexProperty) {
- jsonObject.put(GET_INPUT, inputName);
+ jsonObject.put(GET_INPUT, input.getName());
prop.setValue(jsonObject.toJSONString());
} else {
- final Map<String, Object> mappedToscaTemplate = (Map<String, Object>) objValue;
+ Map<String, Object> mappedToscaTemplate = (Map<String, Object>) objValue;
createInputValue(mappedToscaTemplate, 1, parsedPropNames, inputName);
- final String json = gson.toJson(mappedToscaTemplate);
+ String json = gson.toJson(mappedToscaTemplate);
prop.setValue(json);
}
} else {
- jsonObject.put(GET_INPUT, inputName);
+ jsonObject.put(GET_INPUT, input.getName());
prop.setValue(jsonObject.toJSONString());
}
}
if (CollectionUtils.isEmpty(prop.getGetInputValues())) {
prop.setGetInputValues(new ArrayList<>());
}
- final List<GetInputValueDataDefinition> getInputValues = prop.getGetInputValues();
- final GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
+ List<GetInputValueDataDefinition> getInputValues = prop.getGetInputValues();
+ GetInputValueDataDefinition getInputValueDataDefinition = new GetInputValueDataDefinition();
getInputValueDataDefinition.setInputId(input.getUniqueId());
- getInputValueDataDefinition.setInputName(inputName);
+ getInputValueDataDefinition.setInputName(input.getName());
getInputValues.add(getInputValueDataDefinition);
}
@@ -460,7 +460,8 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
if (result.isLeft()) {
modifiedMappedToscaTemplate = (Map) result.left().value();
} else {
- log.warn("Map cleanup failed -> {}", result.right().value()); //continue, don't break operation
+ log.warn("Map cleanup failed -> " + result.right().value()
+ .toString()); //continue, don't break operation
}
value = gson.toJson(modifiedMappedToscaTemplate);
}
@@ -545,10 +546,11 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
boolean isEmpty = true;
if (element != null) {
if (element instanceof Map) {
- final Map map = (Map) element;
- if (MapUtils.isNotEmpty(map)) {
- for (final Object key : map.keySet()) {
- final Object value = map.get(key);
+ if (MapUtils.isEmpty((Map) element)) {
+ isEmpty = true;
+ } else {
+ for (Object key : ((Map) (element)).keySet()) {
+ Object value = ((Map) (element)).get(key);
isEmpty &= isEmptyNestedMap(value);
}
}
@@ -558,7 +560,7 @@ public abstract class DefaultPropertyDeclarator<PROPERTYOWNER extends Properties
}
return isEmpty;
}
- //@returns true if map nested maps are all empty
+ //@returns true iff map nested maps are all empty
private class PropertiesDeclarationData {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index f3327d7206..85f29bf352 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -802,11 +802,11 @@ public class ToscaExportHandler {
if (CollectionUtils.isNotEmpty(component.getProperties())) {
List<PropertyDefinition> properties = component.getProperties();
Map<String, ToscaProperty> convertedProperties = properties.stream()
- .map(propertyDefinition -> resolvePropertyValueFromInput(propertyDefinition, component.getInputs()))
- .collect(Collectors.toMap(PropertyDataDefinition::getName,
- property -> propertyConvertor.convertProperty(dataTypes, property, PropertyConvertor.PropertyType.PROPERTY)));
+ .map(propertyDefinition -> resolvePropertyValueFromInput(propertyDefinition, component.getInputs())).collect(Collectors
+ .toMap(PropertyDataDefinition::getName,
+ property -> propertyConvertor.convertProperty(dataTypes, property, PropertyConvertor.PropertyType.PROPERTY)));
// merge component properties and inputs properties
- convertedProperties.forEach((k, v) -> mergedProperties.putIfAbsent(k, v));
+ mergedProperties.putAll(convertedProperties);
}
if (MapUtils.isNotEmpty(mergedProperties)) {
toscaNodeType.setProperties(mergedProperties);
@@ -940,7 +940,7 @@ public class ToscaExportHandler {
nodeTemplate.setType(componentInstance.getToscaComponentName());
nodeTemplate.setDirectives(componentInstance.getDirectives());
NodeFilter nodeFilter = convertToNodeTemplateNodeFilterComponent(componentInstance.getNodeFilter());
- if (nodeFilter != null && nodeFilter.hasData()) {
+ if(nodeFilter != null && nodeFilter.hasData()){
nodeTemplate.setNode_filter(nodeFilter);
}
final Either<Component, Boolean> originComponentRes = capabilityRequirementConverter
@@ -1755,7 +1755,7 @@ public class ToscaExportHandler {
}
private Map<String, ToscaProperty> convertInputsToProperties(Map<String, DataTypeDefinition> dataTypes, List<InputDefinition> componentInputs,
- String componentUniqueId) {
+ String componentUniqueId) {
if (CollectionUtils.isEmpty(componentInputs)) {
return new HashMap<>();
}
@@ -1776,10 +1776,6 @@ public class ToscaExportHandler {
.ofNullable(interfacesOperationsConverter.getInterfacesMap(proxyComponent, null, proxyComponentInterfaces, dataTypes, false, false));
}
- private Configuration getConfiguration() {
- return ConfigurationManager.getConfigurationManager().getConfiguration();
- }
-
private static class CustomRepresenter extends Representer {
CustomRepresenter() {
@@ -1935,4 +1931,8 @@ public class ToscaExportHandler {
}
}
+ private Configuration getConfiguration() {
+ return ConfigurationManager.getConfigurationManager().getConfiguration();
+ }
+
}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java
index b94a32291e..55de9e5028 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/utils/InputConverter.java
@@ -56,7 +56,7 @@ public class InputConverter {
* description
* list of properties */
public Map<String, ToscaProperty> convertInputs(List<InputDefinition> inputDef, Map<String, DataTypeDefinition> dataTypes) {
- log.debug("convert inputs to tosca");
+ log.debug("convert inputs to to tosca ");
Map<String, ToscaProperty> inputs = new HashMap<>();
if (inputDef != null) {
inputDef.forEach(i -> {