Fix 'Unable to drag a VFC on to composition if an existing VFC instance has the same...
[sdc.git] / catalog-model / src / main / java / org / openecomp / sdc / be / model / jsonjanusgraph / operations / ToscaOperationFacade.java
index 9c34b4c..d654f23 100644 (file)
  */
 package org.openecomp.sdc.be.model.jsonjanusgraph.operations;
 
-import static java.util.Objects.requireNonNull;
-import static org.apache.commons.collections.CollectionUtils.isEmpty;
-import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
-import static org.janusgraph.core.attribute.Text.REGEX;
-
 import com.vdurmont.semver4j.Semver;
 import com.vdurmont.semver4j.Semver.SemverType;
 import fj.data.Either;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.EnumMap;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.function.BiPredicate;
-import java.util.stream.Collectors;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -68,6 +46,7 @@ import org.openecomp.sdc.be.datatypes.elements.CapabilityDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.DataTypeDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.GroupDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.InterfaceDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.ListCapabilityDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.ListRequirementDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.MapArtifactDataDefinition;
@@ -118,7 +97,6 @@ import org.openecomp.sdc.be.model.catalog.CatalogComponent;
 import org.openecomp.sdc.be.model.jsonjanusgraph.config.ContainerInstanceTypesData;
 import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.TopologyTemplate;
 import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElement;
-import org.openecomp.sdc.be.model.jsonjanusgraph.datamodel.ToscaElementTypeEnum;
 import org.openecomp.sdc.be.model.jsonjanusgraph.operations.exception.ToscaOperationExceptionSupplier;
 import org.openecomp.sdc.be.model.jsonjanusgraph.utils.ModelConverter;
 import org.openecomp.sdc.be.model.operations.StorageException;
@@ -135,6 +113,32 @@ import org.openecomp.sdc.common.log.wrappers.Logger;
 import org.openecomp.sdc.common.util.ValidationUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.EnumMap;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.function.BiPredicate;
+import java.util.stream.Collectors;
+
+import static java.util.Objects.requireNonNull;
+import static org.apache.commons.collections.CollectionUtils.isEmpty;
+import static org.apache.commons.collections.CollectionUtils.isNotEmpty;
+import static org.janusgraph.core.attribute.Text.REGEX;
+import static org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum.TOPOLOGY_TEMPLATE;
+
 @org.springframework.stereotype.Component("tosca-operation-facade")
 public class ToscaOperationFacade {
 
@@ -149,6 +153,8 @@ public class ToscaOperationFacade {
     private static final String VF = "VF";
     private static final String NOT_SUPPORTED_COMPONENT_TYPE = "Not supported component type {}";
     private static final String COMPONENT_CREATED_SUCCESSFULLY = "Component created successfully!!!";
+    private static final String INPUTS_ASSOCIATED_TO_COMPONENT_SUCCESSFULLY = "Inputs associated to component successfully!";
+    private static final String OUTPUTS_ASSOCIATED_TO_COMPONENT_SUCCESSFULLY = "Outputs associated to component successfully!";
     private static final String COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR = "Couldn't fetch component with and unique id {}, error: {}";
     private static final Logger log = Logger.getLogger(ToscaOperationFacade.class.getName());
     @Autowired
@@ -173,12 +179,12 @@ public class ToscaOperationFacade {
             return Optional.empty();
         }
         List<CapabilityDefinition> capabilityDefinitionList = componentCapabilities.values().stream().flatMap(Collection::stream)
-                .collect(Collectors.toList());
+            .collect(Collectors.toList());
         if (CollectionUtils.isEmpty(capabilityDefinitionList)) {
             return Optional.empty();
         }
         return capabilityDefinitionList.stream().filter(capabilityDefinition -> capabilityDefinition.getUniqueId().equals(propertyParentUniqueId))
-                .findAny();
+            .findAny();
     }
 
     public <T extends Component> Either<T, StorageOperationStatus> getToscaFullElement(String componentId) {
@@ -235,7 +241,7 @@ public class ToscaOperationFacade {
         props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
         props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getVertexEither = janusGraphDao
-                .getByCriteria(ModelConverter.getVertexType(component), props);
+            .getByCriteria(ModelConverter.getVertexType(component), props);
         if (getVertexEither.isRight()) {
             log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, component.getUniqueId(), getVertexEither.right().value());
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value()));
@@ -304,7 +310,7 @@ public class ToscaOperationFacade {
             return StorageOperationStatus.OK;
         } else {
             Either<GraphVertex, JanusGraphOperationStatus> getResponse = janusGraphDao
-                    .getVertexById(componentToDelete.getUniqueId(), JsonParseFlagEnum.ParseAll);
+                .getVertexById(componentToDelete.getUniqueId(), JsonParseFlagEnum.ParseAll);
             if (getResponse.isRight()) {
                 log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentToDelete.getUniqueId(), getResponse.right().value());
                 return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getResponse.right().value());
@@ -376,7 +382,7 @@ public class ToscaOperationFacade {
         propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         final Either<List<GraphVertex>, JanusGraphOperationStatus> highestResources = janusGraphDao
-                .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag, model);
+            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag, model);
         if (highestResources.isRight()) {
             final JanusGraphOperationStatus status = highestResources.right().value();
             log.debug("failed to find resource with name {}. status={} ", nodeName, status);
@@ -416,7 +422,7 @@ public class ToscaOperationFacade {
         Map<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class);
         properties.put(GraphPropertyEnum.CSAR_UUID, csarUUID);
         Either<List<GraphVertex>, JanusGraphOperationStatus> resources = janusGraphDao
-                .getByCriteria(null, properties, JsonParseFlagEnum.ParseMetadata);
+            .getByCriteria(null, properties, JsonParseFlagEnum.ParseMetadata);
         if (resources.isRight()) {
             if (resources.right().value() == JanusGraphOperationStatus.NOT_FOUND) {
                 return StorageOperationStatus.OK;
@@ -458,7 +464,7 @@ public class ToscaOperationFacade {
     public Either<Resource, StorageOperationStatus> getByToscaResourceNameMatchingVendorRelease(final String toscaResourceName,
                                                                                                 final String vendorVersion) {
         return getByToscaResourceNameMatchingVendorRelease(toscaResourceName, VertexTypeEnum.NODE_TYPE, JsonParseFlagEnum.ParseMetadata,
-                vendorVersion);
+            vendorVersion);
     }
 
     public Either<Resource, StorageOperationStatus> getByToscaResourceNameMatchingVendorRelease(String toscaResourceName, VertexTypeEnum vertexType,
@@ -468,13 +474,13 @@ public class ToscaOperationFacade {
         props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
         Map<String, Entry<JanusGraphPredicate, Object>> predicateCriteria = getVendorVersionPredicate(vendorRelease);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getLatestRes = janusGraphDao
-                .getByCriteria(vertexType, props, null, predicateCriteria, parseFlag, null);
+            .getByCriteria(vertexType, props, null, predicateCriteria, parseFlag, null);
         if (getLatestRes.isRight() || CollectionUtils.isEmpty(getLatestRes.left().value())) {
             getLatestRes = janusGraphDao.getByCriteria(vertexType, props, parseFlag);
         }
         return getLatestRes.right().map(status -> {
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch {} with name {}. status={} ", vertexType, toscaResourceName, status);
+                .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch {} with name {}. status={} ", vertexType, toscaResourceName, status);
             return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
         }).left().bind(resources -> {
             double version = 0.0;
@@ -507,7 +513,7 @@ public class ToscaOperationFacade {
         hasNotProperties.put(GraphPropertyEnum.IS_DELETED, true);
 
         Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceRes = janusGraphDao
-                .getByCriteria(VertexTypeEnum.NODE_TYPE, hasProperties, hasNotProperties, JsonParseFlagEnum.ParseAll, model);
+            .getByCriteria(VertexTypeEnum.NODE_TYPE, hasProperties, hasNotProperties, JsonParseFlagEnum.ParseAll, model);
         if (getResourceRes.isRight()) {
             JanusGraphOperationStatus status = getResourceRes.right().value();
             log.debug("failed to find resource with toscaResourceName {}, version {}. Status is {} ", toscaResourceName, version, status);
@@ -543,12 +549,12 @@ public class ToscaOperationFacade {
 
     public List<GraphVertex> getResourceModelElementVertices(final Resource resource) {
         final Either<GraphVertex, JanusGraphOperationStatus> vertex =
-                janusGraphDao.getVertexById(resource.getUniqueId(), JsonParseFlagEnum.NoParse);
+            janusGraphDao.getVertexById(resource.getUniqueId(), JsonParseFlagEnum.NoParse);
         if (vertex.isRight() || Objects.isNull(vertex.left().value())) {
             return Collections.emptyList();
         }
         final Either<List<GraphVertex>, JanusGraphOperationStatus> nodeModelVertices =
-                janusGraphDao.getParentVertices(vertex.left().value(), EdgeLabelEnum.MODEL_ELEMENT, JsonParseFlagEnum.NoParse);
+            janusGraphDao.getParentVertices(vertex.left().value(), EdgeLabelEnum.MODEL_ELEMENT, JsonParseFlagEnum.NoParse);
         if (nodeModelVertices.isRight() || nodeModelVertices.left().value() == null) {
             return Collections.emptyList();
         }
@@ -578,7 +584,7 @@ public class ToscaOperationFacade {
         Either<List<GraphVertex>, JanusGraphOperationStatus> getLatestRes = janusGraphDao.getByCriteria(vertexType, props, parseFlag);
         return getLatestRes.right().map(status -> {
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch {} with name {}. status={} ", vertexType, toscaResourceName, status);
+                .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch {} with name {}. status={} ", vertexType, toscaResourceName, status);
             return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status);
         }).left().bind(resources -> {
             double version = 0.0;
@@ -601,7 +607,7 @@ public class ToscaOperationFacade {
 
     public Either<Resource, StorageOperationStatus> getLatestResourceByToscaResourceName(String toscaResourceName) {
         if (toscaResourceName != null && toscaResourceName.contains("org.openecomp.resource.vf")) {
-            return getLatestResourceByToscaResourceName(toscaResourceName, VertexTypeEnum.TOPOLOGY_TEMPLATE, JsonParseFlagEnum.ParseMetadata);
+            return getLatestResourceByToscaResourceName(toscaResourceName, TOPOLOGY_TEMPLATE, JsonParseFlagEnum.ParseMetadata);
         } else {
             return getLatestResourceByToscaResourceName(toscaResourceName, VertexTypeEnum.NODE_TYPE, JsonParseFlagEnum.ParseMetadata);
         }
@@ -620,7 +626,7 @@ public class ToscaOperationFacade {
         if (getLatestRes.isRight()) {
             JanusGraphOperationStatus status = getLatestRes.right().value();
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch {} with name {}. status={} ", vertexType, toscaResourceName, status);
+                .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch {} with name {}. status={} ", vertexType, toscaResourceName, status);
             result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
         }
         if (result == null) {
@@ -678,7 +684,7 @@ public class ToscaOperationFacade {
     public Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> associateResourceInstances(Component component, String componentId,
                                                                                                         List<RequirementCapabilityRelDef> relations) {
         Either<List<RequirementCapabilityRelDef>, StorageOperationStatus> reqAndCapListEither = nodeTemplateOperation
-                .associateResourceInstances(component, componentId, relations);
+            .associateResourceInstances(componentId, relations);
         if (component != null) {
             updateInstancesCapAndReqOnComponentFromDB(component);
         }
@@ -689,7 +695,7 @@ public class ToscaOperationFacade {
         Map<GraphPropertyEnum, Object> properties = new EnumMap<>(GraphPropertyEnum.class);
         properties.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, name);
         Either<List<GraphVertex>, JanusGraphOperationStatus> resources = janusGraphDao
-                .getByCriteria(null, properties, JsonParseFlagEnum.ParseMetadata);
+            .getByCriteria(null, properties, JsonParseFlagEnum.ParseMetadata);
         if (resources.isRight() && resources.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
             log.debug("failed to get resources from graph with property name: {}", name);
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(resources.right().value()));
@@ -714,14 +720,14 @@ public class ToscaOperationFacade {
     public Either<Resource, StorageOperationStatus> overrideComponent(Resource newComponent, Resource oldComponent) {
         copyArtifactsToNewComponent(newComponent, oldComponent);
         Either<GraphVertex, JanusGraphOperationStatus> componentVEither = janusGraphDao
-                .getVertexById(oldComponent.getUniqueId(), JsonParseFlagEnum.NoParse);
+            .getVertexById(oldComponent.getUniqueId(), JsonParseFlagEnum.NoParse);
         if (componentVEither.isRight()) {
             log.debug("Failed to fetch component {} error {}", oldComponent.getUniqueId(), componentVEither.right().value());
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(componentVEither.right().value()));
         }
         GraphVertex componentv = componentVEither.left().value();
         Either<GraphVertex, JanusGraphOperationStatus> parentVertexEither = janusGraphDao
-                .getParentVertex(componentv, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse);
+            .getParentVertex(componentv, EdgeLabelEnum.VERSION, JsonParseFlagEnum.NoParse);
         if (parentVertexEither.isRight() && parentVertexEither.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
             log.debug("Failed to fetch parent version for component {} error {}", oldComponent.getUniqueId(), parentVertexEither.right().value());
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(parentVertexEither.right().value()));
@@ -738,7 +744,7 @@ public class ToscaOperationFacade {
         }
         Resource newElement = createToscaComponent.left().value();
         Either<GraphVertex, JanusGraphOperationStatus> newVersionEither = janusGraphDao
-                .getVertexById(newElement.getUniqueId(), JsonParseFlagEnum.NoParse);
+            .getVertexById(newElement.getUniqueId(), JsonParseFlagEnum.NoParse);
         if (newVersionEither.isRight()) {
             log.debug("Failed to fetch new tosca element component {} error {}", newComponent.getUniqueId(), newVersionEither.right().value());
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(newVersionEither.right().value()));
@@ -746,10 +752,10 @@ public class ToscaOperationFacade {
         if (parentVertexEither.isLeft()) {
             GraphVertex previousVersionV = parentVertexEither.left().value();
             JanusGraphOperationStatus createEdge = janusGraphDao
-                    .createEdge(previousVersionV, newVersionEither.left().value(), EdgeLabelEnum.VERSION, null);
+                .createEdge(previousVersionV, newVersionEither.left().value(), EdgeLabelEnum.VERSION, null);
             if (createEdge != JanusGraphOperationStatus.OK) {
                 log.debug("Failed to associate to previous version {} new version {} error {}", previousVersionV.getUniqueId(),
-                        newVersionEither.right().value(), createEdge);
+                    newVersionEither.right().value(), createEdge);
                 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(createEdge));
             }
         }
@@ -781,7 +787,7 @@ public class ToscaOperationFacade {
         return updateToscaElement(componentToUpdate, new ComponentParametersView());
     }
 
-    public <T extends Component> Either<T, StorageOperationStatus> updateToscaElement(T componentToUpdate, ComponentParametersView filterResult) {
+    private <T extends Component> Either<T, StorageOperationStatus> updateToscaElement(T componentToUpdate, ComponentParametersView filterResult) {
         String componentId = componentToUpdate.getUniqueId();
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.ParseAll);
         if (getVertexEither.isRight()) {
@@ -819,7 +825,7 @@ public class ToscaOperationFacade {
         propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> highestResources = janusGraphDao
-                .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag, model);
+            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag, model);
         if (highestResources.isRight()) {
             JanusGraphOperationStatus status = highestResources.right().value();
             log.debug("failed to find resource with name {}. status={} ", nodeName, status);
@@ -845,44 +851,26 @@ public class ToscaOperationFacade {
         return getLatestByName(property, nodeName, JsonParseFlagEnum.ParseMetadata, modelName);
     }
 
-    public <T extends Component> Either<List<T>, StorageOperationStatus> getBySystemName(ComponentTypeEnum componentType, String systemName) {
-        Either<List<T>, StorageOperationStatus> result = null;
-        Either<T, StorageOperationStatus> getComponentRes;
-        List<T> components = new ArrayList<>();
-        List<GraphVertex> componentVertices;
-        Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
-        Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
+    public <T extends Component> Either<T, StorageOperationStatus> getBySystemNameAndVersion(final ComponentTypeEnum componentType,
+                                                                                             final String systemName,
+                                                                                             final String version) {
+        final Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
+        final Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesToMatch.put(GraphPropertyEnum.SYSTEM_NAME, systemName);
+        propertiesToMatch.put(GraphPropertyEnum.VERSION, version);
         if (componentType != null) {
             propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
         }
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
-        Either<List<GraphVertex>, JanusGraphOperationStatus> getComponentsRes = janusGraphDao
-                .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
-        if (getComponentsRes.isRight()) {
-            JanusGraphOperationStatus status = getComponentsRes.right().value();
-            log.debug("Failed to fetch the component with system name {}. Status is {} ", systemName, status);
-            result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
-        }
-        if (result == null) {
-            componentVertices = getComponentsRes.left().value();
-            for (GraphVertex componentVertex : componentVertices) {
-                getComponentRes = getToscaElementByOperation(componentVertex);
-                if (getComponentRes.isRight()) {
-                    log.debug("Failed to get the component {}. Status is {} ", componentVertex.getJsonMetadataField(JsonPresentationFields.NAME),
-                            getComponentRes.right().value());
-                    result = Either.right(getComponentRes.right().value());
-                    break;
-                }
-                T componentBySystemName = getComponentRes.left().value();
-                log.debug("Found component, id: {}", componentBySystemName.getUniqueId());
-                components.add(componentBySystemName);
-            }
-        }
-        if (result == null) {
-            result = Either.left(components);
+
+        final Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceResult
+            = janusGraphDao.getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+        if (getResourceResult.isRight()) {
+            final JanusGraphOperationStatus status = getResourceResult.right().value();
+            log.debug("Failed to find resource with systemName {}, version {}. Status is {} ", systemName, version, status);
+            return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
         }
-        return result;
+        return getToscaElementByOperation(getResourceResult.left().value().get(0));
     }
 
     public <T extends Component> Either<T, StorageOperationStatus> getComponentByNameAndVersion(ComponentTypeEnum componentType, String name,
@@ -892,7 +880,6 @@ public class ToscaOperationFacade {
 
     public <T extends Component> Either<T, StorageOperationStatus> getComponentByNameAndVersion(ComponentTypeEnum componentType, String name,
                                                                                                 String version, JsonParseFlagEnum parseFlag) {
-        Either<T, StorageOperationStatus> result;
         Map<GraphPropertyEnum, Object> hasProperties = new EnumMap<>(GraphPropertyEnum.class);
         Map<GraphPropertyEnum, Object> hasNotProperties = new EnumMap<>(GraphPropertyEnum.class);
         hasProperties.put(GraphPropertyEnum.NAME, name);
@@ -902,12 +889,11 @@ public class ToscaOperationFacade {
             hasProperties.put(GraphPropertyEnum.COMPONENT_TYPE, componentType.name());
         }
         Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceRes = janusGraphDao
-                .getByCriteria(null, hasProperties, hasNotProperties, parseFlag);
+            .getByCriteria(null, hasProperties, hasNotProperties, parseFlag);
         if (getResourceRes.isRight()) {
             JanusGraphOperationStatus status = getResourceRes.right().value();
             log.debug("failed to find resource with name {}, version {}. Status is {} ", name, version, status);
-            result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
-            return result;
+            return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
         }
         return getToscaElementByOperation(getResourceRes.left().value().get(0));
     }
@@ -925,7 +911,7 @@ public class ToscaOperationFacade {
         }
         Map<String, Entry<JanusGraphPredicate, Object>> predicateCriteria = getVendorVersionPredicate(vendorRelease);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceRes = janusGraphDao.getByCriteria(null, hasProperties, hasNotProperties,
-                predicateCriteria, parseFlag, modelName);
+            predicateCriteria, parseFlag, modelName);
         if (getResourceRes.isRight()) {
             JanusGraphOperationStatus status = getResourceRes.right().value();
             log.debug("failed to find resource with name {}, version {}. Status is {} ", name, predicateCriteria, status);
@@ -937,8 +923,8 @@ public class ToscaOperationFacade {
     public Either<List<CatalogComponent>, StorageOperationStatus> getCatalogOrArchiveComponents(boolean isCatalog,
                                                                                                 List<OriginTypeEnum> excludeTypes) {
         List<ResourceTypeEnum> excludedResourceTypes = Optional.ofNullable(excludeTypes).orElse(Collections.emptyList()).stream()
-                .filter(type -> !type.equals(OriginTypeEnum.SERVICE)).map(type -> ResourceTypeEnum.getTypeByName(type.name()))
-                .collect(Collectors.toList());
+            .filter(type -> !type.equals(OriginTypeEnum.SERVICE)).map(type -> ResourceTypeEnum.getTypeByName(type.name()))
+            .collect(Collectors.toList());
         return topologyTemplateOperation.getElementCatalogData(isCatalog, excludedResourceTypes);
     }
 
@@ -950,8 +936,8 @@ public class ToscaOperationFacade {
         Either<List<ToscaElement>, StorageOperationStatus> catalogDataResult;
         List<ToscaElement> toscaElements = new ArrayList<>();
         List<ResourceTypeEnum> excludedResourceTypes = Optional.ofNullable(excludeTypes).orElse(Collections.emptyList()).stream()
-                .filter(type -> !type.equals(OriginTypeEnum.SERVICE)).map(type -> ResourceTypeEnum.getTypeByName(type.name()))
-                .collect(Collectors.toList());
+            .filter(type -> !type.equals(OriginTypeEnum.SERVICE)).map(type -> ResourceTypeEnum.getTypeByName(type.name()))
+            .collect(Collectors.toList());
         switch (componentType) {
             case RESOURCE:
                 catalogDataResult = nodeTypeOperation.getElementCatalogData(ComponentTypeEnum.RESOURCE, excludedResourceTypes, isHighestVersions);
@@ -1038,12 +1024,12 @@ public class ToscaOperationFacade {
     private void checkNotUsed(List<GraphVertex> vertices) {
         boolean isInUse = isAnyComponentInUse(vertices);
         if (isInUse) {
-            Set<GraphVertex> listOfVertices =  getComponentsUsingComponents(vertices);
+            Set<GraphVertex> listOfVertices = getComponentsUsingComponents(vertices);
             List<String> listOfStringComponents = new ArrayList<>();
             for (GraphVertex componentVertex : listOfVertices) {
                 listOfStringComponents.add(
-                        componentVertex.getMetadataJson().get(GraphPropertyEnum.COMPONENT_TYPE.getProperty()) + " "
-                                + componentVertex.getMetadataJson().get(GraphPropertyEnum.NAME.getProperty())
+                    componentVertex.getMetadataJson().get(GraphPropertyEnum.COMPONENT_TYPE.getProperty()) + " "
+                        + componentVertex.getMetadataJson().get(GraphPropertyEnum.NAME.getProperty())
                 );
             }
             String stringOfComponents = String.join(", ", listOfStringComponents);
@@ -1095,10 +1081,10 @@ public class ToscaOperationFacade {
 
     private List<GraphVertex> isInUse(GraphVertex elementV) {
         final List<EdgeLabelEnum> forbiddenEdgeLabelEnums = Arrays
-                .asList(EdgeLabelEnum.INSTANCE_OF, EdgeLabelEnum.PROXY_OF, EdgeLabelEnum.ALLOTTED_OF);
+            .asList(EdgeLabelEnum.INSTANCE_OF, EdgeLabelEnum.PROXY_OF, EdgeLabelEnum.ALLOTTED_OF);
         for (EdgeLabelEnum edgeLabelEnum : forbiddenEdgeLabelEnums) {
             Either<List<GraphVertex>, JanusGraphOperationStatus> inUseBy =
-                    janusGraphDao.getParentVertices(elementV, edgeLabelEnum, JsonParseFlagEnum.ParseAll);
+                janusGraphDao.getParentVertices(elementV, edgeLabelEnum, JsonParseFlagEnum.ParseAll);
             if (inUseBy.isLeft()) {
                 if (log.isDebugEnabled()) {
                     log.debug("Element {} in use.", elementV.getUniqueId());
@@ -1117,7 +1103,7 @@ public class ToscaOperationFacade {
                 Either<ToscaElement, StorageOperationStatus> deleteToscaElement = deleteToscaElement(elementV);
                 if (deleteToscaElement.isRight()) {
                     log.debug("Failed to delete marked element UniqueID {}, Name {}, error {}", elementV.getUniqueId(),
-                            elementV.getMetadataProperties().get(GraphPropertyEnum.NAME), deleteToscaElement.right().value());
+                        elementV.getMetadataProperties().get(GraphPropertyEnum.NAME), deleteToscaElement.right().value());
                     continue;
                 }
                 deleted.add(elementV.getUniqueId());
@@ -1184,19 +1170,19 @@ public class ToscaOperationFacade {
         }
         String nextComponentInstanceCounter = getNextComponentInstanceCounter(containerComponent, nameToFindForCounter);
         Either<ImmutablePair<TopologyTemplate, String>, StorageOperationStatus> addResult = nodeTemplateOperation
-                .addComponentInstanceToTopologyTemplate(ModelConverter.convertToToscaElement(containerComponent),
-                        ModelConverter.convertToToscaElement(origComponent), nextComponentInstanceCounter, componentInstance, allowDeleted, user);
+            .addComponentInstanceToTopologyTemplate(ModelConverter.convertToToscaElement(containerComponent),
+                ModelConverter.convertToToscaElement(origComponent), nextComponentInstanceCounter, componentInstance, allowDeleted, user);
         if (addResult.isRight()) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the component instance {} to container component {}. ",
-                    componentInstance.getName(), containerComponent.getName());
+                componentInstance.getName(), containerComponent.getName());
             result = Either.right(addResult.right().value());
         }
         if (result == null) {
             updateContainerComponentRes = topologyTemplateOperation.getToscaElement(containerComponent.getUniqueId());
             if (updateContainerComponentRes.isRight()) {
                 CommonUtility
-                        .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch updated topology template {} with updated component instance {}. ",
-                                containerComponent.getName(), componentInstance.getName());
+                    .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch updated topology template {} with updated component instance {}. ",
+                        containerComponent.getName(), componentInstance.getName());
                 result = Either.right(updateContainerComponentRes.right().value());
             }
         }
@@ -1204,8 +1190,8 @@ public class ToscaOperationFacade {
             Component updatedComponent = ModelConverter.convertFromToscaElement(updateContainerComponentRes.left().value());
             String createdInstanceId = addResult.left().value().getRight();
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.TRACE, "The component instance {} has been added to container component {}. ", createdInstanceId,
-                            updatedComponent.getName());
+                .addRecordToLog(log, LogLevelEnum.TRACE, "The component instance {} has been added to container component {}. ", createdInstanceId,
+                    updatedComponent.getName());
             result = Either.left(new ImmutablePair<>(updatedComponent, createdInstanceId));
         }
         return result;
@@ -1215,7 +1201,7 @@ public class ToscaOperationFacade {
                                                        boolean allowDeleted, boolean isUpdateCsar) {
         CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Going to add component instances to component {}", containerComponent.getUniqueId());
         Either<GraphVertex, JanusGraphOperationStatus> metadataVertex = janusGraphDao
-                .getVertexById(containerComponent.getUniqueId(), JsonParseFlagEnum.ParseAll);
+            .getVertexById(containerComponent.getUniqueId(), JsonParseFlagEnum.ParseAll);
         if (metadataVertex.isRight()) {
             JanusGraphOperationStatus status = metadataVertex.right().value();
             if (status == JanusGraphOperationStatus.NOT_FOUND) {
@@ -1224,33 +1210,33 @@ public class ToscaOperationFacade {
             throw new StorageException(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(status));
         }
         Map<String, ComponentInstanceDataDefinition> compnentInstancesMap = nodeTemplateOperation
-                .associateComponentInstancesToComponent(containerComponent, resourcesInstancesMap, metadataVertex.left().value(), allowDeleted,
-                        isUpdateCsar);
+            .associateComponentInstancesToComponent(containerComponent, resourcesInstancesMap, metadataVertex.left().value(), allowDeleted,
+                isUpdateCsar);
         containerComponent.setComponentInstances(ModelConverter.getComponentInstancesFromMapObject(compnentInstancesMap, containerComponent));
     }
 
     public Either<ImmutablePair<Component, String>, StorageOperationStatus> updateComponentInstanceMetadataOfTopologyTemplate(
-            Component containerComponent, Component origComponent, ComponentInstance componentInstance) {
+        Component containerComponent, Component origComponent, ComponentInstance componentInstance) {
         Either<ImmutablePair<Component, String>, StorageOperationStatus> result = null;
         CommonUtility.addRecordToLog(log, LogLevelEnum.TRACE,
-                "Going to update the metadata of the component instance {} belonging to container component {}. ", componentInstance.getName(),
-                containerComponent.getName());
+            "Going to update the metadata of the component instance {} belonging to container component {}. ", componentInstance.getName(),
+            containerComponent.getName());
         componentInstance.setIcon(origComponent.getIcon());
         Either<ImmutablePair<TopologyTemplate, String>, StorageOperationStatus> updateResult = nodeTemplateOperation
-                .updateComponentInstanceMetadataOfTopologyTemplate(ModelConverter.convertToToscaElement(containerComponent),
-                        ModelConverter.convertToToscaElement(origComponent), componentInstance);
+            .updateComponentInstanceMetadataOfTopologyTemplate(ModelConverter.convertToToscaElement(containerComponent),
+                ModelConverter.convertToToscaElement(origComponent), componentInstance);
         if (updateResult.isRight()) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
-                    "Failed to update the metadata of the component instance {} belonging to container component {}. ", componentInstance.getName(),
-                    containerComponent.getName());
+                "Failed to update the metadata of the component instance {} belonging to container component {}. ", componentInstance.getName(),
+                containerComponent.getName());
             result = Either.right(updateResult.right().value());
         }
         if (result == null) {
             Component updatedComponent = ModelConverter.convertFromToscaElement(updateResult.left().value().getLeft());
             String createdInstanceId = updateResult.left().value().getRight();
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.TRACE, "The metadata of the component instance {} has been updated to container component {}. ",
-                            createdInstanceId, updatedComponent.getName());
+                .addRecordToLog(log, LogLevelEnum.TRACE, "The metadata of the component instance {} has been updated to container component {}. ",
+                    createdInstanceId, updatedComponent.getName());
             result = Either.left(new ImmutablePair<>(updatedComponent, createdInstanceId));
         }
         return result;
@@ -1264,18 +1250,18 @@ public class ToscaOperationFacade {
                                                                                                        ComponentParametersView filter) {
         Either<Component, StorageOperationStatus> result = null;
         CommonUtility.addRecordToLog(log, LogLevelEnum.TRACE, "Going to update the metadata  belonging to container component {}. ",
-                containerComponent.getName());
+            containerComponent.getName());
         Either<TopologyTemplate, StorageOperationStatus> updateResult = nodeTemplateOperation
-                .updateComponentInstanceMetadataOfTopologyTemplate(ModelConverter.convertToToscaElement(containerComponent), filter);
+            .updateComponentInstanceMetadataOfTopologyTemplate(ModelConverter.convertToToscaElement(containerComponent), filter);
         if (updateResult.isRight()) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update the metadata  belonging to container component {}. ",
-                    containerComponent.getName());
+                containerComponent.getName());
             result = Either.right(updateResult.right().value());
         }
         if (result == null) {
             Component updatedComponent = ModelConverter.convertFromToscaElement(updateResult.left().value());
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.TRACE, "The metadata has been updated to container component {}. ", updatedComponent.getName());
+                .addRecordToLog(log, LogLevelEnum.TRACE, "The metadata has been updated to container component {}. ", updatedComponent.getName());
             result = Either.left(updatedComponent);
         }
         return result;
@@ -1286,19 +1272,19 @@ public class ToscaOperationFacade {
                                                                                                                         String resourceInstanceId) {
         Either<ImmutablePair<Component, String>, StorageOperationStatus> result = null;
         CommonUtility.addRecordToLog(log, LogLevelEnum.TRACE, "Going to delete the component instance {} belonging to container component {}. ",
-                resourceInstanceId, containerComponent.getName());
+            resourceInstanceId, containerComponent.getName());
         Either<ImmutablePair<TopologyTemplate, String>, StorageOperationStatus> updateResult = nodeTemplateOperation
-                .deleteComponentInstanceFromTopologyTemplate(ModelConverter.convertToToscaElement(containerComponent), resourceInstanceId);
+            .deleteComponentInstanceFromTopologyTemplate(ModelConverter.convertToToscaElement(containerComponent), resourceInstanceId);
         if (updateResult.isRight()) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to delete the component instance {} belonging to container component {}. ",
-                    resourceInstanceId, containerComponent.getName());
+                resourceInstanceId, containerComponent.getName());
             result = Either.right(updateResult.right().value());
         }
         if (result == null) {
             Component updatedComponent = ModelConverter.convertFromToscaElement(updateResult.left().value().getLeft());
             String deletedInstanceId = updateResult.left().value().getRight();
             CommonUtility.addRecordToLog(log, LogLevelEnum.TRACE, "The component instance {} has been deleted from container component {}. ",
-                    deletedInstanceId, updatedComponent.getName());
+                deletedInstanceId, updatedComponent.getName());
             result = Either.left(new ImmutablePair<>(updatedComponent, deletedInstanceId));
         }
         return result;
@@ -1319,14 +1305,22 @@ public class ToscaOperationFacade {
     /**
      * @return max counter of component instance Id's, null if not found
      */
-    private Integer getMaxCounterFromNamesAndIds(Component containerComponent, String normalizedName) {
-        List<String> countersInNames = containerComponent.getComponentInstances().stream()
-                .filter(ci -> ci.getNormalizedName() != null && ci.getNormalizedName().startsWith(normalizedName))
-                .map(ci -> ci.getNormalizedName().split(normalizedName)[1]).collect(Collectors.toList());
-        List<String> countersInIds = containerComponent.getComponentInstances().stream()
-                .filter(ci -> ci.getUniqueId() != null && ci.getUniqueId().contains(normalizedName)).map(ci -> ci.getUniqueId().split(normalizedName)[1])
-                .collect(Collectors.toList());
-        List<String> namesAndIdsList = new ArrayList<>(countersInNames);
+    private Integer getMaxCounterFromNamesAndIds(final Component containerComponent, final String normalizedName) {
+        final Pattern COUNTER_PATTERN = Pattern.compile(normalizedName + "[\\s_:-]?\\d+$");
+        final List<String> countersInNames = containerComponent.getComponentInstances().stream()
+            .filter(ci -> ci.getNormalizedName() != null && ci.getNormalizedName().startsWith(normalizedName))
+            .filter(ci -> !ci.getNormalizedName().equals(normalizedName))
+            .map(ComponentInstance::getNormalizedName)
+            .map(COUNTER_PATTERN::matcher).filter(Matcher::find).map(matcher -> matcher.group(0))
+            .map(nn -> nn.replaceAll("\\D", ""))
+            .collect(Collectors.toList());
+        final List<String> countersInIds = containerComponent.getComponentInstances().stream()
+            .filter(ci -> ci.getUniqueId() != null && ci.getUniqueId().contains(normalizedName))
+            .map(ComponentInstance::getUniqueId)
+            .map(COUNTER_PATTERN::matcher).filter(Matcher::find).map(matcher -> matcher.group(0))
+            .map(nn -> nn.replaceAll("\\D", ""))
+            .collect(Collectors.toList());
+        final List<String> namesAndIdsList = new ArrayList<>(countersInNames);
         namesAndIdsList.addAll(countersInIds);
         return getMaxInteger(namesAndIdsList);
     }
@@ -1341,7 +1335,6 @@ public class ToscaOperationFacade {
                     maxCounter = currCounter;
                 }
             } catch (NumberFormatException e) {
-                continue;
             }
         }
         return currCounter == null ? null : maxCounter;
@@ -1349,7 +1342,7 @@ public class ToscaOperationFacade {
 
     public Either<RequirementCapabilityRelDef, StorageOperationStatus> associateResourceInstances(Component component, String componentId,
                                                                                                   RequirementCapabilityRelDef requirementDef) {
-        return nodeTemplateOperation.associateResourceInstances(component, componentId, requirementDef);
+        return nodeTemplateOperation.associateResourceInstances(componentId, requirementDef);
     }
 
     public Either<List<InputDefinition>, StorageOperationStatus> createAndAssociateInputs(Map<String, InputDefinition> inputs, String componentId) {
@@ -1360,10 +1353,10 @@ public class ToscaOperationFacade {
         }
         GraphVertex vertex = getVertexEither.left().value();
         Map<String, PropertyDataDefinition> inputsMap = inputs.entrySet().stream()
-                .collect(Collectors.toMap(Map.Entry::getKey, e -> new PropertyDataDefinition(e.getValue())));
+            .collect(Collectors.toMap(Map.Entry::getKey, e -> new PropertyDataDefinition(e.getValue())));
         StorageOperationStatus status = topologyTemplateOperation.associateInputsToComponent(vertex, inputsMap, componentId);
         if (StorageOperationStatus.OK == status) {
-            log.debug(COMPONENT_CREATED_SUCCESSFULLY);
+            log.debug(INPUTS_ASSOCIATED_TO_COMPONENT_SUCCESSFULLY);
             List<InputDefinition> inputsResList = null;
             if (inputsMap != null && !inputsMap.isEmpty()) {
                 inputsResList = inputsMap.values().stream().map(InputDefinition::new).collect(Collectors.toList());
@@ -1373,6 +1366,28 @@ public class ToscaOperationFacade {
         return Either.right(status);
     }
 
+    public Either<List<OutputDefinition>, StorageOperationStatus> createAndAssociateOutputs(final Map<String, OutputDefinition> outputs,
+                                                                                            final String componentId) {
+        final Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
+        if (getVertexEither.isRight()) {
+            log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentId, getVertexEither.right().value());
+            return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value()));
+        }
+        final GraphVertex vertex = getVertexEither.left().value();
+        final Map<String, OutputDefinition> outputsMap = outputs.entrySet().stream()
+            .collect(Collectors.toMap(Map.Entry::getKey, e -> new OutputDefinition(e.getValue())));
+        final StorageOperationStatus status = topologyTemplateOperation.associateOutputsToComponent(vertex, outputsMap, componentId);
+        if (StorageOperationStatus.OK == status) {
+            log.debug(OUTPUTS_ASSOCIATED_TO_COMPONENT_SUCCESSFULLY);
+            List<OutputDefinition> outputsResList = null;
+            if (MapUtils.isNotEmpty(outputsMap)) {
+                outputsResList = outputsMap.values().stream().map(OutputDefinition::new).collect(Collectors.toList());
+            }
+            return Either.left(outputsResList);
+        }
+        return Either.right(status);
+    }
+
     public Either<List<InputDefinition>, StorageOperationStatus> addInputsToComponent(Map<String, InputDefinition> inputs, String componentId) {
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
         if (getVertexEither.isRight()) {
@@ -1381,9 +1396,9 @@ public class ToscaOperationFacade {
         }
         GraphVertex vertex = getVertexEither.left().value();
         Map<String, PropertyDefinition> inputsMap = inputs.entrySet().stream()
-                .collect(Collectors.toMap(Map.Entry::getKey, e -> new PropertyDefinition(e.getValue())));
+            .collect(Collectors.toMap(Map.Entry::getKey, e -> new PropertyDefinition(e.getValue())));
         StorageOperationStatus status = topologyTemplateOperation
-                .addToscaDataToToscaElement(vertex, EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, inputsMap, JsonPresentationFields.NAME);
+            .addToscaDataToToscaElement(vertex, EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, inputsMap, JsonPresentationFields.NAME);
         if (StorageOperationStatus.OK == status) {
             log.debug(COMPONENT_CREATED_SUCCESSFULLY);
             List<InputDefinition> inputsResList = null;
@@ -1403,9 +1418,9 @@ public class ToscaOperationFacade {
         }
         GraphVertex vertex = getVertexEither.left().value();
         Map<String, AttributeDefinition> outputsMap = outputs.entrySet().stream()
-                .collect(Collectors.toMap(Map.Entry::getKey, e -> new AttributeDefinition(e.getValue())));
+            .collect(Collectors.toMap(Map.Entry::getKey, e -> new AttributeDefinition(e.getValue())));
         StorageOperationStatus status = topologyTemplateOperation
-                .addToscaDataToToscaElement(vertex, EdgeLabelEnum.OUTPUTS, VertexTypeEnum.OUTPUTS, outputsMap, JsonPresentationFields.NAME);
+            .addToscaDataToToscaElement(vertex, EdgeLabelEnum.OUTPUTS, VertexTypeEnum.OUTPUTS, outputsMap, JsonPresentationFields.NAME);
         if (StorageOperationStatus.OK == status) {
             log.debug(COMPONENT_CREATED_SUCCESSFULLY);
             List<OutputDefinition> outputsResList = null;
@@ -1429,7 +1444,7 @@ public class ToscaOperationFacade {
         log.trace("#addDataTypesToComponent - enter, componentId={}", componentId);
         /* get component vertex */
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao
-                .getVertexById(componentId, JsonParseFlagEnum.NoParse);
+            .getVertexById(componentId, JsonParseFlagEnum.NoParse);
         if (getVertexEither.isRight()) {
             /* not found / error */
             log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentId, getVertexEither.right().value());
@@ -1439,12 +1454,12 @@ public class ToscaOperationFacade {
         log.trace("#addDataTypesToComponent - get vertex ok");
         // convert DataTypeDefinition to DataTypeDataDefinition
         Map<String, DataTypeDataDefinition> dataTypeDataMap = dataTypes.entrySet().stream()
-                .collect(Collectors.toMap(Map.Entry::getKey, e -> convertDataTypeToDataTypeData(e.getValue())));
+            .collect(Collectors.toMap(Map.Entry::getKey, e -> convertDataTypeToDataTypeData(e.getValue())));
         // add datatype(s) to the Component.
 
         // if child vertex does not exist, it will be created.
         StorageOperationStatus status = topologyTemplateOperation
-                .addToscaDataToToscaElement(vertex, EdgeLabelEnum.DATA_TYPES, VertexTypeEnum.DATA_TYPES, dataTypeDataMap, JsonPresentationFields.NAME);
+            .addToscaDataToToscaElement(vertex, EdgeLabelEnum.DATA_TYPES, VertexTypeEnum.DATA_TYPES, dataTypeDataMap, JsonPresentationFields.NAME);
         if (StorageOperationStatus.OK == status) {
             log.debug(COMPONENT_CREATED_SUCCESSFULLY);
             List<DataTypeDefinition> inputsResList = null;
@@ -1461,7 +1476,7 @@ public class ToscaOperationFacade {
         DataTypeDataDefinition dataTypeData = new DataTypeDataDefinition(dataType);
         if (CollectionUtils.isNotEmpty(dataType.getProperties())) {
             List<PropertyDataDefinition> propertyDataList = dataType.getProperties().stream().map(PropertyDataDefinition::new)
-                    .collect(Collectors.toList());
+                .collect(Collectors.toList());
             dataTypeData.setPropertiesData(propertyDataList);
         }
         // if "derivedFrom" data_type exists, copy the name to "derivedFromName"
@@ -1469,7 +1484,7 @@ public class ToscaOperationFacade {
             // if names are different, log it
             if (!StringUtils.equals(dataTypeData.getDerivedFromName(), dataType.getDerivedFrom().getName())) {
                 log.debug("#convertDataTypeToDataTypeData - derivedFromName(={}) overwritten by derivedFrom.name(={})", dataType.getDerivedFromName(),
-                        dataType.getDerivedFrom().getName());
+                    dataType.getDerivedFrom().getName());
             }
             dataTypeData.setDerivedFromName(dataType.getDerivedFrom().getName());
         }
@@ -1506,11 +1521,11 @@ public class ToscaOperationFacade {
         GraphVertex vertex = getVertexEither.left().value();
         List<PropertyDataDefinition> inputsAsDataDef = inputs.stream().map(PropertyDataDefinition::new).collect(Collectors.toList());
         StorageOperationStatus status = topologyTemplateOperation
-                .updateToscaDataOfToscaElement(vertex, EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, inputsAsDataDef, JsonPresentationFields.NAME);
+            .updateToscaDataOfToscaElement(vertex, EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, inputsAsDataDef, JsonPresentationFields.NAME);
         if (StorageOperationStatus.OK == status) {
             log.debug(COMPONENT_CREATED_SUCCESSFULLY);
             List<InputDefinition> inputsResList = null;
-            if (inputsAsDataDef != null && !inputsAsDataDef.isEmpty()) {
+            if (CollectionUtils.isNotEmpty(inputsAsDataDef)) {
                 inputsResList = inputsAsDataDef.stream().map(InputDefinition::new).collect(Collectors.toList());
             }
             return Either.left(inputsResList);
@@ -1518,9 +1533,30 @@ public class ToscaOperationFacade {
         return Either.right(status);
     }
 
+    public Either<List<OutputDefinition>, StorageOperationStatus> updateOutputsToComponent(List<OutputDefinition> outputs, String componentId) {
+        Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
+        if (getVertexEither.isRight()) {
+            log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentId, getVertexEither.right().value());
+            return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value()));
+        }
+        GraphVertex vertex = getVertexEither.left().value();
+        List<AttributeDataDefinition> outputsAsDataDef = outputs.stream().map(AttributeDataDefinition::new).collect(Collectors.toList());
+        StorageOperationStatus status = topologyTemplateOperation
+            .updateToscaDataOfToscaElement(vertex, EdgeLabelEnum.OUTPUTS, VertexTypeEnum.OUTPUTS, outputsAsDataDef, JsonPresentationFields.NAME);
+        if (StorageOperationStatus.OK == status) {
+            log.debug(COMPONENT_CREATED_SUCCESSFULLY);
+            List<OutputDefinition> outputsResList = null;
+            if (!outputsAsDataDef.isEmpty()) {
+                outputsResList = outputsAsDataDef.stream().map(OutputDefinition::new).collect(Collectors.toList());
+            }
+            return Either.left(outputsResList);
+        }
+        return Either.right(status);
+    }
+
     // region - ComponentInstance
     public Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> associateComponentInstancePropertiesToComponent(
-            Map<String, List<ComponentInstanceProperty>> instProperties, String componentId) {
+        Map<String, List<ComponentInstanceProperty>> instProperties, String componentId) {
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
         if (getVertexEither.isRight()) {
             log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentId, getVertexEither.right().value());
@@ -1533,7 +1569,7 @@ public class ToscaOperationFacade {
             for (Entry<String, List<ComponentInstanceProperty>> entry : instProperties.entrySet()) {
                 propertiesMap = new MapPropertiesDataDefinition();
                 propertiesMap.setMapToscaDataDefinition(
-                        entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, e -> e)));
+                    entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, e -> e)));
                 instPropsMap.put(entry.getKey(), propertiesMap);
             }
         }
@@ -1549,7 +1585,7 @@ public class ToscaOperationFacade {
      * saves the instInputs as the updated instance inputs of the component container in DB
      */
     public Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> updateComponentInstanceInputsToComponent(
-            Map<String, List<ComponentInstanceInput>> instInputs, String componentId) {
+        Map<String, List<ComponentInstanceInput>> instInputs, String componentId) {
         if (instInputs == null || instInputs.isEmpty()) {
             return Either.left(instInputs);
         }
@@ -1559,11 +1595,11 @@ public class ToscaOperationFacade {
             List<String> pathKeysPerInst = new ArrayList<>();
             pathKeysPerInst.add(inputsPerIntance.getKey());
             status = topologyTemplateOperation
-                    .updateToscaDataDeepElementsOfToscaElement(componentId, EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS, toscaDataListPerInst,
-                            pathKeysPerInst, JsonPresentationFields.NAME);
+                .updateToscaDataDeepElementsOfToscaElement(componentId, EdgeLabelEnum.INST_INPUTS, VertexTypeEnum.INST_INPUTS, toscaDataListPerInst,
+                    pathKeysPerInst, JsonPresentationFields.NAME);
             if (status != StorageOperationStatus.OK) {
                 log.debug("Failed to update component instance inputs for instance {} in component {} edge type {} error {}",
-                        inputsPerIntance.getKey(), componentId, EdgeLabelEnum.INST_INPUTS, status);
+                    inputsPerIntance.getKey(), componentId, EdgeLabelEnum.INST_INPUTS, status);
                 return Either.right(status);
             }
         }
@@ -1574,7 +1610,7 @@ public class ToscaOperationFacade {
      * saves the instProps as the updated instance properties of the component container in DB
      */
     public Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> updateComponentInstancePropsToComponent(
-            Map<String, List<ComponentInstanceProperty>> instProps, String componentId) {
+        Map<String, List<ComponentInstanceProperty>> instProps, String componentId) {
         if (instProps == null || instProps.isEmpty()) {
             return Either.left(instProps);
         }
@@ -1584,11 +1620,11 @@ public class ToscaOperationFacade {
             List<String> pathKeysPerInst = new ArrayList<>();
             pathKeysPerInst.add(propsPerIntance.getKey());
             status = topologyTemplateOperation
-                    .updateToscaDataDeepElementsOfToscaElement(componentId, EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES,
-                            toscaDataListPerInst, pathKeysPerInst, JsonPresentationFields.NAME);
+                .updateToscaDataDeepElementsOfToscaElement(componentId, EdgeLabelEnum.INST_PROPERTIES, VertexTypeEnum.INST_PROPERTIES,
+                    toscaDataListPerInst, pathKeysPerInst, JsonPresentationFields.NAME);
             if (status != StorageOperationStatus.OK) {
                 log.debug("Failed to update component instance inputs for instance {} in component {} edge type {} error {}",
-                        propsPerIntance.getKey(), componentId, EdgeLabelEnum.INST_PROPERTIES, status);
+                    propsPerIntance.getKey(), componentId, EdgeLabelEnum.INST_PROPERTIES, status);
                 return Either.right(status);
             }
         }
@@ -1596,7 +1632,7 @@ public class ToscaOperationFacade {
     }
 
     public Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> associateComponentInstanceInputsToComponent(
-            Map<String, List<ComponentInstanceInput>> instInputs, String componentId) {
+        Map<String, List<ComponentInstanceInput>> instInputs, String componentId) {
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse);
         if (getVertexEither.isRight()) {
             log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentId, getVertexEither.right().value());
@@ -1609,7 +1645,7 @@ public class ToscaOperationFacade {
             for (Entry<String, List<ComponentInstanceInput>> entry : instInputs.entrySet()) {
                 propertiesMap = new MapPropertiesDataDefinition();
                 propertiesMap.setMapToscaDataDefinition(
-                        entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, e -> e)));
+                    entry.getValue().stream().map(PropertyDataDefinition::new).collect(Collectors.toMap(PropertyDataDefinition::getName, e -> e)));
                 instPropsMap.put(entry.getKey(), propertiesMap);
             }
         }
@@ -1621,8 +1657,51 @@ public class ToscaOperationFacade {
         return Either.right(status);
     }
 
+    public Either<Map<String, MapInterfaceDataDefinition>, StorageOperationStatus> associateComponentInstanceInterfacesToComponent(
+        Map<String, Map<String, InterfaceDefinition>> instInterfaces,
+        String componentId
+    ) {
+        Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao.getVertexById(
+            componentId,
+            JsonParseFlagEnum.NoParse
+        );
+        if (getVertexEither.isRight()) {
+            log.debug(
+                COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR,
+                componentId,
+                getVertexEither.right().value()
+            );
+            return Either.right(
+                DaoStatusConverter.convertJanusGraphStatusToStorageStatus(
+                    getVertexEither.right().value()
+                )
+            );
+        }
+        GraphVertex vertex = getVertexEither.left().value();
+        Map<String, MapInterfaceDataDefinition> instInterfacesMap = new HashMap<>();
+        if (instInterfaces != null) {
+
+            for (Map.Entry<String, Map<String, InterfaceDefinition>> entryInstances : instInterfaces.entrySet()) {
+                Map<String, InterfaceDataDefinition> incomingInterfacesMap = entryInstances.getValue().entrySet().stream()
+                    .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()));
+                MapInterfaceDataDefinition interfacesMap = new MapInterfaceDataDefinition();
+                interfacesMap.setMapToscaDataDefinition(incomingInterfacesMap);
+                instInterfacesMap.put(entryInstances.getKey(), interfacesMap);
+            }
+        }
+        StorageOperationStatus status = topologyTemplateOperation.associateInstInterfacesToComponent(
+            vertex,
+            instInterfacesMap
+        );
+        if (StorageOperationStatus.OK == status) {
+            log.debug(COMPONENT_CREATED_SUCCESSFULLY);
+            return Either.left(instInterfacesMap);
+        }
+        return Either.right(status);
+    }
+
     public Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> addComponentInstanceInputsToComponent(
-            Component containerComponent, Map<String, List<ComponentInstanceInput>> instProperties) {
+        Component containerComponent, Map<String, List<ComponentInstanceInput>> instProperties) {
         requireNonNull(instProperties);
         StorageOperationStatus status;
         for (Entry<String, List<ComponentInstanceInput>> entry : instProperties.entrySet()) {
@@ -1632,7 +1711,7 @@ public class ToscaOperationFacade {
                 for (ComponentInstanceInput property : props) {
                     List<ComponentInstanceInput> componentInstancesInputs = containerComponent.getComponentInstancesInputs().get(componentInstanceId);
                     Optional<ComponentInstanceInput> instanceProperty = componentInstancesInputs.stream()
-                            .filter(p -> p.getName().equals(property.getName())).findAny();
+                        .filter(p -> p.getName().equals(property.getName())).findAny();
                     if (instanceProperty.isPresent()) {
                         status = updateComponentInstanceInput(containerComponent, componentInstanceId, property);
                     } else {
@@ -1651,43 +1730,43 @@ public class ToscaOperationFacade {
     }
 
     public Either<Map<String, List<ComponentInstanceOutput>>, StorageOperationStatus> addComponentInstanceOutputsToComponent(
-            Component containerComponent, Map<String, List<ComponentInstanceOutput>> instProperties) {
-        requireNonNull(instProperties);
+        Component containerComponent, Map<String, List<ComponentInstanceOutput>> instOutputs) {
+        requireNonNull(instOutputs);
         StorageOperationStatus status;
-        for (final Entry<String, List<ComponentInstanceOutput>> entry : instProperties.entrySet()) {
-            final List<ComponentInstanceOutput> props = entry.getValue();
+        for (final Entry<String, List<ComponentInstanceOutput>> entry : instOutputs.entrySet()) {
+            final List<ComponentInstanceOutput> outputs = entry.getValue();
             final String componentInstanceId = entry.getKey();
-            if (!isEmpty(props)) {
-                for (final ComponentInstanceOutput property : props) {
-                    final List<ComponentInstanceOutput> componentInstancesInputs = containerComponent.getComponentInstancesOutputs()
-                            .get(componentInstanceId);
-                    final Optional<ComponentInstanceOutput> instanceProperty = componentInstancesInputs.stream()
-                            .filter(p -> p.getName().equals(property.getName())).findAny();
-                    if (instanceProperty.isPresent()) {
-                        status = updateComponentInstanceOutput(containerComponent, componentInstanceId, property);
+            if (!isEmpty(outputs)) {
+                for (final ComponentInstanceOutput output : outputs) {
+                    final List<ComponentInstanceOutput> componentInstanceOutputs = containerComponent.getComponentInstancesOutputs()
+                        .get(componentInstanceId);
+                    final Optional<ComponentInstanceOutput> componentInstanceOutput = componentInstanceOutputs.stream()
+                        .filter(p -> p.getName().equals(output.getName())).findAny();
+                    if (componentInstanceOutput.isPresent()) {
+                        status = updateComponentInstanceOutput(containerComponent, componentInstanceId, output);
                     } else {
-                        status = addComponentInstanceOutput(containerComponent, componentInstanceId, property);
+                        status = addComponentInstanceOutput(containerComponent, componentInstanceId, output);
                     }
                     if (status != StorageOperationStatus.OK) {
-                        log.debug("Failed to update instance input {} for instance {} error {} ", property, componentInstanceId, status);
+                        log.debug("Failed to update instance output {} for instance {} error {} ", output, componentInstanceId, status);
                         return Either.right(status);
                     } else {
-                        log.trace("instance input {} for instance {} updated", property, componentInstanceId);
+                        log.trace("instance output {} for instance {} updated", output, componentInstanceId);
                     }
                 }
             }
         }
-        return Either.left(instProperties);
+        return Either.left(instOutputs);
     }
 
     public Either<Map<String, List<ComponentInstanceProperty>>, StorageOperationStatus> addComponentInstancePropertiesToComponent(
-            Component containerComponent, Map<String, List<ComponentInstanceProperty>> instProperties) {
+        Component containerComponent, Map<String, List<ComponentInstanceProperty>> instProperties) {
         requireNonNull(instProperties);
         for (Entry<String, List<ComponentInstanceProperty>> entry : instProperties.entrySet()) {
             List<ComponentInstanceProperty> props = entry.getValue();
             String componentInstanceId = entry.getKey();
             List<ComponentInstanceProperty> originalComponentInstProps = containerComponent.getComponentInstancesProperties()
-                    .get(componentInstanceId);
+                .get(componentInstanceId);
             Map<String, List<CapabilityDefinition>> containerComponentCapabilities = containerComponent.getCapabilities();
             if (isEmpty(props)) {
                 continue;
@@ -1698,7 +1777,7 @@ public class ToscaOperationFacade {
                 Optional<CapabilityDefinition> capPropDefinition = getPropertyCapability(propertyParentUniqueId, containerComponent);
                 if (capPropDefinition.isPresent() && MapUtils.isNotEmpty(containerComponentCapabilities)) {
                     status = populateAndUpdateInstanceCapProperty(containerComponent, componentInstanceId, containerComponentCapabilities, property,
-                            capPropDefinition.get());
+                        capPropDefinition.get());
                 }
                 if (status == null) {
                     status = updateOrAddComponentInstanceProperty(containerComponent, componentInstanceId, originalComponentInstProps, property);
@@ -1712,7 +1791,7 @@ public class ToscaOperationFacade {
     }
 
     public Either<Map<String, List<ComponentInstanceAttribute>>, StorageOperationStatus> addComponentInstanceAttributesToComponent(
-            final Component containerComponent, final Map<String, List<ComponentInstanceAttribute>> instProperties) {
+        final Component containerComponent, final Map<String, List<ComponentInstanceAttribute>> instProperties) {
         requireNonNull(instProperties);
         for (final Entry<String, List<ComponentInstanceAttribute>> entry : instProperties.entrySet()) {
             final List<ComponentInstanceAttribute> props = entry.getValue();
@@ -1721,10 +1800,10 @@ public class ToscaOperationFacade {
             }
             final String componentInstanceId = entry.getKey();
             final List<ComponentInstanceAttribute> originalComponentInstProps = containerComponent.getComponentInstancesAttributes()
-                    .get(componentInstanceId);
+                .get(componentInstanceId);
             for (final ComponentInstanceAttribute property : props) {
                 final StorageOperationStatus status = updateOrAddComponentInstanceAttribute(containerComponent, componentInstanceId,
-                        originalComponentInstProps, property);
+                    originalComponentInstProps, property);
                 if (status != StorageOperationStatus.OK) {
                     return Either.right(status);
                 }
@@ -1742,7 +1821,7 @@ public class ToscaOperationFacade {
             return null;
         }
         Optional<CapabilityDefinition> capDefToGetProp = capabilityDefinitions.stream()
-                .filter(cap -> cap.getUniqueId().equals(capabilityDefinition.getUniqueId()) && cap.getPath().size() == 1).findAny();
+            .filter(cap -> cap.getUniqueId().equals(capabilityDefinition.getUniqueId()) && cap.getPath().size() == 1).findAny();
         if (capDefToGetProp.isPresent()) {
             return updateInstanceCapabilityProperty(containerComponent, componentInstanceId, property, capDefToGetProp.get());
         }
@@ -1755,7 +1834,7 @@ public class ToscaOperationFacade {
         StorageOperationStatus status;
         // check if the property already exists or not
         Optional<ComponentInstanceProperty> instanceProperty = originalComponentInstProps.stream()
-                .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
+            .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
         if (instanceProperty.isPresent()) {
             status = updateComponentInstanceProperty(containerComponent, componentInstanceId, property);
         } else {
@@ -1773,7 +1852,7 @@ public class ToscaOperationFacade {
         StorageOperationStatus status;
         // check if the property already exists or not
         Optional<ComponentInstanceAttribute> instanceProperty = originalComponentInstProps.stream()
-                .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
+            .filter(p -> p.getUniqueId().equals(property.getUniqueId())).findAny();
         if (instanceProperty.isPresent()) {
             status = updateComponentInstanceAttribute(containerComponent, componentInstanceId, property);
         } else {
@@ -1805,7 +1884,7 @@ public class ToscaOperationFacade {
         StorageOperationStatus status;
         StringBuilder sb = new StringBuilder(componentInstanceId);
         sb.append(ModelConverter.CAP_PROP_DELIM).append(propOwner).append(ModelConverter.CAP_PROP_DELIM).append(capabilityDefinition.getType())
-                .append(ModelConverter.CAP_PROP_DELIM).append(capabilityDefinition.getName());
+            .append(ModelConverter.CAP_PROP_DELIM).append(capabilityDefinition.getName());
         String capKey = sb.toString();
         status = updateComponentInstanceCapabiltyProperty(containerComponent, componentInstanceId, capKey, property);
         if (status != StorageOperationStatus.OK) {
@@ -1836,7 +1915,7 @@ public class ToscaOperationFacade {
         GraphVertex vertex = getVertexEither.left().value();
         if (MapUtils.isNotEmpty(capabilities)) {
             Either<GraphVertex, StorageOperationStatus> associateElementToData = topologyTemplateOperation
-                    .associateElementToData(vertex, VertexTypeEnum.CAPABILITIES, EdgeLabelEnum.CAPABILITIES, capabilities);
+                .associateElementToData(vertex, VertexTypeEnum.CAPABILITIES, EdgeLabelEnum.CAPABILITIES, capabilities);
             if (associateElementToData.isRight()) {
                 return associateElementToData.right().value();
             }
@@ -1853,7 +1932,7 @@ public class ToscaOperationFacade {
         GraphVertex vertex = getVertexEither.left().value();
         if (MapUtils.isNotEmpty(requirements)) {
             Either<GraphVertex, StorageOperationStatus> associateElementToData = topologyTemplateOperation
-                    .associateElementToData(vertex, VertexTypeEnum.REQUIREMENTS, EdgeLabelEnum.REQUIREMENTS, requirements);
+                .associateElementToData(vertex, VertexTypeEnum.REQUIREMENTS, EdgeLabelEnum.REQUIREMENTS, requirements);
             if (associateElementToData.isRight()) {
                 return associateElementToData.right().value();
             }
@@ -1864,7 +1943,7 @@ public class ToscaOperationFacade {
     public StorageOperationStatus associateDeploymentArtifactsToInstances(Map<String, Map<String, ArtifactDefinition>> instDeploymentArtifacts,
                                                                           Component component, User user) {
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao
-                .getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
+            .getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
         if (getVertexEither.isRight()) {
             log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, component.getUniqueId(), getVertexEither.right().value());
             return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value());
@@ -1876,9 +1955,9 @@ public class ToscaOperationFacade {
             for (Entry<String, Map<String, ArtifactDefinition>> entry : instDeploymentArtifacts.entrySet()) {
                 Map<String, ArtifactDefinition> artList = entry.getValue();
                 Map<String, ArtifactDataDefinition> artifacts = artList.entrySet().stream()
-                        .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
+                    .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
                 artifactsMap = nodeTemplateOperation
-                        .prepareInstDeploymentArtifactPerInstance(artifacts, entry.getKey(), user, NodeTemplateOperation.HEAT_VF_ENV_NAME);
+                    .prepareInstDeploymentArtifactPerInstance(artifacts, entry.getKey(), user, NodeTemplateOperation.HEAT_VF_ENV_NAME);
                 instArtMap.put(entry.getKey(), artifactsMap);
             }
         }
@@ -1888,7 +1967,7 @@ public class ToscaOperationFacade {
 
     public StorageOperationStatus associateArtifactsToInstances(Map<String, Map<String, ArtifactDefinition>> instArtifacts, Component component) {
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao
-                .getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
+            .getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
         if (getVertexEither.isRight()) {
             log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, component.getUniqueId(), getVertexEither.right().value());
             return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value());
@@ -1900,7 +1979,7 @@ public class ToscaOperationFacade {
             for (Entry<String, Map<String, ArtifactDefinition>> entry : instArtifacts.entrySet()) {
                 Map<String, ArtifactDefinition> artList = entry.getValue();
                 Map<String, ArtifactDataDefinition> artifacts = artList.entrySet().stream()
-                        .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
+                    .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
                 artifactsMap = new MapArtifactDataDefinition(artifacts);
                 instArtMap.put(entry.getKey(), artifactsMap);
             }
@@ -1912,7 +1991,7 @@ public class ToscaOperationFacade {
     public StorageOperationStatus associateInstAttributeToComponentToInstances(Map<String, List<AttributeDefinition>> instArttributes,
                                                                                Component component) {
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao
-                .getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
+            .getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
         if (getVertexEither.isRight()) {
             log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, component.getUniqueId(), getVertexEither.right().value());
             return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value());
@@ -1925,7 +2004,7 @@ public class ToscaOperationFacade {
                 final List<AttributeDefinition> value = entry.getValue();
                 attributesMap = new MapAttributesDataDefinition();
                 attributesMap.setMapToscaDataDefinition(
-                        value.stream().map(AttributeDefinition::new).collect(Collectors.toMap(AttributeDefinition::getName, e -> e)));
+                    value.stream().map(AttributeDefinition::new).collect(Collectors.toMap(AttributeDefinition::getName, e -> e)));
                 instAttr.put(entry.getKey(), attributesMap);
             }
         }
@@ -1947,7 +2026,7 @@ public class ToscaOperationFacade {
                                                                  Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instReg,
                                                                  Component component) {
         Either<GraphVertex, JanusGraphOperationStatus> getVertexEither = janusGraphDao
-                .getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
+            .getVertexById(component.getUniqueId(), JsonParseFlagEnum.NoParse);
         if (getVertexEither.isRight()) {
             log.debug(COULDNT_FETCH_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, component.getUniqueId(), getVertexEither.right().value());
             return DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value());
@@ -1962,13 +2041,13 @@ public class ToscaOperationFacade {
                 Map<String, ListCapabilityDataDefinition> mapToscaDataDefinition = new HashMap<>();
                 for (Entry<String, List<CapabilityDefinition>> instCapability : caps.entrySet()) {
                     mapToscaDataDefinition.put(instCapability.getKey(), new ListCapabilityDataDefinition(
-                            instCapability.getValue().stream().map(CapabilityDataDefinition::new).collect(Collectors.toList())));
+                        instCapability.getValue().stream().map(CapabilityDataDefinition::new).collect(Collectors.toList())));
                 }
                 ComponentInstanceDataDefinition componentInstance = new ComponentInstanceDataDefinition(entry.getKey());
                 MapListCapabilityDataDefinition capMap = nodeTemplateOperation
-                        .prepareCalculatedCapabiltyForNodeType(mapToscaDataDefinition, componentInstance);
+                    .prepareCalculatedCapabiltyForNodeType(mapToscaDataDefinition, componentInstance);
                 MapCapabilityProperty mapCapabilityProperty = ModelConverter
-                        .convertToMapOfMapCapabiltyProperties(caps, componentInstance.getUniqueId(), true);
+                    .convertToMapOfMapCapabiltyProperties(caps, componentInstance.getUniqueId(), true);
                 calcCapabilty.put(entry.getKey().getUniqueId(), capMap);
                 calculatedCapabilitiesProperties.put(entry.getKey().getUniqueId(), mapCapabilityProperty);
             }
@@ -1979,24 +2058,24 @@ public class ToscaOperationFacade {
                 Map<String, ListRequirementDataDefinition> mapToscaDataDefinition = new HashMap<>();
                 for (Entry<String, List<RequirementDefinition>> instReq : req.entrySet()) {
                     mapToscaDataDefinition.put(instReq.getKey(), new ListRequirementDataDefinition(
-                            instReq.getValue().stream().map(RequirementDataDefinition::new).collect(Collectors.toList())));
+                        instReq.getValue().stream().map(RequirementDataDefinition::new).collect(Collectors.toList())));
                 }
                 MapListRequirementDataDefinition reqMap = nodeTemplateOperation
-                        .prepareCalculatedRequirementForNodeType(mapToscaDataDefinition, new ComponentInstanceDataDefinition(entry.getKey()));
+                    .prepareCalculatedRequirementForNodeType(mapToscaDataDefinition, new ComponentInstanceDataDefinition(entry.getKey()));
                 String componentInstanceId = entry.getKey().getUniqueId();
                 calcRequirements.put(componentInstanceId, reqMap);
             }
         }
         StorageOperationStatus storageOperationStatus = topologyTemplateOperation
-                .associateOrAddCalcCapReqToComponent(vertex, calcRequirements, calcCapabilty, calculatedCapabilitiesProperties);
+            .associateOrAddCalcCapReqToComponent(vertex, calcRequirements, calcCapabilty, calculatedCapabilitiesProperties);
         updateInstancesCapAndReqOnComponentFromDB(component);
         return storageOperationStatus;
     }
 
     public StorageOperationStatus updateCalculatedCapabilitiesRequirements(
-            final Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
-            final Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instReg,
-            final Component component) {
+        final Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties,
+        final Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instReg,
+        final Component component) {
         StorageOperationStatus storageOperationStatus = StorageOperationStatus.OK;
         if (instCapabilties != null) {
             for (Entry<ComponentInstance, Map<String, List<CapabilityDefinition>>> entry : instCapabilties.entrySet()) {
@@ -2014,7 +2093,7 @@ public class ToscaOperationFacade {
                 for (List<RequirementDefinition> requirementList : req.values()) {
                     for (RequirementDefinition requirement : requirementList) {
                         storageOperationStatus = nodeTemplateOperation.updateComponentInstanceRequirement(component.getUniqueId(),
-                                entry.getKey().getUniqueId(), requirement);
+                            entry.getKey().getUniqueId(), requirement);
                         if (storageOperationStatus != StorageOperationStatus.OK) {
                             return storageOperationStatus;
                         }
@@ -2038,6 +2117,7 @@ public class ToscaOperationFacade {
         Component updatedComponent = componentEither.left().value();
         component.setCapabilities(updatedComponent.getCapabilities());
         component.setRequirements(updatedComponent.getRequirements());
+        component.setComponentInstancesRelations(updatedComponent.getComponentInstancesRelations());
         component.setComponentInstances(updatedComponent.getComponentInstances());
     }
 
@@ -2071,14 +2151,14 @@ public class ToscaOperationFacade {
         Map<GraphPropertyEnum, Object> hasNotProps = new EnumMap<>(GraphPropertyEnum.class);
         fillPropsMap(hasProps, hasNotProps, internalComponentType, componentTypeEnum, isAbstract, vertexType, modelName);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getRes = janusGraphDao
-                .getByCriteria(vertexType, hasProps, hasNotProps, JsonParseFlagEnum.ParseMetadata, modelName, includeNormativeExtensionModels);
+            .getByCriteria(vertexType, hasProps, hasNotProps, JsonParseFlagEnum.ParseMetadata, modelName, includeNormativeExtensionModels);
         if (getRes.isRight() && !JanusGraphOperationStatus.NOT_FOUND.equals(getRes.right().value())) {
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getRes.right().value()));
         }
         // region -> Fetch non checked-out services
         if (internalComponentType != null && internalComponentType.toLowerCase().trim().equals(SERVICE) && VertexTypeEnum.NODE_TYPE == vertexType) {
             Either<List<Service>, StorageOperationStatus> result = getLatestVersionNonCheckoutServicesMetadataOnly(
-                    new EnumMap<>(GraphPropertyEnum.class), new EnumMap<>(GraphPropertyEnum.class), modelName);
+                new EnumMap<>(GraphPropertyEnum.class), new EnumMap<>(GraphPropertyEnum.class), modelName);
             if (result.isRight()) {
                 log.debug("Failed to fetch services for");
                 return Either.right(result.right().value());
@@ -2095,7 +2175,7 @@ public class ToscaOperationFacade {
         if (getRes.isLeft()) {
             for (GraphVertex vertexComponent : getRes.left().value()) {
                 Either<ToscaElement, StorageOperationStatus> componentRes = topologyTemplateOperation
-                        .getLightComponent(vertexComponent, componentTypeEnum, params);
+                    .getLightComponent(vertexComponent, componentTypeEnum, params);
                 if (componentRes.isRight()) {
                     log.debug("Failed to fetch light element for {} error {}", vertexComponent.getUniqueId(), componentRes.right().value());
                     return Either.right(componentRes.right().value());
@@ -2123,15 +2203,15 @@ public class ToscaOperationFacade {
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_ARCHIVED, true); //US382674, US382683
         Either<List<GraphVertex>, JanusGraphOperationStatus> getRes = janusGraphDao
-                .getByCriteria(null, hasProperties, propertiesNotToMatch, parseFlag);
+            .getByCriteria(null, hasProperties, propertiesNotToMatch, parseFlag);
         if (getRes.isRight()) {
             result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getRes.right().value()));
         } else {
             List<ComponentMetadataData> latestVersionList = getRes.left().value().stream().map(ModelConverter::convertToComponentMetadata)
-                    .collect(Collectors.toList());
+                .collect(Collectors.toList());
             ComponentMetadataData latestVersion = latestVersionList.size() == 1 ? latestVersionList.get(0) : latestVersionList.stream().max(
-                    (c1, c2) -> Double.compare(Double.parseDouble(c1.getMetadataDataDefinition().getVersion()),
-                            Double.parseDouble(c2.getMetadataDataDefinition().getVersion()))).get();
+                (c1, c2) -> Double.compare(Double.parseDouble(c1.getMetadataDataDefinition().getVersion()),
+                    Double.parseDouble(c2.getMetadataDataDefinition().getVersion()))).get();
             result = Either.left(latestVersion);
         }
         return result;
@@ -2169,7 +2249,7 @@ public class ToscaOperationFacade {
                     componentParametersView.setIgnoreRequirements(false);
                 }
                 Either<ToscaElement, StorageOperationStatus> getToscaElementRes = nodeTemplateOperation.getToscaElementOperation(componentTypeEnum)
-                        .getLightComponent(componentUid, componentTypeEnum, componentParametersView);
+                    .getLightComponent(componentUid, componentTypeEnum, componentParametersView);
                 if (getToscaElementRes.isRight()) {
                     log.debug("Failed to fetch resource for error is {}", getToscaElementRes.right().value());
                     return Either.right(getToscaElementRes.right().value());
@@ -2196,7 +2276,7 @@ public class ToscaOperationFacade {
     private Either<List<String>, StorageOperationStatus> getComponentUids(boolean isAbstract, ComponentTypeEnum componentTypeEnum,
                                                                           String internalComponentType) {
         Either<List<Component>, StorageOperationStatus> getToscaElementsRes = getLatestVersionNotAbstractMetadataOnly(isAbstract, componentTypeEnum,
-                internalComponentType, null, false);
+            internalComponentType, null, false);
         if (getToscaElementsRes.isRight()) {
             return Either.right(getToscaElementsRes.right().value());
         }
@@ -2231,7 +2311,7 @@ public class ToscaOperationFacade {
                                                                                    ComponentTypeEnum componentType) {
         String normalizedName = ValidationUtils.normaliseComponentName(name);
         Either<List<GraphVertex>, JanusGraphOperationStatus> vertexEither = janusGraphDao
-                .getByCriteria(getVertexTypeEnum(resourceType), propertiesToMatch(normalizedName, componentType), JsonParseFlagEnum.NoParse);
+            .getByCriteria(getVertexTypeEnum(resourceType), propertiesToMatch(normalizedName, componentType), JsonParseFlagEnum.NoParse);
         if (vertexEither.isRight() && vertexEither.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
             log.debug("failed to get vertex from graph with property normalizedName: {}", normalizedName);
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(vertexEither.right().value()));
@@ -2254,18 +2334,18 @@ public class ToscaOperationFacade {
                                                                                             final ComponentTypeEnum componentType) {
         final String normalizedName = ValidationUtils.normaliseComponentName(resourceName);
         final Either<List<GraphVertex>, JanusGraphOperationStatus> vertexEither = janusGraphDao
-                .getByCriteria(getVertexTypeEnum(resourceType), propertiesToMatch(normalizedName, componentType), null, null, JsonParseFlagEnum.NoParse,
-                        modelName);
+            .getByCriteria(getVertexTypeEnum(resourceType), propertiesToMatch(normalizedName, componentType), null, null, JsonParseFlagEnum.NoParse,
+                modelName);
         if (vertexEither.isRight() && vertexEither.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
             log.debug("failed to get vertex from graph with property normalizedName: {} and model: {}", normalizedName, modelName);
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(vertexEither.right().value()));
         }
         return Either.left(CollectionUtils.isEmpty(vertexEither.isLeft() ? vertexEither.left().value().stream()
-                .collect(Collectors.toList()) : null));
+            .collect(Collectors.toList()) : null));
     }
 
     private VertexTypeEnum getVertexTypeEnum(final ResourceTypeEnum resourceType) {
-        return ModelConverter.isAtomicComponent(resourceType) ? VertexTypeEnum.NODE_TYPE : VertexTypeEnum.TOPOLOGY_TEMPLATE;
+        return ModelConverter.isAtomicComponent(resourceType) ? VertexTypeEnum.NODE_TYPE : TOPOLOGY_TEMPLATE;
     }
 
     private Map<GraphPropertyEnum, Object> propertiesToMatch(final String normalizedName, final ComponentTypeEnum componentType) {
@@ -2336,8 +2416,8 @@ public class ToscaOperationFacade {
             internalVertexTypes.add(VertexTypeEnum.NODE_TYPE);
         }
         if (ComponentTypeEnum.SERVICE == componentTypeEnum || SERVICE.equalsIgnoreCase(internalComponentType) || VF.equalsIgnoreCase(
-                internalComponentType)) {
-            internalVertexTypes.add(VertexTypeEnum.TOPOLOGY_TEMPLATE);
+            internalComponentType)) {
+            internalVertexTypes.add(TOPOLOGY_TEMPLATE);
         }
         return internalVertexTypes;
     }
@@ -2351,7 +2431,7 @@ public class ToscaOperationFacade {
         List<Component> result = new ArrayList<>();
         for (VertexTypeEnum vertexType : internalVertexTypes) {
             Either<List<Component>, StorageOperationStatus> listByVertexType = getLatestVersionNotAbstractToscaElementsMetadataOnly(isAbstract,
-                    componentTypeEnum, internalComponentType, vertexType, modelName, includeNormativeExtensionModels);
+                componentTypeEnum, internalComponentType, vertexType, modelName, includeNormativeExtensionModels);
             if (listByVertexType.isRight()) {
                 return listByVertexType;
             }
@@ -2377,7 +2457,7 @@ public class ToscaOperationFacade {
         Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> vertexEither = janusGraphDao
-                .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
         if (vertexEither.isRight()) {
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(vertexEither.right().value()));
         }
@@ -2399,7 +2479,7 @@ public class ToscaOperationFacade {
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_ARCHIVED, true); //US382674, US382683
         Either<List<GraphVertex>, JanusGraphOperationStatus> vertexEither = janusGraphDao
-                .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
         if (vertexEither.isRight()) {
             log.debug("Couldn't fetch metadata for component with uuid {}, error: {}", componentUuid, vertexEither.right().value());
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(vertexEither.right().value()));
@@ -2451,7 +2531,7 @@ public class ToscaOperationFacade {
             return Either.right(StorageOperationStatus.NOT_FOUND);
         }
         Component component = latestVersionList.size() == 1 ? latestVersionList.get(0)
-                : latestVersionList.stream().max((c1, c2) -> Double.compare(Double.parseDouble(c1.getVersion()), Double.parseDouble(c2.getVersion())))
+            : latestVersionList.stream().max((c1, c2) -> Double.compare(Double.parseDouble(c1.getVersion()), Double.parseDouble(c2.getVersion())))
                 .get();
         return Either.left(component);
     }
@@ -2468,7 +2548,7 @@ public class ToscaOperationFacade {
         propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.RESOURCE.name());
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getResourcesRes = janusGraphDao
-                .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
         if (getResourcesRes.isRight()) {
             log.debug("Failed to fetch all certified resources. Status is {}", getResourcesRes.right().value());
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getResourcesRes.right().value()));
@@ -2494,7 +2574,7 @@ public class ToscaOperationFacade {
         hasProperties.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
         hasNotProperties.put(GraphPropertyEnum.IS_DELETED, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceRes = janusGraphDao
-                .getByCriteria(null, hasProperties, hasNotProperties, parseFlag, model);
+            .getByCriteria(null, hasProperties, hasNotProperties, parseFlag, model);
         if (getResourceRes.isRight()) {
             JanusGraphOperationStatus status = getResourceRes.right().value();
             log.debug("failed to find resource with name {}, version {}. Status is {} ", name, version, status);
@@ -2522,7 +2602,7 @@ public class ToscaOperationFacade {
         GraphVertex resourceMetadataData = null;
         List<GraphVertex> resourceMetadataDataList = null;
         Either<List<GraphVertex>, JanusGraphOperationStatus> byCsar = janusGraphDao
-                .getByCriteria(null, props, propsHasNot, JsonParseFlagEnum.ParseMetadata);
+            .getByCriteria(null, props, propsHasNot, JsonParseFlagEnum.ParseMetadata);
         if (byCsar.isRight()) {
             if (JanusGraphOperationStatus.NOT_FOUND == byCsar.right().value()) {
                 // Fix Defect DE256036
@@ -2533,16 +2613,16 @@ public class ToscaOperationFacade {
                 props.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
                 props.put(GraphPropertyEnum.SYSTEM_NAME, systemName);
                 Either<List<GraphVertex>, JanusGraphOperationStatus> bySystemname = janusGraphDao
-                        .getByCriteria(null, props, JsonParseFlagEnum.ParseMetadata);
+                    .getByCriteria(null, props, JsonParseFlagEnum.ParseMetadata);
                 if (bySystemname.isRight()) {
                     log.debug("getLatestResourceByCsarOrName - Failed to find by system name {}  error {} ", systemName,
-                            bySystemname.right().value());
+                        bySystemname.right().value());
                     return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(bySystemname.right().value()));
                 }
                 if (bySystemname.left().value().size() > 2) {
                     log.debug(
-                            "getLatestResourceByCsarOrName - getByCriteria(by system name) must return only 2 latest version, but was returned - {}",
-                            bySystemname.left().value().size());
+                        "getLatestResourceByCsarOrName - getByCriteria(by system name) must return only 2 latest version, but was returned - {}",
+                        bySystemname.left().value().size());
                     return Either.right(StorageOperationStatus.GENERAL_ERROR);
                 }
                 resourceMetadataDataList = bySystemname.left().value();
@@ -2563,7 +2643,7 @@ public class ToscaOperationFacade {
                 final Object csarUuid = resourceMetadataData.getJsonMetadataField(JsonPresentationFields.CSAR_UUID);
                 if (csarUuid != null && !csarUuid.equals(csarUUID)) {
                     log.debug("getLatestResourceByCsarOrName - same system name {} but different csarUUID. exist {} and new {} ", systemName,
-                            csarUuid, csarUUID);
+                        csarUuid, csarUUID);
                     // correct error will be returned from create flow. with all
 
                     // correct audit records!!!!!
@@ -2575,7 +2655,7 @@ public class ToscaOperationFacade {
             resourceMetadataDataList = byCsar.left().value();
             if (resourceMetadataDataList.size() > 2) {
                 log.debug("getLatestResourceByCsarOrName - getByCriteria(by csar) must return only 2 latest version, but was returned - {}",
-                        byCsar.left().value().size());
+                    byCsar.left().value().size());
                 return Either.right(StorageOperationStatus.GENERAL_ERROR);
             }
             if (resourceMetadataDataList.size() == 1) {
@@ -2604,7 +2684,7 @@ public class ToscaOperationFacade {
             Either<Resource, StorageOperationStatus> latestByToscaResourceName = getLatestByToscaResourceName(currentTemplateNameChecked, model);
             if (latestByToscaResourceName.isRight()) {
                 return latestByToscaResourceName.right().value() == StorageOperationStatus.NOT_FOUND ? Either.left(false)
-                        : Either.right(latestByToscaResourceName.right().value());
+                    : Either.right(latestByToscaResourceName.right().value());
             }
             Resource value = latestByToscaResourceName.left().value();
             if (value.getDerivedFrom() != null) {
@@ -2614,7 +2694,7 @@ public class ToscaOperationFacade {
             }
         }
         return (currentTemplateNameChecked != null && currentTemplateNameChecked.equalsIgnoreCase(templateNameCurrent)) ? Either.left(true)
-                : Either.left(false);
+            : Either.left(false);
     }
 
     public Either<List<Component>, StorageOperationStatus> fetchMetaDataByResourceType(String resourceType, ComponentParametersView filterBy) {
@@ -2624,7 +2704,7 @@ public class ToscaOperationFacade {
         Map<GraphPropertyEnum, Object> propsHasNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propsHasNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> resourcesByTypeEither = janusGraphDao
-                .getByCriteria(null, props, propsHasNotToMatch, JsonParseFlagEnum.ParseMetadata);
+            .getByCriteria(null, props, propsHasNotToMatch, JsonParseFlagEnum.ParseMetadata);
         if (resourcesByTypeEither.isRight()) {
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(resourcesByTypeEither.right().value()));
         }
@@ -2642,7 +2722,7 @@ public class ToscaOperationFacade {
 
     public Either<Service, StorageOperationStatus> updateDistributionStatus(Service service, User user, DistributionStatusEnum distributionStatus) {
         Either<GraphVertex, StorageOperationStatus> updateDistributionStatus = topologyTemplateOperation
-                .updateDistributionStatus(service.getUniqueId(), user, distributionStatus);
+            .updateDistributionStatus(service.getUniqueId(), user, distributionStatus);
         if (updateDistributionStatus.isRight()) {
             return Either.right(updateDistributionStatus.right().value());
         }
@@ -2698,11 +2778,11 @@ public class ToscaOperationFacade {
         }
         propertiesToMatch.put(GraphPropertyEnum.COMPONENT_TYPE, ComponentTypeEnum.SERVICE.name());
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
-        if (distStatus != null && !distStatus.isEmpty()) {
+        if (CollectionUtils.isNotEmpty(distStatus)) {
             for (DistributionStatusEnum state : distStatus) {
                 propertiesToMatch.put(GraphPropertyEnum.DISTRIBUTION_STATUS, state.name());
                 Either<List<Service>, StorageOperationStatus> fetchServicesByCriteria = fetchServicesByCriteria(servicesAll, propertiesToMatch,
-                        propertiesNotToMatch, null);
+                    propertiesNotToMatch, null);
                 if (fetchServicesByCriteria.isRight()) {
                     return fetchServicesByCriteria;
                 } else {
@@ -2719,22 +2799,26 @@ public class ToscaOperationFacade {
                                                                                   Map<GraphPropertyEnum, Object> propertiesToMatch,
                                                                                   Map<GraphPropertyEnum, Object> propertiesNotToMatch,
                                                                                   String modelName) {
-        Either<List<GraphVertex>, JanusGraphOperationStatus> getRes = janusGraphDao
-                .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll, modelName);
+        Either<List<GraphVertex>, JanusGraphOperationStatus> getRes;
+        if (StringUtils.isEmpty(modelName)) {
+            getRes = janusGraphDao.getByCriteria(TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+        } else {
+            getRes = janusGraphDao.getByCriteria(TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll, modelName);
+        }
         if (getRes.isRight()) {
             if (getRes.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
-                        "Failed to fetch certified services by match properties {} not match properties {} . Status is {}. ", propertiesToMatch,
-                        propertiesNotToMatch, getRes.right().value());
+                    "Failed to fetch certified services by match properties {} not match properties {} . Status is {}. ", propertiesToMatch,
+                    propertiesNotToMatch, getRes.right().value());
                 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getRes.right().value()));
             }
         } else {
             for (final GraphVertex vertex : getRes.left().value()) {
                 Either<ToscaElement, StorageOperationStatus> getServiceRes = topologyTemplateOperation
-                        .getLightComponent(vertex, ComponentTypeEnum.SERVICE, new ComponentParametersView(true));
+                    .getLightComponent(vertex, ComponentTypeEnum.SERVICE, new ComponentParametersView(true));
                 if (getServiceRes.isRight()) {
                     CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to fetch certified service {}. Status is {}. ",
-                            vertex.getJsonMetadataField(JsonPresentationFields.NAME), getServiceRes.right().value());
+                        vertex.getJsonMetadataField(JsonPresentationFields.NAME), getServiceRes.right().value());
                     return Either.right(getServiceRes.right().value());
                 } else {
                     servicesAll.add(ModelConverter.convertFromToscaElement(getServiceRes.left().value()));
@@ -2751,7 +2835,7 @@ public class ToscaOperationFacade {
     public StorageOperationStatus addDeploymentArtifactsToInstance(String componentId, ComponentInstance componentInstance,
                                                                    Map<String, ArtifactDefinition> finalDeploymentArtifacts) {
         Map<String, ArtifactDataDefinition> instDeplArtifacts = finalDeploymentArtifacts.entrySet().stream()
-                .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
+            .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
         return nodeTemplateOperation.addDeploymentArtifactsToInstance(componentId, componentInstance.getUniqueId(), instDeplArtifacts);
     }
 
@@ -2760,7 +2844,7 @@ public class ToscaOperationFacade {
         StorageOperationStatus status = StorageOperationStatus.OK;
         if (MapUtils.isNotEmpty(artifacts)) {
             Map<String, ArtifactDataDefinition> instDeplArtifacts = artifacts.entrySet().stream()
-                    .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
+                .collect(Collectors.toMap(Map.Entry::getKey, e -> new ArtifactDataDefinition(e.getValue())));
             status = nodeTemplateOperation.addInformationalArtifactsToInstance(componentId, componentInstance.getUniqueId(), instDeplArtifacts);
         }
         return status;
@@ -2774,15 +2858,15 @@ public class ToscaOperationFacade {
         return nodeTemplateOperation.generateCustomizationUUIDOnInstanceGroup(componentId, instanceId, groupInstances);
     }
 
-    public Either<PropertyDefinition, StorageOperationStatus> addPropertyToComponent(String propertyName, PropertyDefinition newPropertyDefinition,
+    public Either<PropertyDefinition, StorageOperationStatus> addPropertyToComponent(PropertyDefinition newPropertyDefinition,
                                                                                      Component component) {
-        newPropertyDefinition.setName(propertyName);
+        final String propertyName = newPropertyDefinition.getName();
         StorageOperationStatus status = getToscaElementOperation(component)
-                .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition,
-                        JsonPresentationFields.NAME);
+            .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition,
+                JsonPresentationFields.NAME);
         if (status != StorageOperationStatus.OK) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the property {} to the component {}. Status is {}. ", propertyName,
-                    component.getName(), status);
+                component.getName(), status);
             return Either.right(status);
         }
         ComponentParametersView filter = new ComponentParametersView(true);
@@ -2791,21 +2875,21 @@ public class ToscaOperationFacade {
         Either<Component, StorageOperationStatus> getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
         if (getUpdatedComponentRes.isRight()) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get updated component {}. Status is {}. ", component.getUniqueId(),
-                    getUpdatedComponentRes.right().value());
+                getUpdatedComponentRes.right().value());
             return Either.right(status);
         }
         PropertyDefinition newProperty = null;
         List<PropertyDefinition> properties = (getUpdatedComponentRes.left().value()).getProperties();
         if (CollectionUtils.isNotEmpty(properties)) {
             Optional<PropertyDefinition> propertyOptional = properties.stream().filter(propertyEntry -> propertyEntry.getName().equals(propertyName))
-                    .findAny();
+                .findAny();
             if (propertyOptional.isPresent()) {
                 newProperty = propertyOptional.get();
             }
         }
         if (newProperty == null) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently added property {} on the component {}. Status is {}. ",
-                    propertyName, component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+                propertyName, component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
             return Either.right(StorageOperationStatus.NOT_FOUND);
         }
         return Either.left(newProperty);
@@ -2815,11 +2899,11 @@ public class ToscaOperationFacade {
                                                                                Component component) {
         newInputDefinition.setName(inputName);
         StorageOperationStatus status = getToscaElementOperation(component)
-                .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, newInputDefinition,
-                        JsonPresentationFields.NAME);
+            .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, newInputDefinition,
+                JsonPresentationFields.NAME);
         if (status != StorageOperationStatus.OK) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the input {} to the component {}. Status is {}. ", inputName,
-                    component.getName(), status);
+                component.getName(), status);
             return Either.right(status);
         }
         ComponentParametersView filter = new ComponentParametersView(true);
@@ -2828,7 +2912,7 @@ public class ToscaOperationFacade {
         Either<Component, StorageOperationStatus> getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
         if (getUpdatedComponentRes.isRight()) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get updated component {}. Status is {}. ", component.getUniqueId(),
-                    getUpdatedComponentRes.right().value());
+                getUpdatedComponentRes.right().value());
             return Either.right(status);
         }
         InputDefinition newInput = null;
@@ -2841,8 +2925,8 @@ public class ToscaOperationFacade {
         }
         if (newInput == null) {
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently added input {} " + "on the component {}. Status is {}. ", inputs,
-                            component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+                .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently added input {} " + "on the component {}. Status is {}. ", inputs,
+                    component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
             return Either.right(StorageOperationStatus.NOT_FOUND);
         }
         return Either.left(newInput);
@@ -2850,24 +2934,24 @@ public class ToscaOperationFacade {
 
     public StorageOperationStatus deletePropertyOfComponent(Component component, String propertyName) {
         return getToscaElementOperation(component)
-                .deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, propertyName,
-                        JsonPresentationFields.NAME);
+            .deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, propertyName,
+                JsonPresentationFields.NAME);
     }
 
     public StorageOperationStatus deleteAttributeOfResource(Component component, String attributeName) {
         return getToscaElementOperation(component)
-                .deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, attributeName,
-                        JsonPresentationFields.NAME);
+            .deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, attributeName,
+                JsonPresentationFields.NAME);
     }
 
     public StorageOperationStatus deleteInputOfResource(Component resource, String inputName) {
         return getToscaElementOperation(resource)
-                .deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, inputName, JsonPresentationFields.NAME);
+            .deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, inputName, JsonPresentationFields.NAME);
     }
 
     public StorageOperationStatus deleteOutputOfResource(final Component resource, final String outputName) {
         return getToscaElementOperation(resource)
-                .deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.OUTPUTS, VertexTypeEnum.OUTPUTS, outputName, JsonPresentationFields.NAME);
+            .deleteToscaDataElement(resource.getUniqueId(), EdgeLabelEnum.OUTPUTS, VertexTypeEnum.OUTPUTS, outputName, JsonPresentationFields.NAME);
     }
 
     /**
@@ -2879,8 +2963,8 @@ public class ToscaOperationFacade {
      */
     public StorageOperationStatus deleteDataTypeOfComponent(Component component, String dataTypeName) {
         return getToscaElementOperation(component)
-                .deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.DATA_TYPES, VertexTypeEnum.DATA_TYPES, dataTypeName,
-                        JsonPresentationFields.NAME);
+            .deleteToscaDataElement(component.getUniqueId(), EdgeLabelEnum.DATA_TYPES, VertexTypeEnum.DATA_TYPES, dataTypeName,
+                JsonPresentationFields.NAME);
     }
 
     public Either<PropertyDefinition, StorageOperationStatus> updatePropertyOfComponent(Component component,
@@ -2888,12 +2972,12 @@ public class ToscaOperationFacade {
         Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
         Either<PropertyDefinition, StorageOperationStatus> result = null;
         StorageOperationStatus status = getToscaElementOperation(component)
-                .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition,
-                        JsonPresentationFields.NAME);
+            .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.PROPERTIES, VertexTypeEnum.PROPERTIES, newPropertyDefinition,
+                JsonPresentationFields.NAME);
         if (status != StorageOperationStatus.OK) {
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newPropertyDefinition.getName(),
-                            component.getName(), status);
+                .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newPropertyDefinition.getName(),
+                    component.getName(), status);
             result = Either.right(status);
         }
         if (result == null) {
@@ -2902,18 +2986,18 @@ public class ToscaOperationFacade {
             getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
             if (getUpdatedComponentRes.isRight()) {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS, component.getUniqueId(),
-                        getUpdatedComponentRes.right().value());
+                    getUpdatedComponentRes.right().value());
                 result = Either.right(status);
             }
         }
         if (result == null) {
             Optional<PropertyDefinition> newProperty = (getUpdatedComponentRes.left().value()).getProperties().stream()
-                    .filter(p -> p.getName().equals(newPropertyDefinition.getName())).findAny();
+                .filter(p -> p.getName().equals(newPropertyDefinition.getName())).findAny();
             if (newProperty.isPresent()) {
                 result = Either.left(newProperty.get());
             } else {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS,
-                        newPropertyDefinition.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+                    newPropertyDefinition.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
                 result = Either.right(StorageOperationStatus.NOT_FOUND);
             }
         }
@@ -2925,12 +3009,12 @@ public class ToscaOperationFacade {
         Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
         Either<AttributeDefinition, StorageOperationStatus> result = null;
         StorageOperationStatus status = getToscaElementOperation(component)
-                .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newPropertyDefinition,
-                        JsonPresentationFields.NAME);
+            .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newPropertyDefinition,
+                JsonPresentationFields.NAME);
         if (status != StorageOperationStatus.OK) {
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newPropertyDefinition.getName(),
-                            component.getName(), status);
+                .addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newPropertyDefinition.getName(),
+                    component.getName(), status);
             result = Either.right(status);
         }
         if (result == null) {
@@ -2939,18 +3023,18 @@ public class ToscaOperationFacade {
             getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
             if (getUpdatedComponentRes.isRight()) {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS, component.getUniqueId(),
-                        getUpdatedComponentRes.right().value());
+                    getUpdatedComponentRes.right().value());
                 result = Either.right(status);
             }
         }
         if (result == null) {
             Optional<AttributeDefinition> newProperty = (getUpdatedComponentRes.left().value()).getAttributes().stream()
-                    .filter(p -> p.getName().equals(newPropertyDefinition.getName())).findAny();
+                .filter(p -> p.getName().equals(newPropertyDefinition.getName())).findAny();
             if (newProperty.isPresent()) {
                 result = Either.left(newProperty.get());
             } else {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS,
-                        newPropertyDefinition.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+                    newPropertyDefinition.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
                 result = Either.right(StorageOperationStatus.NOT_FOUND);
             }
         }
@@ -2966,11 +3050,11 @@ public class ToscaOperationFacade {
             newAttributeDef.setOwnerId(component.getUniqueId());
         }
         StorageOperationStatus status = getToscaElementOperation(component)
-                .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef,
-                        JsonPresentationFields.NAME);
+            .addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef,
+                JsonPresentationFields.NAME);
         if (status != StorageOperationStatus.OK) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newAttributeDef.getName(),
-                    component.getName(), status);
+                component.getName(), status);
             result = Either.right(status);
         }
         if (result == null) {
@@ -2979,18 +3063,18 @@ public class ToscaOperationFacade {
             getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
             if (getUpdatedComponentRes.isRight()) {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS, component.getUniqueId(),
-                        getUpdatedComponentRes.right().value());
+                    getUpdatedComponentRes.right().value());
                 result = Either.right(status);
             }
         }
         if (result == null) {
             Optional<AttributeDefinition> newAttribute = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream()
-                    .filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
+                .filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
             if (newAttribute.isPresent()) {
                 result = Either.left(newAttribute.get());
             } else {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS,
-                        newAttributeDef.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+                    newAttributeDef.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
                 result = Either.right(StorageOperationStatus.NOT_FOUND);
             }
         }
@@ -3001,11 +3085,11 @@ public class ToscaOperationFacade {
         Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
         Either<AttributeDefinition, StorageOperationStatus> result = null;
         StorageOperationStatus status = getToscaElementOperation(component)
-                .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef,
-                        JsonPresentationFields.NAME);
+            .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.ATTRIBUTES, VertexTypeEnum.ATTRIBUTES, newAttributeDef,
+                JsonPresentationFields.NAME);
         if (status != StorageOperationStatus.OK) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_ADD_THE_PROPERTY_TO_THE_RESOURCE_STATUS_IS, newAttributeDef.getName(),
-                    component.getName(), status);
+                component.getName(), status);
             result = Either.right(status);
         }
         if (result == null) {
@@ -3014,18 +3098,18 @@ public class ToscaOperationFacade {
             getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
             if (getUpdatedComponentRes.isRight()) {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS, component.getUniqueId(),
-                        getUpdatedComponentRes.right().value());
+                    getUpdatedComponentRes.right().value());
                 result = Either.right(status);
             }
         }
         if (result == null) {
             Optional<AttributeDefinition> newProperty = ((Resource) getUpdatedComponentRes.left().value()).getAttributes().stream()
-                    .filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
+                .filter(p -> p.getName().equals(newAttributeDef.getName())).findAny();
             if (newProperty.isPresent()) {
                 result = Either.left(newProperty.get());
             } else {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_FIND_RECENTLY_ADDED_PROPERTY_ON_THE_RESOURCE_STATUS_IS,
-                        newAttributeDef.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+                    newAttributeDef.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
                 result = Either.right(StorageOperationStatus.NOT_FOUND);
             }
         }
@@ -3036,11 +3120,11 @@ public class ToscaOperationFacade {
         Either<Component, StorageOperationStatus> getUpdatedComponentRes = null;
         Either<InputDefinition, StorageOperationStatus> result = null;
         StorageOperationStatus status = getToscaElementOperation(component)
-                .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, newInputDefinition,
-                        JsonPresentationFields.NAME);
+            .updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.INPUTS, VertexTypeEnum.INPUTS, newInputDefinition,
+                JsonPresentationFields.NAME);
         if (status != StorageOperationStatus.OK) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to update the input {} to the component {}. Status is {}. ",
-                    newInputDefinition.getName(), component.getName(), status);
+                newInputDefinition.getName(), component.getName(), status);
             result = Either.right(status);
         }
         if (result == null) {
@@ -3049,18 +3133,18 @@ public class ToscaOperationFacade {
             getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
             if (getUpdatedComponentRes.isRight()) {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, FAILED_TO_GET_UPDATED_RESOURCE_STATUS_IS, component.getUniqueId(),
-                        getUpdatedComponentRes.right().value());
+                    getUpdatedComponentRes.right().value());
                 result = Either.right(status);
             }
         }
         if (result == null) {
             Optional<InputDefinition> updatedInput = getUpdatedComponentRes.left().value().getInputs().stream()
-                    .filter(p -> p.getName().equals(newInputDefinition.getName())).findAny();
+                .filter(p -> p.getName().equals(newInputDefinition.getName())).findAny();
             if (updatedInput.isPresent()) {
                 result = Either.left(updatedInput.get());
             } else {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently updated inputs {} on the resource {}. Status is {}. ",
-                        newInputDefinition.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+                    newInputDefinition.getName(), component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
                 result = Either.right(StorageOperationStatus.NOT_FOUND);
             }
         }
@@ -3080,19 +3164,19 @@ public class ToscaOperationFacade {
                                                                                                                String componentInstanceId) {
         String uniqueId = componentInstance.getUniqueId();
         StorageOperationStatus status = nodeTemplateOperation
-                .deleteToscaDataDeepElementsBlockOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_GROUPS, VertexTypeEnum.INST_GROUPS,
-                        uniqueId);
+            .deleteToscaDataDeepElementsBlockOfToscaElement(containerComponent.getUniqueId(), EdgeLabelEnum.INST_GROUPS,
+                uniqueId);
         if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
             CommonUtility
-                    .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to delete group instances for container {}. error {] ", componentInstanceId, status);
+                .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to delete group instances for container {}. error {] ", componentInstanceId, status);
             return Either.right(status);
         }
         if (componentInstance.getGroupInstances() != null) {
             status = addGroupInstancesToComponentInstance(containerComponent, componentInstance, componentInstance.getGroupInstances());
             if (status != StorageOperationStatus.OK && status != StorageOperationStatus.NOT_FOUND) {
                 CommonUtility
-                        .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add group instances for container {}. error {] ", componentInstanceId,
-                                status);
+                    .addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add group instances for container {}. error {] ", componentInstanceId,
+                        status);
                 return Either.right(status);
             }
         }
@@ -3196,25 +3280,25 @@ public class ToscaOperationFacade {
     public StorageOperationStatus deleteComponentInstanceInputsFromTopologyTemplate(Component containerComponent,
                                                                                     List<InputDefinition> inputsToDelete) {
         return topologyTemplateOperation.deleteToscaDataElements(containerComponent.getUniqueId(), EdgeLabelEnum.INPUTS,
-                inputsToDelete.stream().map(PropertyDataDefinition::getName).collect(Collectors.toList()));
+            inputsToDelete.stream().map(PropertyDataDefinition::getName).collect(Collectors.toList()));
     }
 
     public StorageOperationStatus deleteComponentInstanceOutputsFromTopologyTemplate(final Component containerComponent,
                                                                                      final List<OutputDefinition> outputsToDelete) {
         return topologyTemplateOperation.deleteToscaDataElements(containerComponent.getUniqueId(), EdgeLabelEnum.OUTPUTS,
-                outputsToDelete.stream().map(AttributeDataDefinition::getName).collect(Collectors.toList()));
+            outputsToDelete.stream().map(AttributeDataDefinition::getName).collect(Collectors.toList()));
     }
 
     public StorageOperationStatus updateComponentInstanceCapabiltyProperty(Component containerComponent, String componentInstanceUniqueId,
                                                                            String capabilityPropertyKey, ComponentInstanceProperty property) {
         return nodeTemplateOperation
-                .updateComponentInstanceCapabilityProperty(containerComponent, componentInstanceUniqueId, capabilityPropertyKey, property);
+            .updateComponentInstanceCapabilityProperty(containerComponent, componentInstanceUniqueId, capabilityPropertyKey, property);
     }
 
     public StorageOperationStatus updateComponentInstanceCapabilityProperties(Component containerComponent, String componentInstanceUniqueId) {
         return convertComponentInstanceProperties(containerComponent, componentInstanceUniqueId).map(instanceCapProps -> topologyTemplateOperation
-                        .updateComponentInstanceCapabilityProperties(containerComponent, componentInstanceUniqueId, instanceCapProps))
-                .orElse(StorageOperationStatus.NOT_FOUND);
+                .updateComponentInstanceCapabilityProperties(containerComponent, componentInstanceUniqueId, instanceCapProps))
+            .orElse(StorageOperationStatus.NOT_FOUND);
     }
 
     public StorageOperationStatus updateComponentInstanceRequirement(String containerComponentId, String componentInstanceUniqueId,
@@ -3243,19 +3327,19 @@ public class ToscaOperationFacade {
                                                                                        final Component component) {
 
         final boolean match = component.getInterfaces().keySet().stream().anyMatch(s -> s.equals(interfaceName));
-        StorageOperationStatus status = StorageOperationStatus.OK;
+        StorageOperationStatus status;
         final ToscaElementOperation toscaElementOperation = getToscaElementOperation(component);
         if (match) {
             status = toscaElementOperation.updateToscaDataOfToscaElement(component.getUniqueId(), EdgeLabelEnum.INTERFACE_ARTIFACTS,
-                    VertexTypeEnum.INTERFACE_ARTIFACTS, interfaceDefinition, JsonPresentationFields.TYPE);
+                VertexTypeEnum.INTERFACE_ARTIFACTS, interfaceDefinition, JsonPresentationFields.TYPE);
         } else {
             status = toscaElementOperation.addToscaDataToToscaElement(component.getUniqueId(), EdgeLabelEnum.INTERFACE_ARTIFACTS,
-                    VertexTypeEnum.INTERFACE_ARTIFACTS, interfaceDefinition, JsonPresentationFields.TYPE);
+                VertexTypeEnum.INTERFACE_ARTIFACTS, interfaceDefinition, JsonPresentationFields.TYPE);
         }
 
         if (status != StorageOperationStatus.OK) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to add the interface {} to the component {}. Status is {}. ",
-                    interfaceName, component.getName(), status);
+                interfaceName, component.getName(), status);
             return Either.right(status);
         }
         final ComponentParametersView filter = new ComponentParametersView(true);
@@ -3264,7 +3348,7 @@ public class ToscaOperationFacade {
         final Either<Component, StorageOperationStatus> getUpdatedComponentRes = getToscaElement(component.getUniqueId(), filter);
         if (getUpdatedComponentRes.isRight()) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to get updated component {}. Status is {}. ",
-                    component.getUniqueId(), getUpdatedComponentRes.right().value());
+                component.getUniqueId(), getUpdatedComponentRes.right().value());
             return Either.right(getUpdatedComponentRes.right().value());
         }
         InterfaceDefinition newInterfaceDefinition = null;
@@ -3277,7 +3361,7 @@ public class ToscaOperationFacade {
         }
         if (newInterfaceDefinition == null) {
             CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG, "Failed to find recently added interface {} on the component {}. Status is {}. ",
-                    interfaceName, component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
+                interfaceName, component.getUniqueId(), StorageOperationStatus.NOT_FOUND);
             return Either.right(StorageOperationStatus.NOT_FOUND);
         }
         return Either.left(newInterfaceDefinition);
@@ -3290,14 +3374,14 @@ public class ToscaOperationFacade {
 
     public StorageOperationStatus deleteAllCalculatedCapabilitiesRequirements(String topologyTemplateId) {
         StorageOperationStatus status = topologyTemplateOperation
-                .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAPABILITIES, VertexTypeEnum.CALCULATED_CAPABILITIES);
+            .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAPABILITIES);
         if (status == StorageOperationStatus.OK) {
             status = topologyTemplateOperation
-                    .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_REQUIREMENTS, VertexTypeEnum.CALCULATED_REQUIREMENTS);
+                .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_REQUIREMENTS);
         }
         if (status == StorageOperationStatus.OK) {
             status = topologyTemplateOperation
-                    .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES, VertexTypeEnum.CALCULATED_CAP_PROPERTIES);
+                .removeToscaData(topologyTemplateId, EdgeLabelEnum.CALCULATED_CAP_PROPERTIES);
         }
         return status;
     }
@@ -3312,10 +3396,10 @@ public class ToscaOperationFacade {
         GraphVertex nodeTypeV = getVertexEither.left().value();
         ToscaElement toscaElementToUpdate = ModelConverter.convertToToscaElement(clonedResource);
         Either<ToscaElement, StorageOperationStatus> shouldUpdateDerivedVersion = nodeTypeOperation
-                .shouldUpdateDerivedVersion(toscaElementToUpdate, nodeTypeV);
+            .shouldUpdateDerivedVersion(toscaElementToUpdate, nodeTypeV);
         if (shouldUpdateDerivedVersion.isRight() && StorageOperationStatus.OK != shouldUpdateDerivedVersion.right().value()) {
             log.debug("Failed to update derived version for node type {} derived {}, error: {}", componentId, clonedResource.getDerivedFrom().get(0),
-                    shouldUpdateDerivedVersion.right().value());
+                shouldUpdateDerivedVersion.right().value());
             return Either.right(shouldUpdateDerivedVersion.right().value());
         }
         if (shouldUpdateDerivedVersion.isLeft()) {
@@ -3360,7 +3444,7 @@ public class ToscaOperationFacade {
 
     private Optional<MapCapabilityProperty> convertComponentInstanceProperties(Component component, String instanceId) {
         return component.fetchInstanceById(instanceId)
-                .map(ci -> ModelConverter.convertToMapOfMapCapabilityProperties(ci.getCapabilities(), instanceId, ci.getOriginType().isAtomicType()));
+            .map(ci -> ModelConverter.convertToMapOfMapCapabilityProperties(ci.getCapabilities(), instanceId, ci.getOriginType().isAtomicType()));
     }
 
     public Either<PolicyDefinition, StorageOperationStatus> associatePolicyToComponent(String componentId, PolicyDefinition policyDefinition,
@@ -3372,14 +3456,14 @@ public class ToscaOperationFacade {
             log.error(COULDNT_FETCH_A_COMPONENT_WITH_AND_UNIQUE_ID_ERROR, componentId, getVertexEither.right().value());
             result = Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getVertexEither.right().value()));
         } else {
-            if (getVertexEither.left().value().getLabel() != VertexTypeEnum.TOPOLOGY_TEMPLATE) {
+            if (getVertexEither.left().value().getLabel() != TOPOLOGY_TEMPLATE) {
                 log.error("Policy association to component of Tosca type {} is not allowed. ", getVertexEither.left().value().getLabel());
                 result = Either.right(StorageOperationStatus.BAD_REQUEST);
             }
         }
         if (result == null) {
             StorageOperationStatus status = topologyTemplateOperation
-                    .addPolicyToToscaElement(getVertexEither.left().value(), policyDefinition, counter);
+                .addPolicyToToscaElement(getVertexEither.left().value(), policyDefinition, counter);
             if (status != StorageOperationStatus.OK) {
                 return Either.right(status);
             }
@@ -3393,8 +3477,8 @@ public class ToscaOperationFacade {
     public StorageOperationStatus associatePoliciesToComponent(String componentId, List<PolicyDefinition> policies) {
         log.debug("#associatePoliciesToComponent - associating policies for component {}.", componentId);
         return janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.ParseMetadata)
-                .either(containerVertex -> topologyTemplateOperation.addPoliciesToToscaElement(containerVertex, policies),
-                        DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
+            .either(containerVertex -> topologyTemplateOperation.addPoliciesToToscaElement(containerVertex, policies),
+                DaoStatusConverter::convertJanusGraphStatusToStorageStatus);
     }
 
     public Either<PolicyDefinition, StorageOperationStatus> updatePolicyOfComponent(String componentId, PolicyDefinition policyDefinition,
@@ -3422,8 +3506,8 @@ public class ToscaOperationFacade {
     public StorageOperationStatus updatePoliciesOfComponent(String componentId, List<PolicyDefinition> policyDefinition) {
         log.debug("#updatePoliciesOfComponent - updating policies for component {}", componentId);
         return janusGraphDao.getVertexById(componentId, JsonParseFlagEnum.NoParse).right()
-                .map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus)
-                .either(containerVertex -> topologyTemplateOperation.updatePoliciesOfToscaElement(containerVertex, policyDefinition), err -> err);
+            .map(DaoStatusConverter::convertJanusGraphStatusToStorageStatus)
+            .either(containerVertex -> topologyTemplateOperation.updatePoliciesOfToscaElement(containerVertex, policyDefinition), err -> err);
     }
 
     public StorageOperationStatus removePolicyFromComponent(String componentId, String policyId) {
@@ -3475,7 +3559,7 @@ public class ToscaOperationFacade {
 
     private TopologyTemplate getTopologyTemplate(String componentId) {
         return (TopologyTemplate) topologyTemplateOperation.getToscaElement(componentId, getFilterComponentWithCapProperties()).left()
-                .on(this::throwStorageException);
+            .on(this::throwStorageException);
     }
 
     private ComponentParametersView getFilterComponentWithCapProperties() {
@@ -3490,7 +3574,7 @@ public class ToscaOperationFacade {
 
     public Either<Boolean, StorageOperationStatus> isComponentInUse(String componentId) {
         final List<EdgeLabelEnum> forbiddenEdgeLabelEnums = Arrays
-                .asList(EdgeLabelEnum.INSTANCE_OF, EdgeLabelEnum.PROXY_OF, EdgeLabelEnum.ALLOTTED_OF);
+            .asList(EdgeLabelEnum.INSTANCE_OF, EdgeLabelEnum.PROXY_OF, EdgeLabelEnum.ALLOTTED_OF);
         Either<GraphVertex, JanusGraphOperationStatus> vertexById = janusGraphDao.getVertexById(componentId);
         if (vertexById.isLeft()) {
             for (EdgeLabelEnum edgeLabelEnum : forbiddenEdgeLabelEnums) {
@@ -3511,10 +3595,10 @@ public class ToscaOperationFacade {
         }
         propertiesToMatch.put(GraphPropertyEnum.INVARIANT_UUID, componentInvariantUuid);
         Either<List<GraphVertex>, JanusGraphOperationStatus> vertexEither = janusGraphDao
-                .getByCriteria(null, propertiesToMatch, JsonParseFlagEnum.ParseMetadata);
+            .getByCriteria(null, propertiesToMatch, JsonParseFlagEnum.ParseMetadata);
         if (vertexEither.isRight()) {
             log.debug("Couldn't fetch metadata for component with type {} and invariantUUId {}, error: {}", componentInvariantUuid,
-                    vertexEither.right().value());
+                vertexEither.right().value());
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(vertexEither.right().value()));
         }
         List<GraphVertex> vertexList = vertexEither.isLeft() ? vertexEither.left().value() : null;
@@ -3541,7 +3625,7 @@ public class ToscaOperationFacade {
         if (vertexById.isLeft()) {
             for (EdgeLabelEnum edgeLabelEnum : relationEdgeLabelEnums) {
                 Either<GraphVertex, JanusGraphOperationStatus> parentVertexEither = janusGraphDao
-                        .getParentVertex(vertexById.left().value(), edgeLabelEnum, JsonParseFlagEnum.ParseJson);
+                    .getParentVertex(vertexById.left().value(), edgeLabelEnum, JsonParseFlagEnum.ParseJson);
                 if (parentVertexEither.isLeft()) {
                     Either<Component, StorageOperationStatus> componentEither = getToscaElement(parentVertexEither.left().value().getUniqueId());
                     if (componentEither.isLeft()) {