diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/ArtifactsResolver.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/ArtifactsResolver.java
new file mode 100644
index 0000000..95f1edd
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/ArtifactsResolver.java
@@ -0,0 +1,27 @@
+package org.openecomp.sdc.be.components;
+
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+
+public interface ArtifactsResolver {
+
+    /**
+     * searching for an artifact with the give {@code artifactId} on the given {@code component}
+     * @param component the component to look for artifact in
+     * @param componentType the type of the component to look for artifact in
+     * @param artifactId the id of the artifact to find
+     * @return the found artifact or null if not exist
+     */
+    ArtifactDefinition findArtifactOnComponent(Component component, ComponentTypeEnum componentType, String artifactId);
+
+    /**
+     * searching for an artifact with the give {@code artifactId} on the given {@code componentInstance}
+     * @param componentInstance the component instance to look for the artifact in
+     * @param artifactId the if of the artifact to find
+     * @return the found artifact or null if not exist
+     */
+    ArtifactDefinition findArtifactOnComponentInstance(ComponentInstance componentInstance, String artifactId);
+
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/JsonContainerResourceInstance.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/JsonContainerResourceInstance.java
index d1b445b..5efcfe7 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/JsonContainerResourceInstance.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/JsonContainerResourceInstance.java
@@ -118,4 +118,11 @@
 	public void setSubcategory(String subcategory) {
 		this.subcategory = subcategory;
 	}
+
+	@Override
+	public String toString() {
+		return "JsonContainerResourceInstance [resourceInstanceName=" + resourceInstanceName + ", resourceName=" + resourceName + ", resourceVersion=" + resourceVersion + ", resoucreType=" + resoucreType + ", resourceUUID=" + resourceUUID
+				+ ", resourceInvariantUUID=" + resourceInvariantUUID + ", resourceCustomizationUUID=" + resourceCustomizationUUID + ", category=" + category + ", subcategory=" + subcategory + ", artifacts=" + artifacts + "]";
+	}
+	
 }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/NotificationDataImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/NotificationDataImpl.java
index 8a2ef8e..1494998 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/NotificationDataImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/NotificationDataImpl.java
@@ -77,9 +77,11 @@
 		this.serviceDescription = serviceDescription;
 	}
 
+	
 	@Override
 	public String toString() {
-		return "NotificationDataImpl [distributionID=" + distributionID + ", serviceName=" + serviceName + ", serviceVersion=" + serviceVersion + ", serviceUUID=" + serviceUUID + ", serviceInvariantUUID=" + serviceInvariantUUID + "]";
+		return "NotificationDataImpl [distributionID=" + distributionID + ", serviceName=" + serviceName + ", serviceVersion=" + serviceVersion + ", serviceUUID=" + serviceUUID + ", serviceDescription=" + serviceDescription
+				+ ", serviceInvariantUUID=" + serviceInvariantUUID + ", resources=" + resources + ", serviceArtifacts=" + serviceArtifacts + "]";
 	}
 
 	@Override
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
index 71593fa..2bcaa4f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/distribution/engine/VfModuleArtifactPayload.java
@@ -62,6 +62,8 @@
 		vfModuleModelDescription = group.getDescription();
 
 		artifacts = group.getArtifactsUuid();
+		artifacts.addAll(group.getGroupInstanceArtifactsUuid());
+		
 		// Base Value is set from properties
 		setBaseValue(group);
 		
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java
new file mode 100644
index 0000000..7ef3a19
--- /dev/null
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactResolverImpl.java
@@ -0,0 +1,62 @@
+package org.openecomp.sdc.be.components.impl;
+
+import org.openecomp.sdc.be.components.ArtifactsResolver;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.Service;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+@org.springframework.stereotype.Component("artifact-resolver")
+public class ArtifactResolverImpl implements ArtifactsResolver {
+
+    @Override
+    public ArtifactDefinition findArtifactOnComponent(Component component, ComponentTypeEnum componentType, String artifactId) {
+        List<ArtifactDefinition> allComponentsArtifacts = getAllComponentsArtifacts(component, componentType);
+        return findById(allComponentsArtifacts, artifactId);
+
+    }
+
+    @Override
+    public ArtifactDefinition findArtifactOnComponentInstance(ComponentInstance componentInstance, String artifactId) {
+        List<ArtifactDefinition> allInstanceArtifacts = getAllInstanceArtifacts(componentInstance);
+        return findById(allInstanceArtifacts, artifactId);
+    }
+
+    private ArtifactDefinition findById(List<ArtifactDefinition> artifacts, String artifactId) {
+        return artifacts.stream()
+                        .filter(artifact -> artifact.getUniqueId().equals(artifactId))
+                        .findFirst().orElse(null);
+    }
+
+    private List<ArtifactDefinition> getAllComponentsArtifacts(Component component, ComponentTypeEnum componentType) {
+        Map<String, ArtifactDefinition> deploymentArtifacts = Optional.ofNullable(component.getDeploymentArtifacts()).orElse(Collections.emptyMap());
+        Map<String, ArtifactDefinition> artifacts = Optional.ofNullable(component.getArtifacts()).orElse(Collections.emptyMap());
+        Map<String, ArtifactDefinition> serviceApiArtifacts = Collections.emptyMap();
+        if (componentType.equals(ComponentTypeEnum.SERVICE)) {
+            serviceApiArtifacts = Optional.ofNullable(((Service) component).getServiceApiArtifacts()).orElse(Collections.emptyMap());
+        }
+        return appendAllArtifacts(deploymentArtifacts, artifacts, serviceApiArtifacts);
+    }
+
+    private List<ArtifactDefinition> getAllInstanceArtifacts(ComponentInstance instance) {
+        Map<String, ArtifactDefinition> deploymentArtifacts = Optional.ofNullable(instance.getDeploymentArtifacts()).orElse(Collections.emptyMap());
+        Map<String, ArtifactDefinition> artifacts = Optional.ofNullable(instance.getArtifacts()).orElse(Collections.emptyMap());
+        return appendAllArtifacts(deploymentArtifacts, artifacts);
+    }
+
+    @SafeVarargs
+    private final List<ArtifactDefinition> appendAllArtifacts(Map<String, ArtifactDefinition>... artifacts) {
+        List<ArtifactDefinition> allArtifacts = new ArrayList<>();
+        Arrays.stream(artifacts).forEach(a -> allArtifacts.addAll(a.values()));
+        return allArtifacts;
+    }
+
+}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
index 6739d28..83c8183 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ArtifactsBusinessLogic.java
@@ -43,6 +43,7 @@
 import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.components.ArtifactsResolver;
 import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
 import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum;
 import org.openecomp.sdc.be.components.lifecycle.LifecycleBusinessLogic;
@@ -180,6 +181,9 @@
 	@Autowired
 	NodeTemplateOperation nodeTemplateOperation;
 
+	@Autowired
+	private ArtifactsResolver artifactsResolver;
+
 	public ArtifactsBusinessLogic() {
 		// defaultHeatTimeout = ConfigurationManager.getConfigurationManager().getConfiguration().getDefaultHeatArtifactTimeoutMinutes();
 		// if ((defaultHeatTimeout == null) || (defaultHeatTimeout < 1)) {
@@ -609,22 +613,22 @@
 			}
 			if (groupType == ArtifactGroupTypeEnum.DEPLOYMENT) {
 				List<ArtifactDefinition> list = getDeploymentArtifacts(component, componentType.getNodeType(), componentId);
-				if (list != null && !list.isEmpty()){
+				if (list != null && !list.isEmpty()) {
 					resMap = list.stream().collect(Collectors.toMap(a -> a.getArtifactLabel(), a -> a));
-				}else{
+				} else {
 					resMap = new HashMap<>();
 				}
 				resultOp = Either.left(resMap);
 				return resultOp;
 			} else {
 
-				Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifactsMapStatus = getArtifacts(realComponentId, componentType.getNodeType(), false, groupType, componentId	);
+				Either<Map<String, ArtifactDefinition>, StorageOperationStatus> artifactsMapStatus = getArtifacts(realComponentId, componentType.getNodeType(), false, groupType, componentId);
 				if (artifactsMapStatus.isRight()) {
 					if (artifactsMapStatus.right().value() != StorageOperationStatus.NOT_FOUND) {
 						ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.MISSING_INFORMATION);
 						log.debug("handleGetArtifactsByType - not falid groupType {} , component id {}", artifactGroupType, componentId);
 						resultOp = Either.right(responseFormat);
-					}else{
+					} else {
 						resMap = new HashMap<>();
 						resultOp = Either.left(resMap);
 					}
@@ -934,7 +938,7 @@
 		if (validateAndSetArtifactname.isRight()) {
 			return Either.right(validateAndSetArtifactname.right().value());
 		}
-		Either<ArtifactDefinition, ResponseFormat> artifactById = findArtifactOnParentComponent(parentComponent, parentId, operation, artifactId);
+		Either<ArtifactDefinition, ResponseFormat> artifactById = findArtifactOnParentComponent(parentComponent, componentType, parentId, operation, artifactId);
 		if (artifactById.isRight()) {
 			return Either.right(artifactById.right().value());
 		}
@@ -1033,27 +1037,12 @@
 		return Either.left(artifactInfo);
 	}
 
-	private Either<ArtifactDefinition, ResponseFormat> findArtifactOnParentComponent(Component parentComponent, String parentId, ArtifactOperationInfo operation, String artifactId) {
+	private Either<ArtifactDefinition, ResponseFormat> findArtifactOnParentComponent(Component parentComponent, ComponentTypeEnum componentType, String parentId, ArtifactOperationInfo operation, String artifactId) {
 
 		Either<ArtifactDefinition, ResponseFormat> result = null;
 		ArtifactDefinition foundArtifact = null;
 		if (StringUtils.isNotEmpty(artifactId)) {
-			if (parentComponent.getUniqueId().equals(parentId)) {
-				if (parentComponent.getDeploymentArtifacts() != null) {
-					foundArtifact = parentComponent.getDeploymentArtifacts().values().stream().filter(e -> e.getUniqueId().equals(artifactId)).findFirst().orElse(null);
-				}
-				if (foundArtifact == null && parentComponent.getArtifacts() != null) {
-					foundArtifact = parentComponent.getArtifacts().values().stream().filter(e -> e.getUniqueId().equals(artifactId)).findFirst().orElse(null);
-				}
-			} else {
-				ComponentInstance instance = findComponentInstance(parentId, parentComponent);
-				if (instance.getDeploymentArtifacts() != null) {
-					foundArtifact = instance.getDeploymentArtifacts().values().stream().filter(e -> e.getUniqueId().equals(artifactId)).findFirst().orElse(null);
-				}
-				if (foundArtifact == null && instance.getArtifacts() != null) {
-					foundArtifact = instance.getArtifacts().values().stream().filter(e -> e.getUniqueId().equals(artifactId)).findFirst().orElse(null);
-				}
-			}
+			foundArtifact = findArtifact(parentComponent, componentType, parentId, artifactId);
 		}
 		if (foundArtifact != null && operation.getArtifactOperationEnum() == ArtifactOperationEnum.Create) {
 			log.debug("Artifact {} already exist", artifactId);
@@ -1069,6 +1058,17 @@
 		return result;
 	}
 
+	private ArtifactDefinition findArtifact(Component parentComponent, ComponentTypeEnum componentType, String parentId, String artifactId) {
+		ArtifactDefinition foundArtifact;
+		if (parentComponent.getUniqueId().equals(parentId)) {
+            foundArtifact = artifactsResolver.findArtifactOnComponent(parentComponent, componentType, artifactId);
+        } else {
+            ComponentInstance instance = findComponentInstance(parentId, parentComponent);
+            foundArtifact = artifactsResolver.findArtifactOnComponentInstance(instance, artifactId);
+        }
+		return foundArtifact;
+	}
+
 	private Either<Boolean, ResponseFormat> validateInformationalArtifact(ArtifactDefinition artifactInfo, Component parentComponent) {
 		ComponentTypeEnum parentComponentType = parentComponent.getComponentType();
 		ArtifactGroupTypeEnum groupType = artifactInfo.getArtifactGroupType();
@@ -1254,11 +1254,11 @@
 			for (GroupInstance groupInstance : groupInstances) {
 				isUpdated = false;
 				if (CollectionUtils.isNotEmpty(groupInstance.getGroupInstanceArtifacts()) && groupInstance.getGroupInstanceArtifacts().contains(artifactId)) {
-					groupInstance.getArtifacts().remove(artifactId);
+					groupInstance.getGroupInstanceArtifacts().remove(artifactId);
 					isUpdated = true;
 				}
 				if (CollectionUtils.isNotEmpty(groupInstance.getGroupInstanceArtifactsUuid()) && groupInstance.getGroupInstanceArtifactsUuid().contains(foundArtifact.getArtifactUUID())) {
-					groupInstance.getArtifacts().remove(foundArtifact.getArtifactUUID());
+					groupInstance.getGroupInstanceArtifactsUuid().remove(foundArtifact.getArtifactUUID());
 					isUpdated = true;
 				}
 				if (isUpdated) {
@@ -1278,7 +1278,7 @@
 		if (isMandatory) {
 			log.debug("Going to update mandatory artifact {} from the component {}", artifactId, parentId);
 			resetMandatoryArtifactFields(foundArtifact);
-			result = artifactToscaOperation.updateArtifactOnGraph(componentId, foundArtifact, parentType, artifactId, instanceId);
+			result = artifactToscaOperation.updateArtifactOnGraph(componentId, foundArtifact, parentType, artifactId, instanceId, true);
 		} else if (cloneIsNeeded) {
 			log.debug("Going to clone artifacts and to delete the artifact {} from the component {}", artifactId, parentId);
 			result = artifactToscaOperation.deleteArtifactWithClonnigOnGraph(componentId, foundArtifact, parentType, instanceId, false);
@@ -2098,11 +2098,11 @@
 					return deploymentArtifacts;
 				}
 				ComponentInstance ri = getRI.left().value();
-				if(ri.getDeploymentArtifacts() != null){
+				if (ri.getDeploymentArtifacts() != null) {
 					deploymentArtifacts.addAll(ri.getDeploymentArtifacts().values());
 				}
-			} else if(parentComponent.getDeploymentArtifacts() !=null){
-					deploymentArtifacts.addAll(parentComponent.getDeploymentArtifacts().values());
+			} else if (parentComponent.getDeploymentArtifacts() != null) {
+				deploymentArtifacts.addAll(parentComponent.getDeploymentArtifacts().values());
 			}
 		}
 		return deploymentArtifacts;
@@ -3145,7 +3145,7 @@
 					}
 				}
 			}
-			if ( !found ){
+			if (!found) {
 				artifacts = resourceInstance.getArtifacts();
 				if (artifacts != null) {
 					for (Map.Entry<String, ArtifactDefinition> entry : artifacts.entrySet()) {
@@ -3154,7 +3154,7 @@
 							break;
 						}
 					}
-				}	
+				}
 			}
 		}
 		return found;
@@ -3370,7 +3370,37 @@
 	public Either<ArtifactDefinition, ResponseFormat> generateHeatEnvArtifact(ArtifactDefinition artifactDefinition, ComponentTypeEnum componentType, org.openecomp.sdc.be.model.Component component, String resourceInstanceName, User modifier,
 			boolean shouldLock, String instanceId) {
 		String payload = generateHeatEnvPayload(artifactDefinition);
-		return generateAndSaveHeatEnvArtifact(artifactDefinition, payload, componentType, component, resourceInstanceName, modifier, shouldLock, instanceId);
+		String prevUUID = artifactDefinition.getArtifactUUID();
+		ArtifactDefinition clonedBeforeGenerate = new ArtifactDefinition(artifactDefinition);
+		Either<ArtifactDefinition, ResponseFormat> generateResult = generateAndSaveHeatEnvArtifact(artifactDefinition, payload, componentType, component, resourceInstanceName, modifier, shouldLock, instanceId);
+		if (generateResult.isLeft()) {
+			ArtifactDefinition updatedArtDef = generateResult.left().value();
+			if (!prevUUID.equals(updatedArtDef.getArtifactUUID())) {
+				List<ComponentInstance> componentInstances = component.getComponentInstances();
+				if (componentInstances != null) {
+					Optional<ComponentInstance> findFirst = componentInstances.stream().filter(ci -> ci.getUniqueId().equals(instanceId)).findFirst();
+					if (findFirst.isPresent()) {
+						ComponentInstance relevantInst = findFirst.get();
+						List<GroupInstance> updatedGroupInstances = getUpdatedGroupInstances(updatedArtDef.getUniqueId(), clonedBeforeGenerate, relevantInst.getGroupInstances());
+
+						if (CollectionUtils.isNotEmpty(updatedGroupInstances)) {
+							updatedGroupInstances.forEach(gi -> {
+								gi.getGroupInstanceArtifacts().add(updatedArtDef.getUniqueId());
+								gi.getGroupInstanceArtifactsUuid().add(updatedArtDef.getArtifactUUID());
+							});
+							Either<List<GroupInstance>, StorageOperationStatus> status = toscaOperationFacade.updateGroupInstancesOnComponent(component, componentType, instanceId, updatedGroupInstances);
+							if (status.isRight()) {
+								log.debug("Failed to update groups of the component {}. ", component.getUniqueId());
+								ResponseFormat responseFormat = componentsUtils.getResponseFormatByArtifactId(componentsUtils.convertFromStorageResponse(status.right().value()), clonedBeforeGenerate.getArtifactDisplayName());
+								return Either.right(responseFormat);
+							}
+						}
+					}
+				}
+			}
+		}
+
+		return generateResult;
 	}
 
 	private String generateHeatEnvPayload(ArtifactDefinition artifactDefinition) {
@@ -3438,7 +3468,7 @@
 		}
 		sb.append(ConfigurationManager.getConfigurationManager().getConfiguration().getHeatEnvArtifactFooter());
 
-		// DE265919 fix Tal G
+		// DE265919 fix
 		String result = sb.toString().replaceAll("\\\\n", "\n");
 
 		return result;
@@ -3522,7 +3552,7 @@
 
 					oldCheckSum = artifactDefinition.getArtifactChecksum();
 					artifactDefinition.setArtifactChecksum(newCheckSum);
-					artifactToscaOperation.updateUUID(artifactDefinition, oldCheckSum, artifactDefinition.getArtifactVersion());
+//					artifactToscaOperation.updateUUID(artifactDefinition, oldCheckSum, artifactDefinition.getArtifactVersion());
 					artifactDefinition.setEsId(artifactDefinition.getUniqueId());
 					updateArifactDefinitionStatus = artifactToscaOperation.updateArifactOnResource(artifactDefinition, component.getUniqueId(), artifactDefinition.getUniqueId(), componentType.getNodeType(), instanceId);
 
@@ -3530,6 +3560,7 @@
 				}
 				if (updateArifactDefinitionStatus != null && updateArifactDefinitionStatus.isLeft()) {
 
+					artifactDefinition = updateArifactDefinitionStatus.left().value();
 					artifactData.setId(artifactDefinition.getUniqueId());
 					CassandraOperationStatus saveArtifactStatus = artifactCassandraDao.saveArtifact(artifactData);
 
@@ -3965,7 +3996,7 @@
 		String origMd5 = request.getHeader(Constants.MD5_HEADER);
 		String userId = request.getHeader(Constants.USER_ID_HEADER);
 
-		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata);
+		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true);
 		if (getComponentRes.isRight()) {
 			StorageOperationStatus status = getComponentRes.right().value();
 			log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status);
@@ -4026,7 +4057,7 @@
 		String userId = request.getHeader(Constants.USER_ID_HEADER);
 
 		ImmutablePair<Component, ComponentInstance> componentRiPair = null;
-		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata);
+		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true);
 		if (getComponentRes.isRight()) {
 			StorageOperationStatus status = getComponentRes.right().value();
 			log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status);
@@ -4089,7 +4120,7 @@
 		String origMd5 = request.getHeader(Constants.MD5_HEADER);
 		String userId = request.getHeader(Constants.USER_ID_HEADER);
 
-		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata);
+		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true);
 		if (getComponentRes.isRight()) {
 			StorageOperationStatus status = getComponentRes.right().value();
 			log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status);
@@ -4158,7 +4189,7 @@
 		String userId = request.getHeader(Constants.USER_ID_HEADER);
 
 		ImmutablePair<Component, ComponentInstance> componentRiPair = null;
-		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata);
+		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true);
 		if (getComponentRes.isRight()) {
 			StorageOperationStatus status = getComponentRes.right().value();
 			log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status);
@@ -4223,7 +4254,7 @@
 		String origMd5 = request.getHeader(Constants.MD5_HEADER);
 		String userId = request.getHeader(Constants.USER_ID_HEADER);
 
-		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata);
+		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true);
 		if (getComponentRes.isRight()) {
 			StorageOperationStatus status = getComponentRes.right().value();
 			log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status);
@@ -4288,7 +4319,7 @@
 		String origMd5 = request.getHeader(Constants.MD5_HEADER);
 		String userId = request.getHeader(Constants.USER_ID_HEADER);
 		ImmutablePair<Component, ComponentInstance> componentRiPair = null;
-		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata);
+		Either<ComponentMetadataData, StorageOperationStatus> getComponentRes = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, true);
 		if (getComponentRes.isRight()) {
 			StorageOperationStatus status = getComponentRes.right().value();
 			log.debug("Could not fetch component with type {} and uuid {}. Status is {}. ", componentType, componentUuid, status);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
index 84cf20d..4fd4610 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/AttributeBusinessLogic.java
@@ -28,8 +28,8 @@
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.AttributeDefinition;
 import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
 import org.openecomp.sdc.be.model.Resource;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -65,8 +65,8 @@
 	 * @param userId
 	 * @return AttributeDefinition if created successfully Or ResponseFormat
 	 */
-	public Either<AttributeDefinition, ResponseFormat> createAttribute(String resourceId, AttributeDefinition newAttributeDef, String userId) {
-		Either<AttributeDefinition, ResponseFormat> result = null;
+	public Either<PropertyDefinition, ResponseFormat> createAttribute(String resourceId, PropertyDefinition newAttributeDef, String userId) {
+		Either<PropertyDefinition, ResponseFormat> result = null;
 		Either<User, ResponseFormat> resp = validateUserExists(userId, "create Attribute", false);
 		if (resp.isRight()) {
 			return Either.right(resp.right().value());
@@ -111,7 +111,7 @@
 			// add the new attribute to resource on graph
 			// need to get StorageOpaerationStatus and convert to ActionStatus from
 			// componentsUtils
-			Either<AttributeDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
+			Either<PropertyDefinition, StorageOperationStatus> either = toscaOperationFacade.addAttributeOfResource(resource, newAttributeDef);
 			if (either.isRight()) {
 				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(either.right().value()), resource.getName()));
 				return result;
@@ -126,7 +126,7 @@
 
 	}
 
-	private boolean isAttributeExist(List<AttributeDefinition> attributes, String resourceUid, String propertyName) {
+	private boolean isAttributeExist(List<PropertyDefinition> attributes, String resourceUid, String propertyName) {
 		boolean isExist = false;
 		if (attributes != null) {
 			isExist = attributes.stream().filter(p -> Objects.equals(p.getName(), propertyName) && Objects.equals(p.getParentUniqueId(), resourceUid)).findAny().isPresent();
@@ -141,7 +141,7 @@
 	 * @param userId
 	 * @return
 	 */
-	public Either<AttributeDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
+	public Either<PropertyDefinition, ResponseFormat> getAttribute(String resourceId, String attributeId, String userId) {
 
 		Either<User, ResponseFormat> resp = validateUserExists(userId, "get Attribute", false);
 		if (resp.isRight()) {
@@ -155,13 +155,13 @@
 		}
 		Resource resource = status.left().value();
 
-		List<AttributeDefinition> attributes = resource.getAttributes();
+		List<PropertyDefinition> attributes = resource.getAttributes();
 		if (attributes == null) {
 			return Either.right(componentsUtils.getResponseFormat(ActionStatus.ATTRIBUTE_NOT_FOUND, ""));
 		} else {
-			Either<AttributeDefinition, ResponseFormat> result;
+			Either<PropertyDefinition, ResponseFormat> result;
 			// verify attribute exist in resource
-			Optional<AttributeDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && att.getParentUniqueId().equals(resourceId)).findAny();
+			Optional<PropertyDefinition> optionalAtt = attributes.stream().filter(att -> att.getUniqueId().equals(attributeId) && att.getParentUniqueId().equals(resourceId)).findAny();
 
 			if (optionalAtt.isPresent()) {
 				result = Either.left(optionalAtt.get());
@@ -182,8 +182,8 @@
 	 * @param userId
 	 * @return
 	 */
-	public Either<AttributeDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, AttributeDefinition newAttDef, String userId) {
-		Either<AttributeDefinition, ResponseFormat> result = null;
+	public Either<PropertyDefinition, ResponseFormat> updateAttribute(String resourceId, String attributeId, PropertyDefinition newAttDef, String userId) {
+		Either<PropertyDefinition, ResponseFormat> result = null;
 
 		StorageOperationStatus lockResult = graphLockOperation.lockComponent(resourceId, NodeTypeEnum.Resource);
 		if (lockResult != StorageOperationStatus.OK) {
@@ -205,7 +205,7 @@
 			}
 
 			// verify attribute exist in resource
-			Either<AttributeDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
+			Either<PropertyDefinition, ResponseFormat> eitherAttribute = getAttribute(resourceId, attributeId, userId);
 			if (eitherAttribute.isRight()) {
 				return Either.right(eitherAttribute.right().value());
 			}
@@ -228,7 +228,7 @@
 			}
 
 			
-			Either<AttributeDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
+			Either<PropertyDefinition, StorageOperationStatus> eitherAttUpdate = toscaOperationFacade.updateAttributeOfResource(resource, newAttDef);
 
 			if (eitherAttUpdate.isRight()) {
 				log.debug("Problem while updating attribute with id {}. Reason - {}", attributeId, eitherAttUpdate.right().value());
@@ -253,9 +253,9 @@
 	 * @param userId
 	 * @return
 	 */
-	public Either<AttributeDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
+	public Either<PropertyDefinition, ResponseFormat> deleteAttribute(String resourceId, String attributeId, String userId) {
 
-		Either<AttributeDefinition, ResponseFormat> result = null;
+		Either<PropertyDefinition, ResponseFormat> result = null;
 
 		Either<User, ResponseFormat> resp = validateUserExists(userId, "delete Attribute", false);
 		if (resp.isRight()) {
@@ -283,7 +283,7 @@
 			}
 
 			// verify attribute exist in resource
-			Either<AttributeDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
+			Either<PropertyDefinition, ResponseFormat> eitherAttributeExist = getAttribute(resourceId, attributeId, userId);
 			if (eitherAttributeExist.isRight()) {
 				return Either.right(eitherAttributeExist.right().value());
 			}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
index f880883..5ee5c88 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentBusinessLogic.java
@@ -21,38 +21,31 @@
 package org.openecomp.sdc.be.components.impl;
 
 import java.util.ArrayList;
-import java.util.Collection;
 import java.util.EnumMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.function.Function;
-import java.util.function.Predicate;
 import java.util.stream.Collectors;
 
 import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.collections.MapUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
 import org.openecomp.sdc.be.config.ConfigurationManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
 import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
-import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
-import org.openecomp.sdc.be.datatypes.components.ComponentMetadataDataDefinition;
 import org.openecomp.sdc.be.datatypes.components.ServiceMetadataDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
-import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
 import org.openecomp.sdc.be.model.ArtifactDefinition;
 import org.openecomp.sdc.be.model.CapReqDef;
-import org.openecomp.sdc.be.model.CapabilityDefinition;
 import org.openecomp.sdc.be.model.Component;
 import org.openecomp.sdc.be.model.ComponentInstance;
 import org.openecomp.sdc.be.model.ComponentInstanceInput;
@@ -64,13 +57,10 @@
 import org.openecomp.sdc.be.model.LifecycleStateEnum;
 import org.openecomp.sdc.be.model.Operation;
 import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.openecomp.sdc.be.model.RequirementDefinition;
 import org.openecomp.sdc.be.model.Resource;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.model.cache.ComponentCache;
 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.ComponentOperation;
-import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
 import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
 import org.openecomp.sdc.be.resources.data.ComponentMetadataData;
 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
@@ -87,9 +77,6 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 
-import com.datastax.driver.core.UserType.Field;
-import com.wordnik.swagger.models.auth.In;
-
 import fj.data.Either;
 
 public abstract class ComponentBusinessLogic extends BaseBusinessLogic {
@@ -283,40 +270,43 @@
 	}
 
 	
-	public Either<Boolean, ResponseFormat> validateConformanceLevel(String componentId, ComponentTypeEnum componentTypeEnum, String userId) {
+	public Either<Boolean, ResponseFormat> validateConformanceLevel(String componentUuid, ComponentTypeEnum componentTypeEnum, String userId) {
 		log.trace("validate conformance level");
 		
 		if (componentTypeEnum != ComponentTypeEnum.SERVICE) {
-			log.error("conformance level validation for non service component, id {}", componentId);
+			log.error("conformance level validation for non service component, id {}", componentUuid);
 			ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT);
 			return Either.right(errorResponse);
 		}
 		
 		Either<User, ResponseFormat> resp = validateUserExists(userId, "validateConformanceLevel", false);
 		if (resp.isRight()) {
-			log.error("can't validate conformance level, user is not validated, id {}, userId {}", componentId, userId);
+			log.error("can't validate conformance level, user is not validated, uuid {}, userId {}", componentUuid, userId);
 			return Either.right(resp.right().value());
 		}
 		
-		ComponentParametersView filter = new ComponentParametersView(true);
-		Either<Component, ResponseFormat> eitherComponent = validateComponentExists(componentId, componentTypeEnum, filter);
+		Either<ComponentMetadataData, StorageOperationStatus> eitherComponent = toscaOperationFacade.getLatestComponentMetadataByUuid(componentUuid, JsonParseFlagEnum.ParseMetadata, null);
 		if (eitherComponent.isRight()) {
-			log.error("can't validate conformance level, component not found, id {}", componentId);
-			BeEcompErrorManager.getInstance().logBeComponentMissingError("validateConformanceLevel", componentTypeEnum.getValue(), componentId);
-			return Either.right(eitherComponent.right().value());
+			log.error("can't validate conformance level, component not found, uuid {}", componentUuid);
+			BeEcompErrorManager.getInstance().logBeComponentMissingError("validateConformanceLevel", componentTypeEnum.getValue(), componentUuid);
+			
+			StorageOperationStatus status = eitherComponent.right().value();
+			ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(status, componentTypeEnum);
+			ResponseFormat responseFormat = componentsUtils.getResponseFormat(actionStatus);
+			return Either.right(responseFormat);
 		}
 		
-		Component component = eitherComponent.left().value();
-		if (component.getConformanceLevel() == null || "".equals(component.getConformanceLevel())) {
-			log.error("component conformance level property is null or empty, id {}", componentId);
+		String componentConformanceLevel = eitherComponent.left().value().getMetadataDataDefinition().getConformanceLevel();
+		if (StringUtils.isBlank(componentConformanceLevel)) {
+			log.error("component conformance level property is null or empty, uuid {}", componentUuid);
 			ResponseFormat errorResponse = componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR);
 			return Either.right(errorResponse);
 		}
 		
 		String configConformanceLevel = ConfigurationManager.getConfigurationManager().getConfiguration().getMinToscaConformanceLevel();
 		Boolean result = true;
-		if (CommonBeUtils.conformanceLevelCompare(component.getConformanceLevel(), configConformanceLevel) < 0) {
-			log.error("invalid asset conformance level, id {}, asset conformanceLevel {}, config conformanceLevel {}", componentId, component.getConformanceLevel(), configConformanceLevel);
+		if (CommonBeUtils.conformanceLevelCompare(componentConformanceLevel, configConformanceLevel) < 0) {
+			log.error("invalid asset conformance level, uuid {}, asset conformanceLevel {}, config conformanceLevel {}", componentUuid, componentConformanceLevel, configConformanceLevel);
 			result = false;
 		}
 		log.trace("conformance level validation finished");
@@ -1154,9 +1144,7 @@
 			return Either.right(fetchAndSetLatestGeneric.right().value());
 		Resource genericTypeResource = fetchAndSetLatestGeneric.left().value();
 		if(null == currentGenericType || !currentGenericType.equals(genericTypeResource.getToscaResourceName()) || !currentGenericVersion.equals(genericTypeResource.getVersion())){
-			List<PropertyDefinition> genericTypeProps = genericTypeResource.getProperties();
-			List<InputDefinition> genericTypeInputs = null == genericTypeProps? null : convertGenericTypePropertiesToInputsDefintion(genericTypeProps, genericTypeResource.getUniqueId());
-			shouldUpgrade = upgradeToLatestGeneric(clonedComponent, genericTypeInputs);
+			shouldUpgrade = upgradeToLatestGeneric(clonedComponent, genericTypeResource);
 			if(!shouldUpgrade) {
 				reverntUpdateOfGenericVersion(clonedComponent, currentGenericType, currentGenericVersion);
 			}
@@ -1169,12 +1157,37 @@
 		clonedComponent.setDerivedFromGenericVersion(currentGenericVersion);
 	} 
 	
+	private <T extends PropertyDataDefinition> Either<Map<String, T>, String> validateNoConflictingProperties(List<T> currentList, List<T> upgradedList) {
+		Map<String, T> currentMap = ToscaDataDefinition.listToMapByName(currentList);
+		Map<String, T> upgradedMap = ToscaDataDefinition.listToMapByName(upgradedList);
+		return ToscaDataDefinition.mergeDataMaps(upgradedMap, currentMap, true);
+	}
 	
-	private boolean upgradeToLatestGeneric(Component componentToCheckOut, List<InputDefinition> upgradedList) {
+	private boolean shouldUpgradeNodeType(Component componentToCheckOut, Resource latestGeneric){
 		
-		if (!componentToCheckOut.shouldGenerateInputs())
-			return true;
-		
+		List<PropertyDefinition> genericTypeProps = latestGeneric.getProperties();
+		Either<Map<String, PropertyDefinition>, String> validMerge = validateNoConflictingProperties(genericTypeProps, ((Resource)componentToCheckOut).getProperties());
+		if (validMerge.isRight()) { 
+			log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic", validMerge.right().value());
+			return false;
+		}
+		List<PropertyDefinition> genericTypeAttributes = latestGeneric.getAttributes();
+		validMerge = validateNoConflictingProperties(genericTypeAttributes, ((Resource)componentToCheckOut).getAttributes());
+		if (validMerge.isRight()) { 
+			log.debug("attribute {} cannot be overriden, check out performed without upgrading to latest generic", validMerge.right().value());
+			return false;
+		}
+		return true;
+	}
+	
+    private boolean upgradeToLatestGeneric(Component componentToCheckOut, Resource latestGeneric) {
+    	
+		if (!componentToCheckOut.shouldGenerateInputs()) {
+			//node type - validate properties and attributes
+			return shouldUpgradeNodeType(componentToCheckOut, latestGeneric);
+		}
+		List<PropertyDefinition> genericTypeProps = latestGeneric.getProperties();	
+		List<InputDefinition> genericTypeInputs = null == genericTypeProps? null : convertGenericTypePropertiesToInputsDefintion(genericTypeProps, latestGeneric.getUniqueId());
 		List<InputDefinition> currentList = new ArrayList<>();	
 	    // nullify existing ownerId from existing list and merge into updated list
 		if (null != componentToCheckOut.getInputs()) {
@@ -1184,20 +1197,20 @@
 				currentList.add(copy);
 			}
 		}
-		if (null == upgradedList) {
+		if (null == genericTypeInputs) {
 			componentToCheckOut.setInputs(currentList);
 			return true;
 		}
-		Map<String, InputDefinition> currentMap = PropertyDataDefinition.listToMapByName(currentList);
-		Map<String, InputDefinition> upgradedMap = PropertyDataDefinition.listToMapByName(upgradedList);
-		Either<Map<String, InputDefinition>, String> eitherMerged = PropertyDataDefinition.mergeProperties(upgradedMap, currentMap, true);
+		
+		Either<Map<String, InputDefinition>, String> eitherMerged = validateNoConflictingProperties(genericTypeInputs, currentList);
 		if (eitherMerged.isRight()) { 
-			log.debug("property {} cannot be overriden, check out performed without upgrading to latest generic", eitherMerged.right().value());
+			log.debug("input {} cannot be overriden, check out performed without upgrading to latest generic", eitherMerged.right().value());
 			return false;
 		}
 		componentToCheckOut.setInputs(new ArrayList<InputDefinition>(eitherMerged.left().value().values()));
 		return true;
 	}
+	
 
 	private List<ComponentInstance> getFilteredInstances(Component component, List<String> resourceTypes) {
 		List<ComponentInstance> filteredInstances = null;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
index 1623375..203a638 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
@@ -51,7 +51,6 @@
 import org.openecomp.sdc.be.model.ArtifactDefinition;
 import org.openecomp.sdc.be.model.Component;
 import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
 import org.openecomp.sdc.be.model.ComponentInstanceInput;
 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
 import org.openecomp.sdc.be.model.ComponentParametersView;
@@ -338,6 +337,10 @@
 		
 		for (ArtifactDefinition artifact : componentDeploymentArtifacts.values()) {
 			String type = artifact.getArtifactType();
+			
+			if ( !type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_ENV.getType()) ){
+				finalDeploymentArtifacts.put(artifact.getArtifactLabel(), artifact);
+			}
 
 			if (!(type.equalsIgnoreCase(ArtifactTypeEnum.HEAT.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_NET.getType()) || type.equalsIgnoreCase(ArtifactTypeEnum.HEAT_VOL.getType()))) {
 				continue;
@@ -351,9 +354,6 @@
 				}
 				ArtifactDefinition artifactDefinition = createHeatEnvPlaceHolder.left().value();
 				
-				//put heat
-				finalDeploymentArtifacts.put(artifact.getArtifactLabel(), artifact);
-						
 				//put env
 				finalDeploymentArtifacts.put(artifactDefinition.getArtifactLabel(), artifactDefinition);
 				
@@ -890,12 +890,12 @@
 		}
 	}
 
-	private Either<ComponentInstanceAttribute, ResponseFormat> updateAttributeValue(ComponentInstanceAttribute attribute, String resourceInstanceId) {
-		Either<ComponentInstanceAttribute, StorageOperationStatus> eitherAttribute = componentInstanceOperation.updateAttributeValueInResourceInstance(attribute, resourceInstanceId, true);
-		Either<ComponentInstanceAttribute, ResponseFormat> result;
+	private Either<ComponentInstanceProperty, ResponseFormat> updateAttributeValue(ComponentInstanceProperty attribute, String resourceInstanceId) {
+		Either<ComponentInstanceProperty, StorageOperationStatus> eitherAttribute = componentInstanceOperation.updateAttributeValueInResourceInstance(attribute, resourceInstanceId, true);
+		Either<ComponentInstanceProperty, ResponseFormat> result;
 		if (eitherAttribute.isLeft()) {
 			log.debug("Attribute value {} was updated on graph.", attribute.getValueUniqueUid());
-			ComponentInstanceAttribute instanceAttribute = eitherAttribute.left().value();
+			ComponentInstanceProperty instanceAttribute = eitherAttribute.left().value();
 
 			result = Either.left(instanceAttribute);
 
@@ -910,9 +910,9 @@
 		return result;
 	}
 
-	private Either<ComponentInstanceAttribute, ResponseFormat> createAttributeValue(ComponentInstanceAttribute attribute, String resourceInstanceId) {
+	private Either<ComponentInstanceProperty, ResponseFormat> createAttributeValue(ComponentInstanceProperty attribute, String resourceInstanceId) {
 
-		Either<ComponentInstanceAttribute, ResponseFormat> result;
+		Either<ComponentInstanceProperty, ResponseFormat> result;
 
 		Wrapper<Integer> indexCounterWrapper = new Wrapper<>();
 		Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
@@ -921,10 +921,10 @@
 		if (!errorWrapper.isEmpty()) {
 			result = Either.right(errorWrapper.getInnerElement());
 		} else {
-			Either<ComponentInstanceAttribute, StorageOperationStatus> eitherAttribute = componentInstanceOperation.addAttributeValueToResourceInstance(attribute, resourceInstanceId, indexCounterWrapper.getInnerElement(), true);
+			Either<ComponentInstanceProperty, StorageOperationStatus> eitherAttribute = componentInstanceOperation.addAttributeValueToResourceInstance(attribute, resourceInstanceId, indexCounterWrapper.getInnerElement(), true);
 			if (eitherAttribute.isLeft()) {
 				log.debug("Attribute value was added to resource instance {}", resourceInstanceId);
-				ComponentInstanceAttribute instanceAttribute = eitherAttribute.left().value();
+				ComponentInstanceProperty instanceAttribute = eitherAttribute.left().value();
 				result = Either.left(instanceAttribute);
 
 			} else {
@@ -948,8 +948,8 @@
 	 * @param userId
 	 * @return
 	 */
-	public Either<ComponentInstanceAttribute, ResponseFormat> createOrUpdateAttributeValue(ComponentTypeEnum componentTypeEnum, String componentId, String resourceInstanceId, ComponentInstanceAttribute attribute, String userId) {
-		Either<ComponentInstanceAttribute, ResponseFormat> result = null;
+	public Either<ComponentInstanceProperty, ResponseFormat> createOrUpdateAttributeValue(ComponentTypeEnum componentTypeEnum, String componentId, String resourceInstanceId, ComponentInstanceProperty attribute, String userId) {
+		Either<ComponentInstanceProperty, ResponseFormat> result = null;
 		Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
 
 		validateUserExist(userId, "create Or Update Attribute Value", errorWrapper);
@@ -1104,8 +1104,6 @@
 			BeEcompErrorManager.getInstance().logBeInvalidValueError("Add property value", pair.getLeft(), property.getName(), propertyType);
 			return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertTitanStatusToStorageStatus(TitanOperationStatus.ILLEGAL_ARGUMENT))));
 		}
-		
-		
 
 		try {
 			List<ComponentInstanceProperty> instanceProperties = containerComponent.getComponentInstancesProperties().get(resourceInstanceId);
@@ -1122,6 +1120,10 @@
 				resultOp = Either.right(componentsUtils.getResponseFormatForResourceInstanceProperty(actionStatus, ""));
 				return resultOp;
 			}
+			List<String> path = new ArrayList<>();
+			path.add(foundResourceInstance.getUniqueId());
+			property.setPath(path);
+			
 			foundResourceInstance.setCustomizationUUID(UUID.randomUUID().toString());
 			Either<Component, StorageOperationStatus> updateContainerRes = toscaOperationFacade.updateComponentInstanceMetadataOfTopologyTemplate(containerComponent);
 			
@@ -1603,7 +1605,7 @@
 				return resultOp;
 			}
 
-			List<GroupInstance> groupInstances = currentResourceInstance.getGroupInstances();
+		//	List<GroupInstance> groupInstances = currentResourceInstance.getGroupInstances();
 			Map<String, ArtifactDefinition> deploymentArtifacts =  currentResourceInstance.getDeploymentArtifacts();
 			resultOp = deleteComponentInstance(containerComponent, componentInstanceId, containerComponentType);
 			if (resultOp.isRight()) {
@@ -1639,13 +1641,15 @@
 				return resultOp;
 			}
 
-			if (CollectionUtils.isNotEmpty(groupInstances)) {
+	/*		if (CollectionUtils.isNotEmpty(groupInstances)) {
 				StorageOperationStatus addGroupsToComponentInstance = toscaOperationFacade.addGroupInstancesToComponentInstance(containerComponent, updatedComponentInstance, groupInstances);
 				if (addGroupsToComponentInstance != StorageOperationStatus.OK) {
 					BeEcompErrorManager.getInstance().logInternalFlowError("ChangeComponentInstanceVersion", "Failed to associate groups to new component instance", ErrorSeverity.ERROR);
 					resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
 					return resultOp;
 				}
+			
+				
 			}
 			if (MapUtils.isNotEmpty(deploymentArtifacts)) {
 				StorageOperationStatus addDeploymentArtifactsToComponentInstance = toscaOperationFacade.addDeploymentArtifactsToComponentInstance(containerComponent, updatedComponentInstance, deploymentArtifacts);
@@ -1654,7 +1658,7 @@
 					resultOp = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
 					return resultOp;
 				}
-			}
+			}*/
 
 			
 			ComponentParametersView filter = new ComponentParametersView(true);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
index ae62378..3d280ab 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/CsarValidationUtils.java
@@ -289,7 +289,7 @@
 			return Either.right(componentsUtils.getResponseFormat(ActionStatus.CSAR_INVALID, csarUUID));
 		}
 		byte[] toscaMetaBytes = csar.get(TOSCA_METADATA_FILE);
-		// Tal && exchanged for ||
+		// && exchanged for ||
 		if (toscaMetaBytes == null || toscaMetaBytes.length == 0) {
 			log.debug("TOSCA-Metadata/TOSCA.meta file not found in csar, csar ID {}", csarUUID);
 			BeEcompErrorManager.getInstance().logInternalDataError("TOSCA-Metadata/TOSCA.meta file not found in CSAR with id " + csarUUID, "CSAR structure is invalid", ErrorSeverity.ERROR);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
index 958adc0..d874673 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
@@ -990,9 +990,9 @@
 		}
 		Map<String, List<? extends Component>> resMap = new HashMap<>();
 
-		Either<List<Resource>, StorageOperationStatus> resResources = toscaOperationFacade.getCatalogComponents(ComponentTypeEnum.RESOURCE);
+		Either<List<Resource>, StorageOperationStatus> resResources = toscaOperationFacade.getCatalogComponents(ComponentTypeEnum.RESOURCE, true);
 		if (resResources.isLeft()) {
-			Either<List<Service>, StorageOperationStatus> resServices = toscaOperationFacade.getCatalogComponents(ComponentTypeEnum.SERVICE);
+			Either<List<Service>, StorageOperationStatus> resServices = toscaOperationFacade.getCatalogComponents(ComponentTypeEnum.SERVICE, true);
 			if (resServices.isLeft()) {
 				// Either<List<Product>, StorageOperationStatus> resProducts = productOperation.getProductCatalogData(false);
 				// if (resProducts.isLeft()) {
@@ -1021,7 +1021,7 @@
 		}
 
 		if (filters == null || filters.isEmpty()) {
-			Either<List<Component>, StorageOperationStatus> componentsList = toscaOperationFacade.getCatalogComponents(assetTypeEnum);
+			Either<List<Component>, StorageOperationStatus> componentsList = toscaOperationFacade.getCatalogComponents(assetTypeEnum, false);
 			if(componentsList.isRight()) {
 				return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(componentsList.right().value())));
 			}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
index ba08f11..f298b0f 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupBusinessLogic.java
@@ -79,6 +79,7 @@
 import org.openecomp.sdc.be.model.operations.impl.GroupOperation;
 import org.openecomp.sdc.be.model.operations.impl.GroupTypeOperation;
 import org.openecomp.sdc.be.model.operations.impl.UniqueIdBuilder;
+import org.openecomp.sdc.common.api.ArtifactTypeEnum;
 import org.openecomp.sdc.common.api.Constants;
 import org.openecomp.sdc.exception.ResponseFormat;
 import org.slf4j.Logger;
@@ -112,7 +113,6 @@
 	@javax.annotation.Resource
 	private GroupTypeOperation groupTypeOperation;
 
-	
 	@Autowired
 	ArtifactsOperations artifactsOperation;
 
@@ -121,7 +121,6 @@
 	@Autowired
 	private ApplicationDataTypeCache dataTypeCache;
 
-
 	/**
 	 * 
 	 * 1. validate user exist
@@ -145,67 +144,39 @@
 	 * @param inTransaction
 	 * @return
 	 */
-	/*public Either<GroupDefinition, ResponseFormat> createGroup(String componentId, String userId, ComponentTypeEnum componentType, GroupDefinition groupDefinition, boolean inTransaction) {
-
-		Either<GroupDefinition, ResponseFormat> result = null;
-
-		try {
-			Either<User, ResponseFormat> validateUserExists = validateUserExists(userId, CREATE_GROUP, inTransaction);
-
-			if (validateUserExists.isRight()) {
-				result = Either.right(validateUserExists.right().value());
-				return result;
-			}
-
-			User user = validateUserExists.left().value();
-			// 5. check service/resource existence
-			// 6. check service/resource check out
-			// 7. user is owner of checkout state
-			org.openecomp.sdc.be.model.Component component = null;
-
-			// String realComponentId = componentType ==
-			// ComponentTypeEnum.RESOURCE_INSTANCE ? parentId : componentId;
-			String realComponentId = componentId;
-
-			ComponentParametersView componentParametersView = new ComponentParametersView();
-			componentParametersView.disableAll();
-			componentParametersView.setIgnoreGroups(false);
-			componentParametersView.setIgnoreArtifacts(false);
-			componentParametersView.setIgnoreUsers(false);
-			componentParametersView.setIgnoreComponentInstances(false);
-
-			Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> validateComponent = validateComponentExists(realComponentId, componentType, componentParametersView);
-
-			if (validateComponent.isRight()) {
-				result = Either.right(validateComponent.right().value());
-				return result;
-			}
-			component = validateComponent.left().value();
-			Either<Boolean, ResponseFormat> canWork = validateCanWorkOnComponent(component, userId);
-			if (canWork.isRight()) {
-				result = Either.right(canWork.right().value());
-				return result;
-			}
-
-			result = this.createGroup(component, user, componentType, groupDefinition, inTransaction);
-			return result;
-
-		} finally {
-
-			if (false == inTransaction) {
-
-				if (result == null || result.isRight()) {
-					log.debug("Going to execute rollback on create group.");
-					titanDao.rollback();
-				} else {
-					log.debug("Going to execute commit on create group.");
-					titanDao.commit();
-				}
-
-			}
-
-		}
-	}*/
+	/*
+	 * public Either<GroupDefinition, ResponseFormat> createGroup(String componentId, String userId, ComponentTypeEnum componentType, GroupDefinition groupDefinition, boolean inTransaction) {
+	 * 
+	 * Either<GroupDefinition, ResponseFormat> result = null;
+	 * 
+	 * try { Either<User, ResponseFormat> validateUserExists = validateUserExists(userId, CREATE_GROUP, inTransaction);
+	 * 
+	 * if (validateUserExists.isRight()) { result = Either.right(validateUserExists.right().value()); return result; }
+	 * 
+	 * User user = validateUserExists.left().value(); // 5. check service/resource existence // 6. check service/resource check out // 7. user is owner of checkout state org.openecomp.sdc.be.model.Component component = null;
+	 * 
+	 * // String realComponentId = componentType == // ComponentTypeEnum.RESOURCE_INSTANCE ? parentId : componentId; String realComponentId = componentId;
+	 * 
+	 * ComponentParametersView componentParametersView = new ComponentParametersView(); componentParametersView.disableAll(); componentParametersView.setIgnoreGroups(false); componentParametersView.setIgnoreArtifacts(false);
+	 * componentParametersView.setIgnoreUsers(false); componentParametersView.setIgnoreComponentInstances(false);
+	 * 
+	 * Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> validateComponent = validateComponentExists(realComponentId, componentType, componentParametersView);
+	 * 
+	 * if (validateComponent.isRight()) { result = Either.right(validateComponent.right().value()); return result; } component = validateComponent.left().value(); Either<Boolean, ResponseFormat> canWork = validateCanWorkOnComponent(component,
+	 * userId); if (canWork.isRight()) { result = Either.right(canWork.right().value()); return result; }
+	 * 
+	 * result = this.createGroup(component, user, componentType, groupDefinition, inTransaction); return result;
+	 * 
+	 * } finally {
+	 * 
+	 * if (false == inTransaction) {
+	 * 
+	 * if (result == null || result.isRight()) { log.debug("Going to execute rollback on create group."); titanDao.rollback(); } else { log.debug("Going to execute commit on create group."); titanDao.commit(); }
+	 * 
+	 * }
+	 * 
+	 * } }
+	 */
 
 	private String getComponentTypeForResponse(org.openecomp.sdc.be.model.Component component) {
 		String componentTypeForResponse = "SERVICE";
@@ -235,7 +206,7 @@
 		}
 
 		List<String> currentArtifacts = deploymentArtifacts.values().stream().map(p -> p.getUniqueId()).collect(Collectors.toList());
-		log.debug("The deployment artifacts of component {} are {}" ,  component.getNormalizedName(), deploymentArtifacts);
+		log.debug("The deployment artifacts of component {} are {}", component.getNormalizedName(), deploymentArtifacts);
 		if (false == currentArtifacts.containsAll(artifacts)) {
 			BeEcompErrorManager.getInstance().logInvalidInputError(context, "Not all artifacts belongs to component " + component.getNormalizedName(), ErrorSeverity.INFO);
 			return Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_CONTENT));
@@ -285,48 +256,48 @@
 				}
 			}
 
-//			ComponentOperation componentOperation = getComponentOperationByParentComponentType(componentType);
-//			if (componentOperation instanceof ResourceOperation) {
-//				ResourceOperation resourceOperation = (ResourceOperation) componentOperation;
-//
-//				for (Entry<String, String> groupMember : groupMembers.entrySet()) {
-//
-//					String componentInstName = groupMember.getKey();
-//					String componentInstUid = groupMember.getValue();
-//
-//					ComponentInstance componentInstance = compInstUidToCompInstMap.get(componentInstUid);
-//					String componentUid = componentInstance.getComponentUid();
-//					List<String> componentToscaNames = new ArrayList<>();
-//					TitanOperationStatus status = resourceOperation.fillResourceDerivedListFromGraph(componentUid, componentToscaNames);
-//					if (status != TitanOperationStatus.OK) {
-//						BeEcompErrorManager.getInstance().logInternalFlowError(CREATE_GROUP, "Cannot find tosca list of component id " + componentUid, ErrorSeverity.ERROR);
-//						return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
-//					}
-//
-//					log.debug("The tosca names of component id {} are {}", componentUid,  memberToscaTypes);
-//
-//					boolean found = false;
-//					for (String memberToscaType : memberToscaTypes) {
-//						if (componentToscaNames.contains(memberToscaType)) {
-//							found = true;
-//							break;
-//						}
-//					}
-//					if (found == false) {
-//						BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_GROUP,
-//								"No tosca types from " + memberToscaTypes + " can be found in the tosca list " + componentToscaNames + " of component " + componentInstance.getNormalizedName(), ErrorSeverity.INFO);
-//						/*
-//						 * # %1 - member name # %2 - group name # %3 - group type
-//						 */
-//						return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_INVALID_TOSCA_NAME_OF_COMPONENT_INSTANCE, componentInstName, groupName, groupType));
-//					} else {
-//						log.debug("Component instance {} fits to one of the required tosca types", componentInstance.getNormalizedName());
-//					}
-//				}
-//			} else {
-//				BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_GROUP, "Cannot find tosca list since it is not supported for product", ErrorSeverity.ERROR);
-//				return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
-//			}
+			// ComponentOperation componentOperation = getComponentOperationByParentComponentType(componentType);
+			// if (componentOperation instanceof ResourceOperation) {
+			// ResourceOperation resourceOperation = (ResourceOperation) componentOperation;
+			//
+			// for (Entry<String, String> groupMember : groupMembers.entrySet()) {
+			//
+			// String componentInstName = groupMember.getKey();
+			// String componentInstUid = groupMember.getValue();
+			//
+			// ComponentInstance componentInstance = compInstUidToCompInstMap.get(componentInstUid);
+			// String componentUid = componentInstance.getComponentUid();
+			// List<String> componentToscaNames = new ArrayList<>();
+			// TitanOperationStatus status = resourceOperation.fillResourceDerivedListFromGraph(componentUid, componentToscaNames);
+			// if (status != TitanOperationStatus.OK) {
+			// BeEcompErrorManager.getInstance().logInternalFlowError(CREATE_GROUP, "Cannot find tosca list of component id " + componentUid, ErrorSeverity.ERROR);
+			// return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
+			// }
+			//
+			// log.debug("The tosca names of component id {} are {}", componentUid, memberToscaTypes);
+			//
+			// boolean found = false;
+			// for (String memberToscaType : memberToscaTypes) {
+			// if (componentToscaNames.contains(memberToscaType)) {
+			// found = true;
+			// break;
+			// }
+			// }
+			// if (found == false) {
+			// BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_GROUP,
+			// "No tosca types from " + memberToscaTypes + " can be found in the tosca list " + componentToscaNames + " of component " + componentInstance.getNormalizedName(), ErrorSeverity.INFO);
+			// /*
+			// * # %1 - member name # %2 - group name # %3 - group type
+			// */
+			// return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_INVALID_TOSCA_NAME_OF_COMPONENT_INSTANCE, componentInstName, groupName, groupType));
+			// } else {
+			// log.debug("Component instance {} fits to one of the required tosca types", componentInstance.getNormalizedName());
+			// }
+			// }
+			// } else {
+			// BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_GROUP, "Cannot find tosca list since it is not supported for product", ErrorSeverity.ERROR);
+			// return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
+			// }
 
 		}
 
@@ -340,21 +311,12 @@
 	 * @param inTransaction
 	 * @return
 	 */
-	/*public Either<GroupDefinition, StorageOperationStatus> updateGroupVersion(GroupDefinition groupDefinition, boolean inTransaction) {
-		Either<GroupDefinition, StorageOperationStatus> result = null;
-		List<String> groupIdsToUpdateVersion = new ArrayList<>();
-		groupIdsToUpdateVersion.add(groupDefinition.getUniqueId());
-		Either<List<GroupDefinition>, StorageOperationStatus> updateGroupVersion = updateGroupVersion(groupIdsToUpdateVersion, inTransaction);
-		if (updateGroupVersion.isLeft()) {
-			result = Either.left(updateGroupVersion.left().value().get(0));
-		} else {
-			log.debug("Failed to update group version. Status is {} ", updateGroupVersion.right().value());
-			result = Either.right(updateGroupVersion.right().value());
-		}
-		return result;
-	}*/
-	
-	
+	/*
+	 * public Either<GroupDefinition, StorageOperationStatus> updateGroupVersion(GroupDefinition groupDefinition, boolean inTransaction) { Either<GroupDefinition, StorageOperationStatus> result = null; List<String> groupIdsToUpdateVersion = new
+	 * ArrayList<>(); groupIdsToUpdateVersion.add(groupDefinition.getUniqueId()); Either<List<GroupDefinition>, StorageOperationStatus> updateGroupVersion = updateGroupVersion(groupIdsToUpdateVersion, inTransaction); if (updateGroupVersion.isLeft())
+	 * { result = Either.left(updateGroupVersion.left().value().get(0)); } else { log.debug("Failed to update group version. Status is {} ", updateGroupVersion.right().value()); result = Either.right(updateGroupVersion.right().value()); } return
+	 * result; }
+	 */
 
 	/**
 	 * Update list of groups versions
@@ -363,52 +325,44 @@
 	 * @param inTransaction
 	 * @return
 	 */
-	/*public Either<List<GroupDefinition>, StorageOperationStatus> updateGroupVersion(List<String> groupsUniqueId, boolean inTransaction) {
+	/*
+	 * public Either<List<GroupDefinition>, StorageOperationStatus> updateGroupVersion(List<String> groupsUniqueId, boolean inTransaction) {
+	 * 
+	 * Either<List<GroupDefinition>, StorageOperationStatus> result = null;
+	 * 
+	 * try {
+	 * 
+	 * result = groupOperation.updateGroupVersion(groupsUniqueId, true);
+	 * 
+	 * return result;
+	 * 
+	 * } finally {
+	 * 
+	 * if (false == inTransaction) {
+	 * 
+	 * if (result == null || result.isRight()) { log.debug("Going to execute rollback on create group."); titanDao.rollback(); } else { log.debug("Going to execute commit on create group."); titanDao.commit(); }
+	 * 
+	 * }
+	 * 
+	 * }
+	 * 
+	 * }
+	 */
 
-		Either<List<GroupDefinition>, StorageOperationStatus> result = null;
+	/**
+	 * Update GroupDefinition metadata
+	 * 
+	 * @param componentId
+	 * @param user
+	 * @param componentType
+	 * @param updatedGroup
+	 * @param inTransaction
+	 * @return
+	 */
+	public Either<GroupDefinition, ResponseFormat> validateAndUpdateGroupMetadata(String componentId, User user, ComponentTypeEnum componentType, GroupDefinition updatedGroup, boolean inTransaction) {
 
-		try {
-
-			result = groupOperation.updateGroupVersion(groupsUniqueId, true);
-
-			return result;
-
-		} finally {
-
-			if (false == inTransaction) {
-
-				if (result == null || result.isRight()) {
-					log.debug("Going to execute rollback on create group.");
-					titanDao.rollback();
-				} else {
-					log.debug("Going to execute commit on create group.");
-					titanDao.commit();
-				}
-
-			}
-
-		}
-
-	}*/
-
-/**
- * Update GroupDefinition metadata
- * @param componentId
- * @param user
- * @param componentType
- * @param updatedGroup
- * @param inTransaction
- * @return
- */
-	public Either<GroupDefinition, ResponseFormat> validateAndUpdateGroupMetadata(
-			String componentId, 
-			User user, 
-			ComponentTypeEnum componentType, 
-			GroupDefinition updatedGroup, 
-			boolean inTransaction) {
-		
 		Either<GroupDefinition, ResponseFormat> result = null;
-		try{
+		try {
 			// Validate user exist
 			Either<User, ResponseFormat> validateUserExists = validateUserExists(user.getUserId(), UPDATE_GROUP, inTransaction);
 			if (validateUserExists.isRight()) {
@@ -429,14 +383,14 @@
 				return result;
 			}
 			List<GroupDefinition> currentGroups = component.getGroups();
-			if(CollectionUtils.isEmpty(currentGroups)){
+			if (CollectionUtils.isEmpty(currentGroups)) {
 				log.error("Failed to update the metadata of group {} on component {}. The status is {}. ", updatedGroup.getName(), component.getName(), ActionStatus.GROUP_IS_MISSING);
 				result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_IS_MISSING, updatedGroup.getName(), component.getName(), component.getComponentType().getValue()));
 				return result;
 			}
 			// Validate groups exists in the component
 			Optional<GroupDefinition> currentGroupOpt = currentGroups.stream().filter(g -> g.getUniqueId().equals(updatedGroup.getUniqueId())).findAny();
-			if(!currentGroupOpt.isPresent()){
+			if (!currentGroupOpt.isPresent()) {
 				log.error("Failed to update the metadata of group {} on component {}. The status is {}. ", updatedGroup.getName(), component.getName(), ActionStatus.GROUP_IS_MISSING);
 				result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_IS_MISSING, updatedGroup.getName(), component.getName(), component.getComponentType().getValue()));
 				return result;
@@ -451,14 +405,14 @@
 			if (!currentGroup.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE)) {
 				log.error("Failed to update the metadata of group {}. Group type is {} and different then: {}", currentGroup.getName(), currentGroup.getType(), Constants.DEFAULT_GROUP_VF_MODULE);
 				ResponseFormat responseFormat = componentsUtils.getResponseFormat(ActionStatus.INVALID_VF_MODULE_TYPE, updatedGroup.getType());
-				result =  Either.right(responseFormat);
+				result = Either.right(responseFormat);
 				return result;
 			}
 			result = updateGroupMetadata(component, currentGroup, updatedGroup);
 			return result;
-	
+
 		} finally {
-			if(result.isLeft()){
+			if (result.isLeft()) {
 				titanDao.commit();
 			} else {
 				titanDao.rollback();
@@ -466,15 +420,15 @@
 			graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
 		}
 	}
-	
+
 	private Either<GroupDefinition, ResponseFormat> updateGroupMetadata(Component component, GroupDefinition currentGroup, GroupDefinition updatedGroup) {
 		String currentGroupName = currentGroup.getName();
 		Either<GroupDefinition, ResponseFormat> result = validateAndUpdateGroupMetadata(currentGroup, updatedGroup);
-		
-		if(result.isRight()){
+
+		if (result.isRight()) {
 			log.debug("Failed to validate a metadata of the group {} on component {}. ", updatedGroup.getName(), component.getName());
 		}
-		if(result.isLeft()){
+		if (result.isLeft()) {
 			result = updateGroup(component, currentGroup, currentGroupName);
 		}
 		return result;
@@ -483,25 +437,25 @@
 	private Either<GroupDefinition, ResponseFormat> updateGroup(Component component, GroupDefinition updatedGroup, String currentGroupName) {
 		Either<GroupDefinition, StorageOperationStatus> handleGroupRes;
 		Either<GroupDefinition, ResponseFormat> result = null;
-		if(updatedGroup.getName().equals(currentGroupName)){
+		if (updatedGroup.getName().equals(currentGroupName)) {
 			handleGroupRes = groupsOperation.updateGroup(component, updatedGroup);
-			if(handleGroupRes.isRight()){
+			if (handleGroupRes.isRight()) {
 				log.debug("Failed to update a metadata of the group {} on component {}. ", updatedGroup.getName(), component.getName());
 				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(handleGroupRes.right().value())));
 			}
 		} else {
 			StorageOperationStatus deleteStatus = groupsOperation.deleteGroup(component, currentGroupName);
-			if(deleteStatus != StorageOperationStatus.OK){
+			if (deleteStatus != StorageOperationStatus.OK) {
 				log.debug("Failed to delete the group {} from component {}. ", updatedGroup.getName(), component.getName());
-				result =  Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(deleteStatus)));
+				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(deleteStatus)));
 			}
 			handleGroupRes = groupsOperation.addGroup(component, updatedGroup);
-			if(handleGroupRes.isRight()){
+			if (handleGroupRes.isRight()) {
 				log.debug("Failed to add the group {} to component {}. ", updatedGroup.getName(), component.getName());
 				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(handleGroupRes.right().value())));
 			}
 		}
-		if(result == null){
+		if (result == null) {
 			result = Either.left(updatedGroup);
 		}
 		return result;
@@ -509,6 +463,7 @@
 
 	/**
 	 * Validate and Update Group Property
+	 * 
 	 * @param componentId
 	 * @param groupUniqueId
 	 * @param user
@@ -517,43 +472,36 @@
 	 * @param inTransaction
 	 * @return
 	 */
-	public Either<List<GroupProperty>, ResponseFormat> validateAndUpdateGroupProperties(
-			String componentId, 
-			String groupUniqueId, 
-			User user, 
-			ComponentTypeEnum componentType, 
-			List<GroupProperty> groupPropertiesToUpdate, boolean inTransaction) {
-		
+	public Either<List<GroupProperty>, ResponseFormat> validateAndUpdateGroupProperties(String componentId, String groupUniqueId, User user, ComponentTypeEnum componentType, List<GroupProperty> groupPropertiesToUpdate, boolean inTransaction) {
+
 		Either<List<GroupProperty>, ResponseFormat> result = Either.left(groupPropertiesToUpdate);
-		try{
+		try {
 			Optional<GroupDefinition> optionalGroupConnectedToVf = null;
 			GroupDefinition currentGroup = null;
 			StorageOperationStatus lockResult = graphLockOperation.lockComponent(componentId, componentType.getNodeType());
-			if( lockResult != StorageOperationStatus.OK ){
-				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(
-						lockResult, componentType), componentId));
+			if (lockResult != StorageOperationStatus.OK) {
+				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(lockResult, componentType), componentId));
 			}
-			if( result.isLeft() ){
-				//VF exist because lock succedded
+			if (result.isLeft()) {
+				// VF exist because lock succedded
 				Resource vf = (Resource) toscaOperationFacade.getToscaElement(componentId).left().value();
-				optionalGroupConnectedToVf = 
-						//All groups on resource
+				optionalGroupConnectedToVf =
+						// All groups on resource
 						vf.getGroups().stream().
-						//Filter in group sent is part of VF groups
-						filter( e -> e.getUniqueId().equals(groupUniqueId)).
-						//Collect
-						findAny();
-				if( !optionalGroupConnectedToVf.isPresent() ){
-					result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_IS_MISSING,
-							groupUniqueId, vf.getName(), ComponentTypeEnum.RESOURCE.getValue()));
+						// Filter in group sent is part of VF groups
+								filter(e -> e.getUniqueId().equals(groupUniqueId)).
+								// Collect
+								findAny();
+				if (!optionalGroupConnectedToVf.isPresent()) {
+					result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_IS_MISSING, groupUniqueId, vf.getName(), ComponentTypeEnum.RESOURCE.getValue()));
 				}
 			}
-			
-			if( result.isLeft() ){
+
+			if (result.isLeft()) {
 				currentGroup = optionalGroupConnectedToVf.get();
 				result = validateGroupPropertyAndResetEmptyValue(currentGroup, groupPropertiesToUpdate);
 			}
-			if( result.isLeft() ){
+			if (result.isLeft()) {
 				result = updateGroupPropertiesValue(componentId, currentGroup, groupPropertiesToUpdate, inTransaction);
 				if (result.isRight()) {
 					BeEcompErrorManager.getInstance().logBeSystemError("Update GroupProperties");
@@ -561,49 +509,47 @@
 				}
 			}
 
-		}
-		catch(Exception e){
+		} catch (Exception e) {
 			log.debug("Error in validateAndUpdateGroupProperty {}", e);
 			result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
-		}
-		finally{
+		} finally {
 			graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
 		}
 		return result;
 	}
+
 	private void resetEmptyValueWithDefaults(List<GroupProperty> groupPropertiesToUpdate, GroupDefinition originalGroup) {
 		Map<String, GroupProperty> originalProperties =
-				//Stream of original properties from group
+				// Stream of original properties from group
 				originalGroup.convertToGroupProperties().stream().
-				//Collecting to map with name as key
-				collect(Collectors.toMap(e -> e.getName(), e -> e));
-		for( GroupProperty gp : groupPropertiesToUpdate){
-			if( StringUtils.isEmpty(gp.getValue())){
+				// Collecting to map with name as key
+						collect(Collectors.toMap(e -> e.getName(), e -> e));
+		for (GroupProperty gp : groupPropertiesToUpdate) {
+			if (StringUtils.isEmpty(gp.getValue())) {
 				gp.setValue(originalProperties.get(gp.getName()).getDefaultValue());
 			}
 		}
-		
+
 	}
 
-	private Either<List<GroupProperty>, ResponseFormat> validateGroupPropertyAndResetEmptyValue(
-			GroupDefinition originalGroup, List<GroupProperty> groupPropertiesToUpdate) {
-		
+	private Either<List<GroupProperty>, ResponseFormat> validateGroupPropertyAndResetEmptyValue(GroupDefinition originalGroup, List<GroupProperty> groupPropertiesToUpdate) {
+
 		Either<List<GroupProperty>, ResponseFormat> ret = validateOnlyValueChanged(groupPropertiesToUpdate, originalGroup);
 		if (ret.isLeft()) {
 			resetEmptyValueWithDefaults(groupPropertiesToUpdate, originalGroup);
 		}
 		if (ret.isLeft()) {
 			// Validate Type Match Value
-			Optional<StorageOperationStatus> optionalError = 
-					//Stream of group properties
+			Optional<StorageOperationStatus> optionalError =
+					// Stream of group properties
 					groupPropertiesToUpdate.stream().
-					//Validate each and map to returned Strorage status value
-					map( e -> groupOperation .validateAndUpdatePropertyValue(e)).
-					//Keep only failed result if there is such
-					filter( e -> e != StorageOperationStatus.OK).
-					//collect
-					findFirst();
-			if( optionalError.isPresent()){
+					// Validate each and map to returned Strorage status value
+							map(e -> groupOperation.validateAndUpdatePropertyValue(e)).
+							// Keep only failed result if there is such
+							filter(e -> e != StorageOperationStatus.OK).
+							// collect
+							findFirst();
+			if (optionalError.isPresent()) {
 				ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(optionalError.get());
 				ret = Either.right(componentsUtils.getResponseFormat(actionStatus));
 			}
@@ -612,60 +558,54 @@
 		if (ret.isLeft()) {
 			// Validate min max ect...
 			ret = validatePropertyBusinessLogic(groupPropertiesToUpdate, originalGroup);
-		} 
+		}
 
 		return ret;
 	}
-	private Either<List<GroupProperty>, ResponseFormat> validatePropertyBusinessLogic(
-			List<GroupProperty> groupPropertiesToUpdate, GroupDefinition originalGroup) {
+
+	private Either<List<GroupProperty>, ResponseFormat> validatePropertyBusinessLogic(List<GroupProperty> groupPropertiesToUpdate, GroupDefinition originalGroup) {
 
 		Either<List<GroupProperty>, ResponseFormat> ret = Either.left(groupPropertiesToUpdate);
-		
+
 		Map<PropertyNames, String> nameValueMap = new HashMap<>();
-		for(GroupProperty gp : groupPropertiesToUpdate){
-			//Filter out non special properties which does not have Enum
+		for (GroupProperty gp : groupPropertiesToUpdate) {
+			// Filter out non special properties which does not have Enum
 			final PropertyNames gpEnum = PropertyNames.findName(gp.getName());
-			if( gpEnum != null ){
+			if (gpEnum != null) {
 				nameValueMap.put(gpEnum, gp.getValue());
 			}
 		}
-		
-		if ( !MapUtils.isEmpty(nameValueMap) ) {
 
-			if (nameValueMap.containsKey(PropertyNames.INITIAL_COUNT) || nameValueMap.containsKey(PropertyNames.MAX_INSTANCES)
-					|| nameValueMap.containsKey(PropertyNames.MIN_INSTANCES)) {
-				
-				
+		if (!MapUtils.isEmpty(nameValueMap)) {
+
+			if (nameValueMap.containsKey(PropertyNames.INITIAL_COUNT) || nameValueMap.containsKey(PropertyNames.MAX_INSTANCES) || nameValueMap.containsKey(PropertyNames.MIN_INSTANCES)) {
+
 				Map<PropertyNames, String> oldValueMap = prepareMapWithOriginalProperties(originalGroup);
-				
-				Either<Boolean, ResponseFormat> eitherValid = validateMinMaxAndInitialCountPropertyLogicVF(nameValueMap,
-						oldValueMap);
+
+				Either<Boolean, ResponseFormat> eitherValid = validateMinMaxAndInitialCountPropertyLogicVF(nameValueMap, oldValueMap);
 				if (eitherValid.isRight()) {
 					ret = Either.right(eitherValid.right().value());
 				}
 			}
-			if (ret.isLeft() && (nameValueMap.containsKey(PropertyNames.VF_MODULE_DESCRIPTION)
-					|| nameValueMap.containsKey(PropertyNames.VF_MODULE_LABEL))) {
+			if (ret.isLeft() && (nameValueMap.containsKey(PropertyNames.VF_MODULE_DESCRIPTION) || nameValueMap.containsKey(PropertyNames.VF_MODULE_LABEL))) {
 
-				Optional<ResponseFormat> optionalError = 
-						//Stream of group Properties
+				Optional<ResponseFormat> optionalError =
+						// Stream of group Properties
 						groupPropertiesToUpdate.stream().
-						//Filter in only properties that needs text validation
-								filter(e -> enumHasValueFilter(e.getName(),
-										enumName -> PropertyNames.findName(enumName),
-										PropertyNames.VF_MODULE_DESCRIPTION, PropertyNames.VF_MODULE_LABEL)).
-						//validate text properties
-						map( e -> validateFreeText(e)).
-						//filter in only errors if exist
-						filter( e -> e.isRight()).
-						//map the Either value to the Error
-						map( e -> e.right().value())
-						//collect
-						.findFirst();
-				if( optionalError.isPresent() ){
+						// Filter in only properties that needs text validation
+								filter(e -> enumHasValueFilter(e.getName(), enumName -> PropertyNames.findName(enumName), PropertyNames.VF_MODULE_DESCRIPTION, PropertyNames.VF_MODULE_LABEL)).
+								// validate text properties
+								map(e -> validateFreeText(e)).
+								// filter in only errors if exist
+								filter(e -> e.isRight()).
+								// map the Either value to the Error
+								map(e -> e.right().value())
+								// collect
+								.findFirst();
+				if (optionalError.isPresent()) {
 					ret = Either.right(optionalError.get());
 				}
-				
+
 			}
 		}
 
@@ -674,83 +614,77 @@
 
 	private Map<PropertyNames, String> prepareMapWithOriginalProperties(GroupDefinition originalGroup) {
 		Map<PropertyNames, String> oldValueMap = new HashMap<>();
-		PropertyNames[] propertiesToCheck = new PropertyNames[] { PropertyNames.INITIAL_COUNT,
-				PropertyNames.MAX_INSTANCES, PropertyNames.MIN_INSTANCES };
-		
-		for(GroupProperty gp : originalGroup.convertToGroupProperties()){
-			if( enumHasValueFilter(gp.getName(), enumName -> PropertyNames.findName(enumName), propertiesToCheck)){
+		PropertyNames[] propertiesToCheck = new PropertyNames[] { PropertyNames.INITIAL_COUNT, PropertyNames.MAX_INSTANCES, PropertyNames.MIN_INSTANCES };
+
+		for (GroupProperty gp : originalGroup.convertToGroupProperties()) {
+			if (enumHasValueFilter(gp.getName(), enumName -> PropertyNames.findName(enumName), propertiesToCheck)) {
 				oldValueMap.put(PropertyNames.findName(gp.getName()), gp.getValue());
 			}
 		}
-		if( StringUtils.isEmpty(oldValueMap.get(PropertyNames.MAX_INSTANCES)) ){
+		if (StringUtils.isEmpty(oldValueMap.get(PropertyNames.MAX_INSTANCES))) {
 			oldValueMap.put(PropertyNames.MAX_INSTANCES, String.valueOf(Integer.MAX_VALUE));
 		}
 		return oldValueMap;
 	}
-	
-	private Either<List<GroupProperty>, ResponseFormat> validateOnlyValueChanged(
-			List<GroupProperty> groupPropertiesToUpdate, GroupDefinition originalGroup) {
-		
+
+	private Either<List<GroupProperty>, ResponseFormat> validateOnlyValueChanged(List<GroupProperty> groupPropertiesToUpdate, GroupDefinition originalGroup) {
+
 		Either<List<GroupProperty>, ResponseFormat> ret = Either.left(groupPropertiesToUpdate);
-		if( CollectionUtils.isEmpty(groupPropertiesToUpdate) ){
+		if (CollectionUtils.isEmpty(groupPropertiesToUpdate)) {
 			ret = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, StringUtils.EMPTY));
-		}
-		else if (CollectionUtils.isEmpty(originalGroup.getProperties())) {
-			ret = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND,
-					groupPropertiesToUpdate.get(NumberUtils.INTEGER_ZERO).getName()));
+		} else if (CollectionUtils.isEmpty(originalGroup.getProperties())) {
+			ret = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, groupPropertiesToUpdate.get(NumberUtils.INTEGER_ZERO).getName()));
 		} else {
-			Map<String, GroupProperty> namePropertyMap = 
-					//Original Group Properties Stream
+			Map<String, GroupProperty> namePropertyMap =
+					// Original Group Properties Stream
 					originalGroup.convertToGroupProperties().stream().
-					//Collect to map with name as key
-					collect(Collectors.toMap(e -> e.getName(), e -> e));
-			
-			Optional<GroupProperty> optionalMissingProperty = 
-					//Group Properties to be updated Stream
+					// Collect to map with name as key
+							collect(Collectors.toMap(e -> e.getName(), e -> e));
+
+			Optional<GroupProperty> optionalMissingProperty =
+					// Group Properties to be updated Stream
 					groupPropertiesToUpdate.stream().
-					//Filter in property that is not contained in original if there is such
-					filter(e -> !namePropertyMap.containsKey(e.getName())).
-					//collect
-					findFirst();
-			
+					// Filter in property that is not contained in original if there is such
+							filter(e -> !namePropertyMap.containsKey(e.getName())).
+							// collect
+							findFirst();
+
 			if (optionalMissingProperty.isPresent()) {
-				ret = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND,
-						optionalMissingProperty.get().getName()));
-			}
-			else{
-				Optional<GroupProperty> optionalNonValueChange = 
-						//groups to be updated stream
+				ret = Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_NOT_FOUND, optionalMissingProperty.get().getName()));
+			} else {
+				Optional<GroupProperty> optionalNonValueChange =
+						// groups to be updated stream
 						groupPropertiesToUpdate.stream().
-						//filter in only properties with non-value (illegal) change 
-						filter( e -> !isOnlyGroupPropertyValueChanged(e, namePropertyMap.get(e.getName()))).
-						//Collect
-						findFirst();
+						// filter in only properties with non-value (illegal) change
+								filter(e -> !isOnlyGroupPropertyValueChanged(e, namePropertyMap.get(e.getName()))).
+								// Collect
+								findFirst();
 				if (optionalNonValueChange.isPresent()) {
-					ret = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY,
-							optionalNonValueChange.get().getName()));
+					ret = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY, optionalNonValueChange.get().getName()));
 
 				}
 			}
-			
+
 		}
 		return ret;
 	}
 
 	/**
 	 * if groupProperty are the same or if only value is different returns true, otherwise returns false.
+	 * 
 	 * @param groupProperty
 	 * @param groupProperty2
 	 * @return
 	 */
 	private boolean isOnlyGroupPropertyValueChanged(GroupProperty groupProperty, GroupProperty groupProperty2) {
-		//Create 2 duplicates for groupPropery and reset their values
+		// Create 2 duplicates for groupPropery and reset their values
 		Gson gson = new GsonBuilder().setPrettyPrinting().create();
 		try {
 			GroupProperty groupPropertyDuplicate = new GroupProperty(groupProperty);
 			groupPropertyDuplicate.setValue(null);
 			groupPropertyDuplicate.setSchema(null);
 			groupPropertyDuplicate.setParentUniqueId(null);
-//			GroupProperty groupProperty2Duplicate = gson.fromJson(JsonParserUtils.jsonToString(groupProperty2), GroupProperty.class);
+			// GroupProperty groupProperty2Duplicate = gson.fromJson(JsonParserUtils.jsonToString(groupProperty2), GroupProperty.class);
 			GroupProperty groupProperty2Duplicate = new GroupProperty(groupProperty2);
 			groupProperty2Duplicate.setValue(null);
 			groupProperty2Duplicate.setSchema(null);
@@ -759,8 +693,9 @@
 		} catch (Exception e) {
 			log.debug("Failed validate group properties. ", e);
 			return false;
-		} 
+		}
 	}
+
 	/**
 	 * Validate and update GroupDefinition metadata
 	 * 
@@ -864,183 +799,105 @@
 	 * @param inTransaction
 	 * @return
 	 */
-	/*public Either<List<GroupDefinition>, ResponseFormat> associateArtifactsToGroup(String componentId, String userId, ComponentTypeEnum componentType, List<GroupDefinition> groups, boolean shouldLockComp, boolean inTransaction) {
+	/*
+	 * public Either<List<GroupDefinition>, ResponseFormat> associateArtifactsToGroup(String componentId, String userId, ComponentTypeEnum componentType, List<GroupDefinition> groups, boolean shouldLockComp, boolean inTransaction) {
+	 * 
+	 * Either<List<GroupDefinition>, ResponseFormat> result = null;
+	 * 
+	 * if (shouldLockComp == true && inTransaction == true) { BeEcompErrorManager.getInstance().logInternalFlowError("dissociateArtifactsFromGroup", "Cannot lock component since we are inside a transaction", ErrorSeverity.ERROR); // Cannot lock
+	 * component since we are in a middle of another // transaction. ActionStatus actionStatus = ActionStatus.INVALID_CONTENT; result = Either.right(componentsUtils.getResponseFormat(actionStatus)); return result; }
+	 * 
+	 * Component component = null; try {
+	 * 
+	 * if (groups == null || groups.isEmpty()) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.OK)); }
+	 * 
+	 * Either<Component, ResponseFormat> validateGroupsBeforeUpdate = validateGroupsBeforeUpdate(componentId, userId, componentType, groups, inTransaction); if (validateGroupsBeforeUpdate.isRight()) { result =
+	 * Either.right(validateGroupsBeforeUpdate.right().value()); return result; }
+	 * 
+	 * component = validateGroupsBeforeUpdate.left().value();
+	 * 
+	 * if (shouldLockComp) { Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, "Group - Associate Artifacts"); if (lockComponent.isRight()) { return Either.right(lockComponent.right().value()); } }
+	 * 
+	 * List<GroupDefinition> updatedGroups = new ArrayList<>();
+	 * 
+	 * List<GroupDefinition> componentGroups = component.getGroups();
+	 * 
+	 * // per group, associate to it the artifacts for (GroupDefinition groupDefinition : groups) {
+	 * 
+	 * GroupDefinition componentGroup = componentGroups.stream().filter(p -> p.getUniqueId().equals(groupDefinition.getUniqueId())).findFirst().orElse(null); if (componentGroup != null) { List<String> componentArtifacts =
+	 * componentGroup.getArtifacts(); int artifactsSizeInGroup = componentArtifacts == null ? 0 : componentArtifacts.size(); if (artifactsSizeInGroup > 0) { List<String> artifactsToAssociate = groupDefinition.getArtifacts();
+	 * 
+	 * // if no artifcats sent if (artifactsToAssociate == null || true == artifactsToAssociate.isEmpty()) { continue; }
+	 * 
+	 * boolean isChanged = componentArtifacts.removeAll(artifactsToAssociate); if (isChanged) {// I.e. At least one artifact is already // associated to the group log.debug("Some of the artifacts already associated to group {}" ,
+	 * groupDefinition.getUniqueId()); return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_ARTIFACT_ALREADY_ASSOCIATED, componentGroup.getName())); } } }
+	 * 
+	 * Either<GroupDefinition, StorageOperationStatus> associateArtifactsToGroup = groupOperation.associateArtifactsToGroup(groupDefinition.getUniqueId(), groupDefinition.getArtifacts(), true);
+	 * 
+	 * if (associateArtifactsToGroup.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(associateArtifactsToGroup.right().value()); result = Either.right(componentsUtils.getResponseFormat(actionStatus));
+	 * log.debug("Failed to update group {} under component {}, error: {}", groupDefinition.getName(), component.getNormalizedName(), actionStatus.name()); return result; } updatedGroups.add(associateArtifactsToGroup.left().value());
+	 * 
+	 * }
+	 * 
+	 * result = Either.left(updatedGroups); return result;
+	 * 
+	 * } finally {
+	 * 
+	 * if (false == inTransaction) {
+	 * 
+	 * if (result == null || result.isRight()) { log.debug("Going to execute rollback on create group."); titanDao.rollback(); } else { log.debug("Going to execute commit on create group."); titanDao.commit(); }
+	 * 
+	 * }
+	 * 
+	 * // unlock resource if (shouldLockComp && component != null) { graphLockOperation.unlockComponent(componentId, componentType.getNodeType()); }
+	 * 
+	 * } }
+	 */
 
-		Either<List<GroupDefinition>, ResponseFormat> result = null;
-
-		if (shouldLockComp == true && inTransaction == true) {
-			BeEcompErrorManager.getInstance().logInternalFlowError("dissociateArtifactsFromGroup", "Cannot lock component since we are inside a transaction", ErrorSeverity.ERROR);
-			// Cannot lock component since we are in a middle of another
-			// transaction.
-			ActionStatus actionStatus = ActionStatus.INVALID_CONTENT;
-			result = Either.right(componentsUtils.getResponseFormat(actionStatus));
-			return result;
-		}
-
-		Component component = null;
-		try {
-
-			if (groups == null || groups.isEmpty()) {
-				return Either.right(componentsUtils.getResponseFormat(ActionStatus.OK));
-			}
-
-			Either<Component, ResponseFormat> validateGroupsBeforeUpdate = validateGroupsBeforeUpdate(componentId, userId, componentType, groups, inTransaction);
-			if (validateGroupsBeforeUpdate.isRight()) {
-				result = Either.right(validateGroupsBeforeUpdate.right().value());
-				return result;
-			}
-
-			component = validateGroupsBeforeUpdate.left().value();
-
-			if (shouldLockComp) {
-				Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, "Group - Associate Artifacts");
-				if (lockComponent.isRight()) {
-					return Either.right(lockComponent.right().value());
-				}
-			}
-
-			List<GroupDefinition> updatedGroups = new ArrayList<>();
-
-			List<GroupDefinition> componentGroups = component.getGroups();
-
-			// per group, associate to it the artifacts
-			for (GroupDefinition groupDefinition : groups) {
-
-				GroupDefinition componentGroup = componentGroups.stream().filter(p -> p.getUniqueId().equals(groupDefinition.getUniqueId())).findFirst().orElse(null);
-				if (componentGroup != null) {
-					List<String> componentArtifacts = componentGroup.getArtifacts();
-					int artifactsSizeInGroup = componentArtifacts == null ? 0 : componentArtifacts.size();
-					if (artifactsSizeInGroup > 0) {
-						List<String> artifactsToAssociate = groupDefinition.getArtifacts();
-
-						// if no artifcats sent
-						if (artifactsToAssociate == null || true == artifactsToAssociate.isEmpty()) {
-							continue;
-						}
-
-						boolean isChanged = componentArtifacts.removeAll(artifactsToAssociate);
-						if (isChanged) {// I.e. At least one artifact is already
-										// associated to the group
-							log.debug("Some of the artifacts already associated to group {}" , groupDefinition.getUniqueId());
-							return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_ARTIFACT_ALREADY_ASSOCIATED, componentGroup.getName()));
-						}
-					}
-				}
-
-				Either<GroupDefinition, StorageOperationStatus> associateArtifactsToGroup = groupOperation.associateArtifactsToGroup(groupDefinition.getUniqueId(), groupDefinition.getArtifacts(), true);
-
-				if (associateArtifactsToGroup.isRight()) {
-					ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(associateArtifactsToGroup.right().value());
-					result = Either.right(componentsUtils.getResponseFormat(actionStatus));
-					log.debug("Failed to update group {} under component {}, error: {}", groupDefinition.getName(), component.getNormalizedName(), actionStatus.name());
-					return result;
-				}
-				updatedGroups.add(associateArtifactsToGroup.left().value());
-
-			}
-
-			result = Either.left(updatedGroups);
-			return result;
-
-		} finally {
-
-			if (false == inTransaction) {
-
-				if (result == null || result.isRight()) {
-					log.debug("Going to execute rollback on create group.");
-					titanDao.rollback();
-				} else {
-					log.debug("Going to execute commit on create group.");
-					titanDao.commit();
-				}
-
-			}
-
-			// unlock resource
-			if (shouldLockComp && component != null) {
-				graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
-			}
-
-		}
-	}*/
-
-	/*public Either<List<GroupDefinition>, ResponseFormat> associateMembersToGroup(String componentId, String userId, ComponentTypeEnum componentType, List<GroupDefinition> groups, boolean shouldLockComp, boolean inTransaction) {
-
-		Either<List<GroupDefinition>, ResponseFormat> result = null;
-
-		if (shouldLockComp == true && inTransaction == true) {
-			BeEcompErrorManager.getInstance().logInternalFlowError("dissociateArtifactsFromGroup", "Cannot lock component since we are inside a transaction", ErrorSeverity.ERROR);
-			// Cannot lock component since we are in a middle of another
-			// transaction.
-			ActionStatus actionStatus = ActionStatus.INVALID_CONTENT;
-			result = Either.right(componentsUtils.getResponseFormat(actionStatus));
-			return result;
-		}
-
-		Component component = null;
-		try {
-
-			if (groups == null || groups.isEmpty()) {
-				return Either.right(componentsUtils.getResponseFormat(ActionStatus.OK));
-			}
-
-			Either<Component, ResponseFormat> validateGroupsBeforeUpdate = validateGroupsBeforeUpdate(componentId, userId, componentType, groups, inTransaction);
-			if (validateGroupsBeforeUpdate.isRight()) {
-				result = Either.right(validateGroupsBeforeUpdate.right().value());
-				return result;
-			}
-
-			component = validateGroupsBeforeUpdate.left().value();
-
-			if (shouldLockComp) {
-				Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, "Group - Associate Members");
-				if (lockComponent.isRight()) {
-					return Either.right(lockComponent.right().value());
-				}
-			}
-
-			List<GroupDefinition> updatedGroups = new ArrayList<>();
-
-			// per group, associate to it the members
-			for (GroupDefinition groupDefinition : groups) {
-
-				Either<GroupDefinition, StorageOperationStatus> associateMembersToGroup = groupOperation.associateMembersToGroup(groupDefinition.getUniqueId(), groupDefinition.getMembers(), true);
-
-				if (associateMembersToGroup.isRight()) {
-					ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(associateMembersToGroup.right().value());
-					result = Either.right(componentsUtils.getResponseFormat(actionStatus));
-					log.debug("Failed to update group {} under component {}, error: {}", groupDefinition.getName(), component.getNormalizedName(), actionStatus.name());
-					return result;
-				} else {
-					updatedGroups.add(associateMembersToGroup.left().value());
-				}
-
-			}
-
-			result = Either.left(updatedGroups);
-			return result;
-
-		} finally {
-
-			if (false == inTransaction) {
-
-				if (result == null || result.isRight()) {
-					log.debug("Going to execute rollback on create group.");
-					titanDao.rollback();
-				} else {
-					log.debug("Going to execute commit on create group.");
-					titanDao.commit();
-				}
-
-			}
-
-			// unlock resource
-			if (shouldLockComp && component != null) {
-				graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
-			}
-
-		}
-	}*/
+	/*
+	 * public Either<List<GroupDefinition>, ResponseFormat> associateMembersToGroup(String componentId, String userId, ComponentTypeEnum componentType, List<GroupDefinition> groups, boolean shouldLockComp, boolean inTransaction) {
+	 * 
+	 * Either<List<GroupDefinition>, ResponseFormat> result = null;
+	 * 
+	 * if (shouldLockComp == true && inTransaction == true) { BeEcompErrorManager.getInstance().logInternalFlowError("dissociateArtifactsFromGroup", "Cannot lock component since we are inside a transaction", ErrorSeverity.ERROR); // Cannot lock
+	 * component since we are in a middle of another // transaction. ActionStatus actionStatus = ActionStatus.INVALID_CONTENT; result = Either.right(componentsUtils.getResponseFormat(actionStatus)); return result; }
+	 * 
+	 * Component component = null; try {
+	 * 
+	 * if (groups == null || groups.isEmpty()) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.OK)); }
+	 * 
+	 * Either<Component, ResponseFormat> validateGroupsBeforeUpdate = validateGroupsBeforeUpdate(componentId, userId, componentType, groups, inTransaction); if (validateGroupsBeforeUpdate.isRight()) { result =
+	 * Either.right(validateGroupsBeforeUpdate.right().value()); return result; }
+	 * 
+	 * component = validateGroupsBeforeUpdate.left().value();
+	 * 
+	 * if (shouldLockComp) { Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, "Group - Associate Members"); if (lockComponent.isRight()) { return Either.right(lockComponent.right().value()); } }
+	 * 
+	 * List<GroupDefinition> updatedGroups = new ArrayList<>();
+	 * 
+	 * // per group, associate to it the members for (GroupDefinition groupDefinition : groups) {
+	 * 
+	 * Either<GroupDefinition, StorageOperationStatus> associateMembersToGroup = groupOperation.associateMembersToGroup(groupDefinition.getUniqueId(), groupDefinition.getMembers(), true);
+	 * 
+	 * if (associateMembersToGroup.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(associateMembersToGroup.right().value()); result = Either.right(componentsUtils.getResponseFormat(actionStatus));
+	 * log.debug("Failed to update group {} under component {}, error: {}", groupDefinition.getName(), component.getNormalizedName(), actionStatus.name()); return result; } else { updatedGroups.add(associateMembersToGroup.left().value()); }
+	 * 
+	 * }
+	 * 
+	 * result = Either.left(updatedGroups); return result;
+	 * 
+	 * } finally {
+	 * 
+	 * if (false == inTransaction) {
+	 * 
+	 * if (result == null || result.isRight()) { log.debug("Going to execute rollback on create group."); titanDao.rollback(); } else { log.debug("Going to execute commit on create group."); titanDao.commit(); }
+	 * 
+	 * }
+	 * 
+	 * // unlock resource if (shouldLockComp && component != null) { graphLockOperation.unlockComponent(componentId, componentType.getNodeType()); }
+	 * 
+	 * } }
+	 */
 
 	/**
 	 * associate artifacts to a given group
@@ -1084,17 +941,16 @@
 			component = validateComponent.left().value();
 
 			Either<GroupDefinition, StorageOperationStatus> groupEither = findGroupOnComponent(component, groupId);
-			
+
 			if (groupEither.isRight()) {
 				log.debug("Faild to find group {} under component {}", groupId, component.getUniqueId());
 				BeEcompErrorManager.getInstance().logInvalidInputError(GET_GROUP, "group  " + groupId + " not found under component " + component.getUniqueId(), ErrorSeverity.INFO);
 				String componentTypeForResponse = getComponentTypeForResponse(component);
 				result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_IS_MISSING, groupId, component.getSystemName(), componentTypeForResponse));
 				return result;
-			} 
+			}
 			GroupDefinition group = groupEither.left().value();
-			
-						
+
 			Boolean isBase = null;// Constants.IS_BASE;
 			List<GroupProperty> props = group.convertToGroupProperties();
 			if (props != null && !props.isEmpty()) {
@@ -1114,14 +970,14 @@
 			List<ArtifactDefinitionInfo> artifacts = new ArrayList<>();
 			List<ArtifactDefinition> artifactsFromComponent = new ArrayList<>();
 			List<String> artifactsIds = group.getArtifacts();
-			
+
 			Map<String, ArtifactDefinition> deploymentArtifacts = null;
-			if(MapUtils.isNotEmpty(component.getDeploymentArtifacts())){
+			if (MapUtils.isNotEmpty(component.getDeploymentArtifacts())) {
 				deploymentArtifacts = component.getDeploymentArtifacts().values().stream().collect(Collectors.toMap(a -> a.getUniqueId(), a -> a));
 			}
-			
+
 			if (artifactsIds != null && !artifactsIds.isEmpty()) {
-				for(String id: artifactsIds){
+				for (String id : artifactsIds) {
 					if (MapUtils.isEmpty(deploymentArtifacts) || !deploymentArtifacts.containsKey(id)) {
 						log.debug("Failed to get artifact {} . Status is {} ", id, StorageOperationStatus.NOT_FOUND);
 						ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(StorageOperationStatus.NOT_FOUND));
@@ -1166,15 +1022,15 @@
 	}
 
 	private Either<GroupDefinition, StorageOperationStatus> findGroupOnComponent(Component component, String groupId) {
-		
+
 		Either<GroupDefinition, StorageOperationStatus> result = null;
-		if(CollectionUtils.isNotEmpty(component.getGroups())){
+		if (CollectionUtils.isNotEmpty(component.getGroups())) {
 			Optional<GroupDefinition> foundGroup = component.getGroups().stream().filter(g -> g.getUniqueId().equals(groupId)).findFirst();
-			if(foundGroup.isPresent()){
-					result = Either.left(foundGroup.get());
+			if (foundGroup.isPresent()) {
+				result = Either.left(foundGroup.get());
 			}
 		}
-		if(result == null){
+		if (result == null) {
 			result = Either.right(StorageOperationStatus.NOT_FOUND);
 		}
 		return result;
@@ -1308,351 +1164,183 @@
 	 * @param inTransaction
 	 * @return
 	 */
-	/*public Either<List<GroupDefinition>, ResponseFormat> dissociateArtifactsFromGroup(String componentId, String userId, ComponentTypeEnum componentType, List<GroupDefinition> groups, boolean shouldLockComp, boolean inTransaction) {
+	/*
+	 * public Either<List<GroupDefinition>, ResponseFormat> dissociateArtifactsFromGroup(String componentId, String userId, ComponentTypeEnum componentType, List<GroupDefinition> groups, boolean shouldLockComp, boolean inTransaction) {
+	 * 
+	 * Either<List<GroupDefinition>, ResponseFormat> result = null;
+	 * 
+	 * if (shouldLockComp == true && inTransaction == true) { BeEcompErrorManager.getInstance().logInternalFlowError("dissociateArtifactsFromGroup", "Cannot lock component since we are inside a transaction", ErrorSeverity.ERROR); // Cannot lock
+	 * component since we are in a middle of another // transaction. ActionStatus actionStatus = ActionStatus.INVALID_CONTENT; result = Either.right(componentsUtils.getResponseFormat(actionStatus)); return result; }
+	 * 
+	 * Component component = null;
+	 * 
+	 * try {
+	 * 
+	 * if (groups == null || groups.isEmpty()) { return Either.right(componentsUtils.getResponseFormat(ActionStatus.OK)); }
+	 * 
+	 * Either<Component, ResponseFormat> validateGroupsBeforeUpdate = validateGroupsBeforeUpdate(componentId, userId, componentType, groups, inTransaction); if (validateGroupsBeforeUpdate.isRight()) { result =
+	 * Either.right(validateGroupsBeforeUpdate.right().value()); return result; }
+	 * 
+	 * component = validateGroupsBeforeUpdate.left().value();
+	 * 
+	 * if (shouldLockComp) { Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, "Group - Dissociate Artifacts"); if (lockComponent.isRight()) { return Either.right(lockComponent.right().value()); } }
+	 * 
+	 * List<GroupDefinition> updatedGroups = new ArrayList<>();
+	 * 
+	 * List<GroupDefinition> componentGroups = component.getGroups(); // per group, associate to it the artifacts for (GroupDefinition groupDefinition : groups) {
+	 * 
+	 * GroupDefinition componentGroup = componentGroups.stream().filter(p -> p.getUniqueId().equals(groupDefinition.getUniqueId())).findFirst().orElse(null); if (componentGroup != null) { List<String> componentArtifacts =
+	 * componentGroup.getArtifacts(); int artifactsSizeInGroup = componentArtifacts == null ? 0 : componentArtifacts.size(); List<String> artifactsToDissociate = groupDefinition.getArtifacts();
+	 * 
+	 * // if no artifcats sent if (artifactsToDissociate == null || true == artifactsToDissociate.isEmpty()) { continue; }
+	 * 
+	 * if (artifactsSizeInGroup > 0) {
+	 * 
+	 * boolean containsAll = componentArtifacts.containsAll(artifactsToDissociate); if (false == containsAll) { // At least one artifact is // not associated to the // group log.debug("Some of the artifacts already dissociated to group {}" ,
+	 * groupDefinition.getUniqueId()); return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_ARTIFACT_ALREADY_DISSOCIATED, componentGroup.getName())); } } else { if (artifactsSizeInGroup == 0) { if (artifactsToDissociate != null &&
+	 * false == artifactsToDissociate.isEmpty()) { log.debug("No artifact is found under the group {}" , groupDefinition.getUniqueId()); return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_ARTIFACT_ALREADY_DISSOCIATED,
+	 * componentGroup.getName())); } } } }
+	 * 
+	 * Either<GroupDefinition, StorageOperationStatus> associateArtifactsToGroup = groupOperation.dissociateArtifactsFromGroup(groupDefinition.getUniqueId(), groupDefinition.getArtifacts(), true);
+	 * 
+	 * if (associateArtifactsToGroup.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(associateArtifactsToGroup.right().value()); result = Either.right(componentsUtils.getResponseFormat(actionStatus));
+	 * log.debug("Failed to update group {} under component {}, error: {}", groupDefinition.getName(), component.getNormalizedName(), actionStatus.name()); return result; } updatedGroups.add(associateArtifactsToGroup.left().value());
+	 * 
+	 * }
+	 * 
+	 * result = Either.left(updatedGroups); return result;
+	 * 
+	 * } finally {
+	 * 
+	 * if (false == inTransaction) {
+	 * 
+	 * if (result == null || result.isRight()) { log.debug("Going to execute rollback on create group."); titanDao.rollback(); } else { log.debug("Going to execute commit on create group."); titanDao.commit(); }
+	 * 
+	 * } // unlock resource if (shouldLockComp && component != null) { graphLockOperation.unlockComponent(componentId, componentType.getNodeType()); }
+	 * 
+	 * }
+	 * 
+	 * }
+	 */
 
-		Either<List<GroupDefinition>, ResponseFormat> result = null;
+	/*
+	 * public Either<List<GroupDefinition>, ResponseFormat> createGroups(String componentId, String userId, ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions, boolean shouldLockComp, boolean inTransaction) {
+	 * 
+	 * Either<List<GroupDefinition>, ResponseFormat> result = null;
+	 * 
+	 * List<GroupDefinition> groups = new ArrayList<>(); org.openecomp.sdc.be.model.Component component = null; try {
+	 * 
+	 * if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
+	 * 
+	 * if (shouldLockComp && inTransaction) { BeEcompErrorManager.getInstance().logInternalFlowError("createGroups", "Cannot lock component since we are inside a transaction", ErrorSeverity.ERROR); // Cannot lock component since we are in a middle of
+	 * another // transaction. ActionStatus actionStatus = ActionStatus.INVALID_CONTENT; result = Either.right(componentsUtils.getResponseFormat(actionStatus)); return result; }
+	 * 
+	 * Either<User, ResponseFormat> validateUserExists = validateUserExists(userId, CREATE_GROUP, true); if (validateUserExists.isRight()) { result = Either.right(validateUserExists.right().value()); return result; }
+	 * 
+	 * User user = validateUserExists.left().value();
+	 * 
+	 * ComponentParametersView componentParametersView = new ComponentParametersView(); componentParametersView.disableAll(); componentParametersView.setIgnoreGroups(false); componentParametersView.setIgnoreArtifacts(false);
+	 * componentParametersView.setIgnoreUsers(false); componentParametersView.setIgnoreComponentInstances(false);
+	 * 
+	 * Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> validateComponent = validateComponentExists(componentId, componentType, componentParametersView);
+	 * 
+	 * if (validateComponent.isRight()) { result = Either.right(validateComponent.right().value()); return result; } component = validateComponent.left().value();
+	 * 
+	 * if (shouldLockComp) { Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, "CreateGroups"); if (lockComponent.isRight()) { return Either.right(lockComponent.right().value()); } }
+	 * 
+	 * Either<Boolean, ResponseFormat> canWork = validateCanWorkOnComponent(component, userId); if (canWork.isRight()) { result = Either.right(canWork.right().value()); return result; }
+	 * 
+	 * for (GroupDefinition groupDefinition : groupDefinitions) { Either<GroupDefinition, ResponseFormat> createGroup = this.createGroup(component, user, componentType, groupDefinition, true); if (createGroup.isRight()) {
+	 * log.debug("Failed to create group {}." , groupDefinition ); result = Either.right(createGroup.right().value()); return result; } GroupDefinition createdGroup = createGroup.left().value(); groups.add(createdGroup); } }
+	 * 
+	 * result = Either.left(groups); return result;
+	 * 
+	 * } finally {
+	 * 
+	 * if (false == inTransaction) {
+	 * 
+	 * if (result == null || result.isRight()) { log.debug("Going to execute rollback on create group."); titanDao.rollback(); } else { log.debug("Going to execute commit on create group."); titanDao.commit(); }
+	 * 
+	 * } // unlock resource if (shouldLockComp && component != null) { graphLockOperation.unlockComponent(componentId, componentType.getNodeType()); }
+	 * 
+	 * }
+	 * 
+	 * }
+	 * 
+	 * public Either<GroupDefinition, ResponseFormat> createGroup(Component component, User user, ComponentTypeEnum componentType, GroupDefinition groupDefinition, boolean inTransaction) {
+	 * 
+	 * Either<GroupDefinition, ResponseFormat> result = null;
+	 * 
+	 * log.trace("Going to create group {}" , groupDefinition);
+	 * 
+	 * try {
+	 * 
+	 * // 3. verify group not already exist List<GroupDefinition> groups = component.getGroups(); boolean found = false; if (groups != null && false == groups.isEmpty()) {
+	 * 
+	 * GroupDefinition existGroupDef = groups.stream().filter(p -> p.getName().equalsIgnoreCase(groupDefinition.getName())).findFirst().orElse(null);
+	 * 
+	 * found = existGroupDef != null; }
+	 * 
+	 * if (true == found) { String componentTypeForResponse = getComponentTypeForResponse(component); result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_ALREADY_EXIST, groupDefinition.getName(), component.getNormalizedName(),
+	 * componentTypeForResponse)); return result; }
+	 * 
+	 * // 4. verify type of group exist String groupType = groupDefinition.getType(); if (groupType == null || groupType.isEmpty()) { result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_MISSING_GROUP_TYPE,
+	 * groupDefinition.getName())); return result; } Either<GroupTypeDefinition, StorageOperationStatus> getGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType, true); if (getGroupType.isRight()) { StorageOperationStatus status =
+	 * getGroupType.right().value(); if (status == StorageOperationStatus.NOT_FOUND) { BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_GROUP, "group type " + groupType + " cannot be found", ErrorSeverity.INFO); result =
+	 * Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_TYPE_IS_INVALID, groupType)); return result; } else { result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR)); return result; } }
+	 * 
+	 * // 6. verify the component instances type are allowed according to // the member types in the group type GroupTypeDefinition groupTypeDefinition = getGroupType.left().value();
+	 * 
+	 * Either<Boolean, ResponseFormat> areValidMembers = verifyComponentInstancesAreValidMembers(component, componentType, groupDefinition.getName(), groupType, groupDefinition.getMembers(), groupTypeDefinition.getMembers());
+	 * 
+	 * if (areValidMembers.isRight()) { ResponseFormat responseFormat = areValidMembers.right().value(); result = Either.right(responseFormat); return result; }
+	 * 
+	 * // 7. verify the artifacts belongs to the component Either<Boolean, ResponseFormat> areValidArtifacts = verifyArtifactsBelongsToComponent(component, groupDefinition.getArtifacts(), CREATE_GROUP); if (areValidArtifacts.isRight()) {
+	 * ResponseFormat responseFormat = areValidArtifacts.right().value(); result = Either.right(responseFormat); return result; }
+	 * 
+	 * NodeTypeEnum nodeTypeEnum = componentType.getNodeType();
+	 * 
+	 * // add invariantUUID String invariantUUID = UniqueIdBuilder.buildInvariantUUID(); groupDefinition.setInvariantUUID(invariantUUID);
+	 * 
+	 * // add groupUUID String groupUUID = UniqueIdBuilder.generateUUID(); groupDefinition.setGroupUUID(groupUUID);
+	 * 
+	 * // add version groupDefinition.setVersion(INITIAL_VERSION);
+	 * 
+	 * // set groupType uid groupDefinition.setTypeUid(groupTypeDefinition.getUniqueId());
+	 * 
+	 * Either<GroupDefinition, StorageOperationStatus> addGroupToGraph = groupOperation.addGroup(nodeTypeEnum, component.getUniqueId(), groupDefinition, true);
+	 * 
+	 * if (addGroupToGraph.isRight()) { StorageOperationStatus storageOperationStatus = addGroupToGraph.right().value(); ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(storageOperationStatus); result =
+	 * Either.right(componentsUtils.getResponseFormat(actionStatus)); log.debug("Failed to create group {} under component {}, error: {}", groupDefinition.getName(), component.getNormalizedName(), actionStatus.name()); } else { GroupDefinition
+	 * groupDefinitionCreated = addGroupToGraph.left().value(); result = Either.left(groupDefinitionCreated); }
+	 * 
+	 * return result;
+	 * 
+	 * } finally {
+	 * 
+	 * if (false == inTransaction) {
+	 * 
+	 * if (result == null || result.isRight()) { log.debug("Going to execute rollback on create group."); titanDao.rollback(); } else { log.debug("Going to execute commit on create group."); titanDao.commit(); }
+	 * 
+	 * }
+	 * 
+	 * }
+	 * 
+	 * }
+	 * 
+	 * public Either<List<GroupDefinition>, ResponseFormat> updateVfModuleGroupNames(String resourceSystemName, List<GroupDefinition> groups, boolean inTransaction) { List<GroupDefinition> updatedGroups = new ArrayList<>();
+	 * Either<List<GroupDefinition>, ResponseFormat> updateGroupNamesRes = Either.left(updatedGroups); Either<GroupDefinition, StorageOperationStatus> updateGroupNameRes; Either<String, ResponseFormat> validateGenerateGroupNameRes; int counter; for
+	 * (GroupDefinition group : groups) { if (!group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE) && !Pattern.compile(Constants.MODULE_OLD_NAME_PATTERN).matcher(group.getName()).matches()) { continue; } counter =
+	 * Integer.parseInt(group.getName().split(Constants.MODULE_NAME_DELIMITER)[1]); validateGenerateGroupNameRes = validateGenerateVfModuleGroupName(resourceSystemName, group.getDescription(), counter); if (validateGenerateGroupNameRes.isRight()) {
+	 * updateGroupNamesRes = Either.right(validateGenerateGroupNameRes.right().value()); break; } updateGroupNameRes = groupOperation.updateGroupName(group.getUniqueId(), validateGenerateGroupNameRes.left().value(), inTransaction); if
+	 * (updateGroupNameRes.isRight()) { ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(updateGroupNameRes.right().value()); updateGroupNamesRes = Either.right(componentsUtils.getResponseFormat(actionStatus)); break; }
+	 * updatedGroups.add(updateGroupNameRes.left().value()); } return updateGroupNamesRes; }
+	 */
 
-		if (shouldLockComp == true && inTransaction == true) {
-			BeEcompErrorManager.getInstance().logInternalFlowError("dissociateArtifactsFromGroup", "Cannot lock component since we are inside a transaction", ErrorSeverity.ERROR);
-			// Cannot lock component since we are in a middle of another
-			// transaction.
-			ActionStatus actionStatus = ActionStatus.INVALID_CONTENT;
-			result = Either.right(componentsUtils.getResponseFormat(actionStatus));
-			return result;
-		}
-
-		Component component = null;
-
-		try {
-
-			if (groups == null || groups.isEmpty()) {
-				return Either.right(componentsUtils.getResponseFormat(ActionStatus.OK));
-			}
-
-			Either<Component, ResponseFormat> validateGroupsBeforeUpdate = validateGroupsBeforeUpdate(componentId, userId, componentType, groups, inTransaction);
-			if (validateGroupsBeforeUpdate.isRight()) {
-				result = Either.right(validateGroupsBeforeUpdate.right().value());
-				return result;
-			}
-
-			component = validateGroupsBeforeUpdate.left().value();
-
-			if (shouldLockComp) {
-				Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, "Group - Dissociate Artifacts");
-				if (lockComponent.isRight()) {
-					return Either.right(lockComponent.right().value());
-				}
-			}
-
-			List<GroupDefinition> updatedGroups = new ArrayList<>();
-
-			List<GroupDefinition> componentGroups = component.getGroups();
-			// per group, associate to it the artifacts
-			for (GroupDefinition groupDefinition : groups) {
-
-				GroupDefinition componentGroup = componentGroups.stream().filter(p -> p.getUniqueId().equals(groupDefinition.getUniqueId())).findFirst().orElse(null);
-				if (componentGroup != null) {
-					List<String> componentArtifacts = componentGroup.getArtifacts();
-					int artifactsSizeInGroup = componentArtifacts == null ? 0 : componentArtifacts.size();
-					List<String> artifactsToDissociate = groupDefinition.getArtifacts();
-
-					// if no artifcats sent
-					if (artifactsToDissociate == null || true == artifactsToDissociate.isEmpty()) {
-						continue;
-					}
-
-					if (artifactsSizeInGroup > 0) {
-
-						boolean containsAll = componentArtifacts.containsAll(artifactsToDissociate);
-						if (false == containsAll) { // At least one artifact is
-													// not associated to the
-													// group
-							log.debug("Some of the artifacts already dissociated to group {}" , groupDefinition.getUniqueId());
-							return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_ARTIFACT_ALREADY_DISSOCIATED, componentGroup.getName()));
-						}
-					} else {
-						if (artifactsSizeInGroup == 0) {
-							if (artifactsToDissociate != null && false == artifactsToDissociate.isEmpty()) {
-								log.debug("No artifact is found under the group {}" , groupDefinition.getUniqueId());
-								return Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_ARTIFACT_ALREADY_DISSOCIATED, componentGroup.getName()));
-							}
-						}
-					}
-				}
-
-				Either<GroupDefinition, StorageOperationStatus> associateArtifactsToGroup = groupOperation.dissociateArtifactsFromGroup(groupDefinition.getUniqueId(), groupDefinition.getArtifacts(), true);
-
-				if (associateArtifactsToGroup.isRight()) {
-					ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(associateArtifactsToGroup.right().value());
-					result = Either.right(componentsUtils.getResponseFormat(actionStatus));
-					log.debug("Failed to update group {} under component {}, error: {}", groupDefinition.getName(), component.getNormalizedName(), actionStatus.name());
-					return result;
-				}
-				updatedGroups.add(associateArtifactsToGroup.left().value());
-
-			}
-
-			result = Either.left(updatedGroups);
-			return result;
-
-		} finally {
-
-			if (false == inTransaction) {
-
-				if (result == null || result.isRight()) {
-					log.debug("Going to execute rollback on create group.");
-					titanDao.rollback();
-				} else {
-					log.debug("Going to execute commit on create group.");
-					titanDao.commit();
-				}
-
-			}
-			// unlock resource
-			if (shouldLockComp && component != null) {
-				graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
-			}
-
-		}
-
-	}*/
-
-	/*public Either<List<GroupDefinition>, ResponseFormat> createGroups(String componentId, String userId, ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions, boolean shouldLockComp, boolean inTransaction) {
-
-		Either<List<GroupDefinition>, ResponseFormat> result = null;
-
-		List<GroupDefinition> groups = new ArrayList<>();
-		org.openecomp.sdc.be.model.Component component = null;
-		try {
-
-			if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
-
-				if (shouldLockComp && inTransaction) {
-					BeEcompErrorManager.getInstance().logInternalFlowError("createGroups", "Cannot lock component since we are inside a transaction", ErrorSeverity.ERROR);
-					// Cannot lock component since we are in a middle of another
-					// transaction.
-					ActionStatus actionStatus = ActionStatus.INVALID_CONTENT;
-					result = Either.right(componentsUtils.getResponseFormat(actionStatus));
-					return result;
-				}
-
-				Either<User, ResponseFormat> validateUserExists = validateUserExists(userId, CREATE_GROUP, true);
-				if (validateUserExists.isRight()) {
-					result = Either.right(validateUserExists.right().value());
-					return result;
-				}
-
-				User user = validateUserExists.left().value();
-
-				ComponentParametersView componentParametersView = new ComponentParametersView();
-				componentParametersView.disableAll();
-				componentParametersView.setIgnoreGroups(false);
-				componentParametersView.setIgnoreArtifacts(false);
-				componentParametersView.setIgnoreUsers(false);
-				componentParametersView.setIgnoreComponentInstances(false);
-
-				Either<? extends org.openecomp.sdc.be.model.Component, ResponseFormat> validateComponent = validateComponentExists(componentId, componentType, componentParametersView);
-
-				if (validateComponent.isRight()) {
-					result = Either.right(validateComponent.right().value());
-					return result;
-				}
-				component = validateComponent.left().value();
-
-				if (shouldLockComp) {
-					Either<Boolean, ResponseFormat> lockComponent = lockComponent(component, "CreateGroups");
-					if (lockComponent.isRight()) {
-						return Either.right(lockComponent.right().value());
-					}
-				}
-
-				Either<Boolean, ResponseFormat> canWork = validateCanWorkOnComponent(component, userId);
-				if (canWork.isRight()) {
-					result = Either.right(canWork.right().value());
-					return result;
-				}
-
-				for (GroupDefinition groupDefinition : groupDefinitions) {
-					Either<GroupDefinition, ResponseFormat> createGroup = this.createGroup(component, user, componentType, groupDefinition, true);
-					if (createGroup.isRight()) {
-						log.debug("Failed to create group {}." , groupDefinition );
-						result = Either.right(createGroup.right().value());
-						return result;
-					}
-					GroupDefinition createdGroup = createGroup.left().value();
-					groups.add(createdGroup);
-				}
-			}
-
-			result = Either.left(groups);
-			return result;
-
-		} finally {
-
-			if (false == inTransaction) {
-
-				if (result == null || result.isRight()) {
-					log.debug("Going to execute rollback on create group.");
-					titanDao.rollback();
-				} else {
-					log.debug("Going to execute commit on create group.");
-					titanDao.commit();
-				}
-
-			}
-			// unlock resource
-			if (shouldLockComp && component != null) {
-				graphLockOperation.unlockComponent(componentId, componentType.getNodeType());
-			}
-
-		}
-
-	}
-
-	public Either<GroupDefinition, ResponseFormat> createGroup(Component component, User user, ComponentTypeEnum componentType, GroupDefinition groupDefinition, boolean inTransaction) {
-
-		Either<GroupDefinition, ResponseFormat> result = null;
-
-		log.trace("Going to create group {}" , groupDefinition);
-
-		try {
-
-			// 3. verify group not already exist
-			List<GroupDefinition> groups = component.getGroups();
-			boolean found = false;
-			if (groups != null && false == groups.isEmpty()) {
-
-				GroupDefinition existGroupDef = groups.stream().filter(p -> p.getName().equalsIgnoreCase(groupDefinition.getName())).findFirst().orElse(null);
-
-				found = existGroupDef != null;
-			}
-
-			if (true == found) {
-				String componentTypeForResponse = getComponentTypeForResponse(component);
-				result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_ALREADY_EXIST, groupDefinition.getName(), component.getNormalizedName(), componentTypeForResponse));
-				return result;
-			}
-
-			// 4. verify type of group exist
-			String groupType = groupDefinition.getType();
-			if (groupType == null || groupType.isEmpty()) {
-				result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_MISSING_GROUP_TYPE, groupDefinition.getName()));
-				return result;
-			}
-			Either<GroupTypeDefinition, StorageOperationStatus> getGroupType = groupTypeOperation.getLatestGroupTypeByType(groupType, true);
-			if (getGroupType.isRight()) {
-				StorageOperationStatus status = getGroupType.right().value();
-				if (status == StorageOperationStatus.NOT_FOUND) {
-					BeEcompErrorManager.getInstance().logInvalidInputError(CREATE_GROUP, "group type " + groupType + " cannot be found", ErrorSeverity.INFO);
-					result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GROUP_TYPE_IS_INVALID, groupType));
-					return result;
-				} else {
-					result = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
-					return result;
-				}
-			}
-
-			// 6. verify the component instances type are allowed according to
-			// the member types in the group type
-			GroupTypeDefinition groupTypeDefinition = getGroupType.left().value();
-
-			Either<Boolean, ResponseFormat> areValidMembers = verifyComponentInstancesAreValidMembers(component, componentType, groupDefinition.getName(), groupType, groupDefinition.getMembers(), groupTypeDefinition.getMembers());
-
-			if (areValidMembers.isRight()) {
-				ResponseFormat responseFormat = areValidMembers.right().value();
-				result = Either.right(responseFormat);
-				return result;
-			}
-
-			// 7. verify the artifacts belongs to the component
-			Either<Boolean, ResponseFormat> areValidArtifacts = verifyArtifactsBelongsToComponent(component, groupDefinition.getArtifacts(), CREATE_GROUP);
-			if (areValidArtifacts.isRight()) {
-				ResponseFormat responseFormat = areValidArtifacts.right().value();
-				result = Either.right(responseFormat);
-				return result;
-			}
-
-			NodeTypeEnum nodeTypeEnum = componentType.getNodeType();
-
-			// add invariantUUID
-			String invariantUUID = UniqueIdBuilder.buildInvariantUUID();
-			groupDefinition.setInvariantUUID(invariantUUID);
-
-			// add groupUUID
-			String groupUUID = UniqueIdBuilder.generateUUID();
-			groupDefinition.setGroupUUID(groupUUID);
-
-			// add version
-			groupDefinition.setVersion(INITIAL_VERSION);
-
-			// set groupType uid
-			groupDefinition.setTypeUid(groupTypeDefinition.getUniqueId());
-
-			Either<GroupDefinition, StorageOperationStatus> addGroupToGraph = groupOperation.addGroup(nodeTypeEnum, component.getUniqueId(), groupDefinition, true);
-
-			if (addGroupToGraph.isRight()) {
-				StorageOperationStatus storageOperationStatus = addGroupToGraph.right().value();
-				ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(storageOperationStatus);
-				result = Either.right(componentsUtils.getResponseFormat(actionStatus));
-				log.debug("Failed to create group {} under component {}, error: {}", groupDefinition.getName(), component.getNormalizedName(), actionStatus.name());
-			} else {
-				GroupDefinition groupDefinitionCreated = addGroupToGraph.left().value();
-				result = Either.left(groupDefinitionCreated);
-			}
-
-			return result;
-
-		} finally {
-
-			if (false == inTransaction) {
-
-				if (result == null || result.isRight()) {
-					log.debug("Going to execute rollback on create group.");
-					titanDao.rollback();
-				} else {
-					log.debug("Going to execute commit on create group.");
-					titanDao.commit();
-				}
-
-			}
-
-		}
-
-	}
-
-	public Either<List<GroupDefinition>, ResponseFormat> updateVfModuleGroupNames(String resourceSystemName, List<GroupDefinition> groups, boolean inTransaction) {
-		List<GroupDefinition> updatedGroups = new ArrayList<>();
-		Either<List<GroupDefinition>, ResponseFormat> updateGroupNamesRes = Either.left(updatedGroups);
-		Either<GroupDefinition, StorageOperationStatus> updateGroupNameRes;
-		Either<String, ResponseFormat> validateGenerateGroupNameRes;
-		int counter;
-		for (GroupDefinition group : groups) {
-			if (!group.getType().equals(Constants.DEFAULT_GROUP_VF_MODULE) && !Pattern.compile(Constants.MODULE_OLD_NAME_PATTERN).matcher(group.getName()).matches()) {
-				continue;
-			}
-			counter = Integer.parseInt(group.getName().split(Constants.MODULE_NAME_DELIMITER)[1]);
-			validateGenerateGroupNameRes = validateGenerateVfModuleGroupName(resourceSystemName, group.getDescription(), counter);
-			if (validateGenerateGroupNameRes.isRight()) {
-				updateGroupNamesRes = Either.right(validateGenerateGroupNameRes.right().value());
-				break;
-			}
-			updateGroupNameRes = groupOperation.updateGroupName(group.getUniqueId(), validateGenerateGroupNameRes.left().value(), inTransaction);
-			if (updateGroupNameRes.isRight()) {
-				ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(updateGroupNameRes.right().value());
-				updateGroupNamesRes = Either.right(componentsUtils.getResponseFormat(actionStatus));
-				break;
-			}
-			updatedGroups.add(updateGroupNameRes.left().value());
-		}
-		return updateGroupNamesRes;
-	}*/
-
-	private Either<List<GroupProperty>, ResponseFormat> updateGroupPropertiesValue(String componentId,
-			GroupDefinition currentGroup, List<GroupProperty> groupPropertyToUpdate, boolean inTransaction) {
+	private Either<List<GroupProperty>, ResponseFormat> updateGroupPropertiesValue(String componentId, GroupDefinition currentGroup, List<GroupProperty> groupPropertyToUpdate, boolean inTransaction) {
 		Either<List<GroupProperty>, ResponseFormat> result;
 
-		Either<List<GroupProperty>, StorageOperationStatus> eitherUpdate = groupsOperation
-				.updateGroupPropertiesOnComponent(componentId, currentGroup, groupPropertyToUpdate);
+		Either<List<GroupProperty>, StorageOperationStatus> eitherUpdate = groupsOperation.updateGroupPropertiesOnComponent(componentId, currentGroup, groupPropertyToUpdate);
 		if (eitherUpdate.isRight()) {
 			ActionStatus actionStatus = componentsUtils.convertFromStorageResponse(eitherUpdate.right().value());
 			result = Either.right(componentsUtils.getResponseFormat(actionStatus));
@@ -1661,7 +1349,7 @@
 		}
 		return result;
 	}
-	
+
 	public Either<Boolean, ResponseFormat> validateGenerateVfModuleGroupNames(List<ArtifactTemplateInfo> allGroups, String resourceSystemName, int startGroupCounter) {
 		Either<Boolean, ResponseFormat> validateGenerateGroupNamesRes = Either.left(true);
 		Collections.sort(allGroups, (art1, art2) -> ArtifactTemplateInfo.compareByGroupName(art1, art2));
@@ -1768,53 +1456,38 @@
 				}
 				newGroupName = newGroupNameRes.left().value();
 				group.setName(newGroupName);
-			
+
 			}
 			updatedGroups.add(group);
-			
+
 		}
 
 		result = Either.left(updatedGroups);
 		return result;
 	}
 
-	/*public Either<List<GroupDefinition>, ResponseFormat> createGroups(Component component, User user, ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions, boolean inTransaction) {
-
-		List<GroupDefinition> generatedGroups = new ArrayList<>();
-		Either<List<GroupDefinition>, ResponseFormat> result = Either.left(generatedGroups);
-
-		try {
-
-			if (groupDefinitions != null && false == groupDefinitions.isEmpty()) {
-				for (GroupDefinition groupDefinition : groupDefinitions) {
-					Either<GroupDefinition, ResponseFormat> createGroup = this.createGroup(component, user, componentType, groupDefinition, true);
-					if (createGroup.isRight()) {
-						result = Either.right(createGroup.right().value());
-						return result;
-					}
-					GroupDefinition generatedGroup = createGroup.left().value();
-					generatedGroups.add(generatedGroup);
-				}
-			}
-
-			return result;
-		} finally {
-
-			if (false == inTransaction) {
-
-				if (result == null || result.isRight()) {
-					log.debug("Going to execute rollback on create group.");
-					titanDao.rollback();
-				} else {
-					log.debug("Going to execute commit on create group.");
-					titanDao.commit();
-				}
-
-			}
-
-		}
-
-	}*/
+	/*
+	 * public Either<List<GroupDefinition>, ResponseFormat> createGroups(Component component, User user, ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions, boolean inTransaction) {
+	 * 
+	 * List<GroupDefinition> generatedGroups = new ArrayList<>(); Either<List<GroupDefinition>, ResponseFormat> result = Either.left(generatedGroups);
+	 * 
+	 * try {
+	 * 
+	 * if (groupDefinitions != null && false == groupDefinitions.isEmpty()) { for (GroupDefinition groupDefinition : groupDefinitions) { Either<GroupDefinition, ResponseFormat> createGroup = this.createGroup(component, user, componentType,
+	 * groupDefinition, true); if (createGroup.isRight()) { result = Either.right(createGroup.right().value()); return result; } GroupDefinition generatedGroup = createGroup.left().value(); generatedGroups.add(generatedGroup); } }
+	 * 
+	 * return result; } finally {
+	 * 
+	 * if (false == inTransaction) {
+	 * 
+	 * if (result == null || result.isRight()) { log.debug("Going to execute rollback on create group."); titanDao.rollback(); } else { log.debug("Going to execute commit on create group."); titanDao.commit(); }
+	 * 
+	 * }
+	 * 
+	 * }
+	 * 
+	 * }
+	 */
 
 	public Either<GroupDefinitionInfo, ResponseFormat> getGroupInstWithArtifactsById(ComponentTypeEnum componentType, String componentId, String componentInstanceId, String groupInstId, String userId, boolean inTransaction) {
 		Either<GroupDefinitionInfo, ResponseFormat> result = null;
@@ -1833,7 +1506,7 @@
 
 		try {
 			ComponentParametersView componentParametersView = new ComponentParametersView();
-			componentParametersView.disableAll();			
+			componentParametersView.disableAll();
 			componentParametersView.setIgnoreUsers(false);
 			componentParametersView.setIgnoreComponentInstances(false);
 			componentParametersView.setIgnoreArtifacts(false);
@@ -1845,7 +1518,7 @@
 			}
 			component = validateComponent.left().value();
 			Either<ImmutablePair<ComponentInstance, GroupInstance>, StorageOperationStatus> findComponentInstanceAndGroupInstanceRes = findComponentInstanceAndGroupInstanceOnComponent(component, componentInstanceId, groupInstId);
-			
+
 			if (findComponentInstanceAndGroupInstanceRes.isRight()) {
 				log.debug("Failed to get group {} . Status is {} ", groupInstId, findComponentInstanceAndGroupInstanceRes.right().value());
 				ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(findComponentInstanceAndGroupInstanceRes.right().value()));
@@ -1855,7 +1528,7 @@
 
 			GroupInstance group = findComponentInstanceAndGroupInstanceRes.left().value().getRight();
 			ComponentInstance componentInstance = findComponentInstanceAndGroupInstanceRes.left().value().getLeft();
-			
+
 			Boolean isBase = null;// Constants.IS_BASE;
 			List<? extends GroupProperty> props = group.convertToGroupInstancesProperties();
 			if (props != null && !props.isEmpty()) {
@@ -1871,30 +1544,33 @@
 
 				}
 			}
-			
+
 			List<ArtifactDefinitionInfo> artifacts = new ArrayList<>();
-			List<ArtifactDefinition> artifactsFromComponent = new ArrayList<>();
 			List<String> artifactsIds = group.getArtifacts();
 			if (artifactsIds != null && !artifactsIds.isEmpty()) {
-				
-				for(String id: artifactsIds){
-					Either<ArtifactDefinition, StorageOperationStatus> artifactEither = artifactsOperation.getArtifactById(componentInstance.getComponentUid(), id);
-					if (artifactEither.isRight()) {
-						log.debug("Failed to get artifact {} . Status is {} ", id, artifactEither.right().value());
-						ResponseFormat responseFormat = componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(artifactEither.right().value()));
-						result = Either.right(responseFormat);
-						return result;
+
+				List<ComponentInstance> instances = component.getComponentInstances();
+				if (instances != null) {
+					Optional<ComponentInstance> findFirst = instances.stream().filter(i -> i.getUniqueId().equals(componentInstanceId)).findFirst();
+					if (findFirst.isPresent()) {
+						ComponentInstance ci = findFirst.get();
+						Map<String, ArtifactDefinition> deploymentArtifacts = ci.getDeploymentArtifacts();
+						for (String id : artifactsIds) {
+							Optional<ArtifactDefinition> artOp = deploymentArtifacts.values().stream().filter(a -> a.getUniqueId().equals(id)).findFirst();
+							if (artOp.isPresent()) {
+								artifacts.add(new ArtifactDefinitionInfo(artOp.get()));
+							}
+						}
+						List<String> instArtifactsIds = group.getGroupInstanceArtifacts();
+						for (String id : instArtifactsIds) {
+							Optional<ArtifactDefinition> artOp = deploymentArtifacts.values().stream().filter(a -> a.getUniqueId().equals(id)).findFirst();
+							if (artOp.isPresent()) {
+								artifacts.add(new ArtifactDefinitionInfo(artOp.get()));
+							}
+						}
 					}
-					artifactsFromComponent.add(artifactEither.left().value());
+
 				}
-				if (!artifactsFromComponent.isEmpty()) {
-					for (ArtifactDefinition artifactDefinition : artifactsFromComponent) {
-						ArtifactDefinitionInfo artifactDefinitionInfo = new ArtifactDefinitionInfo(artifactDefinition);
-						artifacts.add(artifactDefinitionInfo);
-					}
-				}
-				
-				
 			}
 			GroupDefinitionInfo resultInfo = new GroupDefinitionInfo(group);
 			resultInfo.setIsBase(isBase);
@@ -1905,7 +1581,6 @@
 
 			return result;
 
-			
 		} finally {
 
 			if (false == inTransaction) {
@@ -1922,250 +1597,230 @@
 
 		}
 	}
-	
+
 	private Either<ImmutablePair<ComponentInstance, GroupInstance>, StorageOperationStatus> findComponentInstanceAndGroupInstanceOnComponent(Component component, String componentInstanceId, String groupInstId) {
-		
-		Either<ImmutablePair<ComponentInstance,GroupInstance>, StorageOperationStatus> result = null;
-		if(CollectionUtils.isNotEmpty(component.getComponentInstances())){
+
+		Either<ImmutablePair<ComponentInstance, GroupInstance>, StorageOperationStatus> result = null;
+		if (CollectionUtils.isNotEmpty(component.getComponentInstances())) {
 			Optional<GroupInstance> foundGroup;
 			Optional<ComponentInstance> foundComponent = component.getComponentInstances().stream().filter(ci -> ci.getUniqueId().equals(componentInstanceId)).findFirst();
-			if(foundComponent.isPresent() && CollectionUtils.isNotEmpty(foundComponent.get().getGroupInstances())){
+			if (foundComponent.isPresent() && CollectionUtils.isNotEmpty(foundComponent.get().getGroupInstances())) {
 				foundGroup = foundComponent.get().getGroupInstances().stream().filter(gi -> gi.getUniqueId().equals(groupInstId)).findFirst();
-				if(foundGroup.isPresent()){
+				if (foundGroup.isPresent()) {
 					result = Either.left(new ImmutablePair<>(foundComponent.get(), foundGroup.get()));
 				}
 			}
 		}
-		if(result == null){
+		if (result == null) {
 			result = Either.right(StorageOperationStatus.NOT_FOUND);
 		}
 		return result;
 	}
 
-	private int getLatestIntProperty(Map<PropertyNames, String> newValues, Map<PropertyNames, String> parentValues,
-			PropertyNames propertyKey) {
+	private int getLatestIntProperty(Map<PropertyNames, String> newValues, Map<PropertyNames, String> parentValues, PropertyNames propertyKey) {
 		String value;
-		if( newValues.containsKey(propertyKey) ){
+		if (newValues.containsKey(propertyKey)) {
 			value = newValues.get(propertyKey);
-		}
-		else{
+		} else {
 			value = parentValues.get(propertyKey);
 		}
 		return Integer.valueOf(value);
 	}
 
-	private boolean isPropertyChanged(Map<PropertyNames, String> newValues, Map<PropertyNames, String> parentValues,
-			final PropertyNames minInstances) {
+	private boolean isPropertyChanged(Map<PropertyNames, String> newValues, Map<PropertyNames, String> parentValues, final PropertyNames minInstances) {
 		return newValues.containsKey(minInstances) && newValues.containsKey(minInstances) && !newValues.get(minInstances).equals(parentValues.get(minInstances));
 	}
 
-	private Either<Boolean, ResponseFormat> validateMinMaxAndInitialCountPropertyLogicVF(
-			Map<PropertyNames, String> newValues, Map<PropertyNames, String> parentValues) {
-		
+	private Either<Boolean, ResponseFormat> validateMinMaxAndInitialCountPropertyLogicVF(Map<PropertyNames, String> newValues, Map<PropertyNames, String> parentValues) {
+
 		int latestMaxInstances = getLatestIntProperty(newValues, parentValues, PropertyNames.MAX_INSTANCES);
 		int latestInitialCount = getLatestIntProperty(newValues, parentValues, PropertyNames.INITIAL_COUNT);
 		int latestMinInstances = getLatestIntProperty(newValues, parentValues, PropertyNames.MIN_INSTANCES);
 		Either<Boolean, ResponseFormat> result = Either.left(true);
-		
+
 		if (isPropertyChanged(newValues, parentValues, PropertyNames.INITIAL_COUNT) && result.isLeft()) {
 			if (latestInitialCount > latestMaxInstances || latestInitialCount < latestMinInstances) {
-				result = Either.right(
-						componentsUtils.getResponseFormat(ActionStatus.INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE,
-								PropertyNames.INITIAL_COUNT.getPropertyName(), String.valueOf(latestMinInstances),
-								String.valueOf(latestMaxInstances)));
+				result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_GROUP_INITIAL_COUNT_PROPERTY_VALUE, PropertyNames.INITIAL_COUNT.getPropertyName(), String.valueOf(latestMinInstances), String.valueOf(latestMaxInstances)));
 			}
 		}
 		if (isPropertyChanged(newValues, parentValues, PropertyNames.MAX_INSTANCES) && result.isLeft()) {
 			if (latestMaxInstances < latestInitialCount) {
-				result = Either.right(componentsUtils.getResponseFormat(
-						ActionStatus.INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER,
-						PropertyNames.MAX_INSTANCES.getPropertyName(), "higher", String.valueOf(latestInitialCount)));
+				result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER, PropertyNames.MAX_INSTANCES.getPropertyName(), "higher", String.valueOf(latestInitialCount)));
 			}
 
 		}
 		if (isPropertyChanged(newValues, parentValues, PropertyNames.MIN_INSTANCES) && result.isLeft()) {
 			if (latestMinInstances > latestInitialCount) {
-				result = Either.right(componentsUtils.getResponseFormat(
-						ActionStatus.INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER,
-						PropertyNames.MIN_INSTANCES.getPropertyName(), "lower", String.valueOf(latestInitialCount)));
+				result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_GROUP_PROPERTY_VALUE_LOWER_HIGHER, PropertyNames.MIN_INSTANCES.getPropertyName(), "lower", String.valueOf(latestInitialCount)));
 			}
 
 		}
 		return result;
 	}
+
 	private Either<Boolean, ResponseFormat> validateMinMaxAndInitialCountPropertyLogic(Map<PropertyNames, String> newValues, Map<PropertyNames, String> currValues, Map<PropertyNames, String> parentValues) {
-		
+
 		Either<Boolean, ResponseFormat> result;
-		for(Entry<PropertyNames, String> entry : newValues.entrySet()){
+		for (Entry<PropertyNames, String> entry : newValues.entrySet()) {
 			PropertyNames currPropertyName = entry.getKey();
-			if(currPropertyName == PropertyNames.MIN_INSTANCES){
+			if (currPropertyName == PropertyNames.MIN_INSTANCES) {
 				String minValue = parentValues.get(PropertyNames.MIN_INSTANCES);
 				String maxValue = newValues.containsKey(PropertyNames.INITIAL_COUNT) ? newValues.get(PropertyNames.MAX_INSTANCES) : currValues.get(PropertyNames.INITIAL_COUNT);
-				result = validateValueInRange(new ImmutablePair<PropertyNames, String>(currPropertyName, entry.getValue()),
-						new ImmutablePair<PropertyNames, String>(PropertyNames.MIN_INSTANCES, minValue),
+				result = validateValueInRange(new ImmutablePair<PropertyNames, String>(currPropertyName, entry.getValue()), new ImmutablePair<PropertyNames, String>(PropertyNames.MIN_INSTANCES, minValue),
 						new ImmutablePair<PropertyNames, String>(PropertyNames.MAX_INSTANCES, maxValue));
-				if(result.isRight()){
+				if (result.isRight()) {
 					return result;
 				}
-			}
-			else if(currPropertyName == PropertyNames.INITIAL_COUNT){
+			} else if (currPropertyName == PropertyNames.INITIAL_COUNT) {
 				String minValue = newValues.containsKey(PropertyNames.MIN_INSTANCES) ? newValues.get(PropertyNames.MIN_INSTANCES) : currValues.get(PropertyNames.MIN_INSTANCES);
 				String maxValue = newValues.containsKey(PropertyNames.MAX_INSTANCES) ? newValues.get(PropertyNames.MAX_INSTANCES) : currValues.get(PropertyNames.MAX_INSTANCES);
-				result = validateValueInRange(new ImmutablePair<PropertyNames, String>(currPropertyName, entry.getValue()),
-						new ImmutablePair<PropertyNames, String>(PropertyNames.MIN_INSTANCES,minValue),
+				result = validateValueInRange(new ImmutablePair<PropertyNames, String>(currPropertyName, entry.getValue()), new ImmutablePair<PropertyNames, String>(PropertyNames.MIN_INSTANCES, minValue),
 						new ImmutablePair<PropertyNames, String>(PropertyNames.MAX_INSTANCES, maxValue));
-				if(result.isRight()){
+				if (result.isRight()) {
 					return result;
 				}
-			}
-			else if(currPropertyName == PropertyNames.MAX_INSTANCES){
+			} else if (currPropertyName == PropertyNames.MAX_INSTANCES) {
 				String minValue = newValues.containsKey(PropertyNames.INITIAL_COUNT) ? newValues.get(PropertyNames.MIN_INSTANCES) : currValues.get(PropertyNames.INITIAL_COUNT);
 				String maxValue = parentValues.get(PropertyNames.MAX_INSTANCES);
-				result = validateValueInRange(new ImmutablePair<PropertyNames, String>(currPropertyName, entry.getValue()),
-						new ImmutablePair<PropertyNames, String>(PropertyNames.MIN_INSTANCES, minValue),
+				result = validateValueInRange(new ImmutablePair<PropertyNames, String>(currPropertyName, entry.getValue()), new ImmutablePair<PropertyNames, String>(PropertyNames.MIN_INSTANCES, minValue),
 						new ImmutablePair<PropertyNames, String>(PropertyNames.MAX_INSTANCES, maxValue));
-				if(result.isRight()){
+				if (result.isRight()) {
 					return result;
 				}
 			}
 		}
-	return Either.left(true);
+		return Either.left(true);
 	}
 
-	private Either<Boolean, ResponseFormat> validateValueInRange(ImmutablePair<PropertyNames,String> newValue, ImmutablePair<PropertyNames,String> min, ImmutablePair<PropertyNames,String> max) {
+	private Either<Boolean, ResponseFormat> validateValueInRange(ImmutablePair<PropertyNames, String> newValue, ImmutablePair<PropertyNames, String> min, ImmutablePair<PropertyNames, String> max) {
 		Either<Boolean, ResponseFormat> result;
 		final String warnMessage = "Failed to validate {} as property value of {}. It must be not higher than {}, and not lower than {}.";
 		int newValueInt = parseIntValue(newValue.getValue(), newValue.getKey());
 		int minInt = parseIntValue(min.getValue(), min.getKey());
 		int maxInt = parseIntValue(max.getValue(), max.getKey());
-		if(newValueInt < 0 || minInt < 0 || maxInt < 0){
+		if (newValueInt < 0 || minInt < 0 || maxInt < 0) {
 			result = Either.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_PROPERTY));
-		}
-		else if (newValueInt < minInt || newValueInt > maxInt) {
+		} else if (newValueInt < minInt || newValueInt > maxInt) {
 			log.debug(warnMessage, newValue.getValue(), newValue.getKey().getPropertyName(), min.getValue(), max.getValue());
-			result = Either.right(componentsUtils.getResponseFormat(
-					ActionStatus.INVALID_GROUP_MIN_MAX_INSTANCES_PROPERTY_VALUE,
-					newValue.getKey().getPropertyName(), maxInt == Integer.MAX_VALUE ? Constants.UNBOUNDED : max.getValue(), min.getValue()));
-		}else{
+			result = Either
+					.right(componentsUtils.getResponseFormat(ActionStatus.INVALID_GROUP_MIN_MAX_INSTANCES_PROPERTY_VALUE, newValue.getKey().getPropertyName(), maxInt == Integer.MAX_VALUE ? Constants.UNBOUNDED : max.getValue(), min.getValue()));
+		} else {
 			result = Either.left(true);
 		}
 		return result;
 	}
-	
-		private int parseIntValue(String value, PropertyNames propertyName) {
+
+	private int parseIntValue(String value, PropertyNames propertyName) {
 		int result;
-		if(propertyName == PropertyNames.MAX_INSTANCES ){
+		if (propertyName == PropertyNames.MAX_INSTANCES) {
 			result = convertIfUnboundMax(value);
 		} else if (NumberUtils.isNumber(value)) {
 			result = Integer.parseInt(value);
-		} else{
+		} else {
 			result = -1;
 		}
 		return result;
 	}
 
-/**
- * validates received new property values and updates group instance in case of success
- * @param oldGroupInstance
- * @param groupInstanceId
- * @param newProperties
- * @param inTransaction
- * @return
- */
+	/**
+	 * validates received new property values and updates group instance in case of success
+	 * 
+	 * @param oldGroupInstance
+	 * @param groupInstanceId
+	 * @param newProperties
+	 * @param inTransaction
+	 * @return
+	 */
 	public Either<GroupInstance, ResponseFormat> validateAndUpdateGroupInstancePropertyValues(String componentId, String instanceId, GroupInstance oldGroupInstance, List<GroupInstanceProperty> newProperties, boolean inTransaction) {
-		
+
 		Either<GroupInstance, ResponseFormat> actionResult = null;
 		Either<GroupInstance, StorageOperationStatus> updateGroupInstanceResult = null;
 		Either<List<GroupInstanceProperty>, ResponseFormat> validateRes = validateReduceGroupInstancePropertiesBeforeUpdate(oldGroupInstance, newProperties);
-		if(validateRes.isRight()){
+		if (validateRes.isRight()) {
 			log.debug("Failed to validate group instance {} properties before update. ", oldGroupInstance.getName());
-			actionResult =  Either.right(validateRes.right().value());
+			actionResult = Either.right(validateRes.right().value());
 		}
-		if(actionResult == null){
+		if (actionResult == null) {
 			List<GroupInstanceProperty> validatedReducedNewProperties = validateRes.left().value();
 			updateGroupInstanceResult = groupsOperation.updateGroupInstancePropertyValuesOnGraph(componentId, instanceId, oldGroupInstance, validatedReducedNewProperties);
-			if(updateGroupInstanceResult.isRight()){
+			if (updateGroupInstanceResult.isRight()) {
 				log.debug("Failed to update group instance {} property values. ", oldGroupInstance.getName());
-				actionResult =  Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(updateGroupInstanceResult.right().value())));
+				actionResult = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(updateGroupInstanceResult.right().value())));
 			}
 		}
-		if(actionResult == null){
+		if (actionResult == null) {
 			actionResult = Either.left(updateGroupInstanceResult.left().value());
 		}
 		return actionResult;
 	}
-	
+
 	private Either<List<GroupInstanceProperty>, ResponseFormat> validateReduceGroupInstancePropertiesBeforeUpdate(GroupInstance oldGroupInstance, List<GroupInstanceProperty> newProperties) {
-		
+
 		Either<Boolean, ResponseFormat> validationRes = null;
 		Either<List<GroupInstanceProperty>, ResponseFormat> actionResult;
-		Map<String,GroupInstanceProperty> existingProperties = oldGroupInstance.convertToGroupInstancesProperties().stream().collect(Collectors.toMap(p->p.getName(),p->p));
+		Map<String, GroupInstanceProperty> existingProperties = oldGroupInstance.convertToGroupInstancesProperties().stream().collect(Collectors.toMap(p -> p.getName(), p -> p));
 		Map<PropertyNames, String> newPropertyValues = new EnumMap<>(PropertyNames.class);
 		List<GroupInstanceProperty> reducedProperties = new ArrayList<>();
 		String currPropertyName;
-		try{
-			for(GroupInstanceProperty currNewProperty : newProperties){
+		try {
+			for (GroupInstanceProperty currNewProperty : newProperties) {
 				currPropertyName = currNewProperty.getName();
 				validationRes = handleAndAddProperty(reducedProperties, newPropertyValues, currNewProperty, existingProperties.get(currPropertyName));
-				if(validationRes.isRight()){
+				if (validationRes.isRight()) {
 					log.debug("Failed to handle property {} of group instance {}. ", currPropertyName, oldGroupInstance.getName());
 					break;
 				}
 			}
-			if(validationRes == null || validationRes.isLeft()){
+			if (validationRes == null || validationRes.isLeft()) {
 				Map<PropertyNames, String> existingPropertyValues = new EnumMap<>(PropertyNames.class);
 				Map<PropertyNames, String> parentPropertyValues = new EnumMap<>(PropertyNames.class);
 				fillValuesAndParentValuesFromExistingProperties(existingProperties, existingPropertyValues, parentPropertyValues);
 				validationRes = validateMinMaxAndInitialCountPropertyLogic(newPropertyValues, existingPropertyValues, parentPropertyValues);
 			}
-			if(validationRes.isLeft()){
+			if (validationRes.isLeft()) {
 				actionResult = Either.left(reducedProperties);
 			} else {
 				actionResult = Either.right(validationRes.right().value());
 			}
-		} catch( Exception e){
+		} catch (Exception e) {
 			log.error("Exception occured during validation and reducing group instance properties. The message is {}", e.getMessage(), e);
 			actionResult = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
 		}
 		return actionResult;
 	}
 
-	private  void fillValuesAndParentValuesFromExistingProperties(Map<String, GroupInstanceProperty> existingProperties,
-			Map<PropertyNames, String> propertyValues, Map<PropertyNames, String> parentPropertyValues) {
+	private void fillValuesAndParentValuesFromExistingProperties(Map<String, GroupInstanceProperty> existingProperties, Map<PropertyNames, String> propertyValues, Map<PropertyNames, String> parentPropertyValues) {
 		PropertyNames[] allPropertyNames = PropertyNames.values();
-		for(PropertyNames name : allPropertyNames){
-			if(isUpdatable(name)){
+		for (PropertyNames name : allPropertyNames) {
+			if (isUpdatable(name)) {
 				propertyValues.put(name, String.valueOf(existingProperties.get(name.getPropertyName()).getValue()));
 				parentPropertyValues.put(name, String.valueOf(existingProperties.get(name.getPropertyName()).getParentValue()));
 			}
 		}
 	}
 
-	private Either<Boolean, ResponseFormat> handleAndAddProperty(List<GroupInstanceProperty> reducedProperties,	Map<PropertyNames, String> newPropertyValues,
-			GroupInstanceProperty currNewProperty, GroupInstanceProperty currExistingProperty) {
+	private Either<Boolean, ResponseFormat> handleAndAddProperty(List<GroupInstanceProperty> reducedProperties, Map<PropertyNames, String> newPropertyValues, GroupInstanceProperty currNewProperty, GroupInstanceProperty currExistingProperty) {
 
 		Either<Boolean, ResponseFormat> validationRes = null;
 		String currPropertyName = currNewProperty.getName();
 		PropertyNames propertyName = PropertyNames.findName(currPropertyName);
-		try{
-			if(currExistingProperty == null){
+		try {
+			if (currExistingProperty == null) {
 				log.warn("The value of property with the name {} cannot be updated. The property not found on group instance. ", currPropertyName);
-			}
-			else if(isUpdatable(propertyName)){
+			} else if (isUpdatable(propertyName)) {
 				validationRes = validateAndUpdatePropertyValue(currNewProperty, currExistingProperty);
-				if(validationRes.isRight()){
-					log.debug("Failed to validate property value {} of property {}. ", currNewProperty.getValue() , currPropertyName);
+				if (validationRes.isRight()) {
+					log.debug("Failed to validate property value {} of property {}. ", currNewProperty.getValue(), currPropertyName);
 				} else {
 					addPropertyUpdatedValues(reducedProperties, propertyName, newPropertyValues, currNewProperty, currExistingProperty);
 				}
-			}
-			else{
+			} else {
 				validateImmutableProperty(currExistingProperty, currNewProperty);
 			}
-			if(validationRes == null){
+			if (validationRes == null) {
 				validationRes = Either.left(true);
 			}
-		} catch( Exception e){
+		} catch (Exception e) {
 			log.error("Exception occured during handle and adding property. The message is {}", e.getMessage(), e);
 			validationRes = Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
 		}
@@ -2173,76 +1828,73 @@
 	}
 
 	private boolean isUpdatable(PropertyNames updatablePropertyName) {
-		return updatablePropertyName != null && 
-				updatablePropertyName.getUpdateBehavior().getLevelNumber() >= GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_SERVICE_LEVEL.getLevelNumber();
+		return updatablePropertyName != null && updatablePropertyName.getUpdateBehavior().getLevelNumber() >= GroupInstancePropertyValueUpdateBehavior.UPDATABLE_ON_SERVICE_LEVEL.getLevelNumber();
 	}
 
-	private void addPropertyUpdatedValues(List<GroupInstanceProperty> reducedProperties, PropertyNames propertyName, Map<PropertyNames, String> newPropertyValues,
-			GroupInstanceProperty newProperty, GroupInstanceProperty existingProperty) {
-		
-		String newValue  = newProperty.getValue();
-		if(!newValue.equals(String.valueOf(existingProperty.getValue()))){
+	private void addPropertyUpdatedValues(List<GroupInstanceProperty> reducedProperties, PropertyNames propertyName, Map<PropertyNames, String> newPropertyValues, GroupInstanceProperty newProperty, GroupInstanceProperty existingProperty) {
+
+		String newValue = newProperty.getValue();
+		if (!newValue.equals(String.valueOf(existingProperty.getValue()))) {
 			newProperty.setValueUniqueUid(existingProperty.getValueUniqueUid());
 			reducedProperties.add(newProperty);
 		}
-		if(!isEmptyMinInitialCountValue(propertyName, newValue)){
+		if (!isEmptyMinInitialCountValue(propertyName, newValue)) {
 			newPropertyValues.put(propertyName, newValue);
 		}
 	}
-	
+
 	private boolean isEmptyMinInitialCountValue(PropertyNames propertyName, String newValue) {
 		boolean result = false;
-		if((propertyName == PropertyNames.MIN_INSTANCES || propertyName == PropertyNames.INITIAL_COUNT) && !NumberUtils.isNumber(newValue)){
+		if ((propertyName == PropertyNames.MIN_INSTANCES || propertyName == PropertyNames.INITIAL_COUNT) && !NumberUtils.isNumber(newValue)) {
 			result = true;
 		}
 		return result;
 	}
 
 	private int convertIfUnboundMax(String value) {
-		
+
 		int result;
-		if(!NumberUtils.isNumber(value)){
+		if (!NumberUtils.isNumber(value)) {
 			result = Integer.MAX_VALUE;
-		}
-		else{
+		} else {
 			result = Integer.parseInt(value);
 		}
 		return result;
 	}
 
 	private Either<Boolean, ResponseFormat> validateAndUpdatePropertyValue(GroupInstanceProperty newProperty, GroupInstanceProperty existingProperty) {
-		
+
 		Either<Boolean, ResponseFormat> validationRes = null;
 		String parentValue = existingProperty.getParentValue();
-		
+
 		newProperty.setParentValue(parentValue);
-		if(StringUtils.isEmpty(newProperty.getValue())){
+		if (StringUtils.isEmpty(newProperty.getValue())) {
 			newProperty.setValue(parentValue);
 		}
-		if(StringUtils.isEmpty(existingProperty.getValue())){
+		if (StringUtils.isEmpty(existingProperty.getValue())) {
 			existingProperty.setValue(parentValue);
 		}
-		StorageOperationStatus status =  groupOperation.validateAndUpdatePropertyValue(newProperty);
-		if(status != StorageOperationStatus.OK){
+		StorageOperationStatus status = groupOperation.validateAndUpdatePropertyValue(newProperty);
+		if (status != StorageOperationStatus.OK) {
 			log.debug("Failed to validate property value {} of property with name {}. Status is {}. ", newProperty.getValue(), newProperty.getName(), status);
 			validationRes = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(status)));
 		}
-		if(validationRes == null){
+		if (validationRes == null) {
 			validationRes = Either.left(true);
 		}
 		return validationRes;
 	}
 
 	private void validateImmutableProperty(GroupProperty oldProperty, GroupProperty newProperty) {
-		if(oldProperty.getValue() == null && newProperty.getValue() != null || oldProperty.getValue()!=null && !oldProperty.getValue().equals(newProperty.getValue())){
-			log.warn("The value of property with the name {} cannot be updated on service level. Going to ignore new property value {}. ",oldProperty.getName(), newProperty.getValue());
+		if (oldProperty.getValue() == null && newProperty.getValue() != null || oldProperty.getValue() != null && !oldProperty.getValue().equals(newProperty.getValue())) {
+			log.warn("The value of property with the name {} cannot be updated on service level. Going to ignore new property value {}. ", oldProperty.getName(), newProperty.getValue());
 		}
 	}
 
 	public Either<List<GroupDefinition>, ResponseFormat> createGroups(Component component, User user, ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions) {
 
-		Map<String,GroupDataDefinition> groups = new HashMap<>();
-		//Map<String, MapPropertiesDataDefinition> groupsPropertiesMap = new HashMap<>();
+		Map<String, GroupDataDefinition> groups = new HashMap<>();
+		// Map<String, MapPropertiesDataDefinition> groupsPropertiesMap = new HashMap<>();
 		Either<List<GroupDefinition>, ResponseFormat> result = null;
 		Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
 		Either<Map<String, DataTypeDefinition>, TitanOperationStatus> allDataTypes = dataTypeCache.getAll();
@@ -2253,38 +1905,37 @@
 
 		}
 
-		//handle groups and convert to tosca data
+		// handle groups and convert to tosca data
 		if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
 			for (GroupDefinition groupDefinition : groupDefinitions) {
-				 Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, user, componentType, groupDefinition, allDataTypes.left().value());
+				Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, user, componentType, groupDefinition, allDataTypes.left().value());
 				if (handleGroupRes.isRight()) {
 					result = Either.right(handleGroupRes.right().value());
 					break;
 				}
 				GroupDefinition handledGroup = handleGroupRes.left().value();
 				groups.put(handledGroup.getName(), new GroupDataDefinition(handledGroup));
-				
+
 			}
 		}
-		if(result == null){
+		if (result == null) {
 			createGroupsResult = groupsOperation.createGroups(component, user, componentType, groups);
-			if(createGroupsResult.isRight()){
+			if (createGroupsResult.isRight()) {
 				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(createGroupsResult.right().value())));
 			}
 		}
-		if(result == null){
+		if (result == null) {
 			result = Either.left(createGroupsResult.left().value());
 		}
 		return result;
 	}
-	
+
 	public Either<List<GroupDefinition>, ResponseFormat> addGroups(Component component, User user, ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions) {
 
-		
 		Either<List<GroupDefinition>, ResponseFormat> result = null;
 		Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
 		List<GroupDataDefinition> groups = new ArrayList<>();
-		
+
 		Either<Map<String, DataTypeDefinition>, TitanOperationStatus> allDataTypes = dataTypeCache.getAll();
 		if (allDataTypes.isRight()) {
 			TitanOperationStatus status = allDataTypes.right().value();
@@ -2293,10 +1944,10 @@
 
 		}
 
-		//handle groups and convert to tosca data
+		// handle groups and convert to tosca data
 		if (groupDefinitions != null && !groupDefinitions.isEmpty()) {
 			for (GroupDefinition groupDefinition : groupDefinitions) {
-				 Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, user, componentType, groupDefinition, allDataTypes.left().value());
+				Either<GroupDefinition, ResponseFormat> handleGroupRes = handleGroup(component, user, componentType, groupDefinition, allDataTypes.left().value());
 				if (handleGroupRes.isRight()) {
 					result = Either.right(handleGroupRes.right().value());
 					break;
@@ -2305,35 +1956,34 @@
 				groups.add(new GroupDataDefinition(handledGroup));
 			}
 		}
-		if(result == null){
+		if (result == null) {
 			createGroupsResult = groupsOperation.addGroups(component, user, componentType, groups);
-			if(createGroupsResult.isRight()){
+			if (createGroupsResult.isRight()) {
 				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(createGroupsResult.right().value())));
 			}
 		}
-		if(result == null){
+		if (result == null) {
 			result = Either.left(createGroupsResult.left().value());
 		}
 		return result;
 	}
-	
+
 	public Either<List<GroupDefinition>, ResponseFormat> deleteGroups(Component component, User user, ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions) {
 
-		
 		Either<List<GroupDefinition>, ResponseFormat> result = null;
 		Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
-	
-			createGroupsResult = groupsOperation.deleteGroups(component, user, componentType, groupDefinitions.stream().map(x-> new GroupDataDefinition(x)).collect(Collectors.toList()));
-			if(createGroupsResult.isRight()){
-				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(createGroupsResult.right().value())));
-			}
-		
-		if(result == null){
+
+		createGroupsResult = groupsOperation.deleteGroups(component, user, componentType, groupDefinitions.stream().map(x -> new GroupDataDefinition(x)).collect(Collectors.toList()));
+		if (createGroupsResult.isRight()) {
+			result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(createGroupsResult.right().value())));
+		}
+
+		if (result == null) {
 			result = Either.left(createGroupsResult.left().value());
 		}
 		return result;
 	}
-	
+
 	/**
 	 * Update specific group version
 	 * 
@@ -2341,34 +1991,34 @@
 	 * @param inTransaction
 	 * @return
 	 */
-	public Either<List<GroupDefinition>, ResponseFormat> updateGroups(Component component,  ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions) {
+	public Either<List<GroupDefinition>, ResponseFormat> updateGroups(Component component, ComponentTypeEnum componentType, List<GroupDefinition> groupDefinitions) {
 
 		Either<List<GroupDefinition>, ResponseFormat> result = null;
 		Either<List<GroupDefinition>, StorageOperationStatus> createGroupsResult = null;
-	
-			createGroupsResult = groupsOperation.updateGroups(component,  componentType, groupDefinitions.stream().map(x-> new GroupDataDefinition(x)).collect(Collectors.toList()));
-			if(createGroupsResult.isRight()){
-				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(createGroupsResult.right().value())));
-			}
-		
-		if(result == null){
+
+		createGroupsResult = groupsOperation.updateGroups(component, componentType, groupDefinitions.stream().map(x -> new GroupDataDefinition(x)).collect(Collectors.toList()));
+		if (createGroupsResult.isRight()) {
+			result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(createGroupsResult.right().value())));
+		}
+
+		if (result == null) {
 			result = Either.left(createGroupsResult.left().value());
 		}
 		return result;
 	}
-			
+
 	public Either<GroupDefinition, ResponseFormat> handleGroup(Component component, User user, ComponentTypeEnum componentType, GroupDefinition groupDefinition, Map<String, DataTypeDefinition> allDAtaTypes) {
-			
+
 		Either<GroupDefinition, ResponseFormat> result = null;
-	
-		log.trace("Going to create group {}" , groupDefinition);
+
+		log.trace("Going to create group {}", groupDefinition);
 		// 3. verify group not already exist
 		List<GroupDefinition> groups = component.getGroups();
 		boolean found = false;
 		if (groups != null && false == groups.isEmpty()) {
-	
+
 			GroupDefinition existGroupDef = groups.stream().filter(p -> p.getName().equalsIgnoreCase(groupDefinition.getName())).findFirst().orElse(null);
-	
+
 			found = existGroupDef != null;
 		}
 		if (true == found) {
@@ -2413,7 +2063,7 @@
 			return result;
 		}
 		List<PropertyDefinition> groupTypeProperties = groupTypeDefinition.getProperties();
-		
+
 		List<GroupProperty> properties = groupDefinition.convertToGroupProperties();
 		List<GroupProperty> updatedGroupTypeProperties = new ArrayList<>();
 		if (properties != null && false == properties.isEmpty()) {
@@ -2429,20 +2079,20 @@
 			int i = 1;
 			for (GroupProperty prop : properties) {
 				addPropertyResult = handleProperty(prop, groupTypePropertiesMap.get(prop.getName()), i, allDAtaTypes);
-				if(addPropertyResult.isRight()){
+				if (addPropertyResult.isRight()) {
 					BeEcompErrorManager.getInstance().logInvalidInputError(ADDING_GROUP, "failed to validate property", ErrorSeverity.INFO);
 					return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(DaoStatusConverter.convertTitanStatusToStorageStatus(addPropertyResult.right().value()))));
 				}
 				updatedGroupTypeProperties.add(addPropertyResult.left().value());
-				
+
 				i++;
 			}
 		}
-		if(groupDefinition.getUniqueId() == null){
+		if (groupDefinition.getUniqueId() == null) {
 			String uid = UniqueIdBuilder.buildGroupingUid(component.getUniqueId(), groupDefinition.getName());
 			groupDefinition.setUniqueId(uid);
 		}
-		groupDefinition.convertFromGroupProperties(updatedGroupTypeProperties);		
+		groupDefinition.convertFromGroupProperties(updatedGroupTypeProperties);
 		groupDefinition.setInvariantUUID(UniqueIdBuilder.buildInvariantUUID());
 		groupDefinition.setGroupUUID(UniqueIdBuilder.generateUUID());
 		groupDefinition.setVersion(INITIAL_VERSION);
@@ -2450,9 +2100,7 @@
 
 		return Either.left(groupDefinition);
 	}
-	
-	
-	
+
 	public Either<GroupProperty, TitanOperationStatus> handleProperty(GroupProperty groupProperty, PropertyDefinition prop, Integer index, Map<String, DataTypeDefinition> allDataTypes) {
 
 		if (prop == null) {
@@ -2471,7 +2119,6 @@
 
 		String innerType = checkInnerType.left().value();
 
-		
 		log.debug("Before validateAndUpdatePropertyValue");
 		Either<Object, Boolean> isValid = propertyOperation.validateAndUpdatePropertyValue(propertyType, value, innerType, allDataTypes);
 		log.debug("After validateAndUpdatePropertyValue. isValid = {}", isValid);
@@ -2490,24 +2137,19 @@
 		}
 
 		String uniqueId = UniqueIdBuilder.buildGroupPropertyValueUid((String) prop.getUniqueId(), index);
-	
+
 		groupProperty.setUniqueId(uniqueId);
 		groupProperty.setValue(newValue);
-		groupProperty.setType(prop.getType());		
+		groupProperty.setType(prop.getType());
 		groupProperty.setDefaultValue(prop.getDefaultValue());
 		groupProperty.setDescription(prop.getDescription());
 		groupProperty.setSchema(prop.getSchema());
 		groupProperty.setPassword(prop.isPassword());
 		groupProperty.setParentUniqueId(prop.getUniqueId());
-	
 
 		log.debug("Before adding property value to graph {}", groupProperty);
-	
 
 		return Either.left(groupProperty);
 	}
-	
-	
-	
-	
+
 }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
index 33390e7..1ff22dd 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ImportUtils.java
@@ -33,7 +33,6 @@
 
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
 import org.openecomp.sdc.be.model.HeatParameterDefinition;
 import org.openecomp.sdc.be.model.InputDefinition;
 import org.openecomp.sdc.be.model.LifecycleStateEnum;
@@ -103,7 +102,7 @@
 	}
 
 	public enum ResultStatusEnum {
-		ELEMENT_NOT_FOUND, GENERAL_ERROR, OK, INVALID_PROPERTY_DEFAULT_VALUE, INVALID_PROPERTY_TYPE, INVALID_PROPERTY_VALUE, MISSING_ENTRY_SCHEMA_TYPE
+		ELEMENT_NOT_FOUND, GENERAL_ERROR, OK, INVALID_PROPERTY_DEFAULT_VALUE, INVALID_PROPERTY_TYPE, INVALID_PROPERTY_VALUE, MISSING_ENTRY_SCHEMA_TYPE, INVALID_PROPERTY_NAME
 	}
 
 	public enum ToscaElementTypeEnum {
@@ -346,9 +345,9 @@
 		return inputDef;
 	}
 
-	public static AttributeDefinition createModuleAttribute(Map<String, Object> attributeMap) {
+	public static PropertyDefinition createModuleAttribute(Map<String, Object> attributeMap) {
 
-		AttributeDefinition attributeDef = new AttributeDefinition();
+		PropertyDefinition attributeDef = new PropertyDefinition();
 		ImportUtils.setField(attributeMap, ToscaTagNamesEnum.TYPE, type -> attributeDef.setType(type));
 		ImportUtils.setField(attributeMap, ToscaTagNamesEnum.DESCRIPTION, desc -> attributeDef.setDescription(desc));
 		ImportUtils.setField(attributeMap, ToscaTagNamesEnum.STATUS, status -> attributeDef.setStatus(status));
@@ -374,7 +373,7 @@
 
 	}
 
-	private static void setAttributeFieldStatus(Map<String, Object> propertyValue, AttributeDefinition propertyDef) {
+	private static void setAttributeFieldStatus(Map<String, Object> propertyValue, PropertyDefinition propertyDef) {
 		Either<String, ResultStatusEnum> propertyFieldIsStatus = findFirstToscaStringElement(propertyValue, ToscaTagNamesEnum.STATUS);
 		if (propertyFieldIsStatus.isLeft()) {
 			propertyDef.setStatus(propertyFieldIsStatus.left().value());
@@ -392,7 +391,7 @@
 
 	}
 
-	private static void setAttributeScheme(Map<String, Object> propertyValue, AttributeDefinition propertyDefinition) {
+	private static void setAttributeScheme(Map<String, Object> propertyValue, PropertyDefinition propertyDefinition) {
 		Either<SchemaDefinition, ResultStatusEnum> eitherSchema = getSchema(propertyValue);
 		if (eitherSchema.isLeft()) {
 			SchemaDefinition schemaDef = new SchemaDefinition();
@@ -465,7 +464,7 @@
 		return ResultStatusEnum.OK;
 	}
 
-	private static ResultStatusEnum setAttributeFieldDefaultValue(Map<String, Object> propertyValue, AttributeDefinition dataDefinition) {
+	private static ResultStatusEnum setAttributeFieldDefaultValue(Map<String, Object> propertyValue, PropertyDefinition dataDefinition) {
 		Either<Object, ResultStatusEnum> propertyFieldDefaultValue = findToscaElement(propertyValue, ToscaTagNamesEnum.DEFAULT_VALUE, ToscaElementTypeEnum.ALL);
 		Gson gson = GsonFactory.getGson();
 		if (propertyFieldDefaultValue.isLeft()) {
@@ -519,7 +518,7 @@
 		}
 	}
 
-	private static void setAttributeFieldType(Map<String, Object> propertyValue, AttributeDefinition dataDefinition) {
+	private static void setAttributeFieldType(Map<String, Object> propertyValue, PropertyDefinition dataDefinition) {
 		Either<String, ResultStatusEnum> propertyFieldType = findFirstToscaStringElement(propertyValue, ToscaTagNamesEnum.TYPE);
 		if (propertyFieldType.isLeft()) {
 			dataDefinition.setType(propertyFieldType.left().value());
@@ -533,7 +532,7 @@
 		}
 	}
 
-	private static void setAttributeFieldDescription(Map<String, Object> propertyValue, AttributeDefinition dataDefinition) {
+	private static void setAttributeFieldDescription(Map<String, Object> propertyValue, PropertyDefinition dataDefinition) {
 		Either<String, ResultStatusEnum> propertyFieldDescription = findFirstToscaStringElement(propertyValue, ToscaTagNamesEnum.DESCRIPTION);
 		if (propertyFieldDescription.isLeft()) {
 			dataDefinition.setDescription(propertyFieldDescription.left().value());
@@ -556,9 +555,9 @@
 
 	}
 
-	public static Either<Map<String, AttributeDefinition>, ResultStatusEnum> getAttributes(Map<String, Object> toscaJson) {
-		Function<String, AttributeDefinition> elementGenByName = elementName -> createAttribute(elementName);
-		Function<Map<String, Object>, AttributeDefinition> func = map -> createModuleAttribute(map);
+	public static Either<Map<String, PropertyDefinition>, ResultStatusEnum> getAttributes(Map<String, Object> toscaJson) {
+		Function<String, PropertyDefinition> elementGenByName = elementName -> createAttribute(elementName);
+		Function<Map<String, Object>, PropertyDefinition> func = map -> createModuleAttribute(map);
 
 		return getElements(toscaJson, ToscaTagNamesEnum.ATTRIBUTES, elementGenByName, func);
 	}
@@ -595,8 +594,8 @@
 
 	}
 
-	private static AttributeDefinition createAttribute(String name) {
-		AttributeDefinition attribute = new AttributeDefinition();
+	private static PropertyDefinition createAttribute(String name) {
+		PropertyDefinition attribute = new PropertyDefinition();
 
 		attribute.setName(name);
 		return attribute;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
index 8ffee1f..a2809b4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/InputsBusinessLogic.java
@@ -50,6 +50,7 @@
 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.be.model.CapabilityDefinition;
 import org.openecomp.sdc.be.model.ComponentInstInputsMap;
@@ -551,7 +552,7 @@
 				return result;
 			}
 			
-			Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> addciInputsEither = toscaOperationFacade.addComponentInstanceInputsToComponent(inputsValueToCreateMap, component.getUniqueId());
+			Either<Map<String, List<ComponentInstanceInput>>, StorageOperationStatus> addciInputsEither = toscaOperationFacade.addComponentInstanceInputsToComponent(component, inputsValueToCreateMap);
 			if(addciInputsEither.isRight()){
 				log.debug("Failed to add inputs values under component {}. Status is {}", component.getUniqueId(), assotiateInputsEither.right().value());
 				result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(assotiateInputsEither.right().value())));
@@ -621,6 +622,8 @@
 		input.setImmutable(oldInput.isImmutable());
 		input.setDefinition(oldInput.isDefinition());
 		input.setRequired(oldInput.isRequired());
+		input.setOwnerId(null);
+		input.setParentUniqueId(null);
 		inputsToCreate.put(input.getName(), input);
 		
 		
@@ -739,7 +742,7 @@
 			}
 			if (resourceProperties != null) {
 				Map<String, InputDefinition> generatedInputs = resourceProperties.stream().collect(Collectors.toMap(i -> i.getName(), i -> i));
-				Either<Map<String, InputDefinition>, String> mergeEither = PropertyDataDefinition.mergeProperties(generatedInputs, inputs, false);
+				Either<Map<String, InputDefinition>, String> mergeEither = ToscaDataDefinition.mergeDataMaps(generatedInputs, inputs);
 				if(mergeEither.isRight()){
 					return Either.right(componentsUtils.getResponseFormat(ActionStatus.PROPERTY_ALREADY_EXIST, mergeEither.right().value()));
 				}
@@ -808,6 +811,8 @@
 		if (!optionalInput.isPresent()) {
 			return Either.right(componentsUtils.getResponseFormat(ActionStatus.INPUT_IS_NOT_CHILD_OF_COMPONENT, inputId, componentId));
 		}
+		
+		InputDefinition inputForDelete = optionalInput.get();
 
 		// Lock component
 		Either<Boolean, ResponseFormat> lockResultEither = lockComponent(componentId, component, "deleteInput");
@@ -818,8 +823,6 @@
 		}
 
 		// Delete input operations
-	
-		InputDefinition inputForDelete = optionalInput.get();
 		try {
 			StorageOperationStatus status = toscaOperationFacade.deleteInputOfResource(component, inputForDelete.getName());
 			if(status != StorageOperationStatus.OK){
@@ -863,7 +866,9 @@
 						
 						resetInputName(mappedToscaTemplate, inputForDelete.getName());
 						
-						value = gson.toJson(mappedToscaTemplate);
+						value = "";
+						if(!mappedToscaTemplate.isEmpty())
+							value = gson.toJson(mappedToscaTemplate);
 						propertyValue.setValue(value);
 						String compInstId = propertyValue.getComponentInstanceId();
 						propertyValue.setRules(null);
@@ -1159,6 +1164,8 @@
 			
 			if (properties != null && !properties.isEmpty()) {
 				for (ComponentInstancePropInput propInput : properties) {
+					propInput.setOwnerId(null);
+					propInput.setParentUniqueId(null);
 					Either<InputDefinition, StorageOperationStatus> createInputRes = createInputForComponentInstance(component, origComponent,ci, inputsToCreate, propertiesToCreate, dataTypes, inputName, propInput);
 					
 					if (createInputRes.isRight()) {
@@ -1260,6 +1267,10 @@
 		
 		inputsToCreate.put(input.getName(), input);
 		
+		List<ComponentInstanceProperty> propertiesList = new ArrayList<>(); // adding the property with the new value for UI
+		propertiesList.add(prop);
+		input.setProperties(propertiesList);
+		
 		return Either.left(input);
 		
 	}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
index ffcb87c..587be4d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
@@ -74,7 +74,6 @@
 import org.openecomp.sdc.be.info.ArtifactTemplateInfo;
 import org.openecomp.sdc.be.info.MergedArtifactInfo;
 import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
 import org.openecomp.sdc.be.model.CapabilityDefinition;
 import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
 import org.openecomp.sdc.be.model.Component;
@@ -542,8 +541,15 @@
 		try {
 			Either<ImmutablePair<Resource, ActionStatus>, ResponseFormat> prepareForUpdate = null;
 			Resource preparedResource = null;
-
-			Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = findNodeTypesArtifactsToHandle(csar.left().value(), csarUUID, yamlFileName, oldRresource, user, true);
+			Either<ParsedToscaYamlInfo, ResponseFormat> uploadComponentInstanceInfoMap = parseResourceInfoFromYaml(yamlFileName, newRresource, toscaYamlCsarStatus.left().value().getValue(), user);
+			if (uploadComponentInstanceInfoMap.isRight()) {
+				ResponseFormat responseFormat = uploadComponentInstanceInfoMap.right().value();
+				componentsUtils.auditResource(responseFormat, user, newRresource, "", "", updateResource, null);
+				result = Either.right(responseFormat);
+				return result;
+			}
+			Map<String, UploadComponentInstanceInfo> instances = uploadComponentInstanceInfoMap.left().value().getInstances();
+			Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandleRes = findNodeTypesArtifactsToHandle(csar.left().value(), csarUUID, yamlFileName, oldRresource, user, true, instances);
 			if (findNodeTypesArtifactsToHandleRes.isRight()) {
 				log.debug("failed to find node types for update with artifacts during import csar {}. ", csarUUID);
 				result = Either.right(findNodeTypesArtifactsToHandleRes.right().value());
@@ -571,14 +577,6 @@
 					return result;
 				}
 
-				Either<ParsedToscaYamlInfo, ResponseFormat> uploadComponentInstanceInfoMap = parseResourceInfoFromYaml(yamlFileName, preparedResource, yamlFileContents, user);
-				if (uploadComponentInstanceInfoMap.isRight()) {
-					ResponseFormat responseFormat = uploadComponentInstanceInfoMap.right().value();
-					componentsUtils.auditResource(responseFormat, user, preparedResource, "", "", updateResource, null);
-					result = Either.right(responseFormat);
-					return result;
-				}
-
 				Map<String, InputDefinition> inputs = uploadComponentInstanceInfoMap.left().value().getInputs();
 				Either<Resource, ResponseFormat> createInputsOnResource = createInputsOnResource(preparedResource, user, inputs, true);
 				if (createInputsOnResource.isRight()) {
@@ -590,7 +588,6 @@
 				}
 				preparedResource = createInputsOnResource.left().value();
 
-				Map<String, UploadComponentInstanceInfo> instances = uploadComponentInstanceInfoMap.left().value().getInstances();
 				Either<Resource, ResponseFormat> createResourcesInstancesEither = createResourceInstances(user, yamlFileName, preparedResource, instances, true, false, parseNodeTypeInfoYamlEither.left().value());
 				if (createResourcesInstancesEither.isRight()) {
 					log.debug("failed to create resource instances status is {}", createResourcesInstancesEither.right().value());
@@ -677,7 +674,7 @@
 	}
 
 	private Either<Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>>, ResponseFormat> findNodeTypesArtifactsToHandle(Map<String, byte[]> csar, String csarUUID, String yamlFileName, Resource oldResource, User user,
-			boolean inTransaction) {
+			boolean inTransaction, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
 
 		Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csar);
 		Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = new HashMap<>();
@@ -685,7 +682,7 @@
 
 		try {
 			nodeTypesArtifactsToHandleRes = Either.left(nodeTypesArtifactsToHandle);
-			List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractedVfcToscaNames = extractVfcToscaNames(csar, yamlFileName, oldResource.getSystemName());
+			List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractedVfcToscaNames = extractVfcToscaNames(csar, yamlFileName, oldResource.getSystemName(), uploadComponentInstanceInfoMap);
 			validateNodeTypeIdentifiers(extractedVfcsArtifacts, extractedVfcToscaNames);
 			Either<EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>, ResponseFormat> curNodeTypeArtifactsToHandleRes = null;
 			EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>> curNodeTypeArtifactsToHandle = null;
@@ -913,7 +910,8 @@
 		return handleNodeTypeArtifactsRes;
 	}
 
-	private List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractVfcToscaNames(Map<String, byte[]> csar, String yamlFileName, String vfResourceName) {
+	@SuppressWarnings("unchecked")
+	private List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractVfcToscaNames(Map<String, byte[]> csar, String yamlFileName, String vfResourceName, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
 		List<ImmutablePair<ImmutablePair<String, List<String>>, String>> vfcToscaNames = new ArrayList<>();
 		Map<String, Object> nodeTypes;
 		if (csar != null) {
@@ -921,12 +919,20 @@
 			putNodeTypesFromYaml(csar, yamlFileName, nodeTypes);
 			putNodeTypesFromYaml(csar, Constants.GLOBAL_SUBSTITUTION_TYPES_SERVICE_TEMPLATE, nodeTypes);
 			putNodeTypesFromYaml(csar, Constants.ABSTRACT_SUBSTITUTE_GLOBAL_TYPES_SERVICE_TEMPLATE, nodeTypes);
-
+			Map<String,String> nestedServiceTemplatesMap = new HashMap<>();
+			for(UploadComponentInstanceInfo ci : uploadComponentInstanceInfoMap.values()){
+				if(ci.getProperties() != null && ci.getProperties().containsKey("service_template_filter")){
+					String tempName = CsarUtils.DEFINITIONS_PATH + ((Map<String, String>)ci.getProperties().get("service_template_filter").get(0).getValue()).get("substitute_service_template");
+					putNodeTypesFromYaml(csar,tempName, nodeTypes);
+					nestedServiceTemplatesMap.put(ci.getType(), tempName);
+				}
+			}
+			
 			if (!nodeTypes.isEmpty()) {
 				Iterator<Entry<String, Object>> nodesNameEntry = nodeTypes.entrySet().iterator();
 				while (nodesNameEntry.hasNext()) {
 					Entry<String, Object> nodeType = nodesNameEntry.next();
-					addVfcToscaNameFindSubstitutes(csar, vfResourceName, vfcToscaNames, nodeType.getKey());
+					addVfcToscaNameFindSubstitutes(csar, vfResourceName, vfcToscaNames, nodeType.getKey(), nestedServiceTemplatesMap);
 				}
 			}
 		}
@@ -947,20 +953,23 @@
 		}
 	}
 
-	private void addVfcToscaNameFindSubstitutes(Map<String, byte[]> csar, String vfResourceName, List<ImmutablePair<ImmutablePair<String, List<String>>, String>> vfcToscaNames, String nodeTypeFullName) {
+	private void addVfcToscaNameFindSubstitutes(Map<String, byte[]> csar, String vfResourceName, List<ImmutablePair<ImmutablePair<String, List<String>>, String>> vfcToscaNames, String nodeTypeFullName, Map<String, String> nestedServiceTemplatesMap) {
 
 		String toscaResourceName = buildNestedVfcToscaResourceName(vfResourceName, nodeTypeFullName);
-		String nodeTypeTemplateYamlName = buildNestedSubstituteYamlName(nodeTypeFullName);
+		String nodeTypeTemplateYamlName =null;
+		if(nestedServiceTemplatesMap.containsKey(nodeTypeFullName)){
+			nodeTypeTemplateYamlName = nestedServiceTemplatesMap.get(nodeTypeFullName);
+		}
 		List<String> relatedVfcsToscaNameSpaces = new ArrayList<>();
 		relatedVfcsToscaNameSpaces.add(buildNestedVfcToscaNamespace(nodeTypeFullName));
-		if (csar.containsKey(nodeTypeTemplateYamlName)) {
-			addSubstituteToscaNamespacesRecursively(csar, nodeTypeTemplateYamlName, relatedVfcsToscaNameSpaces);
+		if (nodeTypeTemplateYamlName!=null && csar.containsKey(nodeTypeTemplateYamlName)) {
+			addSubstituteToscaNamespacesRecursively(csar, nodeTypeTemplateYamlName, relatedVfcsToscaNameSpaces, nestedServiceTemplatesMap);
 		}
 		ImmutablePair<String, List<String>> toscaNameSpacesHierarchy = new ImmutablePair<>(nodeTypeFullName, relatedVfcsToscaNameSpaces);
 		vfcToscaNames.add(new ImmutablePair<>(toscaNameSpacesHierarchy, toscaResourceName));
 	}
 
-	private void addSubstituteToscaNamespacesRecursively(Map<String, byte[]> csar, String yamlFileName, List<String> toscaNameSpaces) {
+	private void addSubstituteToscaNamespacesRecursively(Map<String, byte[]> csar, String yamlFileName, List<String> toscaNameSpaces, Map<String, String> nestedServiceTemplatesMap) {
 
 		Map<String, Object> nodeTypes = new HashMap<>();
 
@@ -978,10 +987,13 @@
 				}
 				toscaNameSpaces.add(toscaNameSpace);
 
-				String nodeTypeTemplateYamlName = buildNestedSubstituteYamlName(nodeTypeFullName);
+				String nodeTypeTemplateYamlName =null;
+				if(nestedServiceTemplatesMap.containsKey(nodeTypeFullName)){
+					nodeTypeTemplateYamlName = nestedServiceTemplatesMap.get(nodeTypeFullName);
+				}
 
-				if (csar.containsKey(nodeTypeTemplateYamlName)) {
-					addSubstituteToscaNamespacesRecursively(csar, nodeTypeTemplateYamlName, toscaNameSpaces);
+				if (nodeTypeTemplateYamlName!=null && csar.containsKey(nodeTypeTemplateYamlName)) {
+					addSubstituteToscaNamespacesRecursively(csar, nodeTypeTemplateYamlName, toscaNameSpaces, nestedServiceTemplatesMap);
 				}
 			}
 		}
@@ -1651,7 +1663,7 @@
 		Either<Resource, ResponseFormat> result;
 		Either<Resource, ResponseFormat> createResourcesInstancesEither;
 
-		Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = findNodeTypeArtifactsToCreate(csar, yamlName, resource);
+		Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToCreate = findNodeTypeArtifactsToCreate(csar, yamlName, resource, uploadComponentInstanceInfoMap);
 
 		log.debug("************* Going to create all nodes {}", yamlName);
 		Either<Map<String, Resource>, ResponseFormat> createdResourcesFromdNodeTypeMap = this.handleNodeTypes(yamlName, resource, user, topologyTemplateYaml, csar, false, nodeTypesArtifactsToCreate, nodeTypesNewCreatedArtifacts);
@@ -1694,10 +1706,10 @@
 		return result;
 	}
 
-	private Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> findNodeTypeArtifactsToCreate(Map<String, byte[]> csar, String yamlName, Resource resource) {
+	private Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> findNodeTypeArtifactsToCreate(Map<String, byte[]> csar, String yamlName, Resource resource, Map<String, UploadComponentInstanceInfo> uploadComponentInstanceInfoMap) {
 
 		Map<String, List<ArtifactDefinition>> extractedVfcsArtifacts = CsarUtils.extractVfcsArtifactsFromCsar(csar);
-		List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractedVfcToscaNames = extractVfcToscaNames(csar, yamlName, resource.getSystemName());
+		List<ImmutablePair<ImmutablePair<String, List<String>>, String>> extractedVfcToscaNames = extractVfcToscaNames(csar, yamlName, resource.getSystemName(), uploadComponentInstanceInfoMap);
 		validateNodeTypeIdentifiers(extractedVfcsArtifacts, extractedVfcToscaNames);
 		Map<String, EnumMap<ArtifactOperationEnum, List<ArtifactDefinition>>> nodeTypesArtifactsToHandle = null;
 		if (!extractedVfcsArtifacts.isEmpty() && !extractedVfcToscaNames.isEmpty()) {
@@ -3429,7 +3441,7 @@
 		Map<ComponentInstance, Map<String, List<CapabilityDefinition>>> instCapabilties = new HashMap<>();
 		Map<ComponentInstance, Map<String, List<RequirementDefinition>>> instRequirements = new HashMap<>();
 		Map<String, Map<String, ArtifactDefinition>> instArtifacts = new HashMap<>();
-		Map<String, List<AttributeDefinition>> instAttributes = new HashMap<>();
+		Map<String, List<PropertyDefinition>> instAttributes = new HashMap<>();
 		Map<String, Resource> originCompMap = new HashMap<>();
 		List<RequirementCapabilityRelDef> relations = new ArrayList<>();
 
@@ -4321,7 +4333,7 @@
 				List<Object> getInputList = (List<Object>) getInput;
 				getInputInfo.setPropName(propName);
 				getInputInfo.setInputName((String) getInputList.get(0));
-				if (getInputList.size() >= 1) {
+				if (getInputList.size() > 1) {
 					Object indexObj = getInputList.get(1);
 					if (indexObj instanceof Integer) {
 						getInputInfo.setIndexValue((Integer) indexObj);
@@ -5838,7 +5850,7 @@
 		return Either.left(true);
 	}
 
-	// Tal G for extending inheritance US815447
+	// for extending inheritance US815447
 	private Either<Boolean, ResponseFormat> validateDerivedFromExtending(User user, Resource currentResource, Resource updateInfoResource, AuditingActionEnum actionEnum) {
 		// If updated resource is not deriving, should fail validation
 		/*
@@ -6633,12 +6645,6 @@
 		return toscaResourceName;
 	}
 
-	private String buildNestedSubstituteYamlName(String nodeTypeFullName) {
-		String[] nodeTypeFullNameParsed = nodeTypeFullName.split("\\.");
-		String nodeTypeActualName = nodeTypeFullNameParsed[nodeTypeFullNameParsed.length - 1];
-		return CsarUtils.DEFINITIONS_PATH + nodeTypeActualName + Constants.SERVICE_TEMPLATE_FILE_POSTFIX;
-	}
-
 	public ICacheMangerOperation getCacheManagerOperation() {
 		return cacheManagerOperation;
 	}
@@ -6726,6 +6732,11 @@
 		Either<Resource, StorageOperationStatus> resourceResultEither = toscaOperationFacade.getToscaElement(resourceId, paramsToRetuen);
 
 		if (resourceResultEither.isRight()) {
+			if(resourceResultEither.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
+				log.debug("Failed to found resource with id {} ", resourceId);
+				Either.right(componentsUtils.getResponseFormat(ActionStatus.RESOURCE_NOT_FOUND, resourceId));
+			}
+			
 			log.debug("failed to get resource by id {} with filters {}", resourceId, dataParamsToReturn.toString());
 			return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(resourceResultEither.right().value()), ""));
 		}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
index f35515f..b157b63 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
@@ -31,6 +31,7 @@
 import java.util.Map.Entry;
 import java.util.Set;
 import java.util.function.Function;
+import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 import javax.servlet.ServletContext;
@@ -46,12 +47,12 @@
 import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
 import org.openecomp.sdc.be.model.ArtifactDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
 import org.openecomp.sdc.be.model.CapabilityDefinition;
 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
 import org.openecomp.sdc.be.model.InterfaceDefinition;
@@ -101,7 +102,9 @@
 
 	@Autowired
 	protected ResourceOperation resourceOperation;
-
+	
+	public final static Pattern PROPERTY_NAME_PATTERN_IGNORE_LENGTH = Pattern
+			.compile("[\\w\\-\\_\\d\\:]+");
 	@Autowired
 	protected CapabilityTypeOperation capabilityTypeOperation;
 	@Autowired
@@ -289,7 +292,9 @@
 		eitherResult = setCapabilities(toscaJson, resource, parentResource);
 		if (eitherResult.isRight())
 			return eitherResult;
-		setProperties(toscaJson, resource);
+		eitherResult = setProperties(toscaJson, resource);
+		if (eitherResult.isRight())
+			return eitherResult;
 		eitherResult = setRequirements(toscaJson, resource, parentResource);
 		if (eitherResult.isRight())
 			return eitherResult;
@@ -467,10 +472,10 @@
 		return result;
 	}
 
-	private ResultStatusEnum setProperties(Map<String, Object> toscaJson, Resource resource) {
+	private Either<Boolean, ResponseFormat> setProperties(Map<String, Object> toscaJson, Resource resource) {
 		Map<String, Object> reducedToscaJson = new HashMap<>(toscaJson);
 		ImportUtils.removeElementFromJsonMap(reducedToscaJson, "capabilities");
-		ResultStatusEnum result = ResultStatusEnum.OK;
+		Either<Boolean, ResponseFormat> result = Either.left(true);
 		Either<Map<String, PropertyDefinition>, ResultStatusEnum> properties = ImportUtils.getProperties(reducedToscaJson);
 		if (properties.isLeft()) {
 			List<PropertyDefinition> propertiesList = new ArrayList<>();
@@ -478,28 +483,32 @@
 			if (value != null) {
 				for (Entry<String, PropertyDefinition> entry : value.entrySet()) {
 					String name = entry.getKey();
+					if(!PROPERTY_NAME_PATTERN_IGNORE_LENGTH.matcher(name).matches()){
+						log.debug("The property with invalid name {} occured upon import resource {}. ", name, resource.getName());
+						result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromResultStatusEnum(ResultStatusEnum.INVALID_PROPERTY_NAME, JsonPresentationFields.PROPERTY)));
+					}
 					PropertyDefinition propertyDefinition = entry.getValue();
 					propertyDefinition.setName(name);
 					propertiesList.add(propertyDefinition);
 				}
 			}
 			resource.setProperties(propertiesList);
-		} else {
-			result = properties.right().value();
+		} else if(properties.right().value() != ResultStatusEnum.ELEMENT_NOT_FOUND){
+			result = Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromResultStatusEnum(properties.right().value(), JsonPresentationFields.PROPERTY)));
 		}
 		return result;
 	}
 
 	private ResultStatusEnum setAttributes(Map<String, Object> toscaJson, Resource resource) {
 		ResultStatusEnum result = ResultStatusEnum.OK;
-		Either<Map<String, AttributeDefinition>, ResultStatusEnum> attributes = ImportUtils.getAttributes(toscaJson);
+		Either<Map<String, PropertyDefinition>, ResultStatusEnum> attributes = ImportUtils.getAttributes(toscaJson);
 		if (attributes.isLeft()) {
-			List<AttributeDefinition> attributeList = new ArrayList<>();
-			Map<String, AttributeDefinition> value = attributes.left().value();
+			List<PropertyDefinition> attributeList = new ArrayList<>();
+			Map<String, PropertyDefinition> value = attributes.left().value();
 			if (value != null) {
-				for (Entry<String, AttributeDefinition> entry : value.entrySet()) {
+				for (Entry<String, PropertyDefinition> entry : value.entrySet()) {
 					String name = entry.getKey();
-					AttributeDefinition attributeDef = entry.getValue();
+					PropertyDefinition attributeDef = entry.getValue();
 					attributeDef.setName(name);
 					attributeList.add(attributeDef);
 				}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
index 1f481a7..bc1c6e5 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceBusinessLogic.java
@@ -1390,7 +1390,7 @@
 			}
 			Collections.sort(vfModulePayloadForCurrVF, (art1, art2) -> VfModuleArtifactPayload.compareByGroupName(art1, art2));
 			// Update Payload With Heat Env
-			vfModulePayloadForCurrVF.stream().forEach(e -> addHeatEnvArtifactsToVFModulePayload(e, currVFInstance));
+//			vfModulePayloadForCurrVF.stream().forEach(e -> addHeatEnvArtifactsToVFModulePayload(e, currVFInstance));
 
 			final Gson gson = new GsonBuilder().setPrettyPrinting().create();
 
@@ -1436,7 +1436,7 @@
 			vfModuleAertifact = getVfModuleInstArtifactForCompInstance(currVFInstance, service, modifier, groupsForCurrVF, payloadWrapper, responseWrapper);
 		}
 		if (responseWrapper.isEmpty() && vfModuleAertifact != null) {
-			vfModuleAertifact = fillVfModulePayload(modifier, currVFInstance, vfModuleAertifact, shouldLock, payloadWrapper, responseWrapper);
+			vfModuleAertifact = fillVfModulePayload(modifier, currVFInstance, vfModuleAertifact, shouldLock, payloadWrapper, responseWrapper, service);
 		}
 
 		Either<ArtifactDefinition, ResponseFormat> result;
@@ -1449,21 +1449,21 @@
 		return result;
 	}
 
-	private ArtifactDefinition fillVfModulePayload(User modifier, ComponentInstance currVF, ArtifactDefinition vfModuleArtifact, boolean shouldLock, Wrapper<String> payloadWrapper, Wrapper<ResponseFormat> responseWrapper) {
+	private ArtifactDefinition fillVfModulePayload(User modifier, ComponentInstance currVF, ArtifactDefinition vfModuleArtifact, boolean shouldLock, Wrapper<String> payloadWrapper, Wrapper<ResponseFormat> responseWrapper, Service service) {
 		ArtifactDefinition result = null;
-		final Either<Resource, StorageOperationStatus> eitherResource = toscaOperationFacade.getToscaElement(currVF.getComponentUid());
-		if (eitherResource.isRight()) {
-			responseWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(eitherResource.right().value())));
-		} else if (!payloadWrapper.isEmpty()) {
-			Resource resource = eitherResource.left().value();
-			Either<ArtifactDefinition, ResponseFormat> eitherPayload = artifactsBusinessLogic.generateArtifactPayload(vfModuleArtifact, resource.getComponentType(), resource, currVF.getName(), modifier, shouldLock, () -> System.currentTimeMillis(),
+//		final Either<Resource, StorageOperationStatus> eitherResource = toscaOperationFacade.getToscaElement(currVF.getComponentUid());
+//		if (eitherResource.isRight()) {
+//			responseWrapper.setInnerElement(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(eitherResource.right().value())));
+//		} else if (!payloadWrapper.isEmpty()) {
+//			Resource resource = eitherResource.left().value();
+			Either<ArtifactDefinition, ResponseFormat> eitherPayload = artifactsBusinessLogic.generateArtifactPayload(vfModuleArtifact, ComponentTypeEnum.RESOURCE_INSTANCE, service, currVF.getName(), modifier, shouldLock, () -> System.currentTimeMillis(),
 					() -> Either.left(artifactsBusinessLogic.createEsArtifactData(vfModuleArtifact, payloadWrapper.getInnerElement().getBytes(StandardCharsets.UTF_8))), currVF.getUniqueId());
 			if (eitherPayload.isLeft()) {
 				result = eitherPayload.left().value();
 			} else {
 				responseWrapper.setInnerElement(eitherPayload.right().value());
 			}
-		}
+//		}
 		if (result == null) {
 			result = vfModuleArtifact;
 		}
@@ -1962,13 +1962,18 @@
 		return result;
 	}
 
-	public Either<UiComponentDataTransfer, ResponseFormat> getUiComponentDataTransferByComponentId(String resourceId, List<String> dataParamsToReturn) {
+	public Either<UiComponentDataTransfer, ResponseFormat> getUiComponentDataTransferByComponentId(String serviceId, List<String> dataParamsToReturn) {
 
 		ComponentParametersView paramsToRetuen = new ComponentParametersView(dataParamsToReturn);
-		Either<Service, StorageOperationStatus> serviceResultEither = toscaOperationFacade.getToscaElement(resourceId, paramsToRetuen);
+		Either<Service, StorageOperationStatus> serviceResultEither = toscaOperationFacade.getToscaElement(serviceId, paramsToRetuen);
 
 		if (serviceResultEither.isRight()) {
-			log.debug("failed to get resource by id {} with filters {}", resourceId, dataParamsToReturn.toString());
+			if(serviceResultEither.right().value().equals(StorageOperationStatus.NOT_FOUND)) {
+				log.debug("Failed to found service with id {} ", serviceId);
+				Either.right(componentsUtils.getResponseFormat(ActionStatus.SERVICE_NOT_FOUND, serviceId));
+			}
+			
+			log.debug("failed to get service by id {} with filters {}", serviceId, dataParamsToReturn.toString());
 			return Either.right(componentsUtils.getResponseFormatByResource(componentsUtils.convertFromStorageResponse(serviceResultEither.right().value()), ""));
 		}
 
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
index d6cbd36..14f54e4 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/lifecycle/CheckoutTransition.java
@@ -21,7 +21,10 @@
 package org.openecomp.sdc.be.components.lifecycle;
 
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -29,16 +32,22 @@
 import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
 import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
+import org.openecomp.sdc.be.datatypes.elements.ComponentInstanceDataDefinition;
+import org.openecomp.sdc.be.datatypes.elements.MapPropertiesDataDefinition;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.OriginTypeEnum;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.be.model.Component;
 import org.openecomp.sdc.be.model.InputDefinition;
 import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
 import org.openecomp.sdc.be.model.LifecycleStateEnum;
 import org.openecomp.sdc.be.model.User;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.TopologyTemplate;
 import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElement;
+import org.openecomp.sdc.be.model.jsontitan.datamodel.ToscaElementTypeEnum;
 import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementLifecycleOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaElementOperation;
 import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
 import org.openecomp.sdc.be.model.jsontitan.utils.ModelConverter;
 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -97,6 +106,7 @@
 				ResponseFormat responseFormat = componentUtils.getResponseFormatByComponent(actionStatus, component, componentType);
 				result = Either.right(responseFormat);
 			} else {
+			
 				Component clonedComponent = ModelConverter.convertFromToscaElement(checkoutResourceResult.left().value());
 				result = Either.left(clonedComponent); 
 				Either<Boolean, ResponseFormat> upgradeToLatestGeneric = componentBl.shouldUpgradeToLatestGeneric(clonedComponent);
@@ -132,7 +142,7 @@
 
 	private StorageOperationStatus upgradeToLatestGenericData(Component clonedComponent) {
 		
-		StorageOperationStatus updateStatus = null;
+		StorageOperationStatus updateStatus = StorageOperationStatus.OK;
 		Either<Component, StorageOperationStatus> updateEither = toscaOperationFacade.updateToscaElement(clonedComponent);
 		if (updateEither.isRight())
 			updateStatus = updateEither.right().value();  
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
index 46505b8..6edfe81 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/datamodel/utils/UiComponentDataConverter.java
@@ -11,6 +11,7 @@
 import org.openecomp.sdc.be.model.Resource;
 import org.openecomp.sdc.be.model.Service;
 import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
+import org.openecomp.sdc.be.ui.model.UiComponentMetadata;
 import org.openecomp.sdc.be.ui.model.UiResourceDataTransfer;
 import org.openecomp.sdc.be.ui.model.UiResourceMetadata;
 import org.openecomp.sdc.be.ui.model.UiServiceDataTransfer;
@@ -215,4 +216,20 @@
 		return dataTransfer;
 	}
 
+	
+	public static UiComponentMetadata convertToUiComponentMetadata(Component component) {
+		
+		UiComponentMetadata uiComponentMetadata = null;
+		switch (component.getComponentType()) {
+			case RESOURCE: 
+				Resource resource = (Resource)component;
+				uiComponentMetadata = new UiResourceMetadata(component.getCategories(),  resource.getDerivedFrom(), (ResourceMetadataDataDefinition) resource.getComponentMetadataDefinition().getMetadataDataDefinition());
+				break;
+			case SERVICE:
+				uiComponentMetadata = new UiServiceMetadata(component.getCategories(),  (ServiceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition());
+			default:
+
+		}
+		return uiComponentMetadata;
+	}
 }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
index 7b49d3f..c88ec87 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/EcompIntImpl.java
@@ -26,7 +26,7 @@
 import javax.servlet.http.HttpServletRequest;
 
 import org.openecomp.portalsdk.core.onboarding.crossapi.IPortalRestAPIService;
-import org.openecomp.portalsdk.core.onboarding.crossapi.PortalAPIException;
+import org.openecomp.portalsdk.core.onboarding.exception.PortalAPIException;
 import org.openecomp.portalsdk.core.restful.domain.EcompRole;
 import org.openecomp.portalsdk.core.restful.domain.EcompUser;
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
@@ -37,6 +37,7 @@
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.user.Role;
 import org.openecomp.sdc.be.user.UserBusinessLogic;
+import org.openecomp.sdc.common.api.Constants;
 import org.openecomp.sdc.exception.ResponseFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -378,4 +379,28 @@
 		UserBusinessLogic userBusinessLogic = (UserBusinessLogic) ctx.getBean("userBusinessLogic");
 		return userBusinessLogic;
 	}
+	
+	/**
+     * Gets and returns the userId for the logged-in user based on the request.
+     * If any error occurs, the method should throw PortalApiException with an
+     * appropriate message. The FW library will catch the exception and send an
+     * appropriate response to Portal.
+     * 
+      * As a guideline for AT&T specific implementation, see the sample apps
+     * repository
+     * https://codecloud.web.att.com/projects/EP_SDK/repos/ecomp_portal_sdk_third_party/
+     * for a sample implementation for on-boarded applications using EPSDK-FW.
+     * However, the app can always choose to have a custom implementation of
+     * this method. For Open-source implementation, for example, the app will
+     * have a totally different implementation for this method.
+     * 
+      * @param request
+     * @return true if the request contains appropriate credentials, else false.
+     * @throws PortalAPIException
+     *             If an unexpected error occurs while processing the request.
+     */
+	@Override
+	public String getUserId(HttpServletRequest request) throws PortalAPIException {
+		return request.getHeader(Constants.USER_ID_HEADER);
+	}
 }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetMetadataConverter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverter.java
similarity index 99%
rename from catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetMetadataConverter.java
rename to catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverter.java
index 2c7de70..2e94dfc 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetMetadataConverter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/ecomp/converters/AssetMetadataConverter.java
@@ -18,7 +18,7 @@
  * ============LICENSE_END=========================================================
  */
 
-package org.openecomp.sdc.be.externalapi.servlet;
+package org.openecomp.sdc.be.ecomp.converters;
 
 import java.util.Collection;
 import java.util.HashMap;
@@ -47,7 +47,6 @@
 import org.openecomp.sdc.be.model.category.CategoryDefinition;
 import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
 import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
-import org.openecomp.sdc.be.model.operations.impl.ResourceOperation;
 import org.openecomp.sdc.exception.ResponseFormat;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
index 552ad16..b0947c6 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServlet.java
@@ -68,6 +68,7 @@
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
+import org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter;
 import org.openecomp.sdc.be.externalapi.servlet.representation.AssetMetadata;
 import org.openecomp.sdc.be.model.Component;
 import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
index ea2582c..a6415dc 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/impl/ComponentsUtils.java
@@ -37,12 +37,14 @@
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.module.SimpleModule;
 import org.openecomp.sdc.be.auditing.api.IAuditingManager;
+import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
 import org.openecomp.sdc.be.components.impl.ResponseFormatManager;
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.dao.graph.datatype.AdditionalInformationEnum;
 import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
 import org.openecomp.sdc.be.model.ArtifactDefinition;
 import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
@@ -1254,6 +1256,31 @@
 		log.debug("convert storage response {} to action response {}", storageResponse.name(), responseEnum.name());
 		return responseEnum;
 	}
+	
+	public ActionStatus convertFromResultStatusEnum(ResultStatusEnum resultStatus, JsonPresentationFields elementType) {
+		ActionStatus responseEnum = ActionStatus.GENERAL_ERROR;
+		switch (resultStatus) {
+		case OK:
+			responseEnum = ActionStatus.OK;
+			break;
+		case ELEMENT_NOT_FOUND:
+			if(elementType!= null && elementType == JsonPresentationFields.PROPERTY){
+				responseEnum = ActionStatus.PROPERTY_NOT_FOUND;
+			}
+		break;
+		case INVALID_PROPERTY_DEFAULT_VALUE:
+		case INVALID_PROPERTY_TYPE:
+		case INVALID_PROPERTY_VALUE:
+		case INVALID_PROPERTY_NAME:
+		case MISSING_ENTRY_SCHEMA_TYPE:
+			responseEnum = ActionStatus.INVALID_PROPERTY;
+			break;
+		default:
+			responseEnum = ActionStatus.GENERAL_ERROR;
+			break;
+		}
+		return responseEnum;
+	}
 
 	public ResponseFormat getResponseFormatAdditionalProperty(ActionStatus actionStatus, AdditionalInfoParameterInfo additionalInfoParameterInfo, NodeTypeEnum nodeType, AdditionalInformationEnum labelOrValue) {
 
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/listen/BEAppContextListener.java b/catalog-be/src/main/java/org/openecomp/sdc/be/listen/BEAppContextListener.java
index 38629ab..436b231 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/listen/BEAppContextListener.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/listen/BEAppContextListener.java
@@ -29,11 +29,7 @@
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
 
-import org.openecomp.portalsdk.core.onboarding.ueb.UebException;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebManager;
-import org.openecomp.sdc.be.config.BeEcompErrorManager;
 import org.openecomp.sdc.be.config.ConfigurationManager;
-import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
 import org.openecomp.sdc.be.impl.DownloadArtifactLogic;
 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
 import org.openecomp.sdc.be.model.operations.api.IResourceOperation;
@@ -49,9 +45,7 @@
 
 	private static final String MANIFEST_FILE_NAME = "/META-INF/MANIFEST.MF";
 	private static Logger log = LoggerFactory.getLogger(BEAppContextListener.class.getName());
-
-	private static UebManager uebManager = null;
-
+	
 	public void contextInitialized(ServletContextEvent context) {
 
 		super.contextInitialized(context);
@@ -73,34 +67,10 @@
 		BeMonitoringService bms = new BeMonitoringService(context.getServletContext());
 		bms.start(configurationManager.getConfiguration().getSystemMonitoring().getProbeIntervalInSeconds(15));
 
-		initUebManager();
-
 		log.debug("After executing {}", this.getClass());
 
 	}
-
-	private void initUebManager() {
-		try {
-			if (uebManager == null) {
-				uebManager = UebManager.getInstance();
-				uebManager.initListener(null);
-			}
-		} catch (UebException ex) {
-			log.debug("Failed to initialize UebManager", ex);
-			BeEcompErrorManager.getInstance().logInternalConnectionError("InitUebManager", "Failed to initialize listener of UebManager", ErrorSeverity.ERROR);
-		}
-		log.debug("After init listener of UebManager");
-	}
-
-	public void contextDestroyed(ServletContextEvent context) {
-		if (uebManager != null) {
-			uebManager.shutdown();
-			uebManager = null;
-		}
-		super.contextDestroyed(context);
-
-	}
-
+	
 	private IResourceOperation getResourceOperationManager(Class<? extends IResourceOperation> clazz, WebApplicationContext webContext) {
 
 		return webContext.getBean(clazz);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
index d8f834c..6b16e71 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AbstractValidationsServlet.java
@@ -278,7 +278,7 @@
 			} else {
 				if (!resourceAuthorityEnum.isBackEndImport()) {
 					isValid = resourceInfoObject.getPayloadName() != null && !resourceInfoObject.getPayloadName().isEmpty();
-					//Tal only resource name is checked
+					//only resource name is checked
 				} else {
 					isValid = true;
 				}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
index c7bc481..0c5961d 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/AttributeServlet.java
@@ -38,7 +38,7 @@
 import org.openecomp.sdc.be.components.impl.AttributeBusinessLogic;
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.model.AttributeDefinition;
+import org.openecomp.sdc.be.model.PropertyDefinition;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.common.api.Constants;
 import org.openecomp.sdc.common.datastructure.Wrapper;
@@ -96,13 +96,13 @@
 
 		try {
 			Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
-			Wrapper<AttributeDefinition> attributesWrapper = new Wrapper<>();
+			Wrapper<PropertyDefinition> attributesWrapper = new Wrapper<>();
 			// convert json to AttributeDefinition
 
 			buildAttributeFromString(data, attributesWrapper, errorWrapper);
 			if (errorWrapper.isEmpty()) {
 				AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
-				Either<AttributeDefinition, ResponseFormat> createAttribute = businessLogic.createAttribute(resourceId, attributesWrapper.getInnerElement(), userId);
+				Either<PropertyDefinition, ResponseFormat> createAttribute = businessLogic.createAttribute(resourceId, attributesWrapper.getInnerElement(), userId);
 				if (createAttribute.isRight()) {
 					errorWrapper.setInnerElement(createAttribute.right().value());
 				} else {
@@ -115,7 +115,7 @@
 				log.info("Failed to create Attribute. Reason - ", errorWrapper.getInnerElement());
 				response = buildErrorResponse(errorWrapper.getInnerElement());
 			} else {
-				AttributeDefinition createdAttDef = attributesWrapper.getInnerElement();
+				PropertyDefinition createdAttDef = attributesWrapper.getInnerElement();
 				log.debug("Attribute {} created successfully with id {}", createdAttDef.getName(), createdAttDef.getUniqueId());
 				ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.CREATED);
 				response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(createdAttDef));
@@ -165,14 +165,14 @@
 		try {
 			// convert json to PropertyDefinition
 			Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
-			Wrapper<AttributeDefinition> attributesWrapper = new Wrapper<>();
+			Wrapper<PropertyDefinition> attributesWrapper = new Wrapper<>();
 			// convert json to AttributeDefinition
 
 			buildAttributeFromString(data, attributesWrapper, errorWrapper);
 
 			if (errorWrapper.isEmpty()) {
 				AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
-				Either<AttributeDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic.updateAttribute(resourceId, attributeId, attributesWrapper.getInnerElement(), userId);
+				Either<PropertyDefinition, ResponseFormat> eitherUpdateAttribute = businessLogic.updateAttribute(resourceId, attributeId, attributesWrapper.getInnerElement(), userId);
 				// update property
 				if (eitherUpdateAttribute.isRight()) {
 					errorWrapper.setInnerElement(eitherUpdateAttribute.right().value());
@@ -186,7 +186,7 @@
 				log.info("Failed to update Attribute. Reason - ", errorWrapper.getInnerElement());
 				response = buildErrorResponse(errorWrapper.getInnerElement());
 			} else {
-				AttributeDefinition updatedAttribute = attributesWrapper.getInnerElement();
+				PropertyDefinition updatedAttribute = attributesWrapper.getInnerElement();
 				log.debug("Attribute id {} updated successfully ", updatedAttribute.getUniqueId());
 				ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
 				response = buildOkResponse(responseFormat, RepresentationUtils.toRepresentation(updatedAttribute));
@@ -232,12 +232,12 @@
 
 			// delete the property
 			AttributeBusinessLogic businessLogic = getClassFromWebAppContext(context, () -> AttributeBusinessLogic.class);
-			Either<AttributeDefinition, ResponseFormat> eitherAttribute = businessLogic.deleteAttribute(resourceId, attributeId, userId);
+			Either<PropertyDefinition, ResponseFormat> eitherAttribute = businessLogic.deleteAttribute(resourceId, attributeId, userId);
 			if (eitherAttribute.isRight()) {
 				log.debug("Failed to delete Attribute. Reason - ", eitherAttribute.right().value());
 				return buildErrorResponse(eitherAttribute.right().value());
 			}
-			AttributeDefinition attributeDefinition = eitherAttribute.left().value();
+			PropertyDefinition attributeDefinition = eitherAttribute.left().value();
 			String name = attributeDefinition.getName();
 
 			log.debug("Attribute {} deleted successfully with id {}", name, attributeDefinition.getUniqueId());
@@ -253,11 +253,11 @@
 		}
 	}
 
-	private void buildAttributeFromString(String data, Wrapper<AttributeDefinition> attributesWrapper, Wrapper<ResponseFormat> errorWrapper) {
+	private void buildAttributeFromString(String data, Wrapper<PropertyDefinition> attributesWrapper, Wrapper<ResponseFormat> errorWrapper) {
 
 		try {
 			Gson gson = new GsonBuilder().setPrettyPrinting().create();
-			final AttributeDefinition attribute = gson.fromJson(data, AttributeDefinition.class);
+			final PropertyDefinition attribute = gson.fromJson(data, PropertyDefinition.class);
 			if (attribute == null) {
 				log.info("Attribute content is invalid - {}", data);
 				ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT);
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeGenericServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeGenericServlet.java
index 2d5402f..4278378 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeGenericServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/BeGenericServlet.java
@@ -49,7 +49,7 @@
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.dao.api.IElementDAO;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
-import org.openecomp.sdc.be.externalapi.servlet.AssetMetadataConverter;
+import org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
 import org.openecomp.sdc.be.model.User;
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
index 6a7ecbb..e509078 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentInstanceServlet.java
@@ -51,7 +51,6 @@
 import org.openecomp.sdc.be.info.CreateAndAssotiateInfo;
 import org.openecomp.sdc.be.info.GroupDefinitionInfo;
 import org.openecomp.sdc.be.model.ComponentInstance;
-import org.openecomp.sdc.be.model.ComponentInstanceAttribute;
 import org.openecomp.sdc.be.model.ComponentInstanceInput;
 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
 import org.openecomp.sdc.be.model.InputDefinition;
@@ -191,7 +190,6 @@
 
 	}
 
-	// TODO Tal New Multiple Instance API
 	@POST
 	@Path("/{containerComponentType}/{componentId}/resourceInstance/multipleComponentInstance")
 	@Consumes(MediaType.APPLICATION_JSON)
@@ -618,13 +616,13 @@
 
 			Wrapper<ResponseFormat> errorWrapper = new Wrapper<>();
 			Wrapper<String> dataWrapper = new Wrapper<>();
-			Wrapper<ComponentInstanceAttribute> attributeWrapper = new Wrapper<>();
+			Wrapper<ComponentInstanceProperty> attributeWrapper = new Wrapper<>();
 			Wrapper<ComponentInstanceBusinessLogic> blWrapper = new Wrapper<>();
 
 			validateInputStream(request, dataWrapper, errorWrapper);
 
 			if (errorWrapper.isEmpty()) {
-				validateClassParse(dataWrapper.getInnerElement(), attributeWrapper, () -> ComponentInstanceAttribute.class, errorWrapper);
+				validateClassParse(dataWrapper.getInnerElement(), attributeWrapper, () -> ComponentInstanceProperty.class, errorWrapper);
 			}
 
 			if (errorWrapper.isEmpty()) {
@@ -635,7 +633,7 @@
 				ComponentInstanceBusinessLogic componentInstanceLogic = blWrapper.getInnerElement();
 				ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(containerComponentType);
 				log.debug("Start handle request of ComponentInstanceAttribute. Received attribute is {}", attributeWrapper.getInnerElement());
-				Either<ComponentInstanceAttribute, ResponseFormat> eitherAttribute = componentInstanceLogic.createOrUpdateAttributeValue(componentTypeEnum, componentId, componentInstanceId, attributeWrapper.getInnerElement(), userId);
+				Either<ComponentInstanceProperty, ResponseFormat> eitherAttribute = componentInstanceLogic.createOrUpdateAttributeValue(componentTypeEnum, componentId, componentInstanceId, attributeWrapper.getInnerElement(), userId);
 				if (eitherAttribute.isRight()) {
 					errorWrapper.setInnerElement(eitherAttribute.right().value());
 				} else {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java
index b28700a..3a40e96 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ComponentServlet.java
@@ -87,12 +87,12 @@
 	private static Logger log = LoggerFactory.getLogger(ComponentServlet.class.getName());
 
 	@GET
-	@Path("/{componentType}/{componentId}/conformanceLevelValidation")
+	@Path("/{componentType}/{componentUuid}/conformanceLevelValidation")
 	@Consumes(MediaType.APPLICATION_JSON)
 	@Produces(MediaType.APPLICATION_JSON)
 	@ApiOperation(value = "Validate Component Conformance Level", httpMethod = "GET", notes = "Returns the result according to conformance level in BE config", response = Resource.class)
 	@ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
-	public Response conformanceLevelValidation(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @Context final HttpServletRequest request,
+	public Response conformanceLevelValidation(@PathParam("componentType") final String componentType, @PathParam("componentUuid") final String componentUuid, @Context final HttpServletRequest request,
 			@HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
 		Response response;
 		ServletContext context = request.getSession().getServletContext();
@@ -103,7 +103,7 @@
 		ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
 		if (componentTypeEnum != null) {
 			ComponentBusinessLogic compBL = getComponentBL(componentTypeEnum, context);
-			Either<Boolean, ResponseFormat> eitherConformanceLevel = compBL.validateConformanceLevel(componentId, componentTypeEnum, userId);
+			Either<Boolean, ResponseFormat> eitherConformanceLevel = compBL.validateConformanceLevel(componentUuid, componentTypeEnum, userId);
 			if (eitherConformanceLevel.isRight()) {
 				response = buildErrorResponse(eitherConformanceLevel.right().value());
 			} else {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java
index 019a6ba..d8b0a0e 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/LifecycleServlet.java
@@ -39,11 +39,13 @@
 import org.openecomp.sdc.be.components.lifecycle.LifecycleChangeInfoWithAction;
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.datamodel.utils.UiComponentDataConverter;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.model.Component;
 import org.openecomp.sdc.be.model.LifeCycleTransitionEnum;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
+import org.openecomp.sdc.be.ui.model.UiComponentMetadata;
 import org.openecomp.sdc.common.api.Constants;
 import org.openecomp.sdc.common.config.EcompErrorName;
 import org.openecomp.sdc.exception.ResponseFormat;
@@ -138,7 +140,8 @@
 				}
 
 				log.debug("change state successful !!!");
-				Object value = RepresentationUtils.toRepresentation(actionResponse.left().value());
+				UiComponentMetadata componentMetatdata = UiComponentDataConverter.convertToUiComponentMetadata(actionResponse.left().value());
+				Object value = RepresentationUtils.toRepresentation(componentMetatdata);
 				response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), value);
 				return response;
 			} else {
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/UserAdminServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/UserAdminServlet.java
index a477bcf..d1e3d02 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/UserAdminServlet.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/UserAdminServlet.java
@@ -43,7 +43,6 @@
 
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.model.FunctionalMenuInfo;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
 import org.openecomp.sdc.be.user.UserBusinessLogic;
@@ -474,41 +473,4 @@
 			return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
 		}
 	}
-
-	@GET
-	@Path("/{userId}/functionalmenu")
-	@Consumes(MediaType.APPLICATION_JSON)
-	@Produces(MediaType.APPLICATION_JSON)
-	@ApiOperation(value = "retrieve user details", httpMethod = "GET", notes = "Returns user details according to userId", response = User.class)
-	@ApiResponses(value = { @ApiResponse(code = 200, message = "Returns user Ok"), @ApiResponse(code = 404, message = "User not found"), @ApiResponse(code = 405, message = "Method Not Allowed"),
-			@ApiResponse(code = 500, message = "Internal Server Error") })
-	public Response getFunctionalMenu(@ApiParam(value = "userId of user to get", required = true) @PathParam("userId") final String userId, @Context final HttpServletRequest request) {
-
-		String url = request.getMethod() + " " + request.getRequestURI();
-		log.debug("(get) Start handle request of {}", url);
-
-		UserBusinessLogic userAdminManager = getUserAdminManager(request.getSession().getServletContext());
-
-		try {
-			Either<FunctionalMenuInfo, ActionStatus> functionalMenuResp = userAdminManager.getFunctionalMenu(userId);
-
-			if (functionalMenuResp.isRight()) {
-				return buildErrorResponse(getComponentsUtils().getResponseFormatByUserId(functionalMenuResp.right().value(), userId));
-			} else {
-				FunctionalMenuInfo functionalMenuInfo = functionalMenuResp.left().value();
-				if (functionalMenuInfo != null && functionalMenuInfo.getFunctionalMenu() != null) {
-					log.debug("Functional menu fetched is {}", functionalMenuInfo.getFunctionalMenu());
-					return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), functionalMenuInfo.getFunctionalMenu());
-				} else {
-					log.debug("Functional menu is null");
-					return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
-				}
-			}
-		} catch (Exception e) {
-			BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get User");
-			log.debug("get user failed with unexpected error: {}", e);
-			return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
-		}
-	}
-
 }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
index 3c0c806..b18cbc9 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/CsarUtils.java
@@ -20,16 +20,12 @@
 
 package org.openecomp.sdc.be.tosca;
 
-import java.io.File;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.EnumMap;
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -41,13 +37,11 @@
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 import java.util.zip.ZipEntry;
-import java.util.zip.ZipException;
-import java.util.zip.ZipFile;
+import java.util.zip.ZipInputStream;
 import java.util.zip.ZipOutputStream;
 
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.codec.digest.DigestUtils;
-import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.lang.WordUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
@@ -79,7 +73,7 @@
 import org.openecomp.sdc.be.model.operations.impl.DaoStatusConverter;
 import org.openecomp.sdc.be.model.operations.impl.LifecycleOperation;
 import org.openecomp.sdc.be.resources.data.ESArtifactData;
-import org.openecomp.sdc.be.resources.data.ESSdcSchemaFilesData;
+import org.openecomp.sdc.be.resources.data.SdcSchemaFilesData;
 import org.openecomp.sdc.be.tosca.model.ToscaTemplate;
 import org.openecomp.sdc.common.api.ArtifactGroupTypeEnum;
 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
@@ -143,8 +137,9 @@
 	private static final String TOSCA_META_PATH_FILE_NAME = "TOSCA-Metadata/TOSCA.meta";
 	private static final String TOSCA_META_VERSION = "1.0";
 	private static final String CSAR_VERSION = "1.1";
-
-	public static final String VFC_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS_PATH + ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "([\\w\\_\\-\\.\\s]+)(/)([\\w\\_\\-\\.\\s]+)(/)([\\w\\_\\-\\.\\s\\/]+)";
+	private static String versionFirstThreeOctates;
+	
+	public static final String VFC_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS_PATH + ImportUtils.Constants.USER_DEFINED_RESOURCE_NAMESPACE_PREFIX + "([\\d\\w\\_\\-\\.\\s]+)(/)([\\d\\w\\_\\-\\.\\s]+)(/)([\\d\\w\\_\\-\\.\\s\\/]+)";
 
 	public static final String VF_NODE_TYPE_ARTIFACTS_PATH_PATTERN = ARTIFACTS_PATH +
 	// Artifact Group (i.e Deployment/Informational)
@@ -155,6 +150,16 @@
 			"([\\w\\_\\-\\.\\s]+)";
 	public static final String ARTIFACT_CREATED_FROM_CSAR = "Artifact created from csar";
 
+	public CsarUtils() {
+		if(SDC_VERSION != null && !SDC_VERSION.isEmpty()){
+			Matcher matcher = Pattern.compile("(?!\\.)(\\d+(\\.\\d+)+)(?![\\d\\.])").matcher(SDC_VERSION);
+			matcher.find();
+			versionFirstThreeOctates = matcher.group(0);			
+		} else {
+			versionFirstThreeOctates = "";
+		}
+	}
+	
 	/**
 	 * 
 	 * @param component
@@ -301,39 +306,40 @@
 				}
 				
 				//add inner components to CSAR
-				innerComponentsCache.forEach((childUid, innerComponentTriple) -> {
-					Component innerComponent = innerComponentTriple.getRight();
-					String icFileName = innerComponentTriple.getMiddle();
-					
-					try {
-						//add component to zip
-						Either<byte[], ActionStatus> entryData = getEntryData(innerComponentTriple.getLeft(), innerComponent);
-						byte[] content = entryData.left().value();
-						zip.putNextEntry(new ZipEntry(DEFINITIONS_PATH + icFileName));
-						zip.write(content);
-						
-					} catch (IOException e) {
+			
+			for (Entry<String, ImmutableTriple<String, String, Component>> innerComponentTripleEntry : innerComponentsCache.entrySet()) {
+				
+				ImmutableTriple<String, String, Component> innerComponentTriple = innerComponentTripleEntry.getValue();
 
-					}
+				Component innerComponent = innerComponentTriple.getRight();
+				String icFileName = innerComponentTriple.getMiddle();
 
-					//add component interface to zip
-					if(!ToscaUtils.isAtomicType(innerComponent)) {
-						writeComponentInterface(innerComponent, zip, icFileName);
-					}
-				});
+				// add component to zip
+				Either<byte[], ActionStatus> entryData = getEntryData(innerComponentTriple.getLeft(), innerComponent);
+				byte[] content = entryData.left().value();
+				zip.putNextEntry(new ZipEntry(DEFINITIONS_PATH + icFileName));
+				zip.write(content);
+
+				// add component interface to zip
+				if (!ToscaUtils.isAtomicType(innerComponent)) {
+					writeComponentInterface(innerComponent, zip, icFileName);
+				}
+			}
 		}
 		
-		/*Either<byte[], ActionStatus> latestSchemaFilesFromCassandra = getLatestSchemaFilesFromCassandra();
+		//retrieve SDC.zip from Cassandra 
+		Either<byte[], ResponseFormat> latestSchemaFilesFromCassandra = getLatestSchemaFilesFromCassandra();
 		
 		if(latestSchemaFilesFromCassandra.isRight()){
-			return null;
-		}*/
+			log.error("Error retrieving SDC Schema files from cassandra" );
+			return Either.right(latestSchemaFilesFromCassandra.right().value());
+		}
 		
-		//TODO Tal G this is quick solution until Cassandra US is alligned 
-		Either<ZipOutputStream, ResponseFormat> addSchemaFilesFromConfig = addSchemaFilesFromConfig(zip);
+		//add files from retireved SDC.zip to Definitions folder in CSAR
+		Either<ZipOutputStream, ResponseFormat> addSchemaFilesFromCassandra = addSchemaFilesFromCassandra(zip, latestSchemaFilesFromCassandra.left().value());
 		
-		if(addSchemaFilesFromConfig.isRight()){
-			return addSchemaFilesFromConfig;
+		if(addSchemaFilesFromCassandra.isRight()){
+			return addSchemaFilesFromCassandra;
 		}
 		
 		// Artifact Generation
@@ -371,36 +377,47 @@
 		
 		return writeAllFilesToScar(component, collectedComponentCsarDefinition.left().value(), zip, isInCertificationRequest);
 	}
-
-	private Either<ZipOutputStream, ResponseFormat> addSchemaFilesFromConfig(ZipOutputStream zip) throws ZipException, IOException {
-		final String pathAndFile = "config/SDC.zip";
+	
+	private Either<ZipOutputStream, ResponseFormat> addSchemaFilesFromCassandra(ZipOutputStream zip, byte[] schemaFileZip){
 		
-		File file = new File(pathAndFile);
-		if(!file.exists()){
-			log.debug("SDC.zip schema files archive not found");
-			return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
-		}
+		final int initSize = 2048;
 		
-		try(ZipFile zipFile = new ZipFile(new File(pathAndFile));){
-			Enumeration<? extends ZipEntry> entries = zipFile.entries();
+		log.debug("Starting coppy from Schema file zip to CSAR zip");
+		
+		try (ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(schemaFileZip));
+				ByteArrayOutputStream out = new ByteArrayOutputStream();
+				BufferedOutputStream bos = new BufferedOutputStream(out, initSize);) {
 			
-			while(entries.hasMoreElements()){
-				ZipEntry nextElement = entries.nextElement();
-				InputStream inputStream = zipFile.getInputStream(nextElement);
-				byte[] byteArray = IOUtils.toByteArray(inputStream);
-				
-				zip.putNextEntry(new ZipEntry(DEFINITIONS_PATH + nextElement.getName()));
-				zip.write(byteArray);
+			ZipEntry entry = null;
+			
+			while ((entry = zipStream.getNextEntry()) != null) {
+			
+				String entryName = entry.getName();
+				int readSize = initSize;
+				byte[] entryData = new byte[initSize];
+
+				while ((readSize = zipStream.read(entryData, 0, readSize)) != -1) {
+					bos.write(entryData, 0, readSize);
+				}
+
+				bos.flush();
+				out.flush();
+				zip.putNextEntry(new ZipEntry(DEFINITIONS_PATH + entryName));
+				zip.write(out.toByteArray());
+				zip.flush();
+				out.reset();
 			}
-			zipFile.close();			
-		}catch (Exception e) {
-			log.debug("Error in writing SDC.zip schema files to CSAR");
+		} catch (IOException e) {
+			log.error("Error while writing the SDC schema file to the CSAR {}", e);
 			return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERAL_ERROR));
 		}
 		
+		log.debug("Finished coppy from Schema file zip to CSAR zip");
+		
 		return Either.left(zip);
 	}
 
+	
 	private void insertInnerComponentsToCache(Map<String, ImmutableTriple<String, String, Component>> componentCache,
 			Component childComponent) {
 		
@@ -705,25 +722,24 @@
 		return Either.left(content);
 	}
 	
-	private Either<byte[], ActionStatus> getLatestSchemaFilesFromCassandra() {
-		Matcher matcher = Pattern.compile("(?!\\.)(\\d+(\\.\\d+)+)(?![\\d\\.])").matcher(SDC_VERSION);
-		matcher.find();
-		final String VERSION_FIRST_THREE_OCTATES = matcher.group(0);
-		Either<List<ESSdcSchemaFilesData>, ActionStatus> specificSchemaFiles = sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(VERSION_FIRST_THREE_OCTATES, CONFORMANCE_LEVEL);
+	private Either<byte[], ResponseFormat> getLatestSchemaFilesFromCassandra() {
+		Either<List<SdcSchemaFilesData>, CassandraOperationStatus> specificSchemaFiles = sdcSchemaFilesCassandraDao.getSpecificSchemaFiles(versionFirstThreeOctates, CONFORMANCE_LEVEL);
 		
-		if(specificSchemaFiles.isRight()){
-			log.debug("Failed to get the schema files SDC-Version: {} Conformance-Level {}", VERSION_FIRST_THREE_OCTATES, CONFORMANCE_LEVEL);
-			return Either.right(specificSchemaFiles.right().value()); 
+		if(specificSchemaFiles.isRight()){			
+			log.debug("Failed to get the schema files SDC-Version: {} Conformance-Level {}", versionFirstThreeOctates, CONFORMANCE_LEVEL);
+			StorageOperationStatus storageStatus = DaoStatusConverter.convertCassandraStatusToStorageStatus(specificSchemaFiles.right().value());
+			ActionStatus convertedFromStorageResponse = componentsUtils.convertFromStorageResponse(storageStatus);
+			return Either.right(componentsUtils.getResponseFormat(convertedFromStorageResponse)); 
 		}
 		
-		 List<ESSdcSchemaFilesData> listOfSchemas = specificSchemaFiles.left().value();
+		 List<SdcSchemaFilesData> listOfSchemas = specificSchemaFiles.left().value();
 		
 		if(listOfSchemas.isEmpty()){
-			log.debug("Failed to get the schema files SDC-Version: {} Conformance-Level {}", VERSION_FIRST_THREE_OCTATES, CONFORMANCE_LEVEL);
-			return Either.right(ActionStatus.GENERAL_ERROR);
+			log.debug("Failed to get the schema files SDC-Version: {} Conformance-Level {}", versionFirstThreeOctates, CONFORMANCE_LEVEL);
+			return Either.right(componentsUtils.getResponseFormat(ActionStatus.TOSCA_SCHEMA_FILES_NOT_FOUND, versionFirstThreeOctates, CONFORMANCE_LEVEL));
 		}
 		
-		ESSdcSchemaFilesData schemaFile = listOfSchemas.iterator().next();
+		SdcSchemaFilesData schemaFile = listOfSchemas.iterator().next();
 		
 		return Either.left(schemaFile.getPayloadAsArray());
 	}
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
index 072861b..8be5b0b 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
@@ -336,10 +336,9 @@
 			Resource resource = (Resource) component;
 			toscaMetadata.setType(resource.getResourceType().name());
 			toscaMetadata.setSubcategory(categoryDefinition.getSubcategories().get(0).getName());
-			if (!isInstance) {
-				toscaMetadata.setResourceVendor(resource.getVendorName());
-				toscaMetadata.setResourceVendorRelease(resource.getVendorRelease());
-			}
+			toscaMetadata.setResourceVendor(resource.getVendorName());
+			toscaMetadata.setResourceVendorRelease(resource.getVendorRelease());
+			
 			break;
 		case SERVICE:
 			toscaMetadata.setType(component.getComponentType().getValue());
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/user/IUserBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/user/IUserBusinessLogic.java
index 54ba9bf..6bec3fa 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/user/IUserBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/user/IUserBusinessLogic.java
@@ -25,7 +25,6 @@
 import javax.servlet.ServletContext;
 
 import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.model.FunctionalMenuInfo;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.exception.ResponseFormat;
 
@@ -50,7 +49,4 @@
 	public Either<User, ResponseFormat> deActivateUser(User modifier, String userUniuqeIdToDeactive);
 
 	public Either<User, ResponseFormat> authorize(User authUser);
-
-	public Either<FunctionalMenuInfo, ActionStatus> getFunctionalMenu(String userId);
-
 }
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
index c90cc61..7135bfb 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/user/UserBusinessLogic.java
@@ -28,18 +28,14 @@
 import javax.annotation.Resource;
 import javax.servlet.ServletContext;
 
-import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.tinkerpop.gremlin.structure.Edge;
-import org.openecomp.portalsdk.core.onboarding.ueb.FunctionalMenu;
-import org.openecomp.portalsdk.core.onboarding.ueb.UebException;
 import org.openecomp.sdc.be.config.BeEcompErrorManager;
-import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
 import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
 import org.openecomp.sdc.be.dao.utils.UserStatusEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
-import org.openecomp.sdc.be.model.FunctionalMenuInfo;
 import org.openecomp.sdc.be.model.LifecycleStateEnum;
 import org.openecomp.sdc.be.model.User;
 import org.openecomp.sdc.be.model.operations.api.IUserAdminOperation;
@@ -249,16 +245,17 @@
 		// comment until admin will be able to do do check-in/check-out from the
 		// UI
 
-		Either<List<Edge>, StorageOperationStatus> userPendingTasksReq = getPandingUserPandingTasksWithCommit(userToUpdate);
+		Either<List<Edge>, StorageOperationStatus> userPendingTasksReq = getPendingUserPendingTasksWithCommit(userToUpdate);
 		if (userPendingTasksReq.isRight()) {
-			log.debug("updateUserRole method - failed to get user pending tasks list", userIdToUpdate);
+			log.debug("updateUserRole method - failed to get user pending tasks list userId {}", userIdToUpdate);
 			return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(userPendingTasksReq.right().value())));
 		}
 
 		List<Edge> userPendingTasks = userPendingTasksReq.left().value();
-		if (userPendingTasks.size() > 0) {
-			log.debug("updateUserRole method - User canot be updated, user have panding projects", userIdToUpdate);
-			String userTasksStatusForErrorMessage = getUserPandingTaskStatusByRole(UserRoleEnum.valueOf(userToUpdate.getRole()));
+		if (!userPendingTasks.isEmpty()) {
+			log.debug("updateUserRole method - User canot be updated, user have pending projects userId {}", userIdToUpdate);
+			
+			String userTasksStatusForErrorMessage = getUserPendingTaskStatusByRole(UserRoleEnum.valueOf(userToUpdate.getRole()));
 			String userInfo = userToUpdate.getFirstName() + " " + userToUpdate.getLastName() + '(' + userToUpdate.getUserId() + ')';
 			responseFormat = componentsUtils.getResponseFormat(ActionStatus.CANNOT_UPDATE_USER_WITH_ACTIVE_ELEMENTS, userInfo, userTasksStatusForErrorMessage);
 			handleAuditing(modifier, userToUpdate, userToUpdate, responseFormat, AuditingActionEnum.UPDATE_USER);
@@ -413,7 +410,7 @@
 			return Either.right(responseFormat);
 		}
 
-		Either<List<Edge>, StorageOperationStatus> userPendingTasksReq = getPandingUserPandingTasksWithCommit(userToDeactivate);
+		Either<List<Edge>, StorageOperationStatus> userPendingTasksReq = getPendingUserPendingTasksWithCommit(userToDeactivate);
 		if (userPendingTasksReq.isRight()) {
 			log.debug("deActivateUser method - failed to get user pending tasks list", userUniuqeIdToDeactive);
 			return Either.right(componentsUtils.getResponseFormat(componentsUtils.convertFromStorageResponse(userPendingTasksReq.right().value())));
@@ -421,9 +418,9 @@
 
 		List<Edge> userPendingTasks = userPendingTasksReq.left().value();
 		if (userPendingTasks.size() > 0) {
-			log.debug("deActivateUser method - User canot be deleted, user have panding projects", userUniuqeIdToDeactive);
+			log.debug("deActivateUser method - User canot be deleted, user have pending projects", userUniuqeIdToDeactive);
 
-			String userTasksStatusForErrorMessage = getUserPandingTaskStatusByRole(UserRoleEnum.valueOf(userToDeactivate.getRole()));
+			String userTasksStatusForErrorMessage = getUserPendingTaskStatusByRole(UserRoleEnum.valueOf(userToDeactivate.getRole()));
 			String userInfo = userToDeactivate.getFirstName() + " " + userToDeactivate.getLastName() + '(' + userToDeactivate.getUserId() + ')';
 			responseFormat = componentsUtils.getResponseFormat(ActionStatus.CANNOT_DELETE_USER_WITH_ACTIVE_ELEMENTS, userInfo, userTasksStatusForErrorMessage);
 			handleAuditing(modifier, userToDeactivate, userToDeactivate, responseFormat, AuditingActionEnum.DELETE_USER);
@@ -589,7 +586,7 @@
 		return Either.left(updatedUser);
 	}
 
-	private Either<List<Edge>, StorageOperationStatus> getPandingUserPandingTasksWithCommit(User user) {
+	private Either<List<Edge>, StorageOperationStatus> getPendingUserPendingTasksWithCommit(User user) {
 
 		Either<List<Edge>, StorageOperationStatus> result = null;
 
@@ -601,21 +598,21 @@
 			case PRODUCT_STRATEGIST:
 			case PRODUCT_MANAGER:
 				properties.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
-				return userAdminOperation.getUserPandingTasksList(user, properties);
+				return userAdminOperation.getUserPendingTasksList(user, properties);
 			case TESTER:
 				properties.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.name());
-				return userAdminOperation.getUserPandingTasksList(user, properties);
+				return userAdminOperation.getUserPendingTasksList(user, properties);
 			case ADMIN:
 				properties.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.CERTIFICATION_IN_PROGRESS.name());
 				properties.put(GraphPropertiesDictionary.STATE.getProperty(), LifecycleStateEnum.NOT_CERTIFIED_CHECKOUT.name());
-				return userAdminOperation.getUserPandingTasksList(user, properties);
+				return userAdminOperation.getUserPendingTasksList(user, properties);
 			default:
 				return Either.left(new ArrayList<>());
 			}
 		} finally {
 			// commit will be perform outside!!!
 			if (result == null || result.isRight()) {
-				log.debug("getUserPandingTasksList failed to perform fetching");
+				log.debug("getUserPendingTasksList failed to perform fetching");
 				titanDao.rollback();
 			} else {
 				titanDao.commit();
@@ -623,7 +620,7 @@
 		}
 	}
 
-	private String getUserPandingTaskStatusByRole(UserRoleEnum role) {
+	private String getUserPendingTaskStatusByRole(UserRoleEnum role) {
 
 		switch (role) {
 		case DESIGNER:
@@ -639,77 +636,4 @@
 			return "";
 		}
 	}
-
-	/**
-	 * return the functional menu of a given user
-	 * 
-	 * @param userId
-	 * @param inTransaction
-	 * @return
-	 */
-	public Either<FunctionalMenuInfo, ActionStatus> getFunctionalMenu(String userId) {
-
-		boolean toCommit = false;
-
-		FunctionalMenuInfo functionalMenuInfo = new FunctionalMenuInfo();
-
-		try {
-
-			Either<ImmutablePair<User, FunctionalMenuInfo>, ActionStatus> userResult = userAdminOperation.getUserDataWithFunctionalMenu(userId);
-			if (userResult.isRight()) {
-				ActionStatus actionStatus = userResult.right().value();
-				if (actionStatus == ActionStatus.USER_NOT_FOUND) {
-					actionStatus = ActionStatus.INVALID_USER_ID;
-				}
-				return Either.right(actionStatus);
-			}
-
-			ImmutablePair<User, FunctionalMenuInfo> immutablePair = userResult.left().value();
-			FunctionalMenuInfo currentFunctionalMenu = immutablePair.right;
-			String currentMenuStr = currentFunctionalMenu != null ? currentFunctionalMenu.getFunctionalMenu() : null;
-
-			String functionalMenu = getFunctionalMenuFromUeb(userId);
-
-			// functionalMenu can be null or since we catch UebException
-			if (functionalMenu != null && false == functionalMenu.isEmpty()) {
-				functionalMenuInfo.setFunctionalMenu(functionalMenu);
-				if (false == functionalMenu.equals(currentMenuStr)) {
-					log.debug("Going to update functional menu of user {}. Functional menu is {}", userId, functionalMenu);
-					userAdminOperation.createOrUpdateFunctionalMenu(userId, functionalMenu);
-				}
-			} else {
-				String menu = currentMenuStr;
-				if (menu == null) {
-					menu = "[]";
-				}
-				log.debug("Fetch functional menu from old request. Functional menu is {}", menu);
-				functionalMenuInfo.setFunctionalMenu(menu);
-			}
-
-			toCommit = true;
-
-		} finally {
-			if (toCommit) {
-				titanDao.commit();
-			} else {
-				titanDao.rollback();
-			}
-		}
-
-		return Either.left(functionalMenuInfo);
-	}
-
-	private String getFunctionalMenuFromUeb(String userId) {
-		String functionalMenu = null;
-		try {
-			log.debug("Before calling to FunctionalMenu method for user {}", userId);
-			functionalMenu = FunctionalMenu.get(userId);
-			log.debug("Functional menu fetched is {}", functionalMenu);
-
-		} catch (UebException e) {
-			log.debug("Failed to fetch 'functional menu' of user {} from ecomp portal(via UEB)", userId, e);
-			BeEcompErrorManager.getInstance().logInternalFlowError("FetchFunctionalMenu", "Failed to fetch 'functional menu'", ErrorSeverity.ERROR);
-		}
-		return functionalMenu;
-	}
 }
diff --git a/catalog-be/src/main/resources/application-context.xml b/catalog-be/src/main/resources/application-context.xml
index 702c63e..6c44b27 100644
--- a/catalog-be/src/main/resources/application-context.xml
+++ b/catalog-be/src/main/resources/application-context.xml
@@ -57,7 +57,7 @@
   <bean id="additionalInformationBusinessLogic" class="org.openecomp.sdc.be.components.impl.AdditionalInformationBusinessLogic" />
   <bean id="distribution-engine-cluster-health" class="org.openecomp.sdc.be.components.distribution.engine.DistributionEngineClusterHealth" />
   <bean id="categoriesImportManager" class="org.openecomp.sdc.be.components.impl.CategoriesImportManager" />
-  <bean id="asset-metadata-utils" class="org.openecomp.sdc.be.externalapi.servlet.AssetMetadataConverter" />
+  <bean id="asset-metadata-utils" class="org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter" />
 
   <bean class="org.openecomp.sdc.be.dao.config.DAOSpringConfig"/>
 
diff --git a/catalog-be/src/main/resources/config/SDC.zip b/catalog-be/src/main/resources/config/SDC.zip
index dfb4be8..674f6f8 100644
--- a/catalog-be/src/main/resources/config/SDC.zip
+++ b/catalog-be/src/main/resources/config/SDC.zip
Binary files differ
diff --git a/catalog-be/src/main/resources/config/error-configuration.yaml b/catalog-be/src/main/resources/config/error-configuration.yaml
index ef7a885..0fb4e14 100644
--- a/catalog-be/src/main/resources/config/error-configuration.yaml
+++ b/catalog-be/src/main/resources/config/error-configuration.yaml
@@ -1765,7 +1765,7 @@
 # %4 – Artifact uuid
     ARTIFACT_PAYLOAD_NOT_FOUND_DURING_CSAR_CREATION: {
         code: 400,
-        message: " Error: CSAR packaging failed for %1 %2. Artifact %3 [%4] was not found",
+        message: "Error: CSAR packaging failed for %1 %2. Artifact %3 [%4] was not found",
         messageId: "SVC4659"
     }
 #---------SVC4660------------------------------
@@ -1776,3 +1776,11 @@
         message: "Creation of %1 failed. Generic type %2 was not found",
         messageId: "SVC4660"
     }
+#---------SVC4661------------------------------
+# %1 - assetType
+# %2 - matching generic node type name
+    TOSCA_SCHEMA_FILES_NOT_FOUND: {
+        code: 400,
+        message: "Error: CSAR packaging failed. TOSCA schema files for SDC-Version: %1 and Conformance-Level %2 were not found",
+        messageId: "SVC4661"
+    }
\ No newline at end of file
diff --git a/catalog-be/src/main/resources/config/logback.xml b/catalog-be/src/main/resources/config/logback.xml
index 8ba0a31..ba16783 100644
--- a/catalog-be/src/main/resources/config/logback.xml
+++ b/catalog-be/src/main/resources/config/logback.xml
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration scan="true" scanPeriod="5 seconds">
 
-	<property scope="system" name="ECOMP-component-name" value="ASDC" />
-	<property scope="system" name="ECOMP-subcomponent-name" value="ASDC-BE" />
+	<property scope="system" name="ECOMP-component-name" value="SDC" />
+	<property scope="system" name="ECOMP-subcomponent-name" value="SDC-BE" />
 	<property file="${config.home}/catalog-be/configuration.yaml" />
 	<property scope="context" name="enable-all-log" value="false" />
 
diff --git a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml
index b4c442f..63d70c6 100644
--- a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml
+++ b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.yml
@@ -21,6 +21,19 @@
 
 json:
   derived_from: tosca.datatypes.Root
+
+scalar-unit:
+  derived_from: tosca.datatypes.Root
+
+scalar-unit.size:
+  derived_from: scalar-unit
+
+scalar-unit.time:
+  derived_from: scalar-unit
+
+scalar-unit.frequency:
+  derived_from: scalar-unit
+
   
 tosca.datatypes.Credential: 
   derived_from: tosca.datatypes.Root
diff --git a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip
index 4f3e269..9c5964d 100644
--- a/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip
+++ b/catalog-be/src/main/resources/import/tosca/data-types/dataTypes.zip
Binary files differ
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
index 5bda324..6cb90d0 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactBusinessLogicTest.java
@@ -40,8 +40,10 @@
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.InjectMocks;
+import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
+import org.openecomp.sdc.be.components.ArtifactsResolver;
 import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
 import org.openecomp.sdc.be.config.Configuration.ArtifactTypeConfig;
 import org.openecomp.sdc.be.config.ConfigurationManager;
@@ -96,7 +98,7 @@
 	public static final ServiceOperation serviceOperation = Mockito.mock(ServiceOperation.class);
 	public static final ArtifactCassandraDao artifactCassandraDao =  Mockito.mock(ArtifactCassandraDao.class);
 	public static final ToscaOperationFacade toscaOperationFacade =  Mockito.mock(ToscaOperationFacade.class);
-	
+
 	// public static final InformationDeployedArtifactsBusinessLogic
 	// informationDeployedArtifactsBusinessLogic =
 	// Mockito.mock(InformationDeployedArtifactsBusinessLogic.class);
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
new file mode 100644
index 0000000..fd7717a
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ArtifactResolverTest.java
@@ -0,0 +1,91 @@
+package org.openecomp.sdc.be.components.impl;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.model.ArtifactDefinition;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.Resource;
+import org.openecomp.sdc.be.model.Service;
+
+
+import java.util.Collections;
+import java.util.Map;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+
+public class ArtifactResolverTest {
+
+    private ArtifactResolverImpl testInstance = new ArtifactResolverImpl();
+    private Service service, noArtifactsService;
+    private Resource resource, noArtifactsResource;
+    private ComponentInstance componentInstance, noArtifactsInstance;
+
+    @Before
+    public void setUp() throws Exception {
+        noArtifactsService = new Service();
+        noArtifactsResource = new Resource();
+        resource = new Resource();
+        service = new Service();
+        componentInstance = new ComponentInstance();
+        noArtifactsInstance = new ComponentInstance();
+
+        ArtifactDefinition artifact1 = new ArtifactDefinition();
+        artifact1.setUniqueId("a1");
+
+        ArtifactDefinition artifact2 = new ArtifactDefinition();
+        artifact2.setUniqueId("a2");
+
+        ArtifactDefinition artifact3 = new ArtifactDefinition();
+        artifact3.setUniqueId("a3");
+
+        Map<String, ArtifactDefinition> artifact1Map = Collections.singletonMap("key1", artifact1);
+        Map<String, ArtifactDefinition> artifact2Map = Collections.singletonMap("key1", artifact2);
+        Map<String, ArtifactDefinition> artifact3Map = Collections.singletonMap("key1", artifact3);
+
+        resource.setDeploymentArtifacts(artifact1Map);
+        resource.setArtifacts(artifact2Map);
+
+        service.setDeploymentArtifacts(artifact1Map);
+        service.setArtifacts(artifact2Map);
+        service.setServiceApiArtifacts(artifact3Map);
+
+        componentInstance.setDeploymentArtifacts(artifact1Map);
+        componentInstance.setArtifacts(artifact2Map);
+    }
+
+    @Test
+    public void findArtifactOnComponent_noArtifactsOnComponent() throws Exception {
+        assertNull(testInstance.findArtifactOnComponent(noArtifactsResource, ComponentTypeEnum.RESOURCE, "someId"));
+        assertNull(testInstance.findArtifactOnComponent(noArtifactsService, ComponentTypeEnum.SERVICE, "someId"));
+    }
+
+    @Test
+    public void findArtifactOnComponent_resource() throws Exception {
+        assertNull(testInstance.findArtifactOnComponent(resource, ComponentTypeEnum.RESOURCE, "someId"));
+        assertNotNull(testInstance.findArtifactOnComponent(resource, ComponentTypeEnum.RESOURCE, "a1"));
+        assertNotNull(testInstance.findArtifactOnComponent(resource, ComponentTypeEnum.RESOURCE, "a2"));
+    }
+
+    @Test
+    public void findArtifactOnComponent_service() throws Exception {
+        assertNull(testInstance.findArtifactOnComponent(service, ComponentTypeEnum.SERVICE, "someId"));
+        assertNotNull(testInstance.findArtifactOnComponent(service, ComponentTypeEnum.SERVICE, "a1"));
+        assertNotNull(testInstance.findArtifactOnComponent(service, ComponentTypeEnum.SERVICE, "a2"));
+        assertNotNull(testInstance.findArtifactOnComponent(service, ComponentTypeEnum.SERVICE, "a3"));
+    }
+
+    @Test
+    public void findArtifactOnInstance_instanceHasNoArtifacts() throws Exception {
+        assertNull(testInstance.findArtifactOnComponentInstance(noArtifactsInstance, "someId"));
+    }
+
+    @Test
+    public void findArtifactOnInstance() throws Exception {
+        assertNull(testInstance.findArtifactOnComponentInstance(componentInstance, "someId"));
+        assertNotNull(testInstance.findArtifactOnComponentInstance(componentInstance, "a1"));
+        assertNotNull(testInstance.findArtifactOnComponentInstance(componentInstance, "a2"));
+    }
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
index 6dd19cc..59d49de 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ImportUtilsTest.java
@@ -42,7 +42,6 @@
 import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaTagNamesEnum;
 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
-import org.openecomp.sdc.be.model.AttributeDefinition;
 import org.openecomp.sdc.be.model.HeatParameterDefinition;
 import org.openecomp.sdc.be.model.PropertyDefinition;
 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
@@ -300,7 +299,7 @@
 	public void testGetAttributesFromYml() throws IOException {
 
 		Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaWithAttribute.yml");
-		Either<Map<String, AttributeDefinition>, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson);
+		Either<Map<String, PropertyDefinition>, ResultStatusEnum> actualAttributes = ImportUtils.getAttributes(toscaJson);
 		assertTrue(actualAttributes.isLeft());
 		Map<String, Map<String, Object>> expectedAttributes = getElements(toscaJson, ToscaTagNamesEnum.ATTRIBUTES);
 		compareAttributes(expectedAttributes, actualAttributes.left().value());
@@ -318,10 +317,10 @@
 
 	}
 
-	private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, AttributeDefinition> actual) {
+	private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, PropertyDefinition> actual) {
 
 		Map<String, Object> singleExpectedAttribute;
-		AttributeDefinition actualAttribute, expectedAttributeModel;
+		PropertyDefinition actualAttribute, expectedAttributeModel;
 		// attributes of resource
 		for (Map.Entry<String, Map<String, Object>> expectedAttribute : expected.entrySet()) {
 
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
index 2aa061a..d6808da 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/AssetsDataServletTest.java
@@ -52,6 +52,7 @@
 import org.openecomp.sdc.be.components.impl.ResourceImportManager;
 import org.openecomp.sdc.be.dao.api.ActionStatus;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.ecomp.converters.AssetMetadataConverter;
 import org.openecomp.sdc.be.externalapi.servlet.representation.ResourceAssetMetadata;
 import org.openecomp.sdc.be.impl.ComponentsUtils;
 import org.openecomp.sdc.be.impl.ServletUtils;
