2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.be.components.impl;
23 import fj.data.Either;
24 import org.openecomp.sdc.be.components.property.PropertyDecelerationOrchestrator;
25 import org.openecomp.sdc.be.components.validation.ComponentValidations;
26 import org.openecomp.sdc.be.dao.api.ActionStatus;
27 import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
28 import org.openecomp.sdc.be.dao.utils.MapUtil;
29 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
30 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
31 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
32 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
33 import org.openecomp.sdc.be.model.ComponentInstInputsMap;
34 import org.openecomp.sdc.be.model.ComponentInstance;
35 import org.openecomp.sdc.be.model.ComponentInstanceInput;
36 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
37 import org.openecomp.sdc.be.model.ComponentParametersView;
38 import org.openecomp.sdc.be.model.DataTypeDefinition;
39 import org.openecomp.sdc.be.model.InputDefinition;
40 import org.openecomp.sdc.be.model.User;
41 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
42 import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
43 import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
44 import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
45 import org.openecomp.sdc.exception.ResponseFormat;
46 import org.slf4j.Logger;
47 import org.slf4j.LoggerFactory;
48 import org.springframework.stereotype.Component;
50 import javax.inject.Inject;
51 import java.util.ArrayList;
52 import java.util.Collections;
53 import java.util.List;
55 import java.util.Optional;
56 import java.util.stream.Collectors;
58 @Component("inputsBusinessLogic")
59 public class InputsBusinessLogic extends BaseBusinessLogic {
61 private static final String CREATE_INPUT = "CreateInput";
62 private static final String UPDATE_INPUT = "UpdateInput";
64 private static final Logger log = LoggerFactory.getLogger(InputsBusinessLogic.class);
67 private PropertyDecelerationOrchestrator propertyDecelerationOrchestrator;
69 private ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
72 * associate inputs to a given component with paging
78 public Either<List<InputDefinition>, ResponseFormat> getInputs(String userId, String componentId) {
80 Either<User, ResponseFormat> resp = validateUserExists(userId, "get Inputs", false);
83 return Either.right(resp.right().value());
87 ComponentParametersView filters = new ComponentParametersView();
89 filters.setIgnoreInputs(false);
91 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(componentId, filters);
92 if(getComponentEither.isRight()){
93 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
94 log.debug("Failed to found component {}, error: {}", componentId, actionStatus);
95 return Either.right(componentsUtils.getResponseFormat(actionStatus));
98 org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
99 List<InputDefinition> inputs = component.getInputs();
101 return Either.left(inputs);
105 public Either<List<ComponentInstanceInput>, ResponseFormat> getComponentInstanceInputs(String userId, String componentId, String componentInstanceId) {
107 Either<User, ResponseFormat> resp = validateUserExists(userId, "get Inputs", false);
109 if (resp.isRight()) {
110 return Either.right(resp.right().value());
114 ComponentParametersView filters = new ComponentParametersView();
115 filters.disableAll();
116 filters.setIgnoreInputs(false);
117 filters.setIgnoreComponentInstances(false);
118 filters.setIgnoreComponentInstancesInputs(false);
120 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(componentId, filters);
121 if(getComponentEither.isRight()){
122 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
123 log.debug("Failed to found component {}, error: {}", componentId, actionStatus);
124 return Either.right(componentsUtils.getResponseFormat(actionStatus));
127 org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
129 if(!ComponentValidations.validateComponentInstanceExist(component, componentInstanceId)){
130 ActionStatus actionStatus = ActionStatus.COMPONENT_INSTANCE_NOT_FOUND;
131 log.debug("Failed to found component instance inputs {}, error: {}", componentInstanceId, actionStatus);
132 return Either.right(componentsUtils.getResponseFormat(actionStatus));
134 Map<String, List<ComponentInstanceInput>> ciInputs = Optional.ofNullable(component.getComponentInstancesInputs()).orElse(Collections.emptyMap());
135 return Either.left(ciInputs.getOrDefault(componentInstanceId, Collections.emptyList()));
139 * associate properties to a given component instance input
147 public Either<List<ComponentInstanceProperty>, ResponseFormat> getComponentInstancePropertiesByInputId(String userId, String componentId, String instanceId, String inputId) {
148 Either<User, ResponseFormat> resp = validateUserExists(userId, "get Properties by input", false);
149 if (resp.isRight()) {
150 return Either.right(resp.right().value());
152 String parentId = componentId;
153 org.openecomp.sdc.be.model.Component component = null;
154 ComponentParametersView filters = new ComponentParametersView();
155 filters.disableAll();
156 filters.setIgnoreComponentInstances(false);
158 if(!instanceId.equals(inputId)){
161 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(parentId, filters);
163 if(getComponentEither.isRight()){
164 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
165 log.debug("Failed to found component {}, error: {}", parentId, actionStatus);
166 return Either.right(componentsUtils.getResponseFormat(actionStatus));
169 component = getComponentEither.left().value();
170 Optional<ComponentInstance> ciOp = component.getComponentInstances().stream().filter(ci ->ci.getUniqueId().equals(instanceId)).findAny();
171 if(ciOp.isPresent()){
172 parentId = ciOp.get().getComponentUid();
177 filters.setIgnoreInputs(false);
179 filters.setIgnoreComponentInstancesProperties(false);
180 filters.setIgnoreComponentInstancesInputs(false);
181 filters.setIgnoreProperties(false);
183 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(parentId, filters);
185 if(getComponentEither.isRight()){
186 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
187 log.debug("Failed to found component {}, error: {}", parentId, actionStatus);
188 return Either.right(componentsUtils.getResponseFormat(actionStatus));
191 component = getComponentEither.left().value();
193 Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
195 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
196 log.debug("Failed to found input {} under component {}, error: {}", inputId, parentId, actionStatus);
197 return Either.right(componentsUtils.getResponseFormat(actionStatus));
200 return Either.left(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(component, inputId));
204 private Either<String,ResponseFormat> updateInputObjectValue(InputDefinition currentInput, InputDefinition newInput, Map<String, DataTypeDefinition> dataTypes) {
205 String innerType = null;
206 String propertyType = currentInput.getType();
207 ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
208 log.debug("The type of the property {} is {}", currentInput.getUniqueId(), propertyType);
210 if (type == ToscaPropertyType.LIST || type == ToscaPropertyType.MAP) {
211 SchemaDefinition def = currentInput.getSchema();
213 log.debug("Schema doesn't exists for property of type {}", type);
214 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE)));
216 PropertyDataDefinition propDef = def.getProperty();
217 if (propDef == null) {
218 log.debug("Property in Schema Definition inside property of type {} doesn't exist", type);
219 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE)));
221 innerType = propDef.getType();
223 // Specific Update Logic
225 Either<Object, Boolean> isValid = propertyOperation.validateAndUpdatePropertyValue(propertyType, newInput.getDefaultValue(), true, innerType, dataTypes);
227 String newValue = currentInput.getDefaultValue();
228 if (isValid.isRight()) {
229 Boolean res = isValid.right().value();
230 if (Boolean.FALSE.equals(res)) {
231 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertTitanStatusToStorageStatus(TitanOperationStatus.ILLEGAL_ARGUMENT))));
234 Object object = isValid.left().value();
235 if (object != null) {
236 newValue = object.toString();
239 return Either.left(newValue);
242 private InputDefinition getInputFromInputsListById(List<InputDefinition> componentsOldInputs, InputDefinition input) {
243 Optional<InputDefinition> foundInput = componentsOldInputs.stream().filter(in -> in.getUniqueId().equals(input.getUniqueId())).findFirst();
244 return foundInput.isPresent() ? foundInput.get() : null;
247 public Either<List<InputDefinition>, ResponseFormat> updateInputsValue(ComponentTypeEnum componentType, String componentId, List<InputDefinition> inputs, String userId, boolean shouldLockComp, boolean inTransaction) {
249 List<InputDefinition> returnInputs = new ArrayList<>();
250 Either<List<InputDefinition>, ResponseFormat> result = null;
251 org.openecomp.sdc.be.model.Component component = null;
254 Either<User, ResponseFormat> resp = validateUserExists(userId, "get input", false);
256 if (resp.isRight()) {
257 result = Either.right(resp.right().value());
261 ComponentParametersView componentParametersView = new ComponentParametersView();
262 componentParametersView.disableAll();
263 componentParametersView.setIgnoreInputs(false);
264 componentParametersView.setIgnoreUsers(false);
266 Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> validateComponent = validateComponentExists(componentId, componentType, componentParametersView);
268 if (validateComponent.isRight()) {
269 result = Either.right(validateComponent.right().value());
272 component = validateComponent.left().value();
274 if (shouldLockComp) {
275 Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, UPDATE_INPUT);
276 if (lockComponent.isRight()) {
277 result = Either.right(lockComponent.right().value());
282 Either<Boolean, ResponseFormat> canWork = validateCanWorkOnComponent(component, userId);
283 if (canWork.isRight()) {
284 result = Either.right(canWork.right().value());
288 Either<Map<String, DataTypeDefinition>, ResponseFormat> allDataTypes = getAllDataTypes(applicationDataTypeCache);
289 if (allDataTypes.isRight()) {
290 result = Either.right(allDataTypes.right().value());
294 Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value();
295 List<InputDefinition> componentsOldInputs = Optional.ofNullable(component.getInputs()).orElse(Collections.emptyList());
296 for (InputDefinition newInput: inputs) {
297 InputDefinition currInput = getInputFromInputsListById(componentsOldInputs, newInput);
298 if (currInput == null) {
299 ActionStatus actionStatus = ActionStatus.COMPONENT_NOT_FOUND;
300 log.debug("Failed to found newInput {} under component {}, error: {}", newInput.getUniqueId(), componentId, actionStatus.name());
301 result = Either.right(componentsUtils.getResponseFormat(actionStatus));
304 Either<String, ResponseFormat> updateInputObjectValue = updateInputObjectValue(currInput, newInput, dataTypes);
305 if ( updateInputObjectValue.isRight()) {
306 return Either.right(updateInputObjectValue.right().value());
308 String newValue = updateInputObjectValue.left().value();
309 currInput.setDefaultValue(newValue);
310 currInput.setOwnerId(userId);
311 Either<InputDefinition, StorageOperationStatus> status = toscaOperationFacade.updateInputOfComponent(component, currInput);
312 if(status.isRight()){
313 ActionStatus actionStatus = componentsUtils.convertFromStorageResponseForResourceInstanceProperty(status.right().value());
314 result = Either.right(componentsUtils.getResponseFormat(actionStatus, ""));
317 returnInputs.add(status.left().value());
320 result = Either.left(returnInputs);
323 if (false == inTransaction) {
324 if (result == null || result.isRight()) {
325 log.debug("Going to execute rollback on create group.");
328 log.debug("Going to execute commit on create group.");
333 if (shouldLockComp && component != null) {
334 graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
339 public Either<List<ComponentInstanceInput>, ResponseFormat> getInputsForComponentInput(String userId, String componentId, String inputId) {
340 Either<User, ResponseFormat> resp = validateUserExists(userId, "get Properties by input", false);
341 if (resp.isRight()) {
342 return Either.right(resp.right().value());
344 String parentId = componentId;
345 org.openecomp.sdc.be.model.Component component = null;
346 ComponentParametersView filters = new ComponentParametersView();
347 filters.disableAll();
348 filters.setIgnoreComponentInstances(false);
349 filters.setIgnoreInputs(false);
350 filters.setIgnoreComponentInstancesInputs(false);
351 filters.setIgnoreProperties(false);
353 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(parentId, filters);
355 if(getComponentEither.isRight()){
356 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
357 log.debug("Failed to found component {}, error: {}", parentId, actionStatus);
358 return Either.right(componentsUtils.getResponseFormat(actionStatus));
361 component = getComponentEither.left().value();
363 Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
365 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
366 log.debug("Failed to found input {} under component {}, error: {}", inputId, parentId, actionStatus);
367 return Either.right(componentsUtils.getResponseFormat(actionStatus));
370 return Either.left(componentInstanceBusinessLogic.getComponentInstanceInputsByInputId(component, inputId));
374 public Either<List<InputDefinition>, ResponseFormat> createMultipleInputs(String userId, String componentId, ComponentTypeEnum componentType, ComponentInstInputsMap componentInstInputsMapUi, boolean shouldLockComp, boolean inTransaction) {
376 Either<List<InputDefinition>, ResponseFormat> result = null;
377 org.openecomp.sdc.be.model.Component component = null;
380 Either<User, ResponseFormat> resp = validateUserExists(userId, "get Properties by input", false);
382 if (resp.isRight()) {
383 result = Either.right(resp.right().value());
387 ComponentParametersView componentParametersView = new ComponentParametersView();
388 componentParametersView.disableAll();
389 componentParametersView.setIgnoreInputs(false);
390 componentParametersView.setIgnoreComponentInstancesInputs(false);
391 componentParametersView.setIgnoreComponentInstances(false);
392 componentParametersView.setIgnoreComponentInstancesProperties(false);
393 componentParametersView.setIgnoreUsers(false);
395 Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> validateComponent = validateComponentExists(componentId, componentType, componentParametersView);
397 if (validateComponent.isRight()) {
398 result = Either.right(validateComponent.right().value());
401 component = validateComponent.left().value();
403 if (shouldLockComp) {
404 Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, CREATE_INPUT);
405 if (lockComponent.isRight()) {
406 result = Either.right(lockComponent.right().value());
411 Either<Boolean, ResponseFormat> canWork = validateCanWorkOnComponent(component, userId);
412 if (canWork.isRight()) {
413 result = Either.right(canWork.right().value());
417 result = propertyDecelerationOrchestrator.declarePropertiesToInputs(component, componentInstInputsMapUi)
419 .bind(inputsToCreate -> prepareInputsForCreation(userId, componentId, inputsToCreate))
421 .map(err -> componentsUtils.getResponseFormat(err));
427 if (!inTransaction) {
428 if (result == null || result.isRight()) {
429 log.debug("Going to execute rollback on create group.");
432 log.debug("Going to execute commit on create group.");
437 if (shouldLockComp && component != null) {
438 graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
444 private Either<List<InputDefinition>, StorageOperationStatus> prepareInputsForCreation(String userId, String cmptId, List<InputDefinition> inputsToCreate) {
445 Map<String, InputDefinition> inputsToPersist = MapUtil.toMap(inputsToCreate, InputDefinition::getName);
446 assignOwnerIdToInputs(userId, inputsToPersist);
447 return toscaOperationFacade.addInputsToComponent(inputsToPersist, cmptId)
449 .map(persistedInputs -> inputsToCreate);
452 private void assignOwnerIdToInputs(String userId, Map<String, InputDefinition> inputsToCreate) {
453 inputsToCreate.values().forEach(inputDefinition -> inputDefinition.setOwnerId(userId));
456 public Either<List<InputDefinition>, ResponseFormat> createInputsInGraph(Map<String, InputDefinition> inputs, org.openecomp.sdc.be.model.Component component) {
458 List<InputDefinition> resList = inputs.values().stream().collect(Collectors.toList());
459 Either<List<InputDefinition>, ResponseFormat> result = Either.left(resList);
460 List<InputDefinition> resourceProperties = component.getInputs();
462 Either<Map<String, DataTypeDefinition>, ResponseFormat> allDataTypes = getAllDataTypes(applicationDataTypeCache);
463 if (allDataTypes.isRight()) {
464 return Either.right(allDataTypes.right().value());
467 Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value();
469 for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
470 String inputName = inputDefinition.getKey();
471 inputDefinition.getValue().setName(inputName);
473 Either<InputDefinition, ResponseFormat> preparedInputEither = prepareAndValidateInputBeforeCreate(inputDefinition.getValue(), dataTypes);
474 if(preparedInputEither.isRight()){
475 return Either.right(preparedInputEither.right().value());
479 if (resourceProperties != null) {
480 Map<String, InputDefinition> generatedInputs = resourceProperties.stream().collect(Collectors.toMap(i -> i.getName(), i -> i));
481 Either<Map<String, InputDefinition>, String> mergeEither = ToscaDataDefinition.mergeDataMaps(generatedInputs, inputs);
482 if(mergeEither.isRight()){
483 return Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_ALREADY_EXIST, mergeEither.right().value()));
485 inputs = mergeEither.left().value();
488 Either<List<InputDefinition>, StorageOperationStatus> assotiateInputsEither = toscaOperationFacade.createAndAssociateInputs(inputs, component.getUniqueId());
489 if(assotiateInputsEither.isRight()){
490 log.debug("Failed to create inputs under component {}. Status is {}", component.getUniqueId(), assotiateInputsEither.right().value());
491 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(assotiateInputsEither.right().value())));
493 result = Either.left(assotiateInputsEither.left().value());
499 * Delete input from service
507 public Either<InputDefinition, ResponseFormat> deleteInput(String componentId, String userId, String inputId) {
509 Either<InputDefinition, ResponseFormat> deleteEither = null;
510 if (log.isDebugEnabled())
511 log.debug("Going to delete input id: {}", inputId);
513 // Validate user (exists)
514 Either<User, ResponseFormat> userEither = validateUserExists(userId, "Delete input", true);
515 if (userEither.isRight()) {
516 deleteEither = Either.right(userEither.right().value());
520 // Get component using componentType, componentId
522 ComponentParametersView componentParametersView = new ComponentParametersView();
523 componentParametersView.disableAll();
524 componentParametersView.setIgnoreInputs(false);
525 componentParametersView.setIgnoreComponentInstances(false);
526 componentParametersView.setIgnoreComponentInstancesInputs(false);
527 componentParametersView.setIgnoreComponentInstancesProperties(false);
528 componentParametersView.setIgnorePolicies(false);
529 componentParametersView.setIgnoreUsers(false);
531 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> componentEither = toscaOperationFacade.getToscaElement(componentId, componentParametersView);
532 if (componentEither.isRight()) {
533 deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(componentEither.right().value())));
536 org.openecomp.sdc.be.model.Component component = componentEither.left().value();
538 // Validate inputId is child of the component
539 Optional<InputDefinition> optionalInput = component.getInputs().stream().
541 filter(input -> input.getUniqueId().equals(inputId)).
544 if (!optionalInput.isPresent()) {
545 return Either.right(componentsUtils.getResponseFormat(ActionStatus.INPUT_IS_NOT_CHILD_OF_COMPONENT, inputId, componentId));
548 InputDefinition inputForDelete = optionalInput.get();
551 Either<Boolean, ResponseFormat> lockResultEither = lockComponent(componentId, component, "deleteInput");
552 if (lockResultEither.isRight()) {
553 ResponseFormat responseFormat = lockResultEither.right().value();
554 deleteEither = Either.right(responseFormat);
558 // Delete input operations
560 StorageOperationStatus status = toscaOperationFacade.deleteInputOfResource(component, inputForDelete.getName());
561 if (status != StorageOperationStatus.OK) {
562 log.debug("Component id: {} delete input id: {} failed", componentId, inputId);
563 deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), component.getName()));
566 StorageOperationStatus storageOperationStatus = propertyDecelerationOrchestrator.unDeclarePropertiesAsInputs(component, inputForDelete);
567 if (storageOperationStatus != StorageOperationStatus.OK) {
568 log.debug("Component id: {} update properties declared as input for input id: {} failed", componentId, inputId);
569 deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), component.getName()));
572 deleteEither = Either.left(inputForDelete);
575 if (deleteEither == null || deleteEither.isRight()) {
576 log.debug("Component id: {} delete input id: {} failed", componentId, inputId);
579 log.debug("Component id: {} delete input id: {} success", componentId, inputId);
582 unlockComponent(deleteEither, component);
586 private Either<InputDefinition, ResponseFormat> prepareAndValidateInputBeforeCreate(InputDefinition newInputDefinition, Map<String, DataTypeDefinition> dataTypes) {
589 // validate input default values
590 Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newInputDefinition, dataTypes);
591 if (defaultValuesValidation.isRight()) {
592 return Either.right(defaultValuesValidation.right().value());
595 ToscaPropertyType type = getType(newInputDefinition.getType());
597 PropertyValueConverter converter = type.getConverter();
599 String innerType = null;
600 if (newInputDefinition != null) {
601 SchemaDefinition schema = newInputDefinition.getSchema();
602 if (schema != null) {
603 PropertyDataDefinition prop = schema.getProperty();
605 innerType = prop.getType();
608 String convertedValue = null;
609 if (newInputDefinition.getDefaultValue() != null) {
610 convertedValue = converter.convert(newInputDefinition.getDefaultValue(), innerType, dataTypes);
611 newInputDefinition.setDefaultValue(convertedValue);
615 return Either.left(newInputDefinition);
618 public Either<InputDefinition, ResponseFormat> getInputsAndPropertiesForComponentInput(String userId, String componentId, String inputId, boolean inTransaction) {
619 Either<InputDefinition, ResponseFormat> result = null;
622 Either<User, ResponseFormat> resp = validateUserExists(userId, "get Properties by input", false);
623 if (resp.isRight()) {
624 return Either.right(resp.right().value());
626 ComponentParametersView filters = new ComponentParametersView();
627 filters.disableAll();
628 filters.setIgnoreComponentInstances(false);
629 filters.setIgnoreInputs(false);
630 filters.setIgnoreComponentInstancesInputs(false);
631 filters.setIgnoreComponentInstancesProperties(false);
632 filters.setIgnoreProperties(false);
633 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(componentId, filters);
634 if(getComponentEither.isRight()){
635 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
636 log.debug("Failed to found component {}, error: {}", componentId, actionStatus);
637 return Either.right(componentsUtils.getResponseFormat(actionStatus));
640 org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
641 Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
643 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
644 log.debug("Failed to found input {} under component {}, error: {}", inputId, componentId, actionStatus);
645 return Either.right(componentsUtils.getResponseFormat(actionStatus));
648 InputDefinition resObj = op.get();
650 List<ComponentInstanceInput> inputCIInput = componentInstanceBusinessLogic.getComponentInstanceInputsByInputId(component, inputId) ;
652 resObj.setInputs(inputCIInput);
655 List<ComponentInstanceProperty> inputProps = componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(component, inputId) ;
657 resObj.setProperties(inputProps);
660 result = Either.left(resObj);
666 if (false == inTransaction) {
668 if (result == null || result.isRight()) {
669 log.debug("Going to execute rollback on create group.");
672 log.debug("Going to execute commit on create group.");