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.PropertyDeclarationOrchestrator;
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.*;
34 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
35 import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
36 import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
37 import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
38 import org.openecomp.sdc.common.log.wrappers.Logger;
39 import org.openecomp.sdc.exception.ResponseFormat;
40 import org.springframework.stereotype.Component;
42 import javax.inject.Inject;
44 import java.util.stream.Collectors;
46 @Component("inputsBusinessLogic")
47 public class InputsBusinessLogic extends BaseBusinessLogic {
49 private static final String CREATE_INPUT = "CreateInput";
50 private static final String UPDATE_INPUT = "UpdateInput";
52 private static final Logger log = Logger.getLogger(InputsBusinessLogic.class);
53 private static final String FAILED_TO_FOUND_COMPONENT_ERROR = "Failed to found component {}, error: {}";
54 private static final String GET_PROPERTIES_BY_INPUT = "get Properties by input";
55 private static final String FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR = "Failed to found input {} under component {}, error: {}";
56 private static final String GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP = "Going to execute rollback on create group.";
57 private static final String GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP = "Going to execute commit on create group.";
60 private PropertyDeclarationOrchestrator propertyDeclarationOrchestrator;
62 private ComponentInstanceBusinessLogic componentInstanceBusinessLogic;
65 * associate inputs to a given component with paging
71 public Either<List<InputDefinition>, ResponseFormat> getInputs(String userId, String componentId) {
73 validateUserExists(userId, "get Inputs", false);
75 ComponentParametersView filters = new ComponentParametersView();
77 filters.setIgnoreInputs(false);
79 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(componentId, filters);
80 if(getComponentEither.isRight()){
81 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
82 log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus);
83 return Either.right(componentsUtils.getResponseFormat(actionStatus));
86 org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
87 List<InputDefinition> inputs = component.getInputs();
89 return Either.left(inputs);
93 public Either<List<ComponentInstanceInput>, ResponseFormat> getComponentInstanceInputs(String userId, String componentId, String componentInstanceId) {
95 validateUserExists(userId, "get Inputs", false);
96 ComponentParametersView filters = new ComponentParametersView();
98 filters.setIgnoreInputs(false);
99 filters.setIgnoreComponentInstances(false);
100 filters.setIgnoreComponentInstancesInputs(false);
102 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(componentId, filters);
103 if(getComponentEither.isRight()){
104 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
105 log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus);
106 return Either.right(componentsUtils.getResponseFormat(actionStatus));
109 org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
111 if(!ComponentValidations.validateComponentInstanceExist(component, componentInstanceId)){
112 ActionStatus actionStatus = ActionStatus.COMPONENT_INSTANCE_NOT_FOUND;
113 log.debug("Failed to found component instance inputs {}, error: {}", componentInstanceId, actionStatus);
114 return Either.right(componentsUtils.getResponseFormat(actionStatus));
116 Map<String, List<ComponentInstanceInput>> ciInputs = Optional.ofNullable(component.getComponentInstancesInputs()).orElse(Collections.emptyMap());
117 return Either.left(ciInputs.getOrDefault(componentInstanceId, Collections.emptyList()));
121 * associate properties to a given component instance input
129 public Either<List<ComponentInstanceProperty>, ResponseFormat> getComponentInstancePropertiesByInputId(String userId, String componentId, String instanceId, String inputId) {
130 validateUserExists(userId, GET_PROPERTIES_BY_INPUT, false);
131 String parentId = componentId;
132 org.openecomp.sdc.be.model.Component component = null;
133 ComponentParametersView filters = new ComponentParametersView();
134 filters.disableAll();
135 filters.setIgnoreComponentInstances(false);
137 if(!instanceId.equals(inputId)){
140 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(parentId, filters);
142 if(getComponentEither.isRight()){
143 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
144 log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, parentId, actionStatus);
145 return Either.right(componentsUtils.getResponseFormat(actionStatus));
148 component = getComponentEither.left().value();
149 Optional<ComponentInstance> ciOp = component.getComponentInstances().stream().filter(ci ->ci.getUniqueId().equals(instanceId)).findAny();
150 if(ciOp.isPresent()){
151 parentId = ciOp.get().getComponentUid();
156 filters.setIgnoreInputs(false);
158 filters.setIgnoreComponentInstancesProperties(false);
159 filters.setIgnoreComponentInstancesInputs(false);
160 filters.setIgnoreProperties(false);
162 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(parentId, filters);
164 if(getComponentEither.isRight()){
165 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
166 log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, parentId, actionStatus);
167 return Either.right(componentsUtils.getResponseFormat(actionStatus));
170 component = getComponentEither.left().value();
172 Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
174 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
175 log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, parentId, actionStatus);
176 return Either.right(componentsUtils.getResponseFormat(actionStatus));
179 return Either.left(componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(component, inputId));
183 private Either<String,ResponseFormat> updateInputObjectValue(InputDefinition currentInput, InputDefinition newInput, Map<String, DataTypeDefinition> dataTypes) {
184 String innerType = null;
185 String propertyType = currentInput.getType();
186 ToscaPropertyType type = ToscaPropertyType.isValidType(propertyType);
187 log.debug("The type of the property {} is {}", currentInput.getUniqueId(), propertyType);
189 if (type == ToscaPropertyType.LIST || type == ToscaPropertyType.MAP) {
190 SchemaDefinition def = currentInput.getSchema();
192 log.debug("Schema doesn't exists for property of type {}", type);
193 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE)));
195 PropertyDataDefinition propDef = def.getProperty();
196 if (propDef == null) {
197 log.debug("Property in Schema Definition inside property of type {} doesn't exist", type);
198 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(StorageOperationStatus.INVALID_VALUE)));
200 innerType = propDef.getType();
202 // Specific Update Logic
204 Either<Object, Boolean> isValid = propertyOperation.validateAndUpdatePropertyValue(propertyType, newInput.getDefaultValue(), true, innerType, dataTypes);
206 String newValue = currentInput.getDefaultValue();
207 if (isValid.isRight()) {
208 Boolean res = isValid.right().value();
209 if (Boolean.FALSE.equals(res)) {
210 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertTitanStatusToStorageStatus(TitanOperationStatus.ILLEGAL_ARGUMENT))));
213 Object object = isValid.left().value();
214 if (object != null) {
215 newValue = object.toString();
218 return Either.left(newValue);
221 private InputDefinition getInputFromInputsListById(List<InputDefinition> componentsOldInputs, InputDefinition input) {
222 return componentsOldInputs.stream().filter(in -> in.getUniqueId().equals(input.getUniqueId())).findFirst().orElse(null);
225 public Either<List<InputDefinition>, ResponseFormat> updateInputsValue(ComponentTypeEnum componentType, String componentId, List<InputDefinition> inputs, String userId, boolean shouldLockComp, boolean inTransaction) {
227 List<InputDefinition> returnInputs = new ArrayList<>();
228 Either<List<InputDefinition>, ResponseFormat> result = null;
229 org.openecomp.sdc.be.model.Component component = null;
232 validateUserExists(userId, "get input", false);
234 ComponentParametersView componentParametersView = new ComponentParametersView();
235 componentParametersView.disableAll();
236 componentParametersView.setIgnoreInputs(false);
237 componentParametersView.setIgnoreUsers(false);
239 Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> validateComponent = validateComponentExists(componentId, componentType, componentParametersView);
241 if (validateComponent.isRight()) {
242 result = Either.right(validateComponent.right().value());
245 component = validateComponent.left().value();
247 if (shouldLockComp) {
248 Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, UPDATE_INPUT);
249 if (lockComponent.isRight()) {
250 result = Either.right(lockComponent.right().value());
255 Either<Boolean, ResponseFormat> canWork = validateCanWorkOnComponent(component, userId);
256 if (canWork.isRight()) {
257 result = Either.right(canWork.right().value());
261 Either<Map<String, DataTypeDefinition>, ResponseFormat> allDataTypes = getAllDataTypes(applicationDataTypeCache);
262 if (allDataTypes.isRight()) {
263 result = Either.right(allDataTypes.right().value());
267 Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value();
268 List<InputDefinition> componentsOldInputs = Optional.ofNullable(component.getInputs()).orElse(Collections.emptyList());
269 for (InputDefinition newInput: inputs) {
270 InputDefinition currInput = getInputFromInputsListById(componentsOldInputs, newInput);
271 if (currInput == null) {
272 ActionStatus actionStatus = ActionStatus.COMPONENT_NOT_FOUND;
273 log.debug("Failed to found newInput {} under component {}, error: {}", newInput.getUniqueId(), componentId, actionStatus);
274 result = Either.right(componentsUtils.getResponseFormat(actionStatus));
277 Either<String, ResponseFormat> updateInputObjectValue = updateInputObjectValue(currInput, newInput, dataTypes);
278 if ( updateInputObjectValue.isRight()) {
279 return Either.right(updateInputObjectValue.right().value());
281 String newValue = updateInputObjectValue.left().value();
282 currInput.setDefaultValue(newValue);
283 currInput.setOwnerId(userId);
284 Either<InputDefinition, StorageOperationStatus> status = toscaOperationFacade.updateInputOfComponent(component, currInput);
285 if(status.isRight()){
286 ActionStatus actionStatus = componentsUtils.convertFromStorageResponseForResourceInstanceProperty(status.right().value());
287 result = Either.right(componentsUtils.getResponseFormat(actionStatus, ""));
290 returnInputs.add(status.left().value());
293 result = Either.left(returnInputs);
296 if (!inTransaction) {
297 if (result == null || result.isRight()) {
298 log.debug(GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP);
301 log.debug(GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP);
306 if (shouldLockComp && component != null) {
307 graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
312 public Either<List<ComponentInstanceInput>, ResponseFormat> getInputsForComponentInput(String userId, String componentId, String inputId) {
313 validateUserExists(userId, GET_PROPERTIES_BY_INPUT, false);
314 org.openecomp.sdc.be.model.Component component = null;
315 ComponentParametersView filters = new ComponentParametersView();
316 filters.disableAll();
317 filters.setIgnoreComponentInstances(false);
318 filters.setIgnoreInputs(false);
319 filters.setIgnoreComponentInstancesInputs(false);
320 filters.setIgnoreProperties(false);
322 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(componentId, filters);
324 if(getComponentEither.isRight()){
325 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
326 log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus);
327 return Either.right(componentsUtils.getResponseFormat(actionStatus));
330 component = getComponentEither.left().value();
332 Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
334 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
335 log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, componentId, actionStatus);
336 return Either.right(componentsUtils.getResponseFormat(actionStatus));
339 return Either.left(componentInstanceBusinessLogic.getComponentInstanceInputsByInputId(component, inputId));
343 public Either<List<InputDefinition>, ResponseFormat> createMultipleInputs(String userId, String componentId, ComponentTypeEnum componentType, ComponentInstInputsMap componentInstInputsMapUi, boolean shouldLockComp, boolean inTransaction) {
345 Either<List<InputDefinition>, ResponseFormat> result = null;
346 org.openecomp.sdc.be.model.Component component = null;
349 validateUserExists(userId, GET_PROPERTIES_BY_INPUT, false);
351 ComponentParametersView componentParametersView = new ComponentParametersView();
352 componentParametersView.disableAll();
353 componentParametersView.setIgnoreInputs(false);
354 componentParametersView.setIgnoreComponentInstancesInputs(false);
355 componentParametersView.setIgnoreComponentInstances(false);
356 componentParametersView.setIgnoreComponentInstancesProperties(false);
357 componentParametersView.setIgnorePolicies(false);
358 componentParametersView.setIgnoreGroups(false);
359 componentParametersView.setIgnoreUsers(false);
361 Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> validateComponent = validateComponentExists(componentId, componentType, componentParametersView);
363 if (validateComponent.isRight()) {
364 result = Either.right(validateComponent.right().value());
367 component = validateComponent.left().value();
369 if (shouldLockComp) {
370 Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, CREATE_INPUT);
371 if (lockComponent.isRight()) {
372 result = Either.right(lockComponent.right().value());
377 Either<Boolean, ResponseFormat> canWork = validateCanWorkOnComponent(component, userId);
378 if (canWork.isRight()) {
379 result = Either.right(canWork.right().value());
383 result = propertyDeclarationOrchestrator.declarePropertiesToInputs(component, componentInstInputsMapUi)
385 .bind(inputsToCreate -> prepareInputsForCreation(userId, componentId, inputsToCreate))
387 .map(err -> componentsUtils.getResponseFormat(err));
393 if (!inTransaction) {
394 if (result == null || result.isRight()) {
395 log.debug(GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP);
398 log.debug(GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP);
403 if (shouldLockComp && component != null) {
404 graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
410 private Either<List<InputDefinition>, StorageOperationStatus> prepareInputsForCreation(String userId, String cmptId, List<InputDefinition> inputsToCreate) {
411 Map<String, InputDefinition> inputsToPersist = MapUtil.toMap(inputsToCreate, InputDefinition::getName);
412 assignOwnerIdToInputs(userId, inputsToPersist);
413 return toscaOperationFacade.addInputsToComponent(inputsToPersist, cmptId)
415 .map(persistedInputs -> inputsToCreate);
418 private void assignOwnerIdToInputs(String userId, Map<String, InputDefinition> inputsToCreate) {
419 inputsToCreate.values().forEach(inputDefinition -> inputDefinition.setOwnerId(userId));
422 public Either<List<InputDefinition>, ResponseFormat> createInputsInGraph(Map<String, InputDefinition> inputs, org.openecomp.sdc.be.model.Component component) {
424 List<InputDefinition> resourceProperties = component.getInputs();
425 Either<Map<String, DataTypeDefinition>, ResponseFormat> allDataTypes = getAllDataTypes(applicationDataTypeCache);
426 if (allDataTypes.isRight()) {
427 return Either.right(allDataTypes.right().value());
430 Map<String, DataTypeDefinition> dataTypes = allDataTypes.left().value();
432 for (Map.Entry<String, InputDefinition> inputDefinition : inputs.entrySet()) {
433 String inputName = inputDefinition.getKey();
434 inputDefinition.getValue().setName(inputName);
436 Either<InputDefinition, ResponseFormat> preparedInputEither = prepareAndValidateInputBeforeCreate(inputDefinition.getValue(), dataTypes);
437 if(preparedInputEither.isRight()){
438 return Either.right(preparedInputEither.right().value());
442 if (resourceProperties != null) {
443 Map<String, InputDefinition> generatedInputs = resourceProperties.stream().collect(Collectors.toMap(PropertyDataDefinition::getName, i -> i));
444 Either<Map<String, InputDefinition>, String> mergeEither = ToscaDataDefinition.mergeDataMaps(generatedInputs, inputs);
445 if(mergeEither.isRight()){
446 return Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_ALREADY_EXIST, mergeEither.right().value()));
448 inputs = mergeEither.left().value();
451 Either<List<InputDefinition>, StorageOperationStatus> associateInputsEither = toscaOperationFacade.createAndAssociateInputs(inputs, component.getUniqueId());
452 if(associateInputsEither.isRight()){
453 log.debug("Failed to create inputs under component {}. Status is {}", component.getUniqueId(), associateInputsEither.right().value());
454 return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(associateInputsEither.right().value())));
456 return Either.left(associateInputsEither.left().value());
460 * Delete input from service
467 public Either<InputDefinition, ResponseFormat> deleteInput(String componentId, String userId, String inputId) {
469 Either<InputDefinition, ResponseFormat> deleteEither = null;
470 if (log.isDebugEnabled()) {
471 log.debug("Going to delete input id: {}", inputId);
474 validateUserExists(userId, "Delete input", true);
476 ComponentParametersView componentParametersView = new ComponentParametersView();
477 componentParametersView.disableAll();
478 componentParametersView.setIgnoreInputs(false);
479 componentParametersView.setIgnoreComponentInstances(false);
480 componentParametersView.setIgnoreComponentInstancesInputs(false);
481 componentParametersView.setIgnoreComponentInstancesProperties(false);
482 componentParametersView.setIgnorePolicies(false);
483 componentParametersView.setIgnoreGroups(false);
484 componentParametersView.setIgnoreUsers(false);
486 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> componentEither = toscaOperationFacade.getToscaElement(componentId, componentParametersView);
487 if (componentEither.isRight()) {
488 deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(componentEither.right().value())));
491 org.openecomp.sdc.be.model.Component component = componentEither.left().value();
493 // Validate inputId is child of the component
494 Optional<InputDefinition> optionalInput = component.getInputs().stream().
496 filter(input -> input.getUniqueId().equals(inputId)).
499 if (!optionalInput.isPresent()) {
500 return Either.right(componentsUtils.getResponseFormat(ActionStatus.INPUT_IS_NOT_CHILD_OF_COMPONENT, inputId, componentId));
503 InputDefinition inputForDelete = optionalInput.get();
506 Either<Boolean, ResponseFormat> lockResultEither = lockComponent(componentId, component, "deleteInput");
507 if (lockResultEither.isRight()) {
508 ResponseFormat responseFormat = lockResultEither.right().value();
509 deleteEither = Either.right(responseFormat);
513 // Delete input operations
515 StorageOperationStatus status = toscaOperationFacade.deleteInputOfResource(component, inputForDelete.getName());
516 if (status != StorageOperationStatus.OK) {
517 log.debug("Component id: {} delete input id: {} failed", componentId, inputId);
518 deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), component.getName()));
521 StorageOperationStatus storageOperationStatus = propertyDeclarationOrchestrator.unDeclarePropertiesAsInputs(component, inputForDelete);
522 if (storageOperationStatus != StorageOperationStatus.OK) {
523 log.debug("Component id: {} update properties declared as input for input id: {} failed", componentId, inputId);
524 deleteEither = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status), component.getName()));
527 deleteEither = Either.left(inputForDelete);
530 if (deleteEither == null || deleteEither.isRight()) {
531 log.debug("Component id: {} delete input id: {} failed", componentId, inputId);
534 log.debug("Component id: {} delete input id: {} success", componentId, inputId);
537 unlockComponent(deleteEither, component);
541 private Either<InputDefinition, ResponseFormat> prepareAndValidateInputBeforeCreate(InputDefinition newInputDefinition, Map<String, DataTypeDefinition> dataTypes) {
544 // validate input default values
545 Either<Boolean, ResponseFormat> defaultValuesValidation = validatePropertyDefaultValue(newInputDefinition, dataTypes);
546 if (defaultValuesValidation.isRight()) {
547 return Either.right(defaultValuesValidation.right().value());
550 ToscaPropertyType type = getType(newInputDefinition.getType());
552 PropertyValueConverter converter = type.getConverter();
554 String innerType = null;
555 SchemaDefinition schema = newInputDefinition.getSchema();
556 if (schema != null) {
557 PropertyDataDefinition prop = schema.getProperty();
559 innerType = prop.getType();
562 String convertedValue;
563 if (newInputDefinition.getDefaultValue() != null) {
564 convertedValue = converter.convert(newInputDefinition.getDefaultValue(), innerType, dataTypes);
565 newInputDefinition.setDefaultValue(convertedValue);
568 return Either.left(newInputDefinition);
571 public Either<InputDefinition, ResponseFormat> getInputsAndPropertiesForComponentInput(String userId, String componentId, String inputId, boolean inTransaction) {
572 Either<InputDefinition, ResponseFormat> result = null;
575 validateUserExists(userId, GET_PROPERTIES_BY_INPUT, false);
576 ComponentParametersView filters = new ComponentParametersView();
577 filters.disableAll();
578 filters.setIgnoreComponentInstances(false);
579 filters.setIgnoreInputs(false);
580 filters.setIgnoreComponentInstancesInputs(false);
581 filters.setIgnoreComponentInstancesProperties(false);
582 filters.setIgnoreProperties(false);
583 Either<org.openecomp.sdc.be.model.Component, StorageOperationStatus> getComponentEither = toscaOperationFacade.getToscaElement(componentId, filters);
584 if(getComponentEither.isRight()){
585 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
586 log.debug(FAILED_TO_FOUND_COMPONENT_ERROR, componentId, actionStatus);
587 return Either.right(componentsUtils.getResponseFormat(actionStatus));
590 org.openecomp.sdc.be.model.Component component = getComponentEither.left().value();
591 Optional<InputDefinition> op = component.getInputs().stream().filter(in -> in.getUniqueId().equals(inputId)).findFirst();
593 ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(getComponentEither.right().value());
594 log.debug(FAILED_TO_FOUND_INPUT_UNDER_COMPONENT_ERROR, inputId, componentId, actionStatus);
595 return Either.right(componentsUtils.getResponseFormat(actionStatus));
598 InputDefinition resObj = op.get();
600 List<ComponentInstanceInput> inputCIInput = componentInstanceBusinessLogic.getComponentInstanceInputsByInputId(component, inputId) ;
602 resObj.setInputs(inputCIInput);
605 List<ComponentInstanceProperty> inputProps = componentInstanceBusinessLogic.getComponentInstancePropertiesByInputId(component, inputId) ;
607 resObj.setProperties(inputProps);
610 result = Either.left(resObj);
616 if (!inTransaction) {
618 if (result == null || result.isRight()) {
619 log.debug(GOING_TO_EXECUTE_ROLLBACK_ON_CREATE_GROUP);
622 log.debug(GOING_TO_EXECUTE_COMMIT_ON_CREATE_GROUP);